generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[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 _supported_os Linux
32 _require_test
33 _require_negative_timestamps
34
35 TESTFILE=$TEST_DIR/timestamp-test.txt
36
37 # Create a file with a timestamp prior to the epoch
38 echo "Creating file with timestamp of Jan 1, 1960"
39 touch -t 196001010101 $TESTFILE
40 # Should yield -315593940 (prior to epoch)
41 echo "Testing for negative seconds since epoch"
42 ts=`stat -c %X $TESTFILE`
43 if [ "$ts" -ge 0 ]; then
44         echo "Timestamp wrapped: $ts"
45         _fail "Timestamp wrapped"
46 fi
47
48 # unmount, remount, and check the timestamp
49 echo "Remounting to flush cache"
50 _test_cycle_mount
51
52 # Should yield -315593940 (prior to epoch)
53 echo "Testing for negative seconds since epoch"
54 ts=`stat -c %X $TESTFILE`
55 if [ "$ts" -ge 0 ]; then
56         echo "Timestamp wrapped: $ts"
57         _fail "Timestamp wrapped"
58 fi
59
60 status=0 ; exit