summaryrefslogtreecommitdiff
path: root/harness/cases
diff options
context:
space:
mode:
Diffstat (limited to 'harness/cases')
-rw-r--r--harness/cases/12.t6
-rw-r--r--harness/cases/14.t5
-rw-r--r--harness/cases/15.t94
-rw-r--r--harness/cases/16.t94
-rw-r--r--harness/cases/5.t9
-rw-r--r--harness/cases/7.t3
-rw-r--r--harness/cases/8.t43
-rw-r--r--harness/cases/aio_setup.h10
-rw-r--r--harness/cases/common-7-8.h3
9 files changed, 231 insertions, 36 deletions
diff --git a/harness/cases/12.t b/harness/cases/12.t
index 3499204..e87d1dc 100644
--- a/harness/cases/12.t
+++ b/harness/cases/12.t
@@ -20,11 +20,15 @@ int test_main(void)
{
int res, status;
pid_t pid;
+ sigset_t set;
if (attempt_io_submit(io_ctx, 0, NULL, 0))
return 1;
- sigblock(sigmask(SIGCHLD) | siggetmask());
+ sigemptyset(&set);
+ sigaddset(&set, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &set, NULL);
+
fflush(NULL);
pid = fork(); assert(pid != -1);
diff --git a/harness/cases/14.t b/harness/cases/14.t
index 514622b..87773e3 100644
--- a/harness/cases/14.t
+++ b/harness/cases/14.t
@@ -61,11 +61,14 @@ int test_main(void)
{
int res, status;
pid_t pid;
+ sigset_t set;
if (attempt_io_submit(io_ctx, 0, NULL, 0))
return 1;
- sigblock(sigmask(SIGCHLD) | siggetmask());
+ sigemptyset(&set);
+ sigaddset(&set, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &set, NULL);
fflush(NULL);
pid = fork(); assert(pid != -1);
diff --git a/harness/cases/15.t b/harness/cases/15.t
new file mode 100644
index 0000000..933d008
--- /dev/null
+++ b/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/harness/cases/16.t b/harness/cases/16.t
new file mode 100644
index 0000000..c3157cc
--- /dev/null
+++ b/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/harness/cases/5.t b/harness/cases/5.t
index 7669fd7..2b4b4bb 100644
--- a/harness/cases/5.t
+++ b/harness/cases/5.t
@@ -3,6 +3,7 @@
*/
#include "aio_setup.h"
#include <sys/mman.h>
+#include <errno.h>
int test_main(void)
{
@@ -40,7 +41,13 @@ int test_main(void)
assert(buf != (char *)-1);
status |= attempt_rw(rwfd, buf, SIZE, 0, READ, SIZE);
- status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE, -EFAULT);
+
+ /* 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/harness/cases/7.t b/harness/cases/7.t
index d2d6cbc..f877d8a 100644
--- a/harness/cases/7.t
+++ b/harness/cases/7.t
@@ -9,12 +9,15 @@
*/
#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);
diff --git a/harness/cases/8.t b/harness/cases/8.t
index 8a3d83e..e59199f 100644
--- a/harness/cases/8.t
+++ b/harness/cases/8.t
@@ -2,44 +2,23 @@
- 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
+#include <sys/types.h>
+#include <unistd.h>
long long get_fs_limit(int fd)
{
- struct statfs s;
- int res;
- long long lim = 0;
-
- res = fstatfs(fd, &s); assert(res == 0);
+ long long min = 0, max = 9223372036854775807LL;
+ char c = 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);
+ 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;
}
- break;
- default:
- printf("unknown filesystem 0x%08lx\n", (long)s.f_type);
- exit(3);
}
- return lim;
+ return max;
}
#define SET_RLIMIT(x) do ; while (0)
diff --git a/harness/cases/aio_setup.h b/harness/cases/aio_setup.h
index 37c9618..1914915 100644
--- a/harness/cases/aio_setup.h
+++ b/harness/cases/aio_setup.h
@@ -1,3 +1,4 @@
+#include <time.h>
io_context_t io_ctx;
#define BAD_CTX ((io_context_t)-1)
@@ -58,6 +59,9 @@ int sync_submit(struct iocb *iocb)
#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;
@@ -75,6 +79,12 @@ int attempt_rw(int fd, void *buf, int count, long long pos, int rw, int expect)
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) {
diff --git a/harness/cases/common-7-8.h b/harness/cases/common-7-8.h
index 3ec2bb4..fc54bbf 100644
--- a/harness/cases/common-7-8.h
+++ b/harness/cases/common-7-8.h
@@ -2,6 +2,7 @@
*/
#include "aio_setup.h"
+#include <errno.h>
#include <unistd.h>
#define SIZE 512
@@ -13,7 +14,7 @@ int test_main(void)
int status = 0, res;
long long limit;
- rwfd = open(FILENAME, O_RDWR); assert(rwfd != -1);
+ 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);