]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/regression/bin/date/regress.sh
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / regression / bin / date / regress.sh
1 #!/bin/sh
2
3 #
4 # Regression tests for date(1)
5 #
6 # Submitted by Edwin Groothuis <edwin@FreeBSD.org>
7 #
8 # $FreeBSD$
9 #
10
11 #
12 # These two date/times have been chosen carefully, they
13 # create both the single digit and double/multidigit version of
14 # the values.
15 #
16 # To create a new one, make sure you are using the UTC timezone!
17 #
18
19 TEST1=3222243           # 1970-02-07 07:04:03
20 TEST2=1005600000        # 2001-11-12 21:11:12
21
22 export LC_ALL=C
23 export TZ=UTC
24 count=0
25
26 check()
27 {
28         S=$1
29         A1=$2
30         A2=$3
31
32         count=`expr ${count} + 1`
33
34         if [ -z "${A2}" ]; then A2=${A1}; fi
35
36         R=`date -r ${TEST1} +%${S}`
37         if [ "${R}" = "${A1}" ]; then
38                 echo "ok ${S}{t1}"
39         else
40                 echo "no ok ${S}{t1} - (got ${R}, expected ${A1})"
41         fi
42
43         R=`date -r ${TEST2} +%${S}`
44         if [ "${R}" = "${A2}" ]; then
45                 echo "ok ${S}{t2}"
46         else
47                 echo "no ok ${S}{t2} - (got ${R}, expected ${A2})"
48         fi
49 }
50
51 echo "1..78"
52
53 check A Saturday Monday
54 check a Sat Mon
55 check B February November
56 check b Feb Nov
57 check C 19 20
58 check c "Sat Feb  7 07:04:03 1970" "Mon Nov 12 21:20:00 2001"
59 check D 02/07/70 11/12/01
60 check d 07 12
61 check e " 7" 12
62 check F "1970-02-07" "2001-11-12"
63 check G 1970 2001
64 check g 70 01
65 check H 07 21
66 check h Feb Nov
67 check I 07 09
68 check j 038 316
69 check k " 7" 21
70 check l " 7" " 9"
71 check M 04 20
72 check m 02 11
73 check p AM PM
74 check R 07:04 21:20
75 check r "07:04:03 AM" "09:20:00 PM"
76 check S 03 00
77 check s ${TEST1} ${TEST2}
78 check U 05 45
79 check u 6 1
80 check V 06 46
81 check v " 7-Feb-1970" "12-Nov-2001"
82 check W 05 46
83 check w 6 1
84 check X "07:04:03" "21:20:00"
85 check x "02/07/70" "11/12/01"
86 check Y 1970 2001
87 check y 70 01
88 check Z UTC UTC
89 check z +0000 +0000
90 check % % %
91 check + "Sat Feb  7 07:04:03 UTC 1970" "Mon Nov 12 21:20:00 UTC 2001"