diff options
author | Ben LaHaise <bcrl@kvack.org> | 2002-04-20 00:26:22 +0000 |
---|---|---|
committer | Ben LaHaise <bcrl@kvack.org> | 2002-04-20 00:26:22 +0000 |
commit | ba5fc19bb03c934f84e60d7876f377c3d917355b (patch) | |
tree | 8de63fd938a8ee8838002b0bd6da32b3ae6aa1c6 | |
parent | 869154f74b9de746843b1a41101975c8a38f0b27 (diff) | |
download | libaio-ba5fc19bb03c934f84e60d7876f377c3d917355b.tar.gz |
- add FAILED messages in a few places to make certain failures more obvious.
- EFBIG fixes for 2.4.9
- check ENOSPC
-rw-r--r-- | harness/Makefile | 2 | ||||
-rw-r--r-- | harness/README | 2 | ||||
-rw-r--r-- | harness/cases/10.t | 44 | ||||
-rw-r--r-- | harness/cases/2.t | 3 | ||||
-rw-r--r-- | harness/cases/3.t | 3 | ||||
-rw-r--r-- | harness/cases/4.t | 3 | ||||
-rw-r--r-- | harness/cases/5.t | 14 | ||||
-rw-r--r-- | harness/cases/7.t | 27 | ||||
-rw-r--r-- | harness/cases/8.t | 49 | ||||
-rw-r--r-- | harness/cases/aio_setup.h | 3 | ||||
-rw-r--r-- | harness/cases/common-7-8.h | 37 | ||||
-rwxr-xr-x | harness/runtests.sh | 4 |
12 files changed, 184 insertions, 7 deletions
diff --git a/harness/Makefile b/harness/Makefile index dadedde..0d1b7a2 100644 --- a/harness/Makefile +++ b/harness/Makefile @@ -4,7 +4,7 @@ PROGS:=$(patsubst %.t,%.p,$(TEST_SRCS)) HARNESS_SRCS:=main.c # io_queue.c -CFLAGS=-Wall -g -O -laio -lredhat-kernel +CFLAGS=-Wall -Werror -g -O -laio -lredhat-kernel #-lpthread -lrt all: $(PROGS) diff --git a/harness/README b/harness/README index 3569ea2..5557370 100644 --- a/harness/README +++ b/harness/README @@ -15,3 +15,5 @@ to directories) are as follows: 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/harness/cases/10.t b/harness/cases/10.t new file mode 100644 index 0000000..8a6afe6 --- /dev/null +++ b/harness/cases/10.t @@ -0,0 +1,44 @@ +/* 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) +{ +#define LIMIT 8192 +#define SIZE 8192 + 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, 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/harness/cases/2.t b/harness/cases/2.t index d6d548d..e878bde 100644 --- a/harness/cases/2.t +++ b/harness/cases/2.t @@ -14,7 +14,8 @@ int attempt(int n, io_context_t *ctxp, int expect) printf("expect %3d: io_setup(%5d, %p) = ", expect, n, ctxp); fflush(stdout); res = io_setup(n, ctxp); - printf("%3d [%s]\n", res, strerror(-res)); + printf("%3d [%s]%s\n", res, strerror(-res), + (res != expect) ? " -- FAILED" : ""); if (res != expect) return 1; diff --git a/harness/cases/3.t b/harness/cases/3.t index cc77fb7..0d72241 100644 --- a/harness/cases/3.t +++ b/harness/cases/3.t @@ -11,7 +11,8 @@ int attempt(io_context_t ctx, long nr, struct iocb *ios[], int expect) printf("expect %3d: io_submit(%10p, %3ld, %10p) = ", expect, ctx, nr, ios); fflush(stdout); res = io_submit(ctx, nr, ios); - printf("%3d [%s]\n", res, (res <= 0) ? strerror(-res) : ""); + printf("%3d [%s]%s\n", res, (res <= 0) ? strerror(-res) : "", + (res != expect) ? " -- FAILED" : ""); if (res != expect) return 1; diff --git a/harness/cases/4.t b/harness/cases/4.t index 26e79c5..e6b6ef5 100644 --- a/harness/cases/4.t +++ b/harness/cases/4.t @@ -22,7 +22,8 @@ int attempt(int fd, void *buf, int count, long long pos, int rw, int expect) printf("expect %3d: (%c), res = ", expect, rw); fflush(stdout); res = sync_submit(&iocb); - printf("%3d [%s]\n", res, (res <= 0) ? strerror(-res) : "Success"); + printf("%3d [%s]%s\n", res, (res <= 0) ? strerror(-res) : "Success", + (res != expect) ? " -- FAILED" : ""); if (res != expect) return 1; diff --git a/harness/cases/5.t b/harness/cases/5.t index 07bbfd1..7669fd7 100644 --- a/harness/cases/5.t +++ b/harness/cases/5.t @@ -28,6 +28,20 @@ int test_main(void) 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/harness/cases/7.t b/harness/cases/7.t new file mode 100644 index 0000000..d2d6cbc --- /dev/null +++ b/harness/cases/7.t @@ -0,0 +1,27 @@ +/* 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/harness/cases/8.t b/harness/cases/8.t new file mode 100644 index 0000000..8a3d83e --- /dev/null +++ b/harness/cases/8.t @@ -0,0 +1,49 @@ +/* 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/harness/cases/aio_setup.h b/harness/cases/aio_setup.h index bcaf8a5..ee2bec4 100644 --- a/harness/cases/aio_setup.h +++ b/harness/cases/aio_setup.h @@ -54,7 +54,8 @@ int attempt_rw(int fd, void *buf, int count, long long pos, int rw, int expect) printf("expect %3d: (%c), res = ", expect, rw); fflush(stdout); res = sync_submit(&iocb); - printf("%3d [%s]\n", res, (res <= 0) ? strerror(-res) : "Success"); + printf("%3d [%s]%s\n", res, (res <= 0) ? strerror(-res) : "Success", + (res != expect) ? " -- FAILED" : ""); if (res != expect) return 1; diff --git a/harness/cases/common-7-8.h b/harness/cases/common-7-8.h new file mode 100644 index 0000000..3ec2bb4 --- /dev/null +++ b/harness/cases/common-7-8.h @@ -0,0 +1,37 @@ +/* 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/harness/runtests.sh b/harness/runtests.sh index bbb20b7..d763d88 100755 --- a/harness/runtests.sh +++ b/harness/runtests.sh @@ -11,8 +11,8 @@ while [ $# -ge 1 ] ; do echo "Starting $this_test" $this_test 2>&1 res=$? - if [ $res -eq 0 ] ; then passes=$[passes + 1] ; else fails=$[fails + 1] ; fi - echo "Completed $this_test with $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" |