aboutsummaryrefslogtreecommitdiff
path: root/string/test-string.h
diff options
context:
space:
mode:
Diffstat (limited to 'string/test-string.h')
-rw-r--r--string/test-string.h45
1 files changed, 27 insertions, 18 deletions
diff --git a/string/test-string.h b/string/test-string.h
index 2c36b44..3f72876 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__)