[PATCH v2 5/5] tests: check decoding of readahead syscall

Eugene Syromyatnikov evgsyr at gmail.com
Fri Sep 2 15:28:24 UTC 2016


* tests/readahead.c: New file.
* tests/readahead.test: New test.
* tests/.gitignore: Add readahead.
* tests/Makefile.am (check_PROGRAMS): Likewise.
  (DECODER_TESTS): Add readahead.test.
---
 tests/.gitignore     |    1 +
 tests/Makefile.am    |    2 ++
 tests/readahead.c    |   62 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/readahead.test |    6 +++++
 4 files changed, 71 insertions(+)
 create mode 100644 tests/readahead.c
 create mode 100755 tests/readahead.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 5c5d092..8c41bea 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -185,6 +185,7 @@ pselect6
 ptrace
 pwritev
 read-write
+readahead
 readdir
 readlink
 readlinkat
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2cf9674..0b3b818 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -242,6 +242,7 @@ check_PROGRAMS = \
 	ptrace \
 	pwritev \
 	read-write \
+	readahead \
 	readdir \
 	readlink \
 	readlinkat \
@@ -569,6 +570,7 @@ DECODER_TESTS = \
 	ptrace.test \
 	pwritev.test \
 	read-write.test \
+	readahead.test \
 	readdir.test \
 	readlink.test \
 	readlinkat.test \
diff --git a/tests/readahead.c b/tests/readahead.c
new file mode 100644
index 0000000..e58fcac
--- /dev/null
+++ b/tests/readahead.c
@@ -0,0 +1,62 @@
+#include "tests.h"
+#include <asm/unistd.h>
+
+#ifdef __NR_readahead
+
+# include <fcntl.h>
+# include <stdio.h>
+
+static const int fds[] = {
+	-0x80000000,
+	-100,
+	-1,
+	0,
+	1,
+	2,
+	0x7fffffff,
+};
+
+static const off64_t offsets[] = {
+	-0x8000000000000000LL,
+	-0x5060708090a0b0c0LL,
+	-1LL,
+	 0,
+	 1,
+	 0xbadfaced,
+	 0x7fffffffffffffffLL,
+};
+
+static const unsigned long counts[] = {
+	0UL,
+	0xdeadca75,
+	(unsigned long)0xface1e55beeff00dULL,
+	(unsigned long)0xffffffffffffffffULL,
+};
+
+int
+main(void)
+{
+	unsigned i;
+	unsigned j;
+	unsigned k;
+	ssize_t rc;
+
+	for (i = 0; i < ARRAY_SIZE(fds); i++)
+		for (j = 0; j < ARRAY_SIZE(offsets); j++)
+			for (k = 0; k < ARRAY_SIZE(counts); k++) {
+				rc = readahead(fds[i], offsets[j], counts[k]);
+
+				printf("readahead(%d, %lld, %lu) = %s\n",
+					fds[i], (long long)offsets[j],
+					counts[k], sprintrc(rc));
+			}
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_readahead")
+
+#endif
diff --git a/tests/readahead.test b/tests/readahead.test
new file mode 100755
index 0000000..397c690
--- /dev/null
+++ b/tests/readahead.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check readahead syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a1
-- 
1.7.10.4





More information about the Strace-devel mailing list