mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
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:
committed by
Eryu Guan
parent
2caa208e3a
commit
07094a9652
@@ -242,13 +242,13 @@ _prepare_test_list()
|
|||||||
done
|
done
|
||||||
|
|
||||||
# sort the list of tests into numeric order
|
# sort the list of tests into numeric order
|
||||||
list=`sort -n $tmp.list | uniq`
|
if $randomize; then
|
||||||
rm -f $tmp.list
|
sorter="awk -v seed=$RANDOM -f randomize.awk"
|
||||||
|
else
|
||||||
if $randomize
|
sorter="cat"
|
||||||
then
|
|
||||||
list=`echo $list | awk -f randomize.awk`
|
|
||||||
fi
|
fi
|
||||||
|
list=`sort -n $tmp.list | uniq | $sorter`
|
||||||
|
rm -f $tmp.list
|
||||||
}
|
}
|
||||||
|
|
||||||
# Process command arguments first.
|
# Process command arguments first.
|
||||||
|
|||||||
+8
-4
@@ -15,10 +15,14 @@ function randomize(array, N) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
srand(seed)
|
||||||
|
}
|
||||||
{
|
{
|
||||||
srand()
|
array[NR - 1] = $0
|
||||||
for (i = 0; i < NF; i++ ) array[i] = $(i+1)
|
}
|
||||||
randomize(array, NF)
|
END {
|
||||||
for (i = 0; i < NF; i++) printf("%s ", array[i])
|
randomize(array, NR)
|
||||||
|
for (i = 0; i < NR; i++) printf("%s ", array[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user