Fixed merge issue with TIMESTAMP string printing twice.
[xfstests-dev.git] / check
diff --git a/check b/check
index 51a935c27b70cb7db1d8dbd6b4936ac1307fe3ce..438f351ea0a2c96958a62109ad19611c90c3f095 100755 (executable)
--- a/check
+++ b/check
@@ -33,9 +33,6 @@
 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
 #
 
-export MKFS_OPTIONS=${MKFS_OPTIONS:=-bsize=4096}
-export MOUNT_OPTIONS=${MOUNT_OPTIONS:=-ologbufs=2}
-
 tmp=/tmp/$$
 status=0
 needwrap=true
@@ -45,6 +42,8 @@ bad=""
 notrun=""
 interrupt=true
 
+export QA_CHECK_FS=${QA_CHECK_FS:=true}
+
 # generic initialization
 iam=check
 if ! . ./common.rc
@@ -53,7 +52,7 @@ then
     exit 1
 fi
 
-if [ $UID -ne 0 ]
+if [ `id -u` -ne 0 ]
 then
     echo "check: QA must be run as root"
     exit 1
@@ -64,6 +63,12 @@ _wallclock()
     date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
 }
 
+_timestamp()
+{
+    now=`date "+%D-%T"`
+    echo -n " [$now]"
+}
+
 _wrapup()
 {
     # for hangcheck ...
@@ -120,6 +125,8 @@ END { if (NR > 0) {
        needwrap=false
     fi
 
+    rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
+    rm -f /tmp/check.pid /tmp/check.sts
     rm -f $tmp.*
 }
 
@@ -150,41 +157,43 @@ timestamp=${TIMESTAMP:=false}
 
 [ -f check.time ] || touch check.time
 
-if [ ! -z "$MKFS_OPTIONS" ]
+FULL_FSTYP_DETAILS=`_full_fstyp_details`
+FULL_HOST_DETAILS=`_full_platform_details`
+FULL_MKFS_OPTIONS=`_scratch_mkfs_options`
+FULL_MOUNT_OPTIONS=`_scratch_mount_options`
+
+cat <<EOF
+FSTYP         -- $FULL_FSTYP_DETAILS
+PLATFORM      -- $FULL_HOST_DETAILS
+MKFS_OPTIONS  -- $FULL_MKFS_OPTIONS
+MOUNT_OPTIONS -- $FULL_MOUNT_OPTIONS
+
+EOF
+
+umount $SCRATCH_DEV 2>/dev/null
+# call the overridden mkfs.xfs - make sure the FS is built
+# the same as we'll create it later.
+
+if ! _scratch_mkfs_xfs $flag >$tmp.err 2>&1
 then
-    echo "check: \$MKFS_OPTIONS specified -- \"$MKFS_OPTIONS\""
-    umount $SCRATCH_DEV 2>/dev/null
-    # call the overridden mkfs.xfs - make sure the FS is built
-    # the same as we'll create it later.
-    if ! mkfs_xfs -f $SCRATCH_DEV >$tmp.err 2>&1
-    then
-       echo "our local mkfs_xfs routine ..."
-       cat $tmp.err
-        echo "check: failed to mkfs.xfs \$SCRATCH_DEV using specified options"
-        exit 1
-    fi
+    echo "our local _scratch_mkfs_xfs routine ..."
+    cat $tmp.err
+    echo "check: failed to mkfs.xfs \$SCRATCH_DEV using specified options"
+    exit 1
 fi
 
-if [ ! -z "$MOUNT_OPTIONS" ]
+# call the overridden mount - make sure the FS mounts with
+# the same options that we'll mount with later.
+if ! _scratch_mount >$tmp.err 2>&1
 then
-    echo "check: \$MOUNT_OPTIONS specified -- \"$MOUNT_OPTIONS\""
-    umount $TEST_DEV
-    # call the overridden mount - make sure the FS starts as
-    # the same as we'll set it later.
-    if ! mount -t xfs $TEST_DEV $TEST_DIR >$tmp.err 2>&1
-    then
-       echo "our local mount routine ..."
-       cat $tmp.err
-        # call the normal mount
-       echo "normal mount ..."
-        /bin/mount -t xfs $TEST_DEV $TEST_DIR
-        echo "check: failed to mount \$TEST_DEV using specified mount options"
-        exit 1
-    fi
+    echo "our local mount routine ..."
+    cat $tmp.err
+    echo "check: failed to mount \$SCRATCH_DEV using specified options"
+    exit 1
 fi
 
 seq="check"
-_check_fs $TEST_DEV
+_check_test_fs
 
 for seq in $list
 do
@@ -208,7 +217,11 @@ do
        #
        rm -f $seq.out.bad
        lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time`
-       [ "X$lasttime" != X ] && echo -n " ${lasttime}s ..."
+       if [ "X$lasttime" != X ]; then
+               echo -n " ${lasttime}s ..."
+       else
+               echo -n "       "       # prettier output with timestamps.
+       fi
        rm -f core $seq.notrun
 
        # for hangcheck ...
@@ -217,8 +230,10 @@ do
        start=`_wallclock`
        $timestamp && echo -n " ["`date "+%T"`"]"
        sh $seq >$tmp.rawout 2>&1
+       [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
+       ./$seq >$tmp.rawout 2>&1
        sts=$?
-       $timestamp && echo -n " ["`date "+%T"`"]"
+       $timestamp && _timestamp
        stop=`_wallclock`
 
        _fix_malloc <$tmp.rawout >$tmp.out
@@ -233,7 +248,8 @@ do
 
        if [ -f $seq.notrun ]
        then
-           echo -n " [not run] "
+           $timestamp || echo -n " [not run] "
+           $timestamp && echo " [not run]" && echo -n "        $seq -- "
            cat $seq.notrun
            notrun="$notrun $seq"
        else
@@ -278,8 +294,7 @@ do
     [ -f $seq.notrun ] || try=`expr $try + 1`
     
     seq="after_$seq"
-    _check_fs $TEST_DEV
-    
+    _check_test_fs
 done
 
 interrupt=false