diff options
author | Ben LaHaise <bcrl@kvack.org> | 2002-04-25 19:32:38 +0000 |
---|---|---|
committer | Ben LaHaise <bcrl@kvack.org> | 2002-04-25 19:32:38 +0000 |
commit | 0628c50c33934d4c83a9fe680e87e61e1e277a7d (patch) | |
tree | 55a68d9c37148a114f96f73d051d1843da10c0c6 | |
parent | 37350fa4f94b49345d81177343b5673d5096f5d1 (diff) | |
download | libaio-0628c50c33934d4c83a9fe680e87e61e1e277a7d.tar.gz |
make clean should tidy harness up too.
add 12.t: verify that ioctxs are inaccessible across fork()
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | harness/cases/12.t | 49 | ||||
-rw-r--r-- | harness/cases/3.t | 29 | ||||
-rw-r--r-- | harness/cases/6.t | 2 | ||||
-rw-r--r-- | harness/cases/aio_setup.h | 15 |
5 files changed, 73 insertions, 23 deletions
@@ -15,6 +15,7 @@ install: clean: @$(MAKE) -C src clean + @$(MAKE) -C harness clean tag-archive: @cvs -Q tag -F $(CVSTAG) diff --git a/harness/cases/12.t b/harness/cases/12.t new file mode 100644 index 0000000..3499204 --- /dev/null +++ b/harness/cases/12.t @@ -0,0 +1,49 @@ +/* 12.t +- ioctx access across fork() (12.t) + */ +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> +#include <signal.h> + +#include "aio_setup.h" + +void test_child(void) +{ + int res; + res = attempt_io_submit(io_ctx, 0, NULL, -EINVAL); + fflush(stdout); + _exit(res); +} + +int test_main(void) +{ + int res, status; + pid_t pid; + + if (attempt_io_submit(io_ctx, 0, NULL, 0)) + return 1; + + sigblock(sigmask(SIGCHLD) | siggetmask()); + fflush(NULL); + pid = fork(); assert(pid != -1); + + if (pid == 0) + test_child(); + + res = waitpid(pid, &status, 0); + + if (WIFEXITED(status)) { + int failed = (WEXITSTATUS(status) != 0); + printf("child exited with status %d%s\n", WEXITSTATUS(status), + failed ? " -- FAILED" : ""); + return failed; + } + + /* anything else: failed */ + if (WIFSIGNALED(status)) + printf("child killed by signal %d -- FAILED.\n", + WTERMSIG(status)); + + return 1; +} diff --git a/harness/cases/3.t b/harness/cases/3.t index 0d72241..7773d80 100644 --- a/harness/cases/3.t +++ b/harness/cases/3.t @@ -4,21 +4,6 @@ */ #include "aio_setup.h" -int attempt(io_context_t ctx, long nr, struct iocb *ios[], int expect) -{ - int res; - - printf("expect %3d: io_submit(%10p, %3ld, %10p) = ", expect, ctx, nr, ios); - fflush(stdout); - res = io_submit(ctx, nr, ios); - printf("%3d [%s]%s\n", res, (res <= 0) ? strerror(-res) : "", - (res != expect) ? " -- FAILED" : ""); - if (res != expect) - return 1; - - return 0; -} - int test_main(void) { struct iocb a, b; @@ -27,13 +12,13 @@ int test_main(void) struct iocb *bad2_ios[] = { KERNEL_RW_POINTER, &a }; int status = 0; - status |= attempt(BAD_CTX, 1, good_ios, -EINVAL); - status |= attempt( io_ctx, 0, good_ios, 0); - status |= attempt( io_ctx, 1, NULL, -EFAULT); - status |= attempt( io_ctx, 1, (void *)-1, -EFAULT); - status |= attempt( io_ctx, 2, bad1_ios, -EFAULT); - status |= attempt( io_ctx, 2, bad2_ios, -EFAULT); - status |= attempt( io_ctx, -1, good_ios, -EINVAL); + status |= attempt_io_submit(BAD_CTX, 1, good_ios, -EINVAL); + status |= attempt_io_submit( io_ctx, 0, good_ios, 0); + status |= attempt_io_submit( io_ctx, 1, NULL, -EFAULT); + status |= attempt_io_submit( io_ctx, 1, (void *)-1, -EFAULT); + status |= attempt_io_submit( io_ctx, 2, bad1_ios, -EFAULT); + status |= attempt_io_submit( io_ctx, 2, bad2_ios, -EFAULT); + status |= attempt_io_submit( io_ctx, -1, good_ios, -EINVAL); return status; } diff --git a/harness/cases/6.t b/harness/cases/6.t index 9ace4b2..cea4b01 100644 --- a/harness/cases/6.t +++ b/harness/cases/6.t @@ -50,7 +50,7 @@ int test_main(void) status |= attempt_rw(rwfd, buf, size, 0, WRITE, size); status |= attempt_rw(rwfd, buf, size, 0, READ, size); - res = ftruncate(rwfd, 0); assert(res == 0); + //res = ftruncate(rwfd, 0); assert(res == 0); return status; } diff --git a/harness/cases/aio_setup.h b/harness/cases/aio_setup.h index 617d4b9..ed0947e 100644 --- a/harness/cases/aio_setup.h +++ b/harness/cases/aio_setup.h @@ -11,6 +11,21 @@ void aio_setup(int n) } } +int attempt_io_submit(io_context_t ctx, long nr, struct iocb *ios[], int expect) +{ + int res; + + printf("expect %3d: io_submit(%10p, %3ld, %10p) = ", expect, ctx, nr, ios); + fflush(stdout); + res = io_submit(ctx, nr, ios); + printf("%3d [%s]%s\n", res, (res <= 0) ? strerror(-res) : "", + (res != expect) ? " -- FAILED" : ""); + if (res != expect) + return 1; + + return 0; +} + int sync_submit(struct iocb *iocb) { struct io_event event; |