mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
07094a9652
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>
29 lines
438 B
Awk
29 lines
438 B
Awk
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
|
|
#
|
|
# randomize stdin.
|
|
|
|
function randomize(array, N) {
|
|
for(i = 0; i < N; i++) {
|
|
j = int(rand()*N)
|
|
if ( i != j) {
|
|
tmp = array[i]
|
|
array[i] = array[j]
|
|
array[j] = tmp
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
BEGIN {
|
|
srand(seed)
|
|
}
|
|
{
|
|
array[NR - 1] = $0
|
|
}
|
|
END {
|
|
randomize(array, NR)
|
|
for (i = 0; i < NR; i++) printf("%s ", array[i])
|
|
}
|
|
|