turns printfs back on
[freebsd-src/fkvm-freebsd.git] / contrib / cvs / lib / test-getdate.sh
blob5b1db24edc6533ebddf691a3c4d3b9daf7866603
1 #! /bin/sh
3 # Test that a getdate executable meets its specification.
5 # Copyright (C) 2004 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software Foundation,
19 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 # Why are these dates tested?
23 # February 29, 2003
24 # Is not a leap year - should be invalid.
26 # 2004-12-40
27 # Make sure get_date does not "roll" date forward to January 9th. Some
28 # versions have been known to do this.
30 # Dec-5-1972
31 # This is my birthday. :)
33 # 3/29/1974
34 # 1996/05/12 13:57:45
35 # Because.
37 # 12-05-12
38 # This will be my 40th birthday. Ouch. :)
40 # 05/12/96
41 # Because.
43 # third tuesday in March, 2078
44 # Wanted this to work.
46 # 1969-12-32 2:00:00 UTC
47 # 1970-01-01 2:00:00 UTC
48 # 1969-12-32 2:00:00 +0400
49 # 1970-01-01 2:00:00 +0400
50 # 1969-12-32 2:00:00 -0400
51 # 1970-01-01 2:00:00 -0400
52 # Playing near the UNIX Epoch boundry condition to make sure date rolling
53 # is also disabled there.
55 # 1996-12-12 1 month
56 # Test a relative date.
58 # Tue Jan 19 03:14:07 2038 +0000
59 # For machines with 31-bit time_t, any date past this date will be an
60 # invalid date. So, any test date with a value greater than this
61 # time is not portable.
63 # Feb. 29, 2096 4 years
64 # 4 years from this date is _not_ a leap year, so Feb. 29th does not exist.
66 # Feb. 29, 2096 8 years
67 # 8 years from this date is a leap year, so Feb. 29th does exist,
68 # but on many hosts with 32-bit time_t types time, this test will
69 # fail. So, this is not a portable test.
72 TZ=UTC0; export TZ
74 cat >getdate-expected <<EOF
75 Enter date, or blank line to exit.
76 > Bad format - couldn't convert.
77 > Bad format - couldn't convert.
78 > Bad format - couldn't convert.
79 > Fri Mar 29 00:00:00 1974
80 > Sun May 12 13:57:45 1996
81 > Sat May 12 00:00:00 2012
82 > Sun May 12 00:00:00 1996
83 > Bad format - couldn't convert.
84 > Bad format - couldn't convert.
85 > Thu Jan 1 02:00:00 1970
86 > Bad format - couldn't convert.
87 > Bad format - couldn't convert.
88 > Bad format - couldn't convert.
89 > Thu Jan 1 06:00:00 1970
90 > Sun Jan 12 00:00:00 1997
92 EOF
94 ./getdate >getdate-got <<EOF
95 February 29, 2003
96 2004-12-40
97 Dec-5-1972
98 3/29/1974
99 1996/05/12 13:57:45
100 12-05-12
101 05/12/96
102 third tuesday in March, 2078
103 1969-12-32 2:00:00 UTC
104 1970-01-01 2:00:00 UTC
105 1969-12-32 2:00:00 +0400
106 1970-01-01 2:00:00 +0400
107 1969-12-32 2:00:00 -0400
108 1970-01-01 2:00:00 -0400
109 1996-12-12 1 month
112 echo >>getdate-got
114 if cmp getdate-expected getdate-got >getdate.cmp; then :; else
115 LOGFILE=`pwd`/getdate.log
116 cat getdate.cmp >${LOGFILE}
117 echo "** expected: " >>${LOGFILE}
118 cat getdate-expected >>${LOGFILE}
119 echo "** got: " >>${LOGFILE}
120 cat getdate-got >>${LOGFILE}
121 echo "FAIL: getdate" | tee -a ${LOGFILE}
122 echo "Failed! See ${LOGFILE} for more!" >&2
123 exit 1
126 rm getdate-expected getdate-got getdate.cmp
127 exit 0