* tests/.gitignore: Add oldfstat, oldlstat, oldstat.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add oldfstat.test, oldlstat.test, oldstat.test.
* tests/oldfstat.c: New file.
* tests/oldfstat.test: Likewise.
* tests/oldlstat.c: Likewise.
* tests/oldlstat.test: Likewise.
* tests/oldstat.c: Likewise.
* tests/oldstat.test: Likewise.
* tests/xstatx.c [!OLD_STAT]: define OLD_STAT to 0.
(print_stat) [OLD_STAT]: Print predefined values for
st_blksize/st_blocks.
(print_stat): check for !OLD_STAT in nanosecond precision checks.
(main) [OLD_STAT]: Ignore EOVERFLOW.
(main): Add check for successful rc in returned size value check;
print address only on non-successful rc.
---
 tests/.gitignore    |    3 +++
 tests/Makefile.am   |    6 ++++++
 tests/oldfstat.c    |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/oldfstat.test |   19 +++++++++++++++++++
 tests/oldlstat.c    |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/oldlstat.test |    5 +++++
 tests/oldstat.c     |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/oldstat.test  |    5 +++++
 tests/xstatx.c      |   34 ++++++++++++++++++++++++++--------
 9 files changed, 205 insertions(+), 8 deletions(-)
 create mode 100644 tests/oldfstat.c
 create mode 100755 tests/oldfstat.test
 create mode 100644 tests/oldlstat.c
 create mode 100755 tests/oldlstat.test
 create mode 100644 tests/oldstat.c
 create mode 100755 tests/oldstat.test

diff --git a/tests/.gitignore b/tests/.gitignore
index a71a0f4..11df7e3 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -183,7 +183,10 @@ netlink_unix_diag
 newfstatat
 nsyscalls
 old_mmap
+oldfstat
+oldlstat
 oldselect
+oldstat
 open
 openat
 pause
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 88a1f9a..b79f755 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -241,7 +241,10 @@ check_PROGRAMS = \
        newfstatat \
        nsyscalls \
        old_mmap \
+       oldfstat \
+       oldlstat \
        oldselect \
+       oldstat \
        open \
        openat \
        pause \
@@ -599,7 +602,10 @@ DECODER_TESTS = \
        newfstatat.test \
        nsyscalls.test \
        old_mmap.test \
+       oldfstat.test \
+       oldlstat.test \
        oldselect.test \
+       oldstat.test \
        open.test \
        openat.test \
        pause.test \
diff --git a/tests/oldfstat.c b/tests/oldfstat.c
new file mode 100644
index 0000000..5278599
--- /dev/null
+++ b/tests/oldfstat.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015-2016 Dmitry V. Levin <l...@altlinux.org>
+ * Copyright (c) 2016 Eugene Syromyatnikov <evg...@gmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include <asm/unistd.h>
+
+#if defined __NR_oldfstat && HAVE_STRUCT___OLD_KERNEL_STAT
+
+# define OLD_STAT 1
+# define TEST_SYSCALL_NR __NR_oldfstat
+# define TEST_SYSCALL_STR "oldfstat"
+# define STRUCT_STAT struct __old_kernel_stat
+# define STRUCT_STAT_STR "struct __old_kernel_stat"
+# define STRUCT_STAT_IS_STAT64 0
+# define SAMPLE_SIZE ((kernel_ulong_t) 23147718418U)
+# include "fstatx.c"
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_oldfstat && HAVE_STRUCT___OLD_KERNEL_STAT")
+
+#endif
diff --git a/tests/oldfstat.test b/tests/oldfstat.test
new file mode 100755
index 0000000..66a1056
--- /dev/null
+++ b/tests/oldfstat.test
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Check oldfstat 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=$NAME
+run_prog > /dev/null
+sample=$syscall.sample
+> "$sample"
+run_strace -ve$syscall -P$sample -a21 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
+
+exit 0
diff --git a/tests/oldlstat.c b/tests/oldlstat.c
new file mode 100644
index 0000000..5a53860
--- /dev/null
+++ b/tests/oldlstat.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015-2016 Dmitry V. Levin <l...@altlinux.org>
+ * Copyright (c) 2016 Eugene Syromyatnikov <evg...@gmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include <asm/unistd.h>
+
+#if defined __NR_oldlstat && HAVE_STRUCT___OLD_KERNEL_STAT
+
+# define OLD_STAT 1
+# define TEST_SYSCALL_NR __NR_oldlstat
+# define TEST_SYSCALL_STR "oldlstat"
+# define STRUCT_STAT struct __old_kernel_stat
+# define STRUCT_STAT_STR "struct __old_kernel_stat"
+# define STRUCT_STAT_IS_STAT64 0
+# define SAMPLE_SIZE ((kernel_ulong_t) 23147718418U)
+# include "lstatx.c"
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_oldlstat && HAVE_STRUCT___OLD_KERNEL_STAT")
+
+#endif
diff --git a/tests/oldlstat.test b/tests/oldlstat.test
new file mode 100755
index 0000000..a0f9ab9
--- /dev/null
+++ b/tests/oldlstat.test
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# Check oldlstat syscall decoding.
+
+. "${srcdir=.}/statx.sh"
diff --git a/tests/oldstat.c b/tests/oldstat.c
new file mode 100644
index 0000000..96db6b7
--- /dev/null
+++ b/tests/oldstat.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015-2016 Dmitry V. Levin <l...@altlinux.org>
+ * Copyright (c) 2016 Eugene Syromyatnikov <evg...@gmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include <asm/unistd.h>
+
+#if defined __NR_oldstat && HAVE_STRUCT___OLD_KERNEL_STAT
+
+# define OLD_STAT 1
+# define TEST_SYSCALL_NR __NR_oldstat
+# define TEST_SYSCALL_STR "oldstat"
+# define STRUCT_STAT struct __old_kernel_stat
+# define STRUCT_STAT_STR "struct __old_kernel_stat"
+# define STRUCT_STAT_IS_STAT64 0
+# define SAMPLE_SIZE ((kernel_ulong_t) 131478418U)
+# include "lstatx.c"
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_oldstat && HAVE_STRUCT___OLD_KERNEL_STAT")
+
+#endif
diff --git a/tests/oldstat.test b/tests/oldstat.test
new file mode 100755
index 0000000..42d70f7
--- /dev/null
+++ b/tests/oldstat.test
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# Check oldstat syscall decoding.
+
+. "${srcdir=.}/statx.sh"
diff --git a/tests/xstatx.c b/tests/xstatx.c
index d1ad52d..8fd296f 100644
--- a/tests/xstatx.c
+++ b/tests/xstatx.c
@@ -137,6 +137,10 @@ typedef off_t libc_off_t;
 #  define IS_STAT 0
 # endif
 
