xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / generic / 258
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2011 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 258
6 #
7 # Test timestamps prior to epoch
8 # On 64-bit, ext2/3/4 was sign-extending when read from disk
9 # See also commit 4d7bf11d649c72621ca31b8ea12b9c94af380e63
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18
19 _cleanup()
20 {
21     rm -f $tmp.*
22 }
23
24 trap "_cleanup ; exit \$status" 0 1 2 3 15
25
26 # get standard environment, filters and checks
27 . ./common/rc
28
29 # real QA test starts here
30 _supported_fs generic
31 _require_test
32 _require_negative_timestamps
33
34 TESTFILE=$TEST_DIR/timestamp-test.txt
35
36 # Create a file with a timestamp prior to the epoch
37 echo "Creating file with timestamp of Jan 1, 1960"
38 touch -t 196001010101 $TESTFILE
39 # Should yield -315593940 (prior to epoch)
40 echo "Testing for negative seconds since epoch"
41 ts=`stat -c %X $TESTFILE`
42 if [ "$ts" -ge 0 ]; then
43         echo "Timestamp wrapped: $ts"
44         _fail "Timestamp wrapped"
45 fi
46
47 # unmount, remount, and check the timestamp
48 echo "Remounting to flush cache"
49 _test_cycle_mount
50
51 # Should yield -315593940 (prior to epoch)
52 echo "Testing for negative seconds since epoch"
53 ts=`stat -c %X $TESTFILE`
54 if [ "$ts" -ge 0 ]; then
55         echo "Timestamp wrapped: $ts"
56         _fail "Timestamp wrapped"
57 fi
58
59 status=0 ; exit