diff options
Diffstat (limited to 'tools/libaio/harness')
-rw-r--r-- | tools/libaio/harness/Makefile | 37 | ||||
-rw-r--r-- | tools/libaio/harness/README | 19 | ||||
-rw-r--r-- | tools/libaio/harness/attic/0.t | 9 | ||||
-rw-r--r-- | tools/libaio/harness/attic/1.t | 9 | ||||
-rw-r--r-- | tools/libaio/harness/cases/10.t | 53 | ||||
-rw-r--r-- | tools/libaio/harness/cases/11.t | 39 | ||||
-rw-r--r-- | tools/libaio/harness/cases/12.t | 49 | ||||
-rw-r--r-- | tools/libaio/harness/cases/13.t | 66 | ||||
-rw-r--r-- | tools/libaio/harness/cases/14.t | 90 | ||||
-rw-r--r-- | tools/libaio/harness/cases/2.t | 41 | ||||
-rw-r--r-- | tools/libaio/harness/cases/3.t | 25 | ||||
-rw-r--r-- | tools/libaio/harness/cases/4.t | 72 | ||||
-rw-r--r-- | tools/libaio/harness/cases/5.t | 47 | ||||
-rw-r--r-- | tools/libaio/harness/cases/6.t | 57 | ||||
-rw-r--r-- | tools/libaio/harness/cases/7.t | 27 | ||||
-rw-r--r-- | tools/libaio/harness/cases/8.t | 49 | ||||
-rw-r--r-- | tools/libaio/harness/cases/aio_setup.h | 98 | ||||
-rw-r--r-- | tools/libaio/harness/cases/common-7-8.h | 37 | ||||
-rw-r--r-- | tools/libaio/harness/main.c | 39 | ||||
-rw-r--r-- | tools/libaio/harness/runtests.sh | 19 |
20 files changed, 0 insertions, 882 deletions
diff --git a/tools/libaio/harness/Makefile b/tools/libaio/harness/Makefile deleted file mode 100644 index d2483fdda2..0000000000 --- a/tools/libaio/harness/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# foo. -TEST_SRCS:=$(shell find cases/ -name \*.t | sort -n -t/ -k2) -PROGS:=$(patsubst %.t,%.p,$(TEST_SRCS)) -HARNESS_SRCS:=main.c -# io_queue.c - -CFLAGS=-Wall -Werror -g -O -laio -#-lpthread -lrt - -all: $(PROGS) - -$(PROGS): %.p: %.t $(HARNESS_SRCS) - $(CC) $(CFLAGS) -DTEST_NAME=\"$<\" -o $@ main.c - -clean: - rm -f $(PROGS) *.o runtests.out rofile wofile rwfile - -.PHONY: - -testdir/rofile: .PHONY - rm -f $@ - echo "test" >$@ - chmod 400 $@ - -testdir/wofile: .PHONY - rm -f $@ - echo "test" >$@ - chmod 200 $@ - -testdir/rwfile: .PHONY - rm -f $@ - echo "test" >$@ - chmod 600 $@ - -check: $(PROGS) testdir/rofile testdir/rwfile testdir/wofile - ./runtests.sh $(PROGS) - diff --git a/tools/libaio/harness/README b/tools/libaio/harness/README deleted file mode 100644 index 5557370589..0000000000 --- a/tools/libaio/harness/README +++ /dev/null @@ -1,19 +0,0 @@ -Notes on running this test suite: - -To run the test suite, run "make check". All test cases should pass -and there should be 0 fails. - -Several of the test cases require a directory on the filesystem under -test for the creation of test files, as well as the generation of -error conditions. The test cases assume the directories (or symlinks -to directories) are as follows: - - testdir/ - - used for general read/write test cases. Must have at - least as much free space as the machine has RAM (up - to 768MB). - testdir.enospc/ - - a filesystem that has space for writing 8KB out, but - fails with -ENOSPC beyond 8KB. - testdir.ext2/ - - must be an ext2 filesystem. diff --git a/tools/libaio/harness/attic/0.t b/tools/libaio/harness/attic/0.t deleted file mode 100644 index 033e62c1b2..0000000000 --- a/tools/libaio/harness/attic/0.t +++ /dev/null @@ -1,9 +0,0 @@ -/* 0.t - Test harness check: okay. -*/ -int test_main(void) -{ - printf("test_main: okay\n"); - return 0; -} - diff --git a/tools/libaio/harness/attic/1.t b/tools/libaio/harness/attic/1.t deleted file mode 100644 index 799ffd179a..0000000000 --- a/tools/libaio/harness/attic/1.t +++ /dev/null @@ -1,9 +0,0 @@ -/* 1.t - Test harness check: fail. -*/ -int test_main(void) -{ - printf("test_main: fail\n"); - return 1; -} - diff --git a/tools/libaio/harness/cases/10.t b/tools/libaio/harness/cases/10.t deleted file mode 100644 index 9d3beb2fdb..0000000000 --- a/tools/libaio/harness/cases/10.t +++ /dev/null @@ -1,53 +0,0 @@ -/* 10.t - uses testdir.enospc/rwfile -- Check results on out-of-space and out-of-quota. (10.t) - - write that fills filesystem but does not go over should succeed - - write that fills filesystem and goes over should be partial - - write to full filesystem should return -ENOSPC - - read beyond end of file after ENOSPC should return 0 -*/ -#include "aio_setup.h" - -#include <sys/time.h> -#include <sys/resource.h> -#include <unistd.h> - -int test_main(void) -{ -/* Note: changing either of these requires updating the ext2-enospc.img - * filesystem image. Also, if SIZE is less than PAGE_SIZE, problems - * crop up due to ext2's preallocation. - */ -#define LIMIT 65536 -#define SIZE 65536 - char *buf; - int rwfd; - int status = 0, res; - - rwfd = open("testdir.enospc/rwfile", O_RDWR|O_CREAT|O_TRUNC, 0600); - assert(rwfd != -1); - res = ftruncate(rwfd, 0); assert(res == 0); - buf = malloc(SIZE); assert(buf != NULL); - memset(buf, 0, SIZE); - - - status |= attempt_rw(rwfd, buf, SIZE, LIMIT-SIZE, WRITE, SIZE); - status |= attempt_rw(rwfd, buf, SIZE, LIMIT-SIZE, READ, SIZE); - - status |= attempt_rw(rwfd, buf, SIZE, LIMIT, WRITE, -ENOSPC); - status |= attempt_rw(rwfd, buf, SIZE, LIMIT, READ, 0); - - res = ftruncate(rwfd, 0); assert(res == 0); - - status |= attempt_rw(rwfd, buf, SIZE, 1+LIMIT-SIZE, WRITE, SIZE-1); - status |= attempt_rw(rwfd, buf, SIZE, 1+LIMIT-SIZE, READ, SIZE-1); - status |= attempt_rw(rwfd, buf, SIZE, LIMIT, READ, 0); - - status |= attempt_rw(rwfd, buf, SIZE, LIMIT, WRITE, -ENOSPC); - status |= attempt_rw(rwfd, buf, SIZE, LIMIT, READ, 0); - status |= attempt_rw(rwfd, buf, 0, LIMIT, WRITE, 0); - - res = close(rwfd); assert(res == 0); - res = unlink("testdir.enospc/rwfile"); assert(res == 0); - return status; -} - diff --git a/tools/libaio/harness/cases/11.t b/tools/libaio/harness/cases/11.t deleted file mode 100644 index efcf6d45f3..0000000000 --- a/tools/libaio/harness/cases/11.t +++ /dev/null @@ -1,39 +0,0 @@ -/* 11.t - uses testdir/rwfile -- repeated read / write of same page (to check accounting) (11.t) -*/ -#include "aio_setup.h" - -#include <sys/time.h> -#include <sys/resource.h> -#include <unistd.h> - -int test_main(void) -{ -#define COUNT 1000000 -#define SIZE 256 - char *buf; - int rwfd; - int status = 0; - int i; - - rwfd = open("testdir/rwfile", O_RDWR|O_CREAT|O_TRUNC, 0600); - assert(rwfd != -1); - buf = malloc(SIZE); assert(buf != NULL); - memset(buf, 0, SIZE); - - for (i=0; i<COUNT; i++) { - status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE_SILENT, SIZE); - if (status) - break; - } - printf("completed %d out of %d writes\n", i, COUNT); - for (i=0; i<COUNT; i++) { - status |= attempt_rw(rwfd, buf, SIZE, 0, READ_SILENT, SIZE); - if (status) - break; - } - printf("completed %d out of %d reads\n", i, COUNT); - - return status; -} - diff --git a/tools/libaio/harness/cases/12.t b/tools/libaio/harness/cases/12.t deleted file mode 100644 index 3499204440..0000000000 --- a/tools/libaio/harness/cases/12.t +++ /dev/null @@ -1,49 +0,0 @@ -/* 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/tools/libaio/harness/cases/13.t b/tools/libaio/harness/cases/13.t deleted file mode 100644 index 5f18005b6a..0000000000 --- a/tools/libaio/harness/cases/13.t +++ /dev/null @@ -1,66 +0,0 @@ -/* 13.t - uses testdir/rwfile -- Submit multiple writes larger than aio-max-size (deadlocks on older - aio code) -*/ -#include "aio_setup.h" - -#include <sys/time.h> -#include <sys/resource.h> -#include <unistd.h> - -int test_main(void) -{ -#define SIZE (1024 * 1024) -#define IOS 8 - struct iocb iocbs[IOS]; - struct iocb *iocb_list[IOS]; - char *bufs[IOS]; - int rwfd; - int status = 0, res; - int i; - - rwfd = open("testdir/rwfile", O_RDWR|O_CREAT|O_TRUNC, 0600); - assert(rwfd != -1); - res = ftruncate(rwfd, 0); assert(res == 0); - - for (i=0; i<IOS; i++) { - bufs[i] = malloc(SIZE); - assert(bufs[i] != NULL); - memset(bufs[i], 0, SIZE); - - io_prep_pwrite(&iocbs[i], rwfd, bufs[i], SIZE, i * SIZE); - iocb_list[i] = &iocbs[i]; - } - - status |= attempt_io_submit(io_ctx, IOS, iocb_list, IOS); - - for (i=0; i<IOS; i++) { - struct timespec ts = { tv_sec: 30, tv_nsec: 0 }; - struct io_event event; - struct iocb *iocb; - - res = io_getevents(io_ctx, 0, 1, &event, &ts); - if (res != 1) { - status |= 1; - printf("io_getevents failed [%d] with res=%d [%s]\n", - i, res, (res < 0) ? strerror(-res) : "okay"); - break; - } - - if (event.res != SIZE) - status |= 1; - - iocb = (void *)event.obj; - printf("event[%d]: write[%d] %s, returned: %ld [%s]\n", - i, (int)(iocb - &iocbs[0]), - (event.res != SIZE) ? "failed" : "okay", - (long)event.res, - (event.res < 0) ? strerror(-event.res) : "okay" - ); - } - - res = ftruncate(rwfd, 0); assert(res == 0); - res = close(rwfd); assert(res == 0); - return status; -} - diff --git a/tools/libaio/harness/cases/14.t b/tools/libaio/harness/cases/14.t deleted file mode 100644 index 514622b569..0000000000 --- a/tools/libaio/harness/cases/14.t +++ /dev/null @@ -1,90 +0,0 @@ -#include <sys/types.h> -#include <sys/wait.h> -#include <unistd.h> -#include <signal.h> - -#include "aio_setup.h" -#include <sys/mman.h> - -#define SIZE 768*1024*1024 - -//just submit an I/O - -int test_child(void) -{ - char *buf; - int rwfd; - int res; - long size; - struct iocb iocb; - struct iocb *iocbs[] = { &iocb }; - int loop = 10; - int i; - - aio_setup(1024); - - size = SIZE; - - printf("size = %ld\n", size); - - rwfd = open("testdir/rwfile", O_RDWR); assert(rwfd != --1); - res = ftruncate(rwfd, 0); assert(res == 0); - buf = malloc(size); assert(buf != -NULL); - - for(i=0;i<loop;i++) { - - switch(i%2) { - case 0: - io_prep_pwrite(&iocb, rwfd, buf, size, 0); - break; - case 1: - io_prep_pread(&iocb, rwfd, buf, size, 0); - } - - res = io_submit(io_ctx, 1, iocbs); - if (res != 1) { - printf("child: submit: io_submit res=%d [%s]\n", res, -strerror(-res)); - _exit(1); - } - } - - res = ftruncate(rwfd, 0); assert(res == 0); - - _exit(0); -} - -/* from 12.t */ -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/tools/libaio/harness/cases/2.t b/tools/libaio/harness/cases/2.t deleted file mode 100644 index 3a0212d698..0000000000 --- a/tools/libaio/harness/cases/2.t +++ /dev/null @@ -1,41 +0,0 @@ -/* 2.t -- io_setup (#2) - - with invalid context pointer - - with maxevents <= 0 - - with an already initialized ctxp -*/ - -int attempt(int n, io_context_t *ctxp, int expect) -{ - int res; - - printf("expect %3d: io_setup(%5d, %p) = ", expect, n, ctxp); - fflush(stdout); - res = io_setup(n, ctxp); - printf("%3d [%s]%s\n", res, strerror(-res), - (res != expect) ? " -- FAILED" : ""); - if (res != expect) - return 1; - - return 0; -} - -int test_main(void) -{ - io_context_t ctx; - int status = 0; - - ctx = NULL; - status |= attempt(-1000, KERNEL_RW_POINTER, -EFAULT); - status |= attempt( 1000, KERNEL_RW_POINTER, -EFAULT); - status |= attempt( 0, KERNEL_RW_POINTER, -EFAULT); - status |= attempt(-1000, &ctx, -EINVAL); - status |= attempt( -1, &ctx, -EINVAL); - status |= attempt( 0, &ctx, -EINVAL); - assert(ctx == NULL); - status |= attempt( 1, &ctx, 0); - status |= attempt( 1, &ctx, -EINVAL); - - return status; -} - diff --git a/tools/libaio/harness/cases/3.t b/tools/libaio/harness/cases/3.t deleted file mode 100644 index 7773d80f06..0000000000 --- a/tools/libaio/harness/cases/3.t +++ /dev/null @@ -1,25 +0,0 @@ -/* 3.t -- io_submit/io_getevents with invalid addresses (3.t) - -*/ -#include "aio_setup.h" - -int test_main(void) -{ - struct iocb a, b; - struct iocb *good_ios[] = { &a, &b }; - struct iocb *bad1_ios[] = { NULL, &b }; - struct iocb *bad2_ios[] = { KERNEL_RW_POINTER, &a }; - int status = 0; - - 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/tools/libaio/harness/cases/4.t b/tools/libaio/harness/cases/4.t deleted file mode 100644 index 972b4f24b1..0000000000 --- a/tools/libaio/harness/cases/4.t +++ /dev/null @@ -1,72 +0,0 @@ -/* 4.t -- read of descriptor without read permission (4.t) -- write to descriptor without write permission (4.t) -- check that O_APPEND writes actually append - -*/ -#include "aio_setup.h" - -#define SIZE 512 -#define READ 'r' -#define WRITE 'w' -int attempt(int fd, void *buf, int count, long long pos, int rw, int expect) -{ - struct iocb iocb; - int res; - - switch(rw) { - case READ: io_prep_pread (&iocb, fd, buf, count, pos); break; - case WRITE: io_prep_pwrite(&iocb, fd, buf, count, pos); break; - } - - printf("expect %3d: (%c), res = ", expect, rw); - fflush(stdout); - res = sync_submit(&iocb); - printf("%3d [%s]%s\n", res, (res <= 0) ? strerror(-res) : "Success", - (res != expect) ? " -- FAILED" : ""); - if (res != expect) - return 1; - - return 0; -} - -int test_main(void) -{ - char buf[SIZE]; - int rofd, wofd, rwfd; - int status = 0, res; - - memset(buf, 0, SIZE); - - rofd = open("testdir/rofile", O_RDONLY); assert(rofd != -1); - wofd = open("testdir/wofile", O_WRONLY); assert(wofd != -1); - rwfd = open("testdir/rwfile", O_RDWR); assert(rwfd != -1); - - status |= attempt(rofd, buf, SIZE, 0, WRITE, -EBADF); - status |= attempt(wofd, buf, SIZE, 0, READ, -EBADF); - status |= attempt(rwfd, buf, SIZE, 0, WRITE, SIZE); - status |= attempt(rwfd, buf, SIZE, 0, READ, SIZE); - status |= attempt(rwfd, buf, SIZE, -1, READ, -EINVAL); - status |= attempt(rwfd, buf, SIZE, -1, WRITE, -EINVAL); - - rwfd = open("testdir/rwfile", O_RDWR|O_APPEND); assert(rwfd != -1); - res = ftruncate(rwfd, 0); assert(res == 0); - status |= attempt(rwfd, buf, SIZE, 0, READ, 0); - status |= attempt(rwfd, "1234", 4, 0, WRITE, 4); - status |= attempt(rwfd, "5678", 4, 0, WRITE, 4); - memset(buf, 0, SIZE); - status |= attempt(rwfd, buf, SIZE, 0, READ, 8); - printf("read after append: [%s]\n", buf); - assert(memcmp(buf, "12345678", 8) == 0); - - status |= attempt(rwfd, KERNEL_RW_POINTER, SIZE, 0, READ, -EFAULT); - status |= attempt(rwfd, KERNEL_RW_POINTER, SIZE, 0, WRITE, -EFAULT); - - /* Some architectures map the 0 page. Ugh. */ -#if !defined(__ia64__) - status |= attempt(rwfd, NULL, SIZE, 0, WRITE, -EFAULT); -#endif - - return status; -} - diff --git a/tools/libaio/harness/cases/5.t b/tools/libaio/harness/cases/5.t deleted file mode 100644 index 7669fd7006..0000000000 --- a/tools/libaio/harness/cases/5.t +++ /dev/null @@ -1,47 +0,0 @@ -/* 5.t -- Write from a mmap() of the same file. (5.t) -*/ -#include "aio_setup.h" -#include <sys/mman.h> - -int test_main(void) -{ - int page_size = getpagesize(); -#define SIZE 512 - char *buf; - int rwfd; - int status = 0, res; - - rwfd = open("testdir/rwfile", O_RDWR); assert(rwfd != -1); - res = ftruncate(rwfd, 512); assert(res == 0); - - buf = mmap(0, page_size, PROT_READ|PROT_WRITE, MAP_SHARED, rwfd, 0); - assert(buf != (char *)-1); - - status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE, SIZE); - status |= attempt_rw(rwfd, buf, SIZE, 0, READ, SIZE); - - res = munmap(buf, page_size); assert(res == 0); - buf = mmap(0, page_size, PROT_READ|PROT_WRITE, MAP_SHARED, rwfd, 0); - assert(buf != (char *)-1); - - status |= attempt_rw(rwfd, buf, SIZE, 0, READ, SIZE); - status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE, SIZE); - - res = munmap(buf, page_size); assert(res == 0); - buf = mmap(0, page_size, PROT_READ, MAP_SHARED, rwfd, 0); - assert(buf != (char *)-1); - - status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE, SIZE); - status |= attempt_rw(rwfd, buf, SIZE, 0, READ, -EFAULT); - - res = munmap(buf, page_size); assert(res == 0); - buf = mmap(0, page_size, PROT_WRITE, MAP_SHARED, rwfd, 0); - assert(buf != (char *)-1); - - status |= attempt_rw(rwfd, buf, SIZE, 0, READ, SIZE); - status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE, -EFAULT); - - return status; -} - diff --git a/tools/libaio/harness/cases/6.t b/tools/libaio/harness/cases/6.t deleted file mode 100644 index cea4b01c96..0000000000 --- a/tools/libaio/harness/cases/6.t +++ /dev/null @@ -1,57 +0,0 @@ -/* 6.t -- huge reads (pinned pages) (6.t) -- huge writes (6.t) -*/ -#include "aio_setup.h" -#include <sys/mman.h> - -long getmemsize(void) -{ - FILE *f = fopen("/proc/meminfo", "r"); - long size; - int gotit = 0; - char str[256]; - - assert(f != NULL); - while (NULL != fgets(str, 255, f)) { - str[255] = 0; - if (0 == memcmp(str, "MemTotal:", 9)) { - if (1 == sscanf(str + 9, "%ld", &size)) { - gotit = 1; - break; - } - } - } - fclose(f); - - assert(gotit != 0); - return size; -} - -int test_main(void) -{ - char *buf; - int rwfd; - int status = 0, res; - long size; - - size = getmemsize(); - printf("size = %ld\n", size); - assert(size >= (16 * 1024)); - if (size > (768 * 1024)) - size = 768 * 1024; - size *= 1024; - - rwfd = open("testdir/rwfile", O_RDWR); assert(rwfd != -1); - res = ftruncate(rwfd, 0); assert(res == 0); - buf = malloc(size); assert(buf != NULL); - - //memset(buf, 0, size); - 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); - - return status; -} - diff --git a/tools/libaio/harness/cases/7.t b/tools/libaio/harness/cases/7.t deleted file mode 100644 index d2d6cbc653..0000000000 --- a/tools/libaio/harness/cases/7.t +++ /dev/null @@ -1,27 +0,0 @@ -/* 7.t -- Write overlapping the file size rlimit boundary: should be a short - write. (7.t) -- Write at the file size rlimit boundary: should give EFBIG. (I think - the spec requires that you do NOT deliver SIGXFSZ in this case, where - you would do so for sync IO.) (7.t) -- Special case: a write of zero bytes at or beyond the file size rlimit - boundary must return success. (7.t) -*/ - -#include <sys/resource.h> - -void SET_RLIMIT(long long limit) -{ - struct rlimit rlim; - int res; - - rlim.rlim_cur = limit; assert(rlim.rlim_cur == limit); - rlim.rlim_max = limit; assert(rlim.rlim_max == limit); - - res = setrlimit(RLIMIT_FSIZE, &rlim); assert(res == 0); -} - -#define LIMIT 8192 -#define FILENAME "testdir/rwfile" - -#include "common-7-8.h" diff --git a/tools/libaio/harness/cases/8.t b/tools/libaio/harness/cases/8.t deleted file mode 100644 index 8a3d83ec94..0000000000 --- a/tools/libaio/harness/cases/8.t +++ /dev/null @@ -1,49 +0,0 @@ -/* 8.t -- Ditto for the above three tests at the offset maximum (largest - possible ext2/3 file size.) (8.t) - */ -#include <sys/vfs.h> - -#define EXT2_OLD_SUPER_MAGIC 0xEF51 -#define EXT2_SUPER_MAGIC 0xEF53 - -long long get_fs_limit(int fd) -{ - struct statfs s; - int res; - long long lim = 0; - - res = fstatfs(fd, &s); assert(res == 0); - - switch(s.f_type) { - case EXT2_OLD_SUPER_MAGIC: - case EXT2_SUPER_MAGIC: -#if 0 - { - long long tmp; - tmp = s.f_bsize / 4; - /* 12 direct + indirect block + dind + tind */ - lim = 12 + tmp + tmp * tmp + tmp * tmp * tmp; - lim *= s.f_bsize; - printf("limit(%ld) = %Ld\n", (long)s.f_bsize, lim); - } -#endif - switch(s.f_bsize) { - case 4096: lim = 2199023251456; break; - default: - printf("unknown ext2 blocksize %ld\n", (long)s.f_bsize); - exit(3); - } - break; - default: - printf("unknown filesystem 0x%08lx\n", (long)s.f_type); - exit(3); - } - return lim; -} - -#define SET_RLIMIT(x) do ; while (0) -#define LIMIT get_fs_limit(rwfd) -#define FILENAME "testdir.ext2/rwfile" - -#include "common-7-8.h" diff --git a/tools/libaio/harness/cases/aio_setup.h b/tools/libaio/harness/cases/aio_setup.h deleted file mode 100644 index 37c96189b2..0000000000 --- a/tools/libaio/harness/cases/aio_setup.h +++ /dev/null @@ -1,98 +0,0 @@ -io_context_t io_ctx; -#define BAD_CTX ((io_context_t)-1) - -void aio_setup(int n) -{ - int res = io_queue_init(n, &io_ctx); - if (res != 0) { - printf("io_queue_setup(%d) returned %d (%s)\n", - n, res, strerror(-res)); - exit(3); - } -} - -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; - struct iocb *iocbs[] = { iocb }; - int res; - - /* 30 second timeout should be enough */ - struct timespec ts; - ts.tv_sec = 30; - ts.tv_nsec = 0; - - res = io_submit(io_ctx, 1, iocbs); - if (res != 1) { - printf("sync_submit: io_submit res=%d [%s]\n", res, strerror(-res)); - return res; - } - - res = io_getevents(io_ctx, 0, 1, &event, &ts); - if (res != 1) { - printf("sync_submit: io_getevents res=%d [%s]\n", res, strerror(-res)); - return res; - } - return event.res; -} - -#define SETUP aio_setup(1024) - - -#define READ 'r' -#define WRITE 'w' -#define READ_SILENT 'R' -#define WRITE_SILENT 'W' -int attempt_rw(int fd, void *buf, int count, long long pos, int rw, int expect) -{ - struct iocb iocb; - int res; - int silent = 0; - - switch(rw) { - case READ_SILENT: - silent = 1; - case READ: - io_prep_pread (&iocb, fd, buf, count, pos); - break; - case WRITE_SILENT: - silent = 1; - case WRITE: - io_prep_pwrite(&iocb, fd, buf, count, pos); - break; - } - - if (!silent) { - printf("expect %5d: (%c), res = ", expect, rw); - fflush(stdout); - } - res = sync_submit(&iocb); - if (!silent || res != expect) { - if (silent) - printf("expect %5d: (%c), res = ", expect, rw); - printf("%5d [%s]%s\n", res, - (res <= 0) ? strerror(-res) : "Success", - (res != expect) ? " -- FAILED" : ""); - } - - if (res != expect) - return 1; - - return 0; -} - diff --git a/tools/libaio/harness/cases/common-7-8.h b/tools/libaio/harness/cases/common-7-8.h deleted file mode 100644 index 3ec2bb439d..0000000000 --- a/tools/libaio/harness/cases/common-7-8.h +++ /dev/null @@ -1,37 +0,0 @@ -/* common-7-8.h -*/ -#include "aio_setup.h" - -#include <unistd.h> - -#define SIZE 512 - -int test_main(void) -{ - char *buf; - int rwfd; - int status = 0, res; - long long limit; - - rwfd = open(FILENAME, O_RDWR); assert(rwfd != -1); - res = ftruncate(rwfd, 0); assert(res == 0); - buf = malloc(SIZE); assert(buf != NULL); - memset(buf, 0, SIZE); - - limit = LIMIT; - - SET_RLIMIT(limit); - - status |= attempt_rw(rwfd, buf, SIZE, limit-SIZE, WRITE, SIZE); - status |= attempt_rw(rwfd, buf, SIZE, limit-SIZE, READ, SIZE); - - status |= attempt_rw(rwfd, buf, SIZE, 1+limit-SIZE, WRITE, SIZE-1); - status |= attempt_rw(rwfd, buf, SIZE, 1+limit-SIZE, READ, SIZE-1); - - status |= attempt_rw(rwfd, buf, SIZE, limit, WRITE, -EFBIG); - status |= attempt_rw(rwfd, buf, SIZE, limit, READ, 0); - status |= attempt_rw(rwfd, buf, 0, limit, WRITE, 0); - - return status; -} - diff --git a/tools/libaio/harness/main.c b/tools/libaio/harness/main.c deleted file mode 100644 index 74b2764620..0000000000 --- a/tools/libaio/harness/main.c +++ /dev/null @@ -1,39 +0,0 @@ -#include <stdio.h> -#include <errno.h> -#include <assert.h> -#include <stdlib.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> - -#include <libaio.h> - -#if defined(__i386__) -#define KERNEL_RW_POINTER ((void *)0xc0010000) -#else -//#warning Not really sure where kernel memory is. Guessing. -#define KERNEL_RW_POINTER ((void *)0xffffffffc0010000) -#endif - - -char test_name[] = TEST_NAME; - -#include TEST_NAME - -int main(void) -{ - int res; - -#if defined(SETUP) - SETUP; -#endif - - res = test_main(); - printf("test %s completed %s.\n", test_name, - res ? "FAILED" : "PASSED" - ); - fflush(stdout); - return res ? 1 : 0; -} diff --git a/tools/libaio/harness/runtests.sh b/tools/libaio/harness/runtests.sh deleted file mode 100644 index d763d88b31..0000000000 --- a/tools/libaio/harness/runtests.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -passes=0 -fails=0 - -echo "Test run starting at" `date` - -while [ $# -ge 1 ] ; do - this_test=$1 - shift - echo "Starting $this_test" - $this_test 2>&1 - res=$? - if [ $res -eq 0 ] ; then str="" ; passes=$[passes + 1] ; else str=" -- FAILED" ; fails=$[fails + 1] ; fi - echo "Completed $this_test with $res$str". -done - -echo "Pass: $passes Fail: $fails" -echo "Test run complete at" `date` |