+# ifndef OLD_STAT
+#  define OLD_STAT 0
+# endif
+
 static void
 print_ftype(const unsigned int mode)
 {
@@ -172,8 +176,12 @@ print_stat(const STRUCT_STAT *st)
        printf(", st_nlink=%llu", zero_extend_signed_to_ull(st->st_nlink));
        printf(", st_uid=%llu", zero_extend_signed_to_ull(st->st_uid));
        printf(", st_gid=%llu", zero_extend_signed_to_ull(st->st_gid));
+# if OLD_STAT
+       printf(", st_blksize=0, st_blocks=0");
+# else /* !OLD_STAT */
        printf(", st_blksize=%llu", zero_extend_signed_to_ull(st->st_blksize));
        printf(", st_blocks=%llu", zero_extend_signed_to_ull(st->st_blocks));
+# endif /* OLD_STAT */
 
        switch (st->st_mode & S_IFMT) {
        case S_IFCHR: case S_IFBLK:
@@ -187,19 +195,19 @@ print_stat(const STRUCT_STAT *st)
 
        printf(", st_atime=");
        print_time(sign_extend_unsigned_to_ll(st->st_atime));
-# ifdef HAVE_STRUCT_STAT_ST_MTIME_NSEC
+# if defined(HAVE_STRUCT_STAT_ST_MTIME_NSEC) && !OLD_STAT
        if (st->st_atime_nsec)
                printf(".%09llu", zero_extend_signed_to_ull(st->st_atime_nsec));
 # endif
        printf(", st_mtime=");
        print_time(sign_extend_unsigned_to_ll(st->st_mtime));
-# ifdef HAVE_STRUCT_STAT_ST_MTIME_NSEC
+# if defined(HAVE_STRUCT_STAT_ST_MTIME_NSEC) && !OLD_STAT
        if (st->st_mtime_nsec)
                printf(".%09llu", zero_extend_signed_to_ull(st->st_mtime_nsec));
 # endif
        printf(", st_ctime=");
        print_time(sign_extend_unsigned_to_ll(st->st_ctime));
-# ifdef HAVE_STRUCT_STAT_ST_MTIME_NSEC
+# if defined(HAVE_STRUCT_STAT_ST_MTIME_NSEC) && !OLD_STAT
        if (st->st_ctime_nsec)
                printf(".%09llu", zero_extend_signed_to_ull(st->st_ctime_nsec));
 # endif
@@ -264,12 +272,17 @@ main(void)
 # endif
 
        if ((rc = TEST_SYSCALL_INVOKE(sample, st))) {
-               perror(TEST_SYSCALL_STR);
-               (void) unlink(sample);
-               return 77;
+# if OLD_STAT
+               if (errno != EOVERFLOW)
+# endif
+               {
+                       perror(TEST_SYSCALL_STR);
+                       (void) unlink(sample);
+                       return 77;
+               }
        }
        (void) unlink(sample);
-       if (zero_extend_signed_to_ull(SAMPLE_SIZE) !=
+       if (!rc && zero_extend_signed_to_ull(SAMPLE_SIZE) !=
            zero_extend_signed_to_ull(st[0].st_size)) {
                fprintf(stderr, "Size mismatch: "
                                "requested size(%llu) != st_size(%llu)\n",
@@ -311,6 +324,7 @@ main(void)
                                ", sizeof(st_size) = %zu\n",
                        STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_size),
                        sizeof(st[0].st_size));
+# if !OLD_STAT
                fprintf(stderr, "offsetof(%s, st_blksize) = %zu"
                                ", sizeof(st_blksize) = %zu\n",
                        STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_blksize),
@@ -319,11 +333,15 @@ main(void)
                                ", sizeof(st_blocks) = %zu\n",
                        STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_blocks),
                        sizeof(st[0].st_blocks));
+# endif /* !OLD_STAT */
                return 77;
        }
 
        PRINT_SYSCALL_HEADER(sample);
-       print_stat(st);
+       if (rc)
+               printf("%p", st);
+       else
+               print_stat(st);
        PRINT_SYSCALL_FOOTER(rc);
 
        puts("+++ exited with 0 +++");
-- 
1.7.10.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to