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
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2011 Red Hat, Inc. All Rights Reserved.
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.
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.
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
24 #-----------------------------------------------------------------------
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
39 trap "_cleanup ; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
44 # real QA test starts here
48 TESTFILE=$TEST_DIR/timestamp-test.txt
50 # Create a file with a timestamp prior to the epoch
51 echo "Creating file with timestamp of Jan 1, 1960"
52 touch -t 196001010101 $TESTFILE
53 # Should yield -315593940 (prior to epoch)
54 echo "Testing for negative seconds since epoch"
55 ts=`stat -c %X $TESTFILE`
56 if [ "$ts" -ge 0 ]; then
57 echo "Timestamp wrapped: $ts"
58 _fail "Timestamp wrapped"
61 # unmount, remount, and check the timestamp
62 echo "Remounting to flush cache"
64 mount $TEST_DEV $TEST_DIR
66 # Should yield -315593940 (prior to epoch)
67 echo "Testing for negative seconds since epoch"
68 ts=`stat -c %X $TESTFILE`
69 if [ "$ts" -ge 0 ]; then
70 echo "Timestamp wrapped: $ts"
71 _fail "Timestamp wrapped"