Currently integck uses the same global random generator for everything -
for choosing the operation, generating the data, and for checking. This
makes integck to become stuck sometimes. My guess this is because of
we somehow re-set it back with srand() when checking files.
This patch makes integck use different generators for data and for
choosing operations by using rand_r() with own seed for operations.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
up the file system */
static unsigned int check_run_no;
+static unsigned int random_seed;
+
/*
* A buffer which is used by 'make_name()' to return the generated random name.
*/
assert(max < RAND_MAX);
if (max == 0)
return 0;
- return rand() % max;
+ return rand_r(&random_seed) % max;
}
/*
{
int ret;
long rpt;
+ unsigned int pid = getpid();
ret = parse_opts(argc, argv);
if (ret)
get_tested_fs_info();
/* Seed the random generator with out PID */
- srand(getpid());
+ srand(pid);
+ random_seed = pid;
random_name_buf = malloc(fsinfo.max_name_len + 1);
CHECK(random_name_buf != NULL);