* 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.
---
Simple test for simple decoder.

 tests/.gitignore     |    1 +
 tests/Makefile.am    |    2 ++
 tests/readahead.c    |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/readahead.test |    6 +++++
 4 files changed, 72 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 b879bf4..d7421fc 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -241,6 +241,7 @@ check_PROGRAMS = \
        ptrace \
        pwritev \
        read-write \
+       readahead \
        readdir \
        readlink \
        readlinkat \
@@ -568,6 +569,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..307dbff
--- /dev/null
+++ b/tests/readahead.c
@@ -0,0 +1,63 @@
+#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) = "
+                                       "%ld %s (%m)\n", fds[i],
+                                       (long long)offsets[j], counts[k], rc,
+                                       errno2name());
+                       }
+
+       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


------------------------------------------------------------------------------
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to