summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheck12
-rw-r--r--randomize.awk12
2 files changed, 14 insertions, 10 deletions
diff --git a/check b/check
index 20e95302..ecd1d39a 100755
--- a/check
+++ b/check
@@ -242,13 +242,13 @@ _prepare_test_list()
done
# sort the list of tests into numeric order
- list=`sort -n $tmp.list | uniq`
- rm -f $tmp.list
-
- if $randomize
- then
- list=`echo $list | awk -f randomize.awk`
+ if $randomize; then
+ sorter="awk -v seed=$RANDOM -f randomize.awk"
+ else
+ sorter="cat"
fi
+ list=`sort -n $tmp.list | uniq | $sorter`
+ rm -f $tmp.list
}
# Process command arguments first.
diff --git a/randomize.awk b/randomize.awk
index 0a8ad71a..d979fb03 100644
--- a/randomize.awk
+++ b/randomize.awk
@@ -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])
}