]> granicus.if.org Git - strace/commitdiff
tests: prepare for 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)
PRINT_SYSCALL_HEADER/PRINT_SYSCALL_FOOTER now contain open/close brace
pair in order to save errno.  PRINT_SYSCALL_FOOTER now uses sprintrc for
printing rc/errno.

* tests/xstatx.c: Include <errno.h>.
(main): Update PRINT_SYSCALL_FOOTER call convention.
* tests/fstatat.c (PRINT_SYSCALL_HEADER): Add errno saving.
(PRINT_SYSCALL_FOOTER): Restore errno.
* tests/fstatx.c: Likewise.
* tests/lstatx.c: Likewise.

tests/fstatat.c
tests/fstatx.c
tests/lstatx.c
tests/xstatx.c

index ff4760114788cce40eb134760152fdc5c3b16b2c..ec55ca04dd7eb96a48f86e2d857929ad7e70322a 100644 (file)
 # define TEST_SYSCALL_INVOKE(sample, pst) \
        fstatat(AT_FDCWD, sample, pst, AT_SYMLINK_NOFOLLOW)
 # define PRINT_SYSCALL_HEADER(sample) \
-       printf("%s(AT_FDCWD, \"%s\", ", TEST_SYSCALL_STR, sample)
-# define PRINT_SYSCALL_FOOTER \
-       puts(", AT_SYMLINK_NOFOLLOW) = 0")
+       do { \
+               int saved_errno = errno; \
+               printf("%s(AT_FDCWD, \"%s\", ", TEST_SYSCALL_STR, sample)
+# define PRINT_SYSCALL_FOOTER(rc) \
+               errno = saved_errno; \
+               printf(", AT_SYMLINK_NOFOLLOW) = %s\n", sprintrc(rc)); \
+       } while (0)
 
 # include "xstatx.c"
 
index 890e30d4e6da96f1b6919ddb49fd76f084767a47..5749e069116c45d4c6f0d8568c4528f194940f65 100644 (file)
 #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")
+       do { \
+               int saved_errno = errno; \
+               printf("%s(0, ", TEST_SYSCALL_STR)
+#define PRINT_SYSCALL_FOOTER(rc) \
+               errno = saved_errno; \
+               printf(") = %s\n", sprintrc(rc)); \
+       } while (0)
 
 #define USE_ASM_STAT
 
index 2bd4e9f5d02ad855272f60ddbc17aa538e5e84c2..a3ff843637306b1245678ae6438db1bd1ebdb497 100644 (file)
 #define TEST_SYSCALL_INVOKE(sample, pst) \
        syscall(TEST_SYSCALL_NR, sample, pst)
 #define PRINT_SYSCALL_HEADER(sample) \
-       printf("%s(\"%s\", ", TEST_SYSCALL_STR, sample)
-#define PRINT_SYSCALL_FOOTER \
-       puts(") = 0")
+       do { \
+               int saved_errno = errno; \
+               printf("%s(\"%s\", ", TEST_SYSCALL_STR, sample)
+#define PRINT_SYSCALL_FOOTER(rc) \
+               errno = saved_errno; \
+               printf(") = %s\n", sprintrc(rc)); \
+       } while (0)
 
 #define USE_ASM_STAT
 
index 2d0dac36e8ecbda29b188517adec7a51320535ac..dcdf49fdbd287cdc814a3c7d7df91494d1c04842 100644 (file)
@@ -40,6 +40,7 @@
 #  error PRINT_SYSCALL_FOOTER must be defined
 # endif
 
+# include <errno.h>
 # include <stdio.h>
 # include <stddef.h>
 # include <time.h>
@@ -236,7 +237,7 @@ main(void)
                return rc;
        }
 
-       if (TEST_SYSCALL_INVOKE(sample, st)) {
+       if ((rc = TEST_SYSCALL_INVOKE(sample, st))) {
                perror(TEST_SYSCALL_STR);
                (void) unlink(sample);
                return 77;
@@ -297,7 +298,7 @@ main(void)
 
        PRINT_SYSCALL_HEADER(sample);
        print_stat(st);
-       PRINT_SYSCALL_FOOTER;
+       PRINT_SYSCALL_FOOTER(rc);
 
        puts("+++ exited with 0 +++");
        return 0;