gzip --no-name: avoid spurious warning
[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      gzip in
30      test $? = 2 || fail=1
31   fi
32   rm -f in.gz in
33 done
34
35 # Test that time stamps in range for gzip do not generate warnings.
36 for time in 197001010000.01 203801190314.07 203801190314.08 210602070628.15; do
37   if touch -t $time in; then
38      gzip in || fail=1
39   fi
40   rm -f in.gz in
41 done
42
43 # On platforms that fail to support time stamps within gzip's range,
44 # test that gzip warns when converting them from gzip format.
45 touch -t 210602070628.15 in || {
46   printf '\037\213\10\0\377\377\377\377\0\377\3\0\0\0\0\0\0\0\0\0' >y2106.gz ||
47     framework_failure_
48   gzip -Nlv <y2106.gz
49   test $? = 2 || fail=1
50 }
51
52 # Ensure that --no-name does not provoke a time stamp warning.
53 : | gzip --no-name > k || fail=1
54
55 Exit $fail