generic/402: skip test if xfs_io can't parse the date value
[xfstests-dev.git] / tests / generic / 402
index 0392c2581ebda6c05058ee9ce869249730608df6..2481a5d246148946ce4db14f1b8f41ce00b09eb0 100755 (executable)
@@ -16,7 +16,13 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1       # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+}
 
 # Get standard environment, filters and checks.
 . ./common/rc
@@ -30,6 +36,7 @@ rm -f $seqres.full
 _supported_fs generic
 _supported_os Linux
 _require_scratch
+_require_check_dmesg
 _require_xfs_io_command utimes
 
 # Compare file timestamps obtained from stat
@@ -56,10 +63,26 @@ run_test_individual()
        # check if the time needs update
        if [ $update_time -eq 1 ]; then
                echo "Updating file: $file to timestamp $timestamp"  >> $seqres.full
-               $XFS_IO_PROG -f -c "utimes $timestamp 0 $timestamp 0" $file
-               if [ $? -ne 0 ]; then
+               rm -f $tmp.utimes
+               $XFS_IO_PROG -f -c "utimes $timestamp 0 $timestamp 0" $file > $tmp.utimes 2>&1
+               local res=$?
+
+               cat $tmp.utimes >> $seqres.full
+               if [ "$timestamp" -ne 0 ] && grep -q "Bad value" "$tmp.utimes"; then
+                       echo "xfs_io could not interpret time value \"$timestamp\", skipping \"$file\" test." >> $seqres.full
+                       rm -f $file $tmp.utimes
+                       return
+               fi
+               cat $tmp.utimes
+               rm -f $tmp.utimes
+               if [ $res -ne 0 ]; then
                        echo "Failed to update times on $file" | tee -a $seqres.full
                fi
+       else
+               if [ ! -f "$file" ]; then
+                       echo "xfs_io did not create file for time value \"$timestamp\", skipping test." >> $seqres.full
+                       return
+               fi
        fi
 
        tsclamp=$((timestamp<tsmin?tsmin:timestamp>tsmax?tsmax:timestamp))
@@ -80,6 +103,8 @@ run_test()
 }
 
 _scratch_mkfs &>> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount || _fail "scratch mount failed"
+
 _require_timestamp_range $SCRATCH_DEV
 
 read tsmin tsmax <<<$(_filesystem_timestamp_range $SCRATCH_DEV)
@@ -96,8 +121,6 @@ declare -a TIMESTAMPS=(
        $((tsmax+1))
 )
 
-_scratch_mount || _fail "scratch mount failed"
-
 status=0
 
 # Begin test case 1