xfstests: resolve symlinked devices to real paths
[xfstests-dev.git] / 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 # creator
27 owner=sandeen@redhat.com
28
29 seq=`basename $0`
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35
36 _cleanup()
37 {
38     rm -f $tmp.*
39 }
40
41 trap "_cleanup ; exit \$status" 0 1 2 3 15
42
43 # get standard environment, filters and checks
44 . ./common.rc
45
46 # real QA test starts here
47 _supported_fs generic
48 _supported_os Linux
49
50 TESTFILE=$TEST_DIR/timestamp-test.txt
51
52 # Create a file with a timestamp prior to the epoch
53 echo "Creating file with timestamp of Jan 1, 1960"
54 touch -t 196001010101 $TESTFILE
55 # Should yield -315593940 (prior to epoch)
56 echo "Testing for negative seconds since epoch"
57 ts=`stat -c %X $TESTFILE`
58 if [ "$ts" -ge 0 ]; then
59         echo "Timestamp wrapped: $ts"
60         _fail "Timestamp wrapped"
61 fi
62
63 # unmount, remount, and check the timestamp
64 echo "Remounting to flush cache"
65 umount $TEST_DEV
66 mount $TEST_DEV $TEST_DIR
67
68 # Should yield -315593940 (prior to epoch)
69 echo "Testing for negative seconds since epoch"
70 ts=`stat -c %X $TESTFILE`
71 if [ "$ts" -ge 0 ]; then
72         echo "Timestamp wrapped: $ts"
73         _fail "Timestamp wrapped"
74 fi
75
76 status=0 ; exit