From c863827ddbe5a89a393e45c92eb05ce307779151 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sat, 5 Dec 2015 00:02:44 +0000 Subject: [PATCH] tests: add fstat.test and fstat64.test * tests/fstat.c: New file. * tests/fstat64.c: Likewise. * tests/fstatx.c: Likewise. * tests/fstat.test: New test. * tests/fstat64.test: Likewise. * tests/Makefile.am (check_PROGRAMS): Add fstat and fstat64. (fstat64_CFLAGS): Define. (TESTS): Add fstat.test and fstat64.test. (EXTRA_DIST): Add fstatx.c. * tests/.gitignore: Add fstat and fstat64. --- tests/.gitignore | 2 ++ tests/Makefile.am | 6 ++++++ tests/fstat.c | 13 +++++++++++++ tests/fstat.test | 20 ++++++++++++++++++++ tests/fstat64.c | 14 ++++++++++++++ tests/fstat64.test | 5 +++++ tests/fstatx.c | 14 ++++++++++++++ 7 files changed, 74 insertions(+) create mode 100644 tests/fstat.c create mode 100755 tests/fstat.test create mode 100644 tests/fstat64.c create mode 100755 tests/fstat64.test create mode 100644 tests/fstatx.c diff --git a/tests/.gitignore b/tests/.gitignore index 5c5c5721..ffd3bf6c 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -11,6 +11,8 @@ execveat fanotify_mark file_handle filter-unavailable +fstat +fstat64 fstatat64 ftruncate ftruncate64 diff --git a/tests/Makefile.am b/tests/Makefile.am index 69ffbc21..fdbf3f08 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -24,6 +24,8 @@ check_PROGRAMS = \ fanotify_mark \ file_handle \ filter-unavailable \ + fstat \ + fstat64 \ fstatat64 \ ftruncate \ ftruncate64 \ @@ -106,6 +108,7 @@ check_PROGRAMS = \ clock_xettime_LDADD = -lrt filter_unavailable_LDADD = -lpthread +fstat64_CFLAGS = $(AM_CFLAGS) -D_FILE_OFFSET_BITS=64 fstatat64_CFLAGS = $(AM_CFLAGS) -D_FILE_OFFSET_BITS=64 ftruncate64_CFLAGS = $(AM_CFLAGS) -D_FILE_OFFSET_BITS=64 mmap64_CFLAGS = $(AM_CFLAGS) -D_FILE_OFFSET_BITS=64 @@ -138,6 +141,8 @@ TESTS = \ fanotify_mark.test \ file_handle.test \ filter-unavailable.test \ + fstat.test \ + fstat64.test \ fstatat64.test \ ftruncate.test \ ftruncate64.test \ @@ -238,6 +243,7 @@ EXTRA_DIST = init.sh run.sh match.awk \ fanotify_mark.expected \ filter-unavailable.expected \ fstatat.c \ + fstatx.c \ ip_mreq.expected \ ipc.sh \ ipc_msgbuf.expected \ diff --git a/tests/fstat.c b/tests/fstat.c new file mode 100644 index 00000000..b75b5502 --- /dev/null +++ b/tests/fstat.c @@ -0,0 +1,13 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +#undef TEST_SYSCALL_NAME +#ifdef __NR_fstat +# define TEST_SYSCALL_NAME fstat +# define SAMPLE_SIZE ((kernel_ulong_t) 43147718418) +#endif + +#include "fstatx.c" diff --git a/tests/fstat.test b/tests/fstat.test new file mode 100755 index 00000000..696151bc --- /dev/null +++ b/tests/fstat.test @@ -0,0 +1,20 @@ +#!/bin/sh + +# Check fstat syscall decoding. + +. "${srcdir=.}/init.sh" + +# strace -P is implemented using /proc/self/fd +[ -d /proc/self/fd/ ] || + framework_skip_ '/proc/self/fd/ is not available' + +syscall=${ME_%.test} +run_prog > /dev/null +OUT="$LOG.out" +sample=$syscall.sample +> "$sample" +run_strace -ve$syscall -P$sample $args > "$OUT" +match_diff "$LOG" "$OUT" +rm -f "$OUT" + +exit 0 diff --git a/tests/fstat64.c b/tests/fstat64.c new file mode 100644 index 00000000..e64cf085 --- /dev/null +++ b/tests/fstat64.c @@ -0,0 +1,14 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +#undef TEST_SYSCALL_NAME +#ifdef __NR_fstat64 +# define TEST_SYSCALL_NAME fstat64 +# define STRUCT_STAT struct stat64 +# define SAMPLE_SIZE ((libc_off_t) 43147718418) +#endif + +#include "fstatx.c" diff --git a/tests/fstat64.test b/tests/fstat64.test new file mode 100755 index 00000000..8b4f5ef1 --- /dev/null +++ b/tests/fstat64.test @@ -0,0 +1,5 @@ +#!/bin/sh + +# Check fstat64 syscall decoding. + +. "${srcdir=.}/fstat.test" diff --git a/tests/fstatx.c b/tests/fstatx.c new file mode 100644 index 00000000..04bb3a6f --- /dev/null +++ b/tests/fstatx.c @@ -0,0 +1,14 @@ +#define TEST_SYSCALL_INVOKE(sample, pst) \ + syscall(TEST_SYSCALL_NR, 0, pst) +#define PRINT_SYSCALL_HEADER(sample) \ + printf("%s(0, ", TEST_SYSCALL_STR) +#define PRINT_SYSCALL_FOOTER \ + puts(") = 0") + +#define TEST_SYSCALL_NR nrify(TEST_SYSCALL_NAME) +#define nrify(arg) nrify_(arg) +#define nrify_(arg) __NR_ ## arg + +#define USE_ASM_STAT + +#include "xstatx.c" -- 2.40.0