Added randomize test option to ./check
[xfstests-dev.git] / common
diff --git a/common b/common
index febd52e4140c66bc3206310cefbb3a8750cdb059..5ca85415196d263349052aa13304d4bceba1fe17 100644 (file)
--- a/common
+++ b/common
@@ -1,34 +1,6 @@
-##/bin/sh
+##/bin/sh 
 #
-# Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
-# 
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2 of the GNU General Public License as
-# published by the Free Software Foundation.
-# 
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# 
-# Further, this software is distributed without any warranty that it is
-# free of the rightful claim of any third person regarding infringement
-# or the like.  Any license provided herein, whether implied or
-# otherwise, applies only to this software file.  Patent licenses, if
-# any, provided herein do not apply to combinations of this program with
-# other software, or any other product whatsoever.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston MA 02111-1307, USA.
-# 
-# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
-# Mountain View, CA  94043, or:
-# 
-# http://www.sgi.com 
-# 
-# For further information regarding this notice, see: 
-# 
-# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+# Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
 #
 # common procedures for QA scripts
 #
@@ -47,36 +19,26 @@ _setenvironment
 
 check=${check-true}
 
-if $check
-then
-    if make >/tmp/$$.make 2>&1
-    then
-       :
-    else
-       cat /tmp/$$.make
-       echo "Warning: make failed -- some tests may be missing"
-       warn=1
-    fi
-    rm -f /tmp/$$.make
-fi
-
 diff=diff
 if [ ! -z "$DISPLAY" ]
 then
     which xdiff >/dev/null 2>&1 && diff=xdiff
     which gdiff >/dev/null 2>&1 && diff=gdiff
     which tkdiff >/dev/null 2>&1 && diff=tkdiff
+    which xxdiff >/dev/null 2>&1 && diff=xxdiff
 fi
 verbose=false
-quick=${quick-false}
 group=false
 xgroup=false
 showme=false
 sortme=false
 expunge=true
 have_test_arg=false
+randomize=false
 rm -f $tmp.list $tmp.tmp $tmp.sed
 
+export FSTYP=xfs
+
 for r
 do
 
@@ -147,16 +109,35 @@ common options
     -v                 verbose
 
 check options
+    -xfs                test XFS
+    -udf                test UDF
+    -nfs                test NFS
     -g group[,group...]        include tests from these groups
     -l                 line mode diff [xdiff]
     -n                 show me, do not run tests
-    -q                 quick, no checks (you are on your own)
+    -q                 quick [deprecated]
     -T                 output timestamps
     -x group[,group...]        exclude tests from these groups
+    -r                         randomize test order
 '
            exit 0
            ;;
 
+       -udf)   # -udf ... set FSTYP to udf
+           FSTYP=udf
+           xpand=false
+           ;;
+
+       -xfs)   # -xfs ... set FSTYP to xfs
+           FSTYP=xfs
+           xpand=false
+           ;;
+
+       -nfs)   # -nfs ... set FSTYP to nfs
+           FSTYP=nfs
+           xpand=false
+           ;;
+
        -g)     # -g group ... pick from group file
            group=true
            xpand=false
@@ -167,8 +148,7 @@ check options
            xpand=false
            ;;
 
-       -q)     # "quick", no checks (you are on your own)
-           quick=true
+       -q)     # "quick", no longer used - always quick :-)
            xpand=false
            ;;
 
@@ -176,6 +156,10 @@ check options
            showme=true
            xpand=false
            ;;
+        -r)    # randomize test order
+           randomize=true
+           xpand=false
+           ;;
 
        -T)     # turn on timestamp output
            timestamp=true
@@ -186,12 +170,10 @@ check options
            verbose=true
            xpand=false
            ;;
-
        -x)     # -x group ... exclude from group file
            xgroup=true
            xpand=false
            ;;
-
        '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
            echo "No tests?"
            status=1
@@ -220,6 +202,10 @@ check options
 
     esac
 
+    # get rid of leading 0s as can be interpreted as octal
+    start=`echo $start | sed 's/^0*//'`
+    end=`echo $end | sed 's/^0*//'`
+
     if $xpand
     then
        have_test_arg=true
@@ -267,21 +253,22 @@ fi
 list=`sort $tmp.list`
 rm -f $tmp.list $tmp.tmp $tmp.sed
 
-if $quick
+if $randomize
 then
-    :
-else
-
-    if ( cd src; make -i )
-    then
-       :
-    else
-       echo
-       echo ":----------------------------------------------"
-       echo ": Warning: make failed in src -- some tests may fail as a result"
-       echo ":----------------------------------------------"
-       echo
-       warn=1
-    fi
-
+    list=`echo $list | awk -f randomize.awk`
 fi
+
+case "$FSTYP" in
+    xfs)
+        [ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
+        [ "$XFS_REPAIR_PROG" = "" ] && _fatal "xfs_repair not found"
+        [ "$XFS_CHECK_PROG" = "" ] && _fatal "xfs_check not found"
+        [ "$XFS_DB_PROG" = "" ] && _fatal "xfs_db not found"
+        [ "$MKFS_XFS_PROG" = "" ] && _fatal "mkfs_xfs not found" 
+        ;;
+    udf)
+        [ "$MKFS_UDF_PROG" = "" ] && _fatal "mkfs_udf/mkudffs not found"
+        ;;
+    nfs)
+        ;;
+esac