xfstests: cleanup duplicates in all tests
[xfstests-dev.git] / tests / generic / 258
1 #! /bin/bash
2 # FS QA Test No. 258
3 #
4 # Test timestamps prior to epoch
5 # On 64-bit, ext2/3/4 was sign-extending when read from disk
6 # See also commit 4d7bf11d649c72621ca31b8ea12b9c94af380e63
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2011 Red Hat, Inc.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34
35 _cleanup()
36 {
37     rm -f $tmp.*
38 }
39
40 trap "_cleanup ; exit \$status" 0 1 2 3 15
41
42 # get standard environment, filters and checks
43 . ./common/rc
44
45 # real QA test starts here
46 _supported_fs generic
47 _supported_os Linux
48
49 TESTFILE=$TEST_DIR/timestamp-test.txt
50
51 # Create a file with a timestamp prior to the epoch
52 echo "Creating file with timestamp of Jan 1, 1960"
53 touch -t 196001010101 $TESTFILE
54 # Should yield -315593940 (prior to epoch)
55 echo "Testing for negative seconds since epoch"
56 ts=`stat -c %X $TESTFILE`
57 if [ "$ts" -ge 0 ]; then
58         echo "Timestamp wrapped: $ts"
59         _fail "Timestamp wrapped"
60 fi
61
62 # unmount, remount, and check the timestamp
63 echo "Remounting to flush cache"
64 umount $TEST_DEV
65 mount $TEST_DEV $TEST_DIR
66
67 # Should yield -315593940 (prior to epoch)
68 echo "Testing for negative seconds since epoch"
69 ts=`stat -c %X $TESTFILE`
70 if [ "$ts" -ge 0 ]; then
71         echo "Timestamp wrapped: $ts"
72         _fail "Timestamp wrapped"
73 fi
74
75 status=0 ; exit