]> granicus.if.org Git - strace/commitdiff
tests: additional tests of stat decoders
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 19 Oct 2016 08:11:41 +0000 (11:11 +0300)
committerEugene Syromyatnikov <evgsyr@gmail.com>
Sun, 30 Oct 2016 21:49:28 +0000 (00:49 +0300)
* 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
tests/fstatat64.c
tests/fstatx.c
tests/statx.sh
tests/xstatx.c

index 506b4406b1421d2f84d4bf14169ac1cf524dce90..2ba0fbaabcd6877ca7c96136a1170c634d392ad9 100755 (executable)
@@ -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"
 
index fa8992df5fcf3b31ce18a6d7218d897ea3ec124e..96786412806d6e2a9d976d7595087d8495c82a1c 100644 (file)
@@ -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
index 5749e069116c45d4c6f0d8568c4528f194940f65..174f29fb4e9a20f99ef1767675c5567b11b6af34 100644 (file)
@@ -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) \
index 830e5fc71941ec6a43a07ad353aa6e36e2c2968d..a630193d7091f52db5c4df5089dfaca20a9f808a 100755 (executable)
@@ -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
index dcdf49fdbd287cdc814a3c7d7df91494d1c04842..a04a3dabacab752679651436229deb59992b8be4 100644 (file)
@@ -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);