Added randomize test option to ./check
authorAndrew Jones <ajones@sgi.com>
Fri, 2 Dec 2005 05:03:41 +0000 (05:03 +0000)
committerAndrew Jones <ajones@sgi.com>
Fri, 2 Dec 2005 05:03:41 +0000 (05:03 +0000)
Merge of master-melb:xfs-cmds:24664a by kenmcd.

  Added comment about the randomize '-r' option.

README
common
randomize.awk [new file with mode: 0644]

diff --git a/README b/README
index 049ae08..375e07c 100644 (file)
--- a/README
+++ b/README
@@ -76,6 +76,7 @@ Running tests:
     - for udf tests: ./check -udf [test(s)]
       Running all the udf tests: ./check -udf -g udf
     - for running nfs tests: ./check -nfs [test(s)]
+    - To randomize test order: ./check -r [test(s)]
 
     
     The check script tests the return value of each script, and
diff --git a/common b/common
index 29046cf..5ca8541 100644 (file)
--- a/common
+++ b/common
@@ -1,6 +1,6 @@
 ##/bin/sh 
 #
-# Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
+# Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
 #
 # common procedures for QA scripts
 #
@@ -34,6 +34,7 @@ showme=false
 sortme=false
 expunge=true
 have_test_arg=false
+randomize=false
 rm -f $tmp.list $tmp.tmp $tmp.sed
 
 export FSTYP=xfs
@@ -117,7 +118,7 @@ check options
     -q                 quick [deprecated]
     -T                 output timestamps
     -x group[,group...]        exclude tests from these groups
-    -r                         randomize order
+    -r                         randomize test order
 '
            exit 0
            ;;
@@ -155,6 +156,10 @@ check options
            showme=true
            xpand=false
            ;;
+        -r)    # randomize test order
+           randomize=true
+           xpand=false
+           ;;
 
        -T)     # turn on timestamp output
            timestamp=true
@@ -248,6 +253,11 @@ fi
 list=`sort $tmp.list`
 rm -f $tmp.list $tmp.tmp $tmp.sed
 
+if $randomize
+then
+    list=`echo $list | awk -f randomize.awk`
+fi
+
 case "$FSTYP" in
     xfs)
         [ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
diff --git a/randomize.awk b/randomize.awk
new file mode 100644 (file)
index 0000000..88f86da
--- /dev/null
@@ -0,0 +1,23 @@
+# 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
+}
+
+{
+    srand()
+    for (i = 0; i < NF; i++ ) array[i] = $(i+1)
+    randomize(array, NF)
+    for (i = 0; i < NF; i++) printf("%s ", array[i])
+}
+