1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/bin/sh
: ${PERL=perl}
: ${srcdir=.}
$PERL -e 1 > /dev/null 2>&1 || {
echo 1>&2 "$0: configure didn't find a usable version of Perl," \
"so can't run this test"
exit 77
}
exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF
require 5.003;
use strict;
(my $ME = $0) =~ s|.*/||;
# Turn off localisation of executable's ouput.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
# Export TZ=UTC0 so that zone-dependent strings match.
$ENV{TZ} = 'UTC0';
my @Tests =
(
# This would infloop (or appear to) prior to coreutils-4.5.5,
# due to a bug in strftime.c.
['wide-fmt', "-d '1999-06-01'", '+%3004Y', {OUT=>'0' x 3000 . '1999'}],
# Ensure that we can parse MONTHNAME-DAY-YEAR.
['moname-d-y', '--iso -d May-23-2003', {OUT=>'2003-05-23'}],
['epoch', '--iso=sec -d @31536000',
{OUT=>'1971-01-01T00:00:00+0000'}],
['ns-10', '--iso=ns', '-d "1969-12-31 13:00:00.00000001-1100"',
{OUT=>'1970-01-01T00:00:00,000000010+0000'}],
['ns-max32', '--iso=ns', '-d "2038-01-19 03:14:07.999999999"',
{OUT=>'2038-01-19T03:14:07,999999999+0000'}],
['ns-relative',
'--iso=ns', "-d'1970-01-01 00:00:00.1234567 UTC +961062237.987654321 sec'",
{OUT=>'2000-06-15T09:43:58,111111021+0000'}],
# Since coreutils/lib/getdate.y revision 1.96 (post-coreutils-5.3.0),
# a command like the following would mistakenly exit nonzero with an
# `invalid date ...' diagnostic, but when run in a time zone for
# which daylight savings time is in effect for the starting date.
# Unfortunately (for ease of testing), if you set TZ at all, this
# failure is not triggered, hence the removal of TZ from the environment.
['cross-dst', "-d'2005-03-27 +1 day'", '+%Y', {OUT=>'2005'},
{PRE => sub {delete $ENV{TZ}}},
],
['empty-fmt', '+', {OUT=>''}],
);
# Repeat the cross-dst test, using Jan 1, 2005 and every interval from 1..364.
foreach my $i (1..364)
{
push @Tests, ["cross-dst$i",
"-d'2005-01-01 +$i day'", '+%Y', {OUT=>'2005'},
{PRE => sub {delete $ENV{TZ}}},
];
}
# Append "\n" to each OUT=> RHS.
foreach my $t (@Tests)
{
foreach my $e (@$t)
{
!ref $e || ref $e ne 'HASH'
and next;
defined $e->{OUT}
and $e->{OUT} .= "\n";
}
}
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
my $prog = 'date';
my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose);
exit $fail;
EOF
|