Skip to contentSkip to conversation

xfstests: make 258 more forgiving of timestamp rounding

PATCH In review Eric Sandeen 3 participants 3 messages Oct 3, 2011 – Oct 6, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests: make 258 more forgiving of timestamp rounding

Rather than testing for an exact timestamp, which could vary due to rounding, just check that it is not positive, which is the failure case we're looking for.

---

258 +13 -4
index 6fadca0..ad73494 100644
@@ -53,8 +53,12 @@ TESTFILE=$TEST_DIR/timestamp-test.txt
 echo "Creating file with timestamp of Jan 1, 1960"
 touch -t 196001010101 $TESTFILE
 # Should yield -315593940 (prior to epoch)
-echo -n "Stat of file yields: "
-stat -c %X $TESTFILE
+echo "Testing for negative seconds since epoch"
+ts=`stat -c %X $TESTFILE`
+if [ "$ts" -ge 0 ]; then
+	echo "Timestamp wrapped: $ts"
+	_fail "Timestamp wrapped"
+fi
 
 # unmount, remount, and check the timestamp
 echo "Remounting to flush cache"
@@ -62,7 +66,12 @@ umount $TEST_DEV
 mount $TEST_DEV $TEST_DIR
 
 # Should yield -315593940 (prior to epoch)
-echo -n "Stat of file yields: "
-stat -c %X $TESTFILE
+echo "Testing for negative seconds since epoch"
+ts=`stat -c %X $TESTFILE`
+if [ "$ts" -ge 0 ]; then
+	echo "Timestamp wrapped: $ts"
+	_fail "Timestamp wrapped"
+fi
 
 status=0 ; exit
+
258.out +2 -2
index 11b9168..87fae0f 100644
@@ -1,5 +1,5 @@
 QA output created by 258
 Creating file with timestamp of Jan 1, 1960
-Stat of file yields: -315593940
+Testing for negative seconds since epoch
 Remounting to flush cache
-Stat of file yields: -315593940
+Testing for negative seconds since epoch

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Sandeen
Quoted 5 lines · Eric Sandeen

Rather than testing for an exact timestamp, which could vary due to rounding, just check that it is not positive, which is the failure case we're looking for.

Looks good,

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs