[PATCH 9/9] tests: Some additional aio checks

Eugene Syromyatnikov evgsyr at gmail.com
Mon Sep 5 01:32:52 UTC 2016


* aio.c: Additional checks added.
---
 tests/aio.c |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 108 insertions(+)

diff --git a/tests/aio.c b/tests/aio.c
index 8c5bfa7..00de5ae 100644
--- a/tests/aio.c
+++ b/tests/aio.c
@@ -111,6 +111,33 @@ main(void)
 	};
 	const struct iocb *cbv = tail_memdup(proto_cbv, sizeof(proto_cbv));
 
+	/* For additional decoder testing */
+	const struct iocb proto_cbv2[] = {
+		{
+			.aio_data = 0xbadfacedc0ffeeed,
+			.aio_key = 0xdefaced0,
+			.aio_lio_opcode = 0xf00d,
+			.aio_reqprio = 0xbeef,
+			.aio_fildes = 0xdefaced1,
+			.aio_buf = 0,
+		},
+		{
+			.aio_data = 0xbadfacedc0ffeeed,
+			.aio_key = 0xdefaced0,
+			.aio_lio_opcode = 1,
+			.aio_reqprio = 0xbeef,
+			.aio_fildes = 0xdefaced1,
+			.aio_buf = 0,
+			.aio_nbytes = 0x1020304050607080,
+			.aio_offset = 0xdeadda7abadc0ded,
+# ifdef IOCB_FLAG_RESFD
+			.aio_flags = 0xfacef157,
+			.aio_resfd = 0xded1ca7e,
+# endif
+		},
+	};
+	const struct iocb *cbv2 = tail_memdup(proto_cbv2, sizeof(proto_cbv2));
+
 	const struct iocb proto_cbc = {
 		.aio_data = 0xdeadbeefbadc0ded,
 		.aio_reqprio = 99,
@@ -128,6 +155,11 @@ main(void)
 	};
 	const long *cbvs = tail_memdup(proto_cbvs, sizeof(proto_cbvs));
 
+	const long proto_cbvs2[] = {
+		(long) &cbv2[0], (long) &cbv2[1],
+	};
+	const long *cbvs2 = tail_memdup(proto_cbvs2, sizeof(proto_cbvs2));
+
 	unsigned long *ctx = tail_alloc(sizeof(unsigned long));
 	*ctx = 0;
 
@@ -142,10 +174,26 @@ main(void)
 	if (open("/dev/zero", O_RDONLY))
 		perror_msg_and_skip("open: %s", "/dev/zero");
 
+	assert(syscall(__NR_io_setup, 0xdeadbeef, NULL) == -1);
+	printf("io_setup(%u, NULL) = %s\n", 0xdeadbeef, sprintrc(-1));
+
+	assert(syscall(__NR_io_setup, lnr, ctx + 1) == -1);
+	printf("io_setup(%u, %p) = %s\n", nr, ctx + 1, sprintrc(-1));
+
 	if (syscall(__NR_io_setup, lnr, ctx))
 		perror_msg_and_skip("io_setup");
 	printf("io_setup(%u, [%lu]) = 0\n", nr, *ctx);
 
+	assert(syscall(__NR_io_submit, (aio_context_t) 0xface1e55deadbeef,
+	       (long) 0xca7faceddeadf00d, NULL) == -1);
+	printf("io_submit(%lu, %ld, NULL) = %s\n",
+	       (aio_context_t) 0xface1e55deadbeef, (long) 0xca7faceddeadf00d,
+	       sprintrc(-1));
+
+	assert(syscall(__NR_io_submit, *ctx, nr, cbs + nr) == -1);
+	printf("io_submit(%lu, %u, %p) = %s\n",
+	       *ctx, nr, cbs + nr, sprintrc(-1));
+
 	assert(syscall(__NR_io_submit, *ctx, -1L, cbs) == -1);
 	printf("io_submit(%lu, -1, %p) = %s\n",
 	       *ctx, cbs, sprintrc(-1));
@@ -165,6 +213,22 @@ main(void)
 	       sizeof_data1, (long long) cb[1].aio_offset,
 	       nr);
 
