From 7497b1c700165afc51cfd67b38c29e06d8a6c8a1 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Wed, 19 Oct 2016 11:11:41 +0300 Subject: [PATCH] tests: additional tests of stat decoders * tests/fstatx.c (IS_FSTAT): Define to 1. * tests/fstatat64.c [__GLIBC__ && __sparc64__] (TEST_BOGUS_STRUCT_STAT): Define to 0. * tests/xstatx.c [!IS_STAT] (IS_STAT): Define to 0. [!TEST_BOGUS_STRUCT_STAT] (TEST_BOGUS_STRUCT_STAT): Define to 1. (main): Add a check for non-available pointer and a check for block device file. * tests/statx.sh: Add tracing of /dev/full file, specify alignment. * tests/fstat.test: Specify alignment. --- tests/fstat.test | 2 +- tests/fstatat64.c | 3 +++ tests/fstatx.c | 1 + tests/statx.sh | 2 +- tests/xstatx.c | 33 ++++++++++++++++++++++++++++++++- 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/tests/fstat.test b/tests/fstat.test index 506b4406..2ba0fbaa 100755 --- a/tests/fstat.test +++ b/tests/fstat.test @@ -12,7 +12,7 @@ syscall=$NAME run_prog > /dev/null sample=$syscall.sample > "$sample" -run_strace -ve$syscall -P$sample $args > "$OUT" +run_strace -ve$syscall -P$sample -a21 $args > "$OUT" match_diff "$LOG" "$OUT" rm -f "$OUT" diff --git a/tests/fstatat64.c b/tests/fstatat64.c index fa8992df..96786412 100644 --- a/tests/fstatat64.c +++ b/tests/fstatat64.c @@ -32,6 +32,9 @@ # define TEST_SYSCALL_NR __NR_fstatat64 # define TEST_SYSCALL_STR "fstatat64" +# if defined __GLIBC__ && defined __sparc__ && defined __arch64__ +# define TEST_BOGUS_STRUCT_STAT 0 +# endif # include "fstatat.c" #else diff --git a/tests/fstatx.c b/tests/fstatx.c index 5749e069..174f29fb 100644 --- a/tests/fstatx.c +++ b/tests/fstatx.c @@ -25,6 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define IS_FSTAT 1 #define TEST_SYSCALL_INVOKE(sample, pst) \ syscall(TEST_SYSCALL_NR, 0, pst) #define PRINT_SYSCALL_HEADER(sample) \ diff --git a/tests/statx.sh b/tests/statx.sh index 830e5fc7..a630193d 100755 --- a/tests/statx.sh +++ b/tests/statx.sh @@ -3,4 +3,4 @@ # Check decoding of stat family syscalls. . "${srcdir=.}/init.sh" -run_strace_match_diff -v -P $NAME.sample +run_strace_match_diff -v -P $NAME.sample -P /dev/full -a32 diff --git a/tests/xstatx.c b/tests/xstatx.c index dcdf49fd..a04a3dab 100644 --- a/tests/xstatx.c +++ b/tests/xstatx.c @@ -133,6 +133,14 @@ typedef off_t libc_off_t; # endif /* HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC */ # endif +# ifndef TEST_BOGUS_STRUCT_STAT +# define TEST_BOGUS_STRUCT_STAT 1 +# endif + +# ifndef IS_FSTAT +# define IS_STAT 0 +# endif + static void print_ftype(const unsigned int mode) { @@ -228,15 +236,38 @@ create_sample(const char *fname, const libc_off_t size) int main(void) { +# if !IS_FSTAT + static const char full[] = "/dev/full"; +# endif static const char sample[] = TEST_SYSCALL_STR ".sample"; STRUCT_STAT st[2]; - int rc = create_sample(sample, SAMPLE_SIZE); + int rc; + + rc = create_sample(sample, SAMPLE_SIZE); if (rc) { (void) unlink(sample); return rc; } +# if TEST_BOGUS_STRUCT_STAT + STRUCT_STAT *st_cut = tail_alloc(sizeof(long) * 4); + rc = TEST_SYSCALL_INVOKE(sample, st_cut); + PRINT_SYSCALL_HEADER(sample); + printf("%p", st_cut); + PRINT_SYSCALL_FOOTER(rc); +# endif + +# if !IS_FSTAT + rc = TEST_SYSCALL_INVOKE(full, st); + PRINT_SYSCALL_HEADER(full); + if (rc) + printf("%p", st); + else + print_stat(st); + PRINT_SYSCALL_FOOTER(rc); +# endif + if ((rc = TEST_SYSCALL_INVOKE(sample, st))) { perror(TEST_SYSCALL_STR); (void) unlink(sample); -- 2.40.0