1#!/bin/sh 2# Test --time-style in programs like 'ls'. 3 4# Copyright (C) 2016-2023 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 <https://www.gnu.org/licenses/>. 18 19. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 20print_ver_ du 21print_ver_ ls 22print_ver_ pr 23 24echo hello >a || framework_failure_ 25 26# The tests assume this is an old timestamp in northern hemisphere summer. 27TZ=UTC0 touch -d '1970-07-08 09:10:11' a || framework_failure_ 28 29for 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 39done 40 41sed 's/[^ ]* //' duout >dued || framework_failure_ 42sed 's/[^ ]* *[^ ]* *[^ ]* *[^ ]* *//' lsout >lsed || framework_failure_ 43sed '/^$/d' prout >pred || framework_failure_ 44 45cat <<\EOF > duexp || framework_failure_ 461970-07-08 09:10:11.000000000 +0000 a 471970-07-08 09:10 a 481970-07-08 a 491970-07-08 09:10:11 +0000 (UTC) a 50%bJul%bJul a 511970-07-08 01:10:11.000000000 -0800 a 521970-07-08 01:10 a 531970-07-08 a 541970-07-08 01:10:11 -0800 (PST) a 55%bJul%bJul a 561970-07-08 02:10:11.000000000 -0700 a 571970-07-08 02:10 a 581970-07-08 a 591970-07-08 02:10:11 -0700 (PDT) a 60%bJul%bJul a 611970-07-08 21:40:11.000000000 +1230 a 621970-07-08 21:40 a 631970-07-08 a 641970-07-08 21:40:11 +1230 (XXXYYY) a 65%bJul%bJul a 66EOF 67 68cat <<\EOF > lsexp || framework_failure_ 691970-07-08 09:10:11.000000000 +0000 a 701970-07-08 09:10 a 711970-07-08 a 72Jul 8 1970 a 731970-07-08 09:10:11 +0000 (UTC) a 74%bJul%bJul a 751970-07-08 01:10:11.000000000 -0800 a 761970-07-08 01:10 a 771970-07-08 a 78Jul 8 1970 a 791970-07-08 01:10:11 -0800 (PST) a 80%bJul%bJul a 811970-07-08 02:10:11.000000000 -0700 a 821970-07-08 02:10 a 831970-07-08 a 84Jul 8 1970 a 851970-07-08 02:10:11 -0700 (PDT) a 86%bJul%bJul a 871970-07-08 21:40:11.000000000 +1230 a 881970-07-08 21:40 a 891970-07-08 a 90Jul 8 1970 a 911970-07-08 21:40:11 +1230 (XXXYYY) a 92%bJul%bJul a 93EOF 94 95cat <<\EOF > prexp || framework_failure_ 96+1970-07-08 09:10:11 +0000 (UTC) a Page 1 97hello 98+%bJul%bJul a Page 1 99hello 100+1970-07-08 01:10:11 -0800 (PST) a Page 1 101hello 102+%bJul%bJul a Page 1 103hello 104+1970-07-08 02:10:11 -0700 (PDT) a Page 1 105hello 106+%bJul%bJul a Page 1 107hello 108+1970-07-08 21:40:11 +1230 (XXXYYY) a Page 1 109hello 110+%bJul%bJul a Page 1 111hello 112EOF 113 114compare duexp dued || fail=1 115compare lsexp lsed || fail=1 116compare prexp pred || fail=1 117compare /dev/null err || fail=1 118 119Exit $fail 120