diff options
author | Ben LaHaise <bcrl@kvack.org> | 2002-04-23 22:41:42 +0000 |
---|---|---|
committer | Ben LaHaise <bcrl@kvack.org> | 2002-04-23 22:41:42 +0000 |
commit | 37350fa4f94b49345d81177343b5673d5096f5d1 (patch) | |
tree | de883418e8ccaf46d3cefe5131ae8559fe816996 | |
parent | 1d76943d543eacdc3a5476749d391b732301c79b (diff) | |
download | libaio-37350fa4f94b49345d81177343b5673d5096f5d1.tar.gz |
11.t: check for memory leaks in accounting with many repeated read/writes
6.t: don't memset (slows things down)
aio_setup.h: support for _SILENT read/writes
ext2-enospc.img: test filesystem image for ENOSPC case.
-rw-r--r-- | harness/cases/10.t | 1 | ||||
-rw-r--r-- | harness/cases/11.t | 39 | ||||
-rw-r--r-- | harness/cases/6.t | 2 | ||||
-rw-r--r-- | harness/cases/aio_setup.h | 35 | ||||
-rw-r--r-- | harness/ext2-enospc.img | bin | 0 -> 409600 bytes |
5 files changed, 68 insertions, 9 deletions
diff --git a/harness/cases/10.t b/harness/cases/10.t index 8cda16a..e1ff4fe 100644 --- a/harness/cases/10.t +++ b/harness/cases/10.t @@ -30,6 +30,7 @@ int test_main(void) 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); diff --git a/harness/cases/11.t b/harness/cases/11.t new file mode 100644 index 0000000..efcf6d4 --- /dev/null +++ b/harness/cases/11.t @@ -0,0 +1,39 @@ +/* 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/harness/cases/6.t b/harness/cases/6.t index e4fb5e6..9ace4b2 100644 --- a/harness/cases/6.t +++ b/harness/cases/6.t @@ -45,8 +45,8 @@ int test_main(void) 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); + //memset(buf, 0, size); status |= attempt_rw(rwfd, buf, size, 0, WRITE, size); status |= attempt_rw(rwfd, buf, size, 0, READ, size); diff --git a/harness/cases/aio_setup.h b/harness/cases/aio_setup.h index ee2bec4..617d4b9 100644 --- a/harness/cases/aio_setup.h +++ b/harness/cases/aio_setup.h @@ -39,23 +39,42 @@ int sync_submit(struct iocb *iocb) #define SETUP aio_setup(1024) -#define READ 'r' -#define WRITE 'w' +#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: io_prep_pread (&iocb, fd, buf, count, pos); break; - case WRITE: io_prep_pwrite(&iocb, fd, buf, count, pos); break; + 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; } - printf("expect %3d: (%c), res = ", expect, rw); - fflush(stdout); + if (!silent) { + printf("expect %5d: (%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 (!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; diff --git a/harness/ext2-enospc.img b/harness/ext2-enospc.img Binary files differnew file mode 100644 index 0000000..74c0f0e --- /dev/null +++ b/harness/ext2-enospc.img |