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.

* xstatx.c (main): Add check for non-available pointer, for block device
file. Update PRINT_SYSCALL_FOOTER call convention.
* fstatat.c (PRINT_SYSCALL_HEADER): Add errno saving.
(PRINT_SYSCALL_FOOTER): Restore errno.
* fstatx.c (PRINT_SYSCALL_HEADER): Add errno saving.
(PRINT_SYSCALL_FOOTER): Restore errno.
* lstatx.c (PRINT_SYSCALL_HEADER): Add errno saving.
(PRINT_SYSCALL_FOOTER): Restore errno.
* statx.sh: Add tracing of /dev/full file, specify alignment.
* fstat.test: Specify alignment.
---
 tests/fstat.test |    2 +-
 tests/fstatat.c  |   10 +++++++---
 tests/fstatx.c   |   11 ++++++++---
 tests/lstatx.c   |   10 +++++++---
 tests/statx.sh   |    2 +-
 tests/xstatx.c   |   33 ++++++++++++++++++++++++++++++---
 6 files changed, 54 insertions(+), 14 deletions(-)

diff --git a/tests/fstat.test b/tests/fstat.test
index 506b440..2ba0fba 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/fstatat.c b/tests/fstatat.c
index ff47601..ec55ca0 100644
--- a/tests/fstatat.c
+++ b/tests/fstatat.c
@@ -30,9 +30,13 @@
 # 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"
 
diff --git a/tests/fstatx.c b/tests/fstatx.c
index 890e30d..174f29f 100644
--- a/tests/fstatx.c
+++ b/tests/fstatx.c
@@ -25,12 +25,17 @@
  * 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) \
-       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
 
diff --git a/tests/lstatx.c b/tests/lstatx.c
index 2bd4e9f..a3ff843 100644
--- a/tests/lstatx.c
+++ b/tests/lstatx.c
@@ -28,9 +28,13 @@
 #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
 
diff --git a/tests/statx.sh b/tests/statx.sh
index 830e5fc..a630193 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 2d0dac3..d1ad52d 100644
--- a/tests/xstatx.c
+++ b/tests/xstatx.c
@@ -40,6 +40,7 @@
 #  error PRINT_SYSCALL_FOOTER must be defined
 # endif
 
+# include <errno.h>
 # include <stdio.h>
 # include <stddef.h>
 # include <time.h>
@@ -132,6 +133,10 @@ typedef off_t libc_off_t;
 #  endif /* HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC */
 # endif
 
+# ifndef IS_FSTAT
+#  define IS_STAT 0
+# endif
+
 static void
 print_ftype(const unsigned int mode)
 {
@@ -227,16 +232,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);
+       STRUCT_STAT *st_cut = tail_alloc(sizeof(*st_cut) - 4);
+
+       int rc;
+
+       rc = create_sample(sample, SAMPLE_SIZE);
        if (rc) {
                (void) unlink(sample);
                return rc;
        }
 
-       if (TEST_SYSCALL_INVOKE(sample, st)) {
+       rc = TEST_SYSCALL_INVOKE(sample, st_cut);
+       PRINT_SYSCALL_HEADER(sample);
+       printf("%p", st_cut);
+       PRINT_SYSCALL_FOOTER(rc);
+
+# 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);
                return 77;
@@ -297,7 +324,7 @@ main(void)
 
        PRINT_SYSCALL_HEADER(sample);
        print_stat(st);
-       PRINT_SYSCALL_FOOTER;
+       PRINT_SYSCALL_FOOTER(rc);
 
        puts("+++ exited with 0 +++");
        return 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