2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2011 Red Hat, Inc. All Rights Reserved.
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
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
24 trap "_cleanup ; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
29 # real QA test starts here
33 _require_negative_timestamps
35 TESTFILE=$TEST_DIR/timestamp-test.txt
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"
48 # unmount, remount, and check the timestamp
49 echo "Remounting to flush cache"
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"