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)
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?
24 # Is not a leap year - should be invalid.
27 # Make sure get_date does not "roll" date forward to January 9th. Some
28 # versions have been known to do this.
31 # This is my birthday. :)
38 # This will be my 40th birthday. Ouch. :)
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.
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.
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
94 .
/getdate
>getdate-got
<<EOF
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
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
126 rm getdate-expected getdate-got getdate.
cmp