]> granicus.if.org Git - strace/commitdiff
tests: fix TEST_SYSCALL_{NR,STR} and STRUCT_STAT_STR macros for musl
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 12 Jan 2016 00:03:41 +0000 (00:03 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 12 Jan 2016 03:07:39 +0000 (03:07 +0000)
The contents of TEST_SYSCALL_NAME and STRUCT_STAT macros was subject
to macro expansion when used in definitions of TEST_SYSCALL_NR,
TEST_SYSCALL_STR, and STRUCT_STAT_STR macros.

As some libcs, e.g. musl libc, define lfs64 names as macros
(stat64 as stat, lstat64 as lstat, etc.), this might result to incorrect
expansion of TEST_SYSCALL_NR, TEST_SYSCALL_STR, and STRUCT_STAT_STR
macros.  To avoid this problem, define these macros directly and remove
TEST_SYSCALL_NAME macro.

* tests/_newselect.c (TEST_SYSCALL_NAME): Remove.
(TEST_SYSCALL_NR, TEST_SYSCALL_STR): New macros.
* tests/fcntl.c: Likewise.
* tests/fcntl64.c: Likewise.
* tests/fstat.c: Likewise.
* tests/fstatat64.c: Likewise.
* tests/lstat.c: Likewise.
* tests/newfstatat.c: Likewise.
* tests/select.c: Likewise.
* tests/stat.c: Likewise.
* tests/fstat64.c (TEST_SYSCALL_NAME): Remove.
(TEST_SYSCALL_NR, TEST_SYSCALL_STR, STRUCT_STAT_STR): New macros.
* tests/lstat64.c: Likewise.
* tests/stat64.c: Likewise.
* tests/fstatx.c (TEST_SYSCALL_NR, nrify, nrify_): Remove.
* tests/lstatx.c: Likewise.
* tests/struct_flock.c (TEST_SYSCALL_NR, TEST_SYSCALL_STR, nrify,
nrify_, stringify, stringify_): Remove.
* tests/xselect.c: Likewise.
* tests/xstatx.c: Check TEST_SYSCALL_STR instead of TEST_SYSCALL_NAME.
(STRUCT_STAT_STR, TEST_SYSCALL_STR, stringify, stringify_): Remove.
[!STRUCT_STAT] (STRUCT_STAT_STR): New macro.

17 files changed:
tests/_newselect.c
tests/fcntl.c
tests/fcntl64.c
tests/fstat.c
tests/fstat64.c
tests/fstatat64.c
tests/fstatx.c
tests/lstat.c
tests/lstat64.c
tests/lstatx.c
tests/newfstatat.c
tests/select.c
tests/stat.c
tests/stat64.c
tests/struct_flock.c
tests/xselect.c
tests/xstatx.c

index 6a14fbb87dd502b80f781916f3cb6500516a796b..be1672e7d21e7558ed23c2c3122c29adc501e899 100644 (file)
@@ -30,7 +30,8 @@
 
 #ifdef __NR__newselect
 
-# define TEST_SYSCALL_NAME _newselect
+# define TEST_SYSCALL_NR __NR__newselect
+# define TEST_SYSCALL_STR "_newselect"
 # include "xselect.c"
 
 #else
index a55703c519561e15e6d4f6b64e834074904cfa17..dfad530ac0d86ff8948cf36fdddfeafaf76e5cde 100644 (file)
@@ -30,7 +30,8 @@
 
 #ifdef __NR_fcntl
 
-# define TEST_SYSCALL_NAME fcntl
+# define TEST_SYSCALL_NR __NR_fcntl
+# define TEST_SYSCALL_STR "fcntl"
 # include "struct_flock.c"
 
 # define TEST_FLOCK64_EINVAL(cmd) test_flock64_einval(cmd, #cmd)
index 960c4dca03dabf4014f8ca20f3801e72c4c846c5..726576e62aef8779258438eb3da17956c9cc05c0 100644 (file)
@@ -30,7 +30,8 @@
 
 #ifdef __NR_fcntl64
 
-# define TEST_SYSCALL_NAME fcntl64
+# define TEST_SYSCALL_NR __NR_fcntl64
+# define TEST_SYSCALL_STR "fcntl64"
 # include "struct_flock.c"
 
 # define TEST_FLOCK64_EINVAL(cmd) test_flock64_einval(cmd, #cmd)
index 89c38c01825d9670165076398d3f138bf49d8285..0206c9fd2a29405fc4a9920a49d6ab904bb82e21 100644 (file)
@@ -30,7 +30,8 @@
 
 #ifdef __NR_fstat
 
-# define TEST_SYSCALL_NAME fstat
+# define TEST_SYSCALL_NR __NR_fstat
+# define TEST_SYSCALL_STR "fstat"
 # define SAMPLE_SIZE ((kernel_ulong_t) 43147718418)
 # include "fstatx.c"
 
index c09f52431efeffada28db7694ea9c74ee172fb5e..59c94a2c886fc876ab80190370a2cc8a1eac5fc3 100644 (file)
 
 #ifdef __NR_fstat64
 
-# define TEST_SYSCALL_NAME fstat64
+# define TEST_SYSCALL_NR __NR_fstat64
+# define TEST_SYSCALL_STR "fstat64"
 # define STRUCT_STAT struct stat64
+# define STRUCT_STAT_STR "struct stat64"
 # define SAMPLE_SIZE ((libc_off_t) 43147718418)
 # include "fstatx.c"
 
index 286fd7c52f52ebc4bfb56fa02be709f84460a319..1bf95c101a462c8eee5a58b80bd5aa6d822d45c2 100644 (file)
@@ -30,7 +30,8 @@
 
 #ifdef __NR_fstatat64
 
-# define TEST_SYSCALL_NAME fstatat64
+# define TEST_SYSCALL_NR __NR_fstatat64
+# define TEST_SYSCALL_STR "fstatat64"
 # include "fstatat.c"
 
 #else
index ef17a792c84db4249bbb1e6eda0e167f77e5252d..890e30d4e6da96f1b6919ddb49fd76f084767a47 100644 (file)
 #define PRINT_SYSCALL_FOOTER \
        puts(") = 0")
 
-#define TEST_SYSCALL_NR nrify(TEST_SYSCALL_NAME)
-#define nrify(arg) nrify_(arg)
-#define nrify_(arg) __NR_ ## arg
-
 #define USE_ASM_STAT
 
 #include "xstatx.c"
index aa1d9fe36f6f8abe7c22fa5a048f9a8482b3dd64..663b638a2ca3bbcf134deb5d986d4ce2b814c5ee 100644 (file)
@@ -30,7 +30,8 @@
 
 #ifdef __NR_lstat
 
-# define TEST_SYSCALL_NAME lstat
+# define TEST_SYSCALL_NR __NR_lstat
+# define TEST_SYSCALL_STR "lstat"
 # define SAMPLE_SIZE ((kernel_ulong_t) 43147718418)
 # include "lstatx.c"
 
index dccd90f1df18de7763ec2cd7ae8ac60e19369eaf..4a1858bfee6adb32d9f4780b9d15b7e11f8233ca 100644 (file)
 
 #ifdef __NR_lstat64
 
-# define TEST_SYSCALL_NAME lstat64
+# define TEST_SYSCALL_NR __NR_lstat64
+# define TEST_SYSCALL_STR "lstat64"
 # define STRUCT_STAT struct stat64
+# define STRUCT_STAT_STR "struct stat64"
 # define SAMPLE_SIZE ((libc_off_t) 43147718418)
 # include "lstatx.c"
 
index 7166bb7642fcec650909d04e3d14a999cda4ce31..2bd4e9f5d02ad855272f60ddbc17aa538e5e84c2 100644 (file)
 #define PRINT_SYSCALL_FOOTER \
        puts(") = 0")
 
-#define TEST_SYSCALL_NR nrify(TEST_SYSCALL_NAME)
-#define nrify(arg) nrify_(arg)
-#define nrify_(arg) __NR_ ## arg
-
 #define USE_ASM_STAT
 
 #include "xstatx.c"
index d0bb590aadbd279f9b8e22ad9eaecd95c8da4da1..6fb34db1c6153926bef22e7f59ca0d0d6c8b2a58 100644 (file)
@@ -30,7 +30,8 @@
 
 #ifdef __NR_newfstatat
 
-# define TEST_SYSCALL_NAME newfstatat
+# define TEST_SYSCALL_NR __NR_newfstatat
+# define TEST_SYSCALL_STR "newfstatat"
 # include "fstatat.c"
 
 #else
index bd8a60b6a90f38c1dda94488e6cd54cb47889792..fa551a68933c25aa0fbf8bb277399184ea3502d7 100644 (file)
@@ -30,7 +30,8 @@
 
 #if defined __NR_select && !defined __NR__newselect
 
-# define TEST_SYSCALL_NAME select
+# define TEST_SYSCALL_NR __NR_select
+# define TEST_SYSCALL_STR "select"
 # include "xselect.c"
 
 #else
index 04c1ded05479695fb98168a98e481f050dcc47b7..f64ff302514cfb29000f5a85f3d4836e988a8742 100644 (file)
@@ -30,7 +30,8 @@
 
 #ifdef __NR_stat
 
-# define TEST_SYSCALL_NAME stat
+# define TEST_SYSCALL_NR __NR_stat
+# define TEST_SYSCALL_STR "stat"
 # define SAMPLE_SIZE ((kernel_ulong_t) 43147718418)
 # include "lstatx.c"
 
index dc90184c1e8b8840cc9767c3163cd5d15d5136ea..c1641895da5959a41739fa5cac8c0e2fe1047949 100644 (file)
 
 #ifdef __NR_stat64
 
-# define TEST_SYSCALL_NAME stat64
+# define TEST_SYSCALL_NR __NR_stat64
+# define TEST_SYSCALL_STR "stat64"
 # define STRUCT_STAT struct stat64
+# define STRUCT_STAT_STR "struct stat64"
 # define SAMPLE_SIZE ((libc_off_t) 43147718418)
 # include "lstatx.c"
 
index e514c99fd37ddea7baf16a38777cefc29fdf219c..f942909e11a614e0921a3db51903bb0b03e0fe62 100644 (file)
 #define FILE_LEN 4096
 #define EINVAL_STR "-1 EINVAL (Invalid argument)"
 
-# define TEST_SYSCALL_STR stringify(TEST_SYSCALL_NAME)
-# define stringify(arg) stringify_(arg)
-# define stringify_(arg) #arg
-
-#define TEST_SYSCALL_NR nrify(TEST_SYSCALL_NAME)
-#define nrify(arg) nrify_(arg)
-#define nrify_(arg) __NR_ ## arg
-
 #define TEST_FLOCK_EINVAL(cmd) test_flock_einval(cmd, #cmd)
 
 #ifdef HAVE_TYPEOF
index 5afd7848b46a75ea6020d4a8c1a41e95cc61ad86..08e29e1f4459cf7f676505d3cc2b08ad7e2d041d 100644 (file)
 #include <unistd.h>
 #include <sys/select.h>
 
-#define TEST_SYSCALL_NR nrify(TEST_SYSCALL_NAME)
-#define nrify(arg) nrify_(arg)
-#define nrify_(arg) __NR_ ## arg
-
-#define TEST_SYSCALL_STR stringify(TEST_SYSCALL_NAME)
-#define stringify(arg) stringify_(arg)
-#define stringify_(arg) #arg
-
 static fd_set set[0x1000000 / sizeof(fd_set)];
 
 int main(void)
index 918ea0e1f56d588a4e0757c8b264958a04c576e3..8694f95529e1bc2398e24b1c870c4e67832ce19a 100644 (file)
@@ -27,8 +27,8 @@
 
 #if defined HAVE_FTRUNCATE && defined HAVE_FUTIMENS
 
-# ifndef TEST_SYSCALL_NAME
-#  error TEST_SYSCALL_NAME must be defined
+# ifndef TEST_SYSCALL_STR
+#  error TEST_SYSCALL_STR must be defined
 # endif
 # ifndef TEST_SYSCALL_INVOKE
 #  error TEST_SYSCALL_INVOKE must be defined
@@ -133,6 +133,7 @@ typedef off_t libc_off_t;
 
 # ifndef STRUCT_STAT
 #  define STRUCT_STAT struct stat
+#  define STRUCT_STAT_STR "struct stat"
 # endif
 # ifndef SAMPLE_SIZE
 #  define SAMPLE_SIZE 43147718418
@@ -230,11 +231,6 @@ create_sample(const char *fname, const libc_off_t size)
        return 0;
 }
 
-# define stringify_(arg) #arg
-# define stringify(arg) stringify_(arg)
-# define TEST_SYSCALL_STR stringify(TEST_SYSCALL_NAME)
-# define STRUCT_STAT_STR stringify(STRUCT_STAT)
-
 int
 main(void)
 {