summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-11-20 13:47:05 -0700
committerJens Axboe <axboe@kernel.dk>2019-11-20 13:49:38 -0700
commit2d8dcd28d1c87d152d222c924b5b3c76fcda7773 (patch)
treecd12312a346444737470d832f972c28568748353
parent9c00d79da2919142fdfdcf78bfbcf762c6b1739b (diff)
downloadliburing-2d8dcd28d1c87d152d222c924b5b3c76fcda7773.tar.gz
liburing-2d8dcd28d1c87d152d222c924b5b3c76fcda7773.tar.bz2
test/teardowns: lighten load and wait for children
We don't want excessive workers to bleed into the next tests, so make sure the test is quiesced before we move on. We expect -ENOMEM for a regular user here, so just log failure if we get an error that isn't -ENOMEM. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/teardowns.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/test/teardowns.c b/test/teardowns.c
index df53a79..189fcc7 100644
--- a/test/teardowns.c
+++ b/test/teardowns.c
@@ -6,28 +6,33 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
+#include <errno.h>
#include "liburing.h"
static void loop(void)
{
- int i;
+ int i, ret = 0;
- for (i = 0; i < 1000; i++) {
+ for (i = 0; i < 100; i++) {
struct io_uring ring;
int fd;
memset(&ring, 0, sizeof(ring));
fd = io_uring_queue_init(0xa4, &ring, 0);
- if (fd >= 0)
+ if (fd >= 0) {
close(fd);
+ continue;
+ }
+ if (fd != -ENOMEM)
+ ret++;
}
- exit(0);
+ exit(ret);
}
int main(void)
{
- int i;
+ int i, ret, status;
for (i = 0; i < 12; i++) {
if (!fork()) {
@@ -36,6 +41,15 @@ int main(void)
}
}
- sleep(20);
- return 0;
+ ret = 0;
+ for (i = 0; i < 12; i++) {
+ if (waitpid(-1, &status, 0) < 0) {
+ perror("waitpid");
+ return 1;
+ }
+ if (WEXITSTATUS(status))
+ ret++;
+ }
+
+ return ret;
}