Print this page
11919 date_test needs to set LC_TIME
Reviewed by: Paul Winder <paul@winders.demon.co.uk>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/test/util-tests/tests/date/date_test.ksh
+++ new/usr/src/test/util-tests/tests/date/date_test.ksh
1 1 #!/bin/ksh
2 2 #
3 3 # This file and its contents are supplied under the terms of the
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
4 4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 5 # You may only use this file in accordance with the terms of version
6 6 # 1.0 of the CDDL.
7 7 #
8 8 # A full copy of the text of the CDDL should have accompanied this
9 9 # source. A copy of the CDDL is also available via the Internet at
10 10 # http://www.illumos.org/license/CDDL.
11 11 #
12 12
13 13 #
14 -# Copyright (c) 2017, Joyent, Inc.
14 +# Copyright 2019 Joyent, Inc.
15 15 #
16 16
17 17 #
18 18 # Basic tests of date -r.
19 19 #
20 20
21 -#
22 -# Make sure that we're executing in the C locale and that a given user's
23 -# locale doesn't impact this test.
24 -#
25 -export LANG=C
21 +export LC_ALL=C
26 22
27 23 date_arg0="$(basename $0)"
28 24 date_prog=/usr/bin/date
29 25 date_curcmd=
30 26
31 27 fatal()
32 28 {
33 29 typeset msg="$*"
34 30 [[ -z "$msg" ]] && msg="failed"
35 31 echo "TEST FAILED: $date_arg0: $msg" >&2
36 32 exit 1
37 33 }
38 34
39 35 compare()
40 36 {
41 37 typeset time=$1
42 38 typeset exp=$2
43 39 typeset tz=$3
44 40 typeset val ret
45 41
46 42 date_curcmd="TZ=$3 $date_prog -r $1"
47 43 val=$(TZ=$3 $date_prog -r $1)
48 44 ret=$?
49 45 if [[ $ret -ne 0 ]]; then
50 46 fatal "date not exit zero, exited $ret; command: $date_curcmd"
51 47 fi
52 48 if [[ -z "$val" ]]; then
53 49 fatal "date returned no output; command: $date_curcmd"
54 50 fi
55 51
56 52 if [[ "$val" != "$exp" ]]; then
57 53 fatal "date output mismatch; command: $date_curcmd; expected: " \
58 54 "$exp; found: $val"
59 55 fi
60 56 }
61 57
62 58 if [[ -n $DATE ]]; then
63 59 date_prog=$DATE
64 60 fi
65 61
66 62 #
67 63 # date -r supports base 10, hex, and octal
68 64 #
69 65 compare 0 "Thu Jan 1 00:00:00 UTC 1970" UTC
70 66 compare 0 "Wed Dec 31 16:00:00 PST 1969" US/Pacific
71 67 compare 0 "Thu Jan 1 09:00:00 JST 1970" Japan
72 68 compare 1234567890 "Fri Feb 13 23:31:30 UTC 2009" UTC
73 69 compare -1234567890 "Tue Nov 18 00:28:30 UTC 1930" UTC
74 70 compare 2147483647 "Tue Jan 19 03:14:07 UTC 2038" UTC
75 71 compare -2147483647 "Fri Dec 13 20:45:53 UTC 1901" UTC
76 72 compare 558028800 "Mon Sep 7 16:00:00 UTC 1987" UTC
77 73 compare 0x2142d800 "Mon Sep 7 16:00:00 UTC 1987" UTC
78 74 compare 04120554000 "Mon Sep 7 16:00:00 UTC 1987" UTC
79 75
80 76 #
81 77 # Test the file related logic
82 78 #
83 79 env TZ=UTC touch -t 201712042323.23 $TMPDIR/test.$$
84 80 compare "$TMPDIR/test.$$" "Mon Dec 4 23:23:23 UTC 2017" UTC
85 81 rm -f $TMPDIR/test.$$
86 82
87 83 #
88 84 # date -r should not work with -a
89 85 #
90 86 if $date_prog -r 0 -a 10 2>/dev/null; then
91 87 fatal "date -r 0 -a 10 exited zero when it should have failed"
92 88 fi
93 89
94 90 #
95 91 # date -r and -R or -u should work together
96 92 #
97 93 compare "0 -R" "Thu, 01 Jan 1970 02:00:00 +0200" Africa/Cairo
98 94 compare "0 -u" "Thu Jan 1 00:00:00 GMT 1970" Europe/Rome
99 95
100 96 echo "TEST PASSED: $date_arg0"
↓ open down ↓ |
65 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX