check: improve test list randomization

awk doesn't have a particularly good random number generator -- it seeds
from the Unix epoch time in seconds, which means that the run order
across a bunch of VMs started at exactly the same time are unsettlingly
predictable.  Therefore, at least try to seed it with bash's $RANDOM,
which is slightly less predictable.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Darrick J. Wong
2019-03-19 17:44:42 -07:00
committed by Eryu Guan
parent 2caa208e3a
commit 07094a9652
2 changed files with 14 additions and 10 deletions
+8 -4
View File
@@ -15,10 +15,14 @@ function randomize(array, N) {
return
}
BEGIN {
srand(seed)
}
{
srand()
for (i = 0; i < NF; i++ ) array[i] = $(i+1)
randomize(array, NF)
for (i = 0; i < NF; i++) printf("%s ", array[i])
array[NR - 1] = $0
}
END {
randomize(array, NR)
for (i = 0; i < NR; i++) printf("%s ", array[i])
}