diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2009-10-09 18:17:02 +0000 |
---|---|---|
committer | <> | 2013-09-20 15:53:04 +0000 |
commit | e6a27c468cae77ce26f6aa924b22bd39055892fe (patch) | |
tree | 5799c05ec62d99e582db411ed0fe5ffd2ba519db /libaio-0.3.109/harness/cases/15.t | |
download | libaio-tarball-libaio_0.3.109.orig.tar.gz |
Imported from /home/lorry/working-area/delta_libaio-tarball/libaio_0.3.109.orig.tar.gz.HEADlibaio_0.3.109.origmaster
Diffstat (limited to 'libaio-0.3.109/harness/cases/15.t')
-rw-r--r-- | libaio-0.3.109/harness/cases/15.t | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/libaio-0.3.109/harness/cases/15.t b/libaio-0.3.109/harness/cases/15.t new file mode 100644 index 0000000..933d008 --- /dev/null +++ b/libaio-0.3.109/harness/cases/15.t @@ -0,0 +1,94 @@ +/* 15.t +- pwritev and preadv tests. +*/ +#include "aio_setup.h" +#include <sys/mman.h> +#include <sys/uio.h> +#include <errno.h> + +int test_main(void) +{ +#define SIZE 512 +#define NUM_IOV 10 + char buf[SIZE*NUM_IOV]; + struct iovec iov[NUM_IOV]; + int rwfd; + int status = 0, res, i; + + rwfd = open("testdir/rwfile", O_RDWR); assert(rwfd != -1); + res = ftruncate(rwfd, sizeof(buf)); assert(res == 0); + + for (i = 0; i < NUM_IOV; i++) { + iov[i].iov_base = buf + i*SIZE; + iov[i].iov_len = SIZE; + memset(iov[i].iov_base, i, SIZE); + } + status |= attempt_rw(rwfd, iov, NUM_IOV, 0, WRITEV, SIZE*NUM_IOV); + res = pread(rwfd, buf, sizeof(buf), 0); assert(res == sizeof(buf)); + for (i = 0; i < NUM_IOV; i++) { + unsigned int j; + for (j = 0; j < SIZE; j++) { + if (buf[i*SIZE + j] != i) { + printf("Unexpected value after writev at %i\n", + i*SIZE + j); + status |= 1; + break; + } + } + } + if (!status) + printf("Checking memory: [Success]\n"); + + memset(buf, 0, sizeof(buf)); + status |= attempt_rw(rwfd, iov, NUM_IOV, 0, READV, SIZE*NUM_IOV); + for (i = 0; i < NUM_IOV; i++) { + unsigned int j; + for (j = 0; j < SIZE; j++) { + if (buf[i*SIZE + j] != i) { + printf("Unexpected value after readv at %i\n", + i*SIZE + j); + status |= 1; + break; + } + } + } + + /* Check that offset works. */ + status |= attempt_rw(rwfd, iov+1, NUM_IOV-1, SIZE, WRITEV, + SIZE*(NUM_IOV-1)); + memset(buf, 0, sizeof(buf)); + res = pread(rwfd, buf, sizeof(buf), 0); assert(res == sizeof(buf)); + for (i = 1; i < NUM_IOV; i++) { + unsigned int j; + for (j = 0; j < SIZE; j++) { + if (buf[i*SIZE + j] != i) { + printf("Unexpected value after offset writev at %i\n", + i*SIZE + j); + status |= 1; + break; + } + } + } + if (!status) + printf("Checking memory: [Success]\n"); + + memset(buf, 0, sizeof(buf)); + status |= attempt_rw(rwfd, iov+1, NUM_IOV-1, SIZE, READV, + SIZE*(NUM_IOV-1)); + for (i = 1; i < NUM_IOV; i++) { + unsigned int j; + for (j = 0; j < SIZE; j++) { + if (buf[i*SIZE + j] != i) { + printf("Unexpected value after offset readv at %i\n", + i*SIZE + j); + status |= 1; + break; + } + } + } + if (!status) + printf("Checking memory: [Success]\n"); + + return status; +} + |