tests: add test for locale decimal processing
[coreutils.git] / tests / misc / time-style.sh
blob1cc8e2d641f07eba4bdad44fd9ab67279ae91546
1 #!/bin/sh
2 # Test --time-style in programs like 'ls'.
4 # Copyright (C) 2016-2019 Free Software Foundation, Inc.
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.
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.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ du
21 print_ver_ ls
22 print_ver_ pr
24 echo hello >a || framework_failure_
26 # The tests assume this is an old timestamp in northern hemisphere summer.
27 TZ=UTC0 touch -d '1970-07-08 09:10:11' a || framework_failure_
29 for tz in UTC0 PST8 PST8PDT,M3.2.0,M11.1.0 XXXYYY-12:30; do
30 for style in full-iso long-iso iso locale '+%Y-%m-%d %H:%M:%S %z (%Z)' \
31 +%%b%b%%b%b; do
32 test "$style" = locale ||
33 TZ=$tz LC_ALL=C du --time --time-style="$style" a >>duout 2>>err || fail=1
34 TZ=$tz LC_ALL=C ls -no --time-style="$style" a >>lsout 2>>err || fail=1
35 case $style in
36 (+*) TZ=$tz LC_ALL=C pr -D"$style" a >>prout 2>>err || fail=1 ;;
37 esac
38 done
39 done
41 sed 's/[^ ]* //' duout >dued || framework_failure_
42 sed 's/[^ ]* *[^ ]* *[^ ]* *[^ ]* *//' lsout >lsed || framework_failure_
43 sed '/^$/d' prout >pred || framework_failure_
45 cat <<\EOF > duexp || framework_failure_
46 1970-07-08 09:10:11.000000000 +0000 a
47 1970-07-08 09:10 a
48 1970-07-08 a
49 1970-07-08 09:10:11 +0000 (UTC) a
50 %bJul%bJul a
51 1970-07-08 01:10:11.000000000 -0800 a
52 1970-07-08 01:10 a
53 1970-07-08 a
54 1970-07-08 01:10:11 -0800 (PST) a
55 %bJul%bJul a
56 1970-07-08 02:10:11.000000000 -0700 a
57 1970-07-08 02:10 a
58 1970-07-08 a
59 1970-07-08 02:10:11 -0700 (PDT) a
60 %bJul%bJul a
61 1970-07-08 21:40:11.000000000 +1230 a
62 1970-07-08 21:40 a
63 1970-07-08 a
64 1970-07-08 21:40:11 +1230 (XXXYYY) a
65 %bJul%bJul a
66 EOF
68 cat <<\EOF > lsexp || framework_failure_
69 1970-07-08 09:10:11.000000000 +0000 a
70 1970-07-08 09:10 a
71 1970-07-08 a
72 Jul 8 1970 a
73 1970-07-08 09:10:11 +0000 (UTC) a
74 %bJul%bJul a
75 1970-07-08 01:10:11.000000000 -0800 a
76 1970-07-08 01:10 a
77 1970-07-08 a
78 Jul 8 1970 a
79 1970-07-08 01:10:11 -0800 (PST) a
80 %bJul%bJul a
81 1970-07-08 02:10:11.000000000 -0700 a
82 1970-07-08 02:10 a
83 1970-07-08 a
84 Jul 8 1970 a
85 1970-07-08 02:10:11 -0700 (PDT) a
86 %bJul%bJul a
87 1970-07-08 21:40:11.000000000 +1230 a
88 1970-07-08 21:40 a
89 1970-07-08 a
90 Jul 8 1970 a
91 1970-07-08 21:40:11 +1230 (XXXYYY) a
92 %bJul%bJul a
93 EOF
95 cat <<\EOF > prexp || framework_failure_
96 +1970-07-08 09:10:11 +0000 (UTC) a Page 1
97 hello
98 +%bJul%bJul a Page 1
99 hello
100 +1970-07-08 01:10:11 -0800 (PST) a Page 1
101 hello
102 +%bJul%bJul a Page 1
103 hello
104 +1970-07-08 02:10:11 -0700 (PDT) a Page 1
105 hello
106 +%bJul%bJul a Page 1
107 hello
108 +1970-07-08 21:40:11 +1230 (XXXYYY) a Page 1
109 hello
110 +%bJul%bJul a Page 1
111 hello
114 compare duexp dued || fail=1
115 compare lsexp lsed || fail=1
116 compare prexp pred || fail=1
117 compare /dev/null err || fail=1
119 Exit $fail