mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
fsx: fixes to random seed
Not sure why, but with initstate()/setstate(), fsx generates
same events regadless of the input seed argument.
Change to use srandom() to fix the problem.
Add pid to auto random seed, so parallel fsx executions with auto
seed will use different seed values.
At this time there are 6 tests that use fsx, out of which:
2 use -S 0 as seed (gettime()) - generic/{075,112}
2 do not specify seed (default = 1) - generic/{091,263}
1 uses explicit constant seed - generic/127
1 uses explicit $RANDOM seed - generic/231
This change affects all those tests.
The tests that intended to randomize the seed will now really
randomize the seed.
The tests that intended to use a constant seed will still use
a constant seed, but resulting event sequence will be different
than before this change.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
committed by
Eryu Guan
parent
9b1358a22b
commit
14ceec4027
@@ -116,7 +116,6 @@ int fd; /* fd for our test file */
|
||||
blksize_t block_size = 0;
|
||||
off_t file_size = 0;
|
||||
off_t biggest = 0;
|
||||
char state[256];
|
||||
unsigned long testcalls = 0; /* calls to function "test" */
|
||||
|
||||
unsigned long simulatedopcount = 0; /* -b flag */
|
||||
@@ -1909,8 +1908,10 @@ main(int argc, char **argv)
|
||||
break;
|
||||
case 'S':
|
||||
seed = getnum(optarg, &endp);
|
||||
if (seed == 0)
|
||||
if (seed == 0) {
|
||||
seed = time(0) % 10000;
|
||||
seed += (int)getpid();
|
||||
}
|
||||
if (!quiet)
|
||||
fprintf(stdout, "Seed set to %d\n", seed);
|
||||
if (seed < 0)
|
||||
@@ -1948,8 +1949,7 @@ main(int argc, char **argv)
|
||||
signal(SIGUSR1, cleanup);
|
||||
signal(SIGUSR2, cleanup);
|
||||
|
||||
initstate(seed, state, 256);
|
||||
setstate(state);
|
||||
srandom(seed);
|
||||
fd = open(fname,
|
||||
O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC)|o_direct, 0666);
|
||||
if (fd < 0) {
|
||||
|
||||
Reference in New Issue
Block a user