1# Test time stamps for GNU tar. -*- Autotest -*- 2# 3# Copyright 2012-2021 Free Software Foundation, Inc. 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 3, or (at your option) 8# any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18# written by Paul Eggert 19 20AT_SETUP([time: tricky time stamps]) 21AT_KEYWORDS([time time01]) 22 23AT_TAR_CHECK([ 24export TZ=UTC0 25mkdir dir 26 27# Test files with time stamps that are near common sources of error, 28# typically near powers of 2 (for seconds) or near 0, 1970, or 9999 (years). 29# Use GNU-style @ notation for very large time stamps, since they 30# typically don't render into years correctly due to int overflow. 31for s in \ 32 @-9223372036854775809 @-9223372036854775808 @-9223372036854775807 \ 33 0000-01-01T00:00:00 0000-01-01T00:00:01 \ 34 0000-01-02T00:00:00 \ 35 1697-10-17T11:03:27 1697-10-17T11:03:28 1697-10-17T11:03:29 \ 36 1833-11-24T17:31:43 1833-11-24T17:31:44 1833-11-24T17:31:45 \ 37 1901-12-13T20:45:51 1901-12-13T20:45:52 1901-12-13T20:45:53 \ 38 1901-12-14T20:45:51 \ 39 1969-12-31T23:59:58 1969-12-31T23:59:59 \ 40 1970-01-01T00:00:00 1970-01-01T00:00:01 \ 41 2038-01-18T03:14:07 \ 42 2038-01-19T03:14:07 2038-01-19T03:14:08 \ 43 2106-02-07T06:28:15 2106-02-07T06:28:16 \ 44 2242-03-16T12:56:31 2242-03-16T12:56:32 \ 45 9999-12-31T23:59:58 9999-12-31T23:59:59 \ 46 @9223372036854775807 @9223372036854775808 47do 48 # Skip a time stamp $s if it's out of range for this platform, 49 # of if it uses a notation that this platform does not recognize. 50 touch -d $s dir/f$s >/dev/null 2>&1 || continue 51 52 # Likewise for $s.1. If $s is the most negative time stamp and 53 # time stamps are signed, then $s.1 is out of range. 54 touch -d $s.1 dir/f$s.$ns >/dev/null 2>&1 || continue 55 56 for frac in 01 001 00001 000001 0000001 00000001 000000001 0000000001 \ 57 9 99 999 99999 999999 9999999 99999999 999999999 9999999999 58 do 59 touch -d $s.$frac dir/f$s.$frac 60 done 61done 62 63tar -c -f archive.tar dir 64tar -d -f archive.tar dir 65], 66[0], 67[], [], [], [], 68[pax]) 69 70AT_CLEANUP 71