[Pixman] [PATCH 6/8] stress-test: add -f <file> arg.
bansan85
legarrec.vincent at gmail.com
Wed Dec 13 19:41:37 UTC 2017
---
test/stress-test.c | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
diff --git a/test/stress-test.c b/test/stress-test.c
index c4148ff..d997f1b 100644
--- a/test/stress-test.c
+++ b/test/stress-test.c
@@ -1004,17 +1004,42 @@ main (int argc, char **argv)
i++;
}
}
- else if (strcmp (argv[i], "-s") == 0 && i + 1 < argc)
+ else if (strcmp (argv[i], "-s") == 0 && i + 1 < argc &&
+ random_data == NULL)
{
get_int (argv[i + 1], &seed);
use_threads = FALSE;
i++;
}
- else if (strcmp (argv[i], "-n") == 0 && i + 1 < argc)
+ else if (strcmp (argv[i], "-n") == 0 && i + 1 < argc &&
+ random_data == NULL)
{
get_int (argv[i + 1], &n_tests);
i++;
}
+ else if (strcmp (argv[i], "-f") == 0 && i + 1 < argc)
+ {
+ FILE *file = fopen(argv[i + 1], "rb");
+
+ if (!file)
+ {
+ fprintf(stderr, "Unable to open file %s", argv[i + 1]);
+ exit (-1);
+ }
+
+ /* Get file length */
+ fseek (file, 0, SEEK_END);
+ size_data = ftell (file);
+
+ /* Allocate and load memory */
+ random_data = malloc (fileLen);
+ fread (random_data, fileLen, 1, file);
+ fclose (file);
+
+ n_tests = 0;
+
+ i++;
+ }
else
{
if (strcmp (argv[i], "-h") != 0)
@@ -1023,6 +1048,7 @@ main (int argc, char **argv)
printf ("Options:\n\n"
"-n <number> Number of tests to run\n"
"-s <seed> Seed of first test (ignored if PIXMAN_RANDOMIZE_TESTS is set)\n"
+ "-f <file> Use a file as random data. Not with -n and -s.\n"
"-v Print out seeds\n"
"-v <n> Print out every n'th seed\n\n");
@@ -1036,7 +1062,7 @@ main (int argc, char **argv)
printf ("First seed: 0x%08x\n", seed);
}
- if (use_threads)
+ if (use_threads && n_tests != 1)
{
#ifdef USE_OPENMP
# pragma omp parallel for default(none) shared(verbose, n_tests, mod, seed)
--
2.15.0
More information about the Pixman
mailing list