diff options
46 files changed, 143 insertions, 95 deletions
diff --git a/ChangeLog b/ChangeLog index 7809c3dc2b..5769bf5512 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,56 @@ +2017-03-23 Wainer dos Santos Moschetta <wainersm@linux.vnet.ibm.com> + + * string/test-string.h (TEST_FUNCTION): Use test_main instead of + test_main (). + (CMDLINE_PROCESS): Use function instead of defined macro. + * debug/test-strcpy_chk.c: Import support/test-driver.c and also + <suppport/support.h> to use set_fortify_handler(). + * string/bug-envz1.c: Import support/test-driver.c instead of + test-skeleton.c. + * string/bug-strcoll2.c: Likewise. + * string/bug-strtok1.c: Likewise. + * string/stratcliff.c: Likewise. + * string/test-ffs.c: Likewise. + * string/test-memccpy.c: Likewise. + * string/test-memchr.c: Likewise. + * string/test-memcmp.c: Likewise. + * string/test-memcpy.c: Likewise. + * string/test-memmem.c: Likewise. + * string/test-memmove.c: Likewise. + * string/test-memrchr.c: Likewise. + * string/test-memset.c: Likewise. + * string/test-rawmemchr.c: Likewise. + * string/test-strcasecmp.c: Likewise. + * string/test-strcasestr.c: Likewise. + * string/test-strcat.c: Likewise. + * string/test-strchr.c: Likewise. + * string/test-strcmp.c: Likewise. + * string/test-strcpy.c: Likewise. + * string/test-string.h: Likewise. + * string/test-strlen.c: Likewise. + * string/test-strncasecmp.c: Likewise. + * string/test-strncat.c: Likewise. + * string/test-strncmp.c: Likewise. + * string/test-strncpy.c: Likewise. + * string/test-strnlen.c: Likewise. + * string/test-strpbrk.c: Likewise. + * string/test-strrchr.c: Likewise. + * string/test-strspn.c: Likewise. + * string/test-strstr.c: Likewise. + * string/tst-bswap.c: Likewise. + * string/tst-cmp.c: Likewise. + * string/tst-endian.c: Likewise. + * string/tst-inlcall.c: Likewise. + * string/tst-strcoll-overflow.c: Likewise. + * string/tst-strfry.c: Likewise. + * string/tst-strlen.c: Likewise. + * string/tst-strtok.c: Likewise. + * string/tst-strtok_r.c: Likewise. + * string/tst-strxfrm.c: Likewise. + * string/tst-strxfrm2.c: Likewise. + * string/tst-svc.c: Likewise. + * string/tst-svc2.c: Likewise. + 2017-03-22 Zack Weinberg <zackw@panix.com> * stdio-common/bug25.c: Include stdlib.h. diff --git a/debug/test-strcpy_chk.c b/debug/test-strcpy_chk.c index 6bb0fc0e87..8b729bd6ba 100644 --- a/debug/test-strcpy_chk.c +++ b/debug/test-strcpy_chk.c @@ -55,8 +55,9 @@ simple_strcpy_chk (char *dst, const char *src, size_t len) #include <signal.h> static int test_main (void); -#define TEST_FUNCTION test_main () -#include "../test-skeleton.c" +#define TEST_FUNCTION test_main +#include <support/test-driver.c> +#include <support/support.h> volatile int chk_fail_ok; jmp_buf chk_fail_buf; diff --git a/string/bug-envz1.c b/string/bug-envz1.c index e8a60972b5..931a0559fe 100644 --- a/string/bug-envz1.c +++ b/string/bug-envz1.c @@ -25,7 +25,7 @@ static const struct #define nstrs (sizeof (strs) / sizeof (strs[0])) -static int +int do_test (void) { @@ -72,5 +72,4 @@ do_test (void) return result; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/bug-strcoll2.c b/string/bug-strcoll2.c index 8d4fed5231..ff33007df6 100644 --- a/string/bug-strcoll2.c +++ b/string/bug-strcoll2.c @@ -79,7 +79,7 @@ test_da_DK (void) } } -static int +int do_test (void) { int err = 0; @@ -88,5 +88,4 @@ do_test (void) return err; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/bug-strtok1.c b/string/bug-strtok1.c index da30acf2e6..a47b2f3531 100644 --- a/string/bug-strtok1.c +++ b/string/bug-strtok1.c @@ -2,7 +2,7 @@ #include <string.h> #include <stdio.h> -static int +int do_test (void) { const char str[] = "axaaba"; @@ -41,5 +41,4 @@ do_test (void) return result; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/stratcliff.c b/string/stratcliff.c index e672644888..e28b0c5058 100644 --- a/string/stratcliff.c +++ b/string/stratcliff.c @@ -55,7 +55,7 @@ #define STRINGIFY2(s) #s -static int +int do_test (void) { int size = sysconf (_SC_PAGESIZE); @@ -558,5 +558,4 @@ memccpy copied too much for outer = %d, middle = %d, inner = %d\n", return result; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-ffs.c b/string/test-ffs.c index 8c8ce2a829..11b6ea838b 100644 --- a/string/test-ffs.c +++ b/string/test-ffs.c @@ -21,7 +21,7 @@ #include <stdio.h> #include <string.h> -static int +int do_test (void) { int failures = 0; @@ -62,5 +62,4 @@ do_test (void) return failures; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-memccpy.c b/string/test-memccpy.c index 1b7e177770..7bd67a61e7 100644 --- a/string/test-memccpy.c +++ b/string/test-memccpy.c @@ -266,4 +266,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-memchr.c b/string/test-memchr.c index d64d10cb0e..2403c9242b 100644 --- a/string/test-memchr.c +++ b/string/test-memchr.c @@ -214,4 +214,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-memcmp.c b/string/test-memcmp.c index 0e3cc9fa21..a7969edaea 100644 --- a/string/test-memcmp.c +++ b/string/test-memcmp.c @@ -521,4 +521,5 @@ test_main (void) do_random_tests (); return ret; } -#include "../test-skeleton.c" + +#include <support/test-driver.c> diff --git a/string/test-memcpy.c b/string/test-memcpy.c index 882c603ccf..49f0a76047 100644 --- a/string/test-memcpy.c +++ b/string/test-memcpy.c @@ -256,4 +256,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-memmem.c b/string/test-memmem.c index f49f6e2340..82fd93ccde 100644 --- a/string/test-memmem.c +++ b/string/test-memmem.c @@ -181,4 +181,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-memmove.c b/string/test-memmove.c index d9f332f4b0..51f79f6eb4 100644 --- a/string/test-memmove.c +++ b/string/test-memmove.c @@ -287,4 +287,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-memrchr.c b/string/test-memrchr.c index b313175860..bfc9920dcc 100644 --- a/string/test-memrchr.c +++ b/string/test-memrchr.c @@ -166,4 +166,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-memset.c b/string/test-memset.c index cf73651dd1..ca1bfe1e3b 100644 --- a/string/test-memset.c +++ b/string/test-memset.c @@ -264,4 +264,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-rawmemchr.c b/string/test-rawmemchr.c index 15cdedd5fd..2a53e71026 100644 --- a/string/test-rawmemchr.c +++ b/string/test-rawmemchr.c @@ -162,4 +162,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strcasecmp.c b/string/test-strcasecmp.c index 28b32e27da..9c333f0072 100644 --- a/string/test-strcasecmp.c +++ b/string/test-strcasecmp.c @@ -267,4 +267,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strcasestr.c b/string/test-strcasestr.c index bf4fc5e250..abb3916732 100644 --- a/string/test-strcasestr.c +++ b/string/test-strcasestr.c @@ -191,4 +191,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strcat.c b/string/test-strcat.c index 26e37fa523..01d180eb50 100644 --- a/string/test-strcat.c +++ b/string/test-strcat.c @@ -269,4 +269,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strchr.c b/string/test-strchr.c index dba149ed3c..de9a274f7b 100644 --- a/string/test-strchr.c +++ b/string/test-strchr.c @@ -293,4 +293,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strcmp.c b/string/test-strcmp.c index 7b546d26e8..f7af219149 100644 --- a/string/test-strcmp.c +++ b/string/test-strcmp.c @@ -406,4 +406,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strcpy.c b/string/test-strcpy.c index 77b6e8c857..d4de65a590 100644 --- a/string/test-strcpy.c +++ b/string/test-strcpy.c @@ -242,4 +242,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-string.h b/string/test-string.h index 2c36b44c22..3f72876454 100644 --- a/string/test-string.h +++ b/string/test-string.h @@ -40,6 +40,7 @@ extern impl_t __start_impls[], __stop_impls[]; #undef __USE_STRING_INLINES +#include <getopt.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -55,7 +56,7 @@ extern impl_t __start_impls[], __stop_impls[]; #define GLRO(x) _##x -# define TEST_FUNCTION test_main () +# define TEST_FUNCTION test_main # define TIMEOUT (4 * 60) # define OPT_ITERATIONS 10000 # define OPT_RANDOM 10001 @@ -83,23 +84,31 @@ size_t iterations = 100000; # define CMDLINE_OPTIONS ITERATIONS_OPTIONS \ { "random", no_argument, NULL, OPT_RANDOM }, \ { "seed", required_argument, NULL, OPT_SEED }, -# define CMDLINE_PROCESS ITERATIONS_PROCESS \ - case OPT_RANDOM: \ - { \ - int fdr = open ("/dev/urandom", O_RDONLY); \ - \ - if (fdr < 0 || read (fdr, &seed, sizeof(seed)) != sizeof (seed)) \ - seed = time (NULL); \ - if (fdr >= 0) \ - close (fdr); \ - do_srandom = 1; \ - break; \ - } \ - \ - case OPT_SEED: \ - seed = strtoul (optarg, NULL, 0); \ - do_srandom = 1; \ - break; + +static void __attribute__ ((used)) +cmdline_process_function (int c) +{ + switch (c) + { + ITERATIONS_PROCESS + case OPT_RANDOM: + { + int fdr = open ("/dev/urandom", O_RDONLY); + if (fdr < 0 || read (fdr, &seed, sizeof (seed)) != sizeof (seed)) + seed = time (NULL); + if (fdr >= 0) + close (fdr); + do_srandom = 1; + break; + } + + case OPT_SEED: + seed = strtoul (optarg, NULL, 0); + do_srandom = 1; + break; + } +} +# define CMDLINE_PROCESS cmdline_process_function #define CALL(impl, ...) \ (* (proto_t) (impl)->fn) (__VA_ARGS__) diff --git a/string/test-strlen.c b/string/test-strlen.c index 5d30e10468..99be380e6e 100644 --- a/string/test-strlen.c +++ b/string/test-strlen.c @@ -164,4 +164,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strncasecmp.c b/string/test-strncasecmp.c index 1e05f028ff..bf501cf798 100644 --- a/string/test-strncasecmp.c +++ b/string/test-strncasecmp.c @@ -350,4 +350,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strncat.c b/string/test-strncat.c index 26a6b5b91d..66d58e534d 100644 --- a/string/test-strncat.c +++ b/string/test-strncat.c @@ -319,4 +319,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strncmp.c b/string/test-strncmp.c index a245d0b93d..fe3c4e3320 100644 --- a/string/test-strncmp.c +++ b/string/test-strncmp.c @@ -476,4 +476,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strncpy.c b/string/test-strncpy.c index 88d1d44e49..43f9c236f1 100644 --- a/string/test-strncpy.c +++ b/string/test-strncpy.c @@ -320,4 +320,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strnlen.c b/string/test-strnlen.c index 7059669b24..277146fb6c 100644 --- a/string/test-strnlen.c +++ b/string/test-strnlen.c @@ -191,4 +191,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strpbrk.c b/string/test-strpbrk.c index f7a0a4f2aa..4d680ab354 100644 --- a/string/test-strpbrk.c +++ b/string/test-strpbrk.c @@ -264,4 +264,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strrchr.c b/string/test-strrchr.c index 8908ddac65..10c070aef1 100644 --- a/string/test-strrchr.c +++ b/string/test-strrchr.c @@ -244,4 +244,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strspn.c b/string/test-strspn.c index c32a6958df..d26331fb6d 100644 --- a/string/test-strspn.c +++ b/string/test-strspn.c @@ -242,4 +242,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/test-strstr.c b/string/test-strstr.c index c29d37446c..21944f41a3 100644 --- a/string/test-strstr.c +++ b/string/test-strstr.c @@ -208,4 +208,4 @@ test_main (void) return ret; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/tst-bswap.c b/string/tst-bswap.c index d3e432dbf5..def6e2f28a 100644 --- a/string/tst-bswap.c +++ b/string/tst-bswap.c @@ -21,7 +21,7 @@ extern unsigned long long int wash (unsigned long long int a); -static int +int do_test (void) { int result = 0; @@ -72,5 +72,4 @@ wash (unsigned long long int a) return a + 0; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/tst-cmp.c b/string/tst-cmp.c index ae63228318..d7720194e9 100644 --- a/string/tst-cmp.c +++ b/string/tst-cmp.c @@ -107,7 +107,7 @@ strncasecmp_max (const char *left, const char *right) return strncasecmp (left, right, SIZE_MAX); } -static int +int do_test (void) { enum { @@ -209,5 +209,4 @@ do_test (void) machines. */ #define TIMEOUT 300 -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/tst-endian.c b/string/tst-endian.c index d3c7c2c4c5..b156ede199 100644 --- a/string/tst-endian.c +++ b/string/tst-endian.c @@ -18,7 +18,7 @@ # define DIAG_IGNORE_NEEDS_COMMENT_TAUTOLOGICAL_COMPARE() #endif -static int +int do_test (void) { int result = 0; @@ -131,5 +131,4 @@ do_test (void) return result; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/tst-inlcall.c b/string/tst-inlcall.c index 54a0f373c6..f39f2c33a0 100644 --- a/string/tst-inlcall.c +++ b/string/tst-inlcall.c @@ -31,7 +31,7 @@ #include <fcntl.h> -static int +int do_test (void) { int status; @@ -81,5 +81,4 @@ do_test (void) return status; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/tst-strcoll-overflow.c b/string/tst-strcoll-overflow.c index ee694b61c0..826af4f8a8 100644 --- a/string/tst-strcoll-overflow.c +++ b/string/tst-strcoll-overflow.c @@ -30,7 +30,7 @@ 64-bit. */ #define SIZE 0x40000000ul -static int +int do_test (void) { TEST_VERIFY_EXIT (setlocale (LC_COLLATE, "en_GB.UTF-8") != NULL); diff --git a/string/tst-strfry.c b/string/tst-strfry.c index 2b40a39b13..e4e9018c5b 100644 --- a/string/tst-strfry.c +++ b/string/tst-strfry.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <string.h> -static int +int do_test (void) { char str[] = "this is a test"; @@ -11,5 +11,4 @@ do_test (void) return 0; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/tst-strlen.c b/string/tst-strlen.c index 8376831de5..15fbc8bd7b 100644 --- a/string/tst-strlen.c +++ b/string/tst-strlen.c @@ -5,7 +5,7 @@ #include <stdio.h> #include <string.h> -static int +int do_test (void) { static const size_t lens[] = { 0, 1, 0, 2, 0, 1, 0, 3, @@ -54,5 +54,4 @@ strnlen failed for base=%Zu, words=%Zu, and last=%Zu (is %zd, expected %zd)\n", return 0; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/tst-strtok.c b/string/tst-strtok.c index 6fbef9f33e..628e106a46 100644 --- a/string/tst-strtok.c +++ b/string/tst-strtok.c @@ -2,7 +2,7 @@ #include <stdio.h> #include <string.h> -static int +int do_test (void) { char buf[1] = { 0 }; @@ -22,5 +22,4 @@ do_test (void) return result; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/tst-strtok_r.c b/string/tst-strtok_r.c index 96749b6a2a..fc3ed60b63 100644 --- a/string/tst-strtok_r.c +++ b/string/tst-strtok_r.c @@ -35,4 +35,4 @@ test_main (void) return strcmp (tok, "udf") != 0; } -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/tst-strxfrm.c b/string/tst-strxfrm.c index f48cfc0da4..ffe191c60d 100644 --- a/string/tst-strxfrm.c +++ b/string/tst-strxfrm.c @@ -58,7 +58,7 @@ test (const char *locale) } -static int +int do_test (void) { int result = 0; @@ -70,5 +70,4 @@ do_test (void) return result; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/tst-strxfrm2.c b/string/tst-strxfrm2.c index bea5aa2cea..12117e80d6 100644 --- a/string/tst-strxfrm2.c +++ b/string/tst-strxfrm2.c @@ -2,7 +2,7 @@ #include <stdio.h> #include <string.h> -static int +int do_test (void) { static const char test_locale[] = "de_DE.UTF-8"; @@ -81,5 +81,4 @@ do_test (void) return res; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/tst-svc.c b/string/tst-svc.c index 1b0da3efe5..d5cf2c19c9 100644 --- a/string/tst-svc.c +++ b/string/tst-svc.c @@ -13,7 +13,7 @@ compare (const void *p1, const void *p2) return strverscmp (*((char **) p1), *((char **) p2)); } -static int +int do_test (void) { char line[MAX_LINE_SIZE + 1]; @@ -44,5 +44,4 @@ do_test (void) return EXIT_SUCCESS; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> diff --git a/string/tst-svc2.c b/string/tst-svc2.c index 12c88aa2b8..c0aa03dc18 100644 --- a/string/tst-svc2.c +++ b/string/tst-svc2.c @@ -26,7 +26,7 @@ compare (const char *str1, const char *str2, int exp) } -static int +int do_test (void) { int res = 0; @@ -58,5 +58,4 @@ do_test (void) return res; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> |