765e33d5617ec245370a00919a4b692518bd9290
[debian/gzip] / tests / timestamp
1 #!/bin/sh
2 # Exercise timestamps.
3
4 # Copyright 2016 Free Software Foundation, Inc.
5
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 # limit so don't run it by default.
19
20 . "${srcdir=.}/init.sh"; path_prepend_ ..
21
22 TZ=UTC0
23 export TZ
24
25 # On platforms supporting time stamps outside gzip's range,
26 # test that gzip warns when converting them to gzip format.
27 for time in 190101010000 196912312359.59 197001010000 210602070628.16; do
28   if touch -t $time in; then
29      returns_ 2 gzip in || fail=1
30   fi
31   rm -f in.gz in
32 done
33
34 # Test that time stamps in range for gzip do not generate warnings.
35 for time in 197001010000.01 203801190314.07 203801190314.08 210602070628.15; do
36   if touch -t $time in; then
37      gzip in || fail=1
38   fi
39   rm -f in.gz in
40 done
41
42 # On platforms that fail to support time stamps within gzip's range,
43 # test that gzip warns when converting them from gzip format.
44 touch -t 210602070628.15 in || {
45   printf '\037\213\10\0\377\377\377\377\0\377\3\0\0\0\0\0\0\0\0\0' >y2106.gz ||
46     framework_failure_
47   returns_ 2 gzip -Nlv <y2106.gz || fail=1
48 }
49
50 # Ensure that --no-name does not provoke a time stamp warning.
51 : | gzip --no-name > k || fail=1
52
53 Exit $fail