+	assert(syscall(__NR_io_getevents, (aio_context_t) 0xface1e55deadbeef,
+	       (long) 0xca7faceddeadf00d, (long) 0xba5e1e505ca571e0, ev + 1,
+	       NULL) == -1);
+	printf("io_getevents(%lu, %ld, %ld, %p, NULL) = %s\n",
+	       (aio_context_t) 0xface1e55deadbeef,
+	       (long) 0xca7faceddeadf00d, (long) 0xba5e1e505ca571e0,
+	       ev + 1, sprintrc(-1));
+
+	assert(syscall(__NR_io_getevents, (aio_context_t) 0xface1e55deadbeef,
+	       (long) 0xca7faceddeadf00d, (long) 0xba5e1e505ca571e0, NULL,
+	       ts + 1) == -1);
+	printf("io_getevents(%lu, %ld, %ld, NULL, %p) = %s\n",
+	       (aio_context_t) 0xface1e55deadbeef,
+	       (long) 0xca7faceddeadf00d, (long) 0xba5e1e505ca571e0,
+	       ts + 1, sprintrc(-1));
+
 	assert(syscall(__NR_io_getevents, *ctx, nr, nr + 1, ev, ts) == (long) nr);
 	printf("io_getevents(%lu, %ld, %ld, ["
 		"{data=%#llx, obj=%p, res=%u, res2=0}, "
@@ -175,11 +239,50 @@ main(void)
 	       (unsigned long long) cb[1].aio_data, &cb[1], sizeof_data1,
 	       nr);
 
+	assert(syscall(__NR_io_cancel, *ctx, NULL, NULL) == -1);
+	printf("io_cancel(%lu, NULL, NULL) = %s\n", *ctx, sprintrc(-1));
+
+	assert(syscall(__NR_io_cancel, *ctx, cbc + 1, ev) == -1);
+	printf("io_cancel(%lu, %p, %p) = %s\n", *ctx, cbc + 1, ev,
+	       sprintrc(-1));
+
 	assert(syscall(__NR_io_cancel, *ctx, cbc, ev) == -1);
 	printf("io_cancel(%lu, {data=%#llx, pread, reqprio=99, fildes=-42}, %p) "
 	       "= %s\n",
 	       *ctx, (unsigned long long) cbc->aio_data, ev, sprintrc(-1));
 
+	assert(syscall(__NR_io_submit, (unsigned long)0xfacef157beeff00dULL,
+	       0xfacefeed, NULL) == -1);
+	printf("io_submit(%lu, %u, NULL) = %s\n",
+	       (unsigned long)0xfacef157beeff00dULL, 0xfacefeed, sprintrc(-1));
+
+	assert(syscall(__NR_io_submit, *ctx, -1, cbvs + nr) == -1);
+	printf("io_submit(%lu, %u, %p) = %s\n",
+		*ctx, -1, cbvs + nr, sprintrc(-1));
+
+	assert(syscall(__NR_io_submit, *ctx, -1, cbvs2) == -1);
+	printf("io_submit(%lu, %u, ["
+		"{data=%#llx, key=%u, %hu /* SUB_??? */, reqprio=%hd"
+			", fildes=%d}, "
+		"{data=%#llx, key=%u, pwrite, reqprio=%hd, fildes=%d, str=NULL"
+			", nbytes=%llu, offset=%lld"
+# ifdef IOCB_FLAG_RESFD
+			", resfd=%d, flags=%x"
+# endif
+			"}"
+		", %p]) = %s\n",
+	       *ctx, -1,
+	       (unsigned long long) cbv2[0].aio_data, cbv2[0].aio_key,
+	       cbv2[0].aio_lio_opcode, cbv2[0].aio_reqprio,
+	       cbv2[0].aio_fildes,
+	       (unsigned long long) cbv2[1].aio_data, cbv2[1].aio_key,
+	       cbv2[1].aio_reqprio, cbv2[1].aio_fildes, cbv2[1].aio_nbytes,
+	       cbv2[1].aio_offset,
+# ifdef IOCB_FLAG_RESFD
+	       cbv2[1].aio_resfd, cbv2[1].aio_flags,
+# endif
+	       cbvs2 + 2, sprintrc(-1));
+
 	if (syscall(__NR_io_submit, *ctx, nr, cbvs) != (long) nr)
 		perror_msg_and_skip("io_submit");
 	printf("io_submit(%lu, %u, ["
@@ -201,6 +304,11 @@ main(void)
 	       (long long) cbv[1].aio_offset,
 	       nr);
 
+	assert(syscall(__NR_io_destroy,
+		(unsigned long)0xfacefeedb000b1e5) == -1);
+	printf("io_destroy(%lu) = %s\n",
+		(unsigned long)0xfacefeedb000b1e5, sprintrc(-1));
+
 	assert(syscall(__NR_io_destroy, *ctx) == 0);
 	printf("io_destroy(%lu) = 0\n", *ctx);
 
-- 
1.7.10.4





More information about the Strace-devel mailing list