summaryrefslogtreecommitdiff
path: root/libaio-0.3.109/harness/cases
diff options
context:
space:
mode:
Diffstat (limited to 'libaio-0.3.109/harness/cases')
-rw-r--r--libaio-0.3.109/harness/cases/10.t53
-rw-r--r--libaio-0.3.109/harness/cases/11.t39
-rw-r--r--libaio-0.3.109/harness/cases/12.t53
-rw-r--r--libaio-0.3.109/harness/cases/13.t66
-rw-r--r--libaio-0.3.109/harness/cases/14.t93
-rw-r--r--libaio-0.3.109/harness/cases/15.t94
-rw-r--r--libaio-0.3.109/harness/cases/16.t94
-rw-r--r--libaio-0.3.109/harness/cases/2.t41
-rw-r--r--libaio-0.3.109/harness/cases/3.t25
-rw-r--r--libaio-0.3.109/harness/cases/4.t72
-rw-r--r--libaio-0.3.109/harness/cases/5.t54
-rw-r--r--libaio-0.3.109/harness/cases/6.t57
-rw-r--r--libaio-0.3.109/harness/cases/7.t30
-rw-r--r--libaio-0.3.109/harness/cases/8.t28
-rw-r--r--libaio-0.3.109/harness/cases/aio_setup.h108
-rw-r--r--libaio-0.3.109/harness/cases/common-7-8.h38
16 files changed, 945 insertions, 0 deletions
diff --git a/libaio-0.3.109/harness/cases/10.t b/libaio-0.3.109/harness/cases/10.t
new file mode 100644
index 0000000..9d3beb2
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/10.t
@@ -0,0 +1,53 @@
+/* 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/libaio-0.3.109/harness/cases/11.t b/libaio-0.3.109/harness/cases/11.t
new file mode 100644
index 0000000..efcf6d4
--- /dev/null
+++ b/libaio-0.3.109/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/libaio-0.3.109/harness/cases/12.t b/libaio-0.3.109/harness/cases/12.t
new file mode 100644
index 0000000..e87d1dc
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/12.t
@@ -0,0 +1,53 @@
+/* 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;
+ sigset_t set;
+
+ if (attempt_io_submit(io_ctx, 0, NULL, 0))
+ return 1;
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &set, NULL);
+
+ 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/libaio-0.3.109/harness/cases/13.t b/libaio-0.3.109/harness/cases/13.t
new file mode 100644
index 0000000..5f18005
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/13.t
@@ -0,0 +1,66 @@
+/* 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/libaio-0.3.109/harness/cases/14.t b/libaio-0.3.109/harness/cases/14.t
new file mode 100644
index 0000000..87773e3
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/14.t
@@ -0,0 +1,93 @@
+#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;
+ sigset_t set;
+
+ if (attempt_io_submit(io_ctx, 0, NULL, 0))
+ return 1;
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &set, NULL);
+ 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/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;
+}
+
diff --git a/libaio-0.3.109/harness/cases/16.t b/libaio-0.3.109/harness/cases/16.t
new file mode 100644
index 0000000..c3157cc
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/16.t
@@ -0,0 +1,94 @@
+/* 16.t
+- eventfd tests.
+*/
+#include <stdint.h>
+#include <err.h>
+#include <sys/syscall.h> /* For SYS_xxx definitions */
+
+#ifndef SYS_eventfd
+#if defined(__i386__)
+#define SYS_eventfd 323
+#elif defined(__x86_64__)
+#define SYS_eventfd 284
+#elif defined(__ia64__)
+#define SYS_eventfd 1309
+#elif defined(__PPC__)
+#define SYS_eventfd 307
+#elif defined(__s390__)
+#define SYS_eventfd 318
+#elif defined(__alpha__)
+#define SYS_eventfd 478
+#else
+#error define SYS_eventfd for your arch!
+#endif
+#endif
+
+int test_main(void)
+{
+ /* 10 MB takes long enough that we would fail if eventfd
+ * returned immediately. */
+#define SIZE 10000000
+ char *buf;
+ struct io_event io_event;
+ struct iocb iocb;
+ struct iocb *iocbs[] = { &iocb };
+ int rwfd, efd;
+ int res;
+ io_context_t io_ctx;
+ uint64_t event;
+ struct timespec notime = { .tv_sec = 0, .tv_nsec = 0 };
+
+ buf = malloc(SIZE); assert(buf);
+ efd = syscall(SYS_eventfd, 0);
+ if (efd < 0) {
+ if (errno == ENOSYS) {
+ printf("No eventfd support. [SKIPPING]\n");
+ exit(0);
+ }
+ err(1, "Failed to get eventfd");
+ }
+
+ rwfd = open("testdir/rwfile", O_RDWR); assert(rwfd != -1);
+ res = ftruncate(rwfd, 0); assert(res == 0);
+ memset(buf, 0x42, SIZE);
+
+ /* Write test. */
+ res = io_queue_init(1024, &io_ctx); assert(res == 0);
+ io_prep_pwrite(&iocb, rwfd, buf, SIZE, 0);
+ io_set_eventfd(&iocb, efd);
+ res = io_submit(io_ctx, 1, iocbs); assert(res == 1);
+
+ alarm(30);
+ res = read(efd, &event, sizeof(event)); assert(res == sizeof(event));
+ assert(event == 1);
+
+ /* This should now be ready. */
+ res = io_getevents(io_ctx, 0, 1, &io_event, &notime);
+ if (res != 1)
+ err(1, "io_getevents did not return 1 event after eventfd");
+ assert(io_event.res == SIZE);
+ printf("eventfd write test [SUCCESS]\n");
+
+ /* Read test. */
+ memset(buf, 0, SIZE);
+ io_prep_pread(&iocb, rwfd, buf, SIZE, 0);
+ io_set_eventfd(&iocb, efd);
+ res = io_submit(io_ctx, 1, iocbs); assert(res == 1);
+
+ alarm(30);
+ res = read(efd, &event, sizeof(event)); assert(res == sizeof(event));
+ assert(event == 1);
+
+ /* This should now be ready. */
+ res = io_getevents(io_ctx, 0, 1, &io_event, &notime);
+ if (res != 1)
+ err(1, "io_getevents did not return 1 event after eventfd");
+ assert(io_event.res == SIZE);
+
+ for (res = 0; res < SIZE; res++)
+ assert(buf[res] == 0x42);
+ printf("eventfd read test [SUCCESS]\n");
+
+ return 0;
+}
+
diff --git a/libaio-0.3.109/harness/cases/2.t b/libaio-0.3.109/harness/cases/2.t
new file mode 100644
index 0000000..3a0212d
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/2.t
@@ -0,0 +1,41 @@
+/* 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/libaio-0.3.109/harness/cases/3.t b/libaio-0.3.109/harness/cases/3.t
new file mode 100644
index 0000000..7773d80
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/3.t
@@ -0,0 +1,25 @@
+/* 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/libaio-0.3.109/harness/cases/4.t b/libaio-0.3.109/harness/cases/4.t
new file mode 100644
index 0000000..972b4f2
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/4.t
@@ -0,0 +1,72 @@
+/* 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/libaio-0.3.109/harness/cases/5.t b/libaio-0.3.109/harness/cases/5.t
new file mode 100644
index 0000000..2b4b4bb
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/5.t
@@ -0,0 +1,54 @@
+/* 5.t
+- Write from a mmap() of the same file. (5.t)
+*/
+#include "aio_setup.h"
+#include <sys/mman.h>
+#include <errno.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);
+
+ /* Whether PROT_WRITE is readable is arch-dependent. So compare
+ * against read result. */
+ res = read(rwfd, buf, SIZE);
+ if (res < 0)
+ res = -errno;
+ status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE, res);
+
+ return status;
+}
+
diff --git a/libaio-0.3.109/harness/cases/6.t b/libaio-0.3.109/harness/cases/6.t
new file mode 100644
index 0000000..cea4b01
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/6.t
@@ -0,0 +1,57 @@
+/* 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/libaio-0.3.109/harness/cases/7.t b/libaio-0.3.109/harness/cases/7.t
new file mode 100644
index 0000000..f877d8a
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/7.t
@@ -0,0 +1,30 @@
+/* 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>
+#include <signal.h>
+
+void SET_RLIMIT(long long limit)
+{
+ struct rlimit rlim;
+ int res;
+
+ /* Seems that we do send SIGXFSZ, but hard to fix... */
+ signal(SIGXFSZ, SIG_IGN);
+ 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/libaio-0.3.109/harness/cases/8.t b/libaio-0.3.109/harness/cases/8.t
new file mode 100644
index 0000000..e59199f
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/8.t
@@ -0,0 +1,28 @@
+/* 8.t
+- Ditto for the above three tests at the offset maximum (largest
+ possible ext2/3 file size.) (8.t)
+ */
+#include <sys/types.h>
+#include <unistd.h>
+
+long long get_fs_limit(int fd)
+{
+ long long min = 0, max = 9223372036854775807LL;
+ char c = 0;
+
+ while (max - min > 1) {
+ if (pwrite64(fd, &c, 1, (min + max) / 2) == -1)
+ max = (min + max) / 2;
+ else {
+ ftruncate(fd, 0);
+ min = (min + max) / 2;
+ }
+ }
+ return max;
+}
+
+#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/libaio-0.3.109/harness/cases/aio_setup.h b/libaio-0.3.109/harness/cases/aio_setup.h
new file mode 100644
index 0000000..1914915
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/aio_setup.h
@@ -0,0 +1,108 @@
+#include <time.h>
+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'
+#define READV '<'
+#define WRITEV '>'
+
+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;
+ case WRITEV:
+ io_prep_pwritev(&iocb, fd, buf, count, pos);
+ break;
+ case READV:
+ io_prep_preadv(&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/libaio-0.3.109/harness/cases/common-7-8.h b/libaio-0.3.109/harness/cases/common-7-8.h
new file mode 100644
index 0000000..fc54bbf
--- /dev/null
+++ b/libaio-0.3.109/harness/cases/common-7-8.h
@@ -0,0 +1,38 @@
+/* common-7-8.h
+*/
+#include "aio_setup.h"
+
+#include <errno.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|O_CREAT, 0600); 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;
+}
+