diff options
| author | Wainer dos Santos Moschetta <wainersm@linux.vnet.ibm.com> | 2017-03-23 11:32:17 -0300 |
|---|---|---|
| committer | Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com> | 2017-03-23 11:32:29 -0300 |
| commit | fb82116f24454e450f771a41f18cbdacfae1229d (patch) | |
| tree | da5c958ba91e1b662298de2971f608a05bf6324b /string | |
| parent | b9e8c9087579e2021cf497713e047e040c84da28 (diff) | |
| download | glibc-fb82116f24454e450f771a41f18cbdacfae1229d.tar.xz glibc-fb82116f24454e450f771a41f18cbdacfae1229d.zip | |
Update string tests to use the support test driver.
Replaced all imports of test-skeleton.c with support/test-driver.c.
In some cases it was needed to adjust do_test to return int
instead of static int since that is the method's signature expected by
test-driver.c.
Checked on x86_64.
* 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.
Diffstat (limited to 'string')
44 files changed, 87 insertions, 93 deletions
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 |
