* tests/.gitignore: Add fadvise64, fadvise64_64. * tests/Makefile.am (check_PROGRAMS): Likewise. (DECODER_TESTS): Add fadvise64.test, fadvise64_64.test. * fadvise64.c: New file. * fadvise64_64.c: Likewise. * fadvise64.test: Likewise. * fadvise64_64.test: Likewise. --- tests/.gitignore | 2 ++ tests/Makefile.am | 4 +++ tests/fadvise64.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++ tests/fadvise64.test | 6 ++++ tests/fadvise64_64.c | 59 +++++++++++++++++++++++++++++++++++++++ tests/fadvise64_64.test | 6 ++++ 6 files changed, 148 insertions(+) create mode 100644 tests/fadvise64.c create mode 100755 tests/fadvise64.test create mode 100644 tests/fadvise64_64.c create mode 100755 tests/fadvise64_64.test
diff --git a/tests/.gitignore b/tests/.gitignore index c3665c2..b41459a 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -44,6 +44,8 @@ execve-v execveat execveat-v faccessat +fadvise64 +fadvise64_64 fallocate fanotify_mark fchdir diff --git a/tests/Makefile.am b/tests/Makefile.am index 4fdc877..424c5bb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -103,6 +103,8 @@ check_PROGRAMS = \ execveat \ execveat-v \ faccessat \ + fadvise64 \ + fadvise64_64 \ fallocate \ fanotify_mark \ fchdir \ @@ -443,6 +445,8 @@ DECODER_TESTS = \ execveat-v.test \ execveat.test \ faccessat.test \ + fadvise64.test \ + fadvise64_64.test \ fallocate.test \ fanotify_mark.test \ fchdir.test \ diff --git a/tests/fadvise64.c b/tests/fadvise64.c new file mode 100644 index 0000000..812d4f3 --- /dev/null +++ b/tests/fadvise64.c @@ -0,0 +1,71 @@ +#include "tests.h" + +#include <asm/unistd.h> + +#if defined(__NR_fadvise64) + +# include <errno.h> +# include <limits.h> +# include <stdio.h> +# include <unistd.h> + +# include "xlat.h" +# include "xlat/advise.h" + +#if __BYTE_ORDER == __LITTLE_ENDIAN +# define __LONG_LONG_PAIR(HI, LO) LO, HI +#elif __BYTE_ORDER == __BIG_ENDIAN +# define __LONG_LONG_PAIR(HI, LO) HI, LO +#endif + +void do_fadvise64(int fd, long long offset, long long len, int advice) +{ + long ret; + +# if (LONG_MAX > INT_MAX) || defined(__x86_64__) && defined(__ILP32__) \ + || defined(LINUX_MIPSN32) + ret = syscall(__NR_fadvise64, fd, offset, len, advice); + + printf("fadvise64(%d, %lld, %llu, ", fd, offset, len); +# else /* LONG_MAX > INT_MAX */ +# if defined(POWERPC) + ret = syscall(__NR_fadvise64, fd, 0, + __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset), + (long) len, advice); + printf("fadvise64(%d, %lld, %lu, ", fd, offset, (long) len); +# elif defined(LINUX_MIPSO32) + ret = syscall(__NR_fadvise64, fd, 0, + __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset), + __LONG_LONG_PAIR ((long) (len >> 32), (long) len), advice); + printf("fadvise64(%d, %lld, %lld, ", fd, offset, len); +# else + ret = syscall(__NR_fadvise64, fd, + __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset), + (long) len, advice); + printf("fadvise64(%d, %lld, %lu, ", fd, offset, (long) len); +# endif +# endif /* LONG_MAX > INT_MAX */ + printxval(advise, (unsigned) advice, "POSIX_FADV_???"); + printf(") = %s\n", sprintrc(ret)); +} + +int +main(void) +{ + static const int bogus_fd = 0xbeefface; + static const long long bogus_offset = 0xbadc0dedda7a1057LLU; + static const long long bogus_len = (long) 0xbadfaceca7b0d1e5LLU; + static const int bogus_advice = 0xdeadca75; + + do_fadvise64(bogus_fd, bogus_offset, bogus_len, bogus_advice); + + puts("+++ exited with 0 +++"); + + return 0; +} + +#else + +SKIP_MAIN_UNDEFINED("__NR_fadvise64"); + +#endif diff --git a/tests/fadvise64.test b/tests/fadvise64.test new file mode 100755 index 0000000..46c5856 --- /dev/null +++ b/tests/fadvise64.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# Check fadvise64 syscall decoding. + +. "${srcdir=.}/init.sh" +run_strace_match_diff -a18 diff --git a/tests/fadvise64_64.c b/tests/fadvise64_64.c new file mode 100644 index 0000000..35f64a0 --- /dev/null +++ b/tests/fadvise64_64.c @@ -0,0 +1,59 @@ +#include "tests.h" + +#include <asm/unistd.h> + +#if defined(__NR_fadvise64_64) || defined(__NR_arm_fadvise64_64) + +# include <errno.h> +# include <limits.h> +# include <stdio.h> +# include <unistd.h> + +# include "xlat.h" +# include "xlat/advise.h" + +#if __BYTE_ORDER == __LITTLE_ENDIAN +# define __LONG_LONG_PAIR(HI, LO) LO, HI +#elif __BYTE_ORDER == __BIG_ENDIAN +# define __LONG_LONG_PAIR(HI, LO) HI, LO +#endif + +void do_fadvise64_64(int fd, long long offset, long long len, int advice) +{ + long ret; + +# ifdef ARM + ret = syscall(__NR_arm_fadvise64_64, fd, advice, + __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset), + __LONG_LONG_PAIR ((long) (len >> 32), (long)len)); +# else + ret = syscall(__NR_fadvise64_64, fd, + __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset), + __LONG_LONG_PAIR ((long) (len >> 32), (long) len), advice); +# endif + + printf("fadvise64_64(%d, %lld, %lld, ", fd, offset, len); + printxval(advise, (unsigned) advice, "POSIX_FADV_???"); + printf(") = %s\n", sprintrc(ret)); +} + +int +main(void) +{ + static const int bogus_fd = 0xbeefface; + static const long long bogus_offset = 0xbadc0dedda7a1057LLU; + static const long long bogus_len = (long) 0xbadfaceca7b0d1e5LLU; + static const int bogus_advice = 0xdeadca75; + + do_fadvise64_64(bogus_fd, bogus_offset, bogus_len, bogus_advice); + + puts("+++ exited with 0 +++"); + + return 0; +} + +#else + +SKIP_MAIN_UNDEFINED("__NR_fadvise64_64 || __NR_arm_fadvise64_64"); + +#endif diff --git a/tests/fadvise64_64.test b/tests/fadvise64_64.test new file mode 100755 index 0000000..67a37c0 --- /dev/null +++ b/tests/fadvise64_64.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# Check fadvise64_64 syscall decoding. + +. "${srcdir=.}/init.sh" +run_strace_match_diff -a18 -- 1.7.10.4 ------------------------------------------------------------------------------ _______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel