PR lib/52101

Add 6 extra tests for the 12am/12pm bug - all currently expected to fail.
(That is, 6 subtests of the "times" test will fail, all new ones)>

While here, when parsedate() fails (returns -1) avoid converting that
failure value (-1) to a struct tm (1969-12-31T23:59:59 UTC) and then
comparing the values with those expected by the test, and complaining
about all of those (where ANY was not permitted) that don't match...
This commit is contained in:
kre 2017-03-21 20:06:27 +00:00
parent 4f3a1f302d
commit 0c8a4b80f9
1 changed files with 25 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_parsedate.c,v 1.25 2016/06/22 15:01:38 kre Exp $ */
/* $NetBSD: t_parsedate.c,v 1.26 2017/03/21 20:06:27 kre Exp $ */
/*-
* Copyright (c) 2010, 2015 The NetBSD Foundation, Inc.
* All rights reserved.
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_parsedate.c,v 1.25 2016/06/22 15:01:38 kre Exp $");
__RCSID("$NetBSD: t_parsedate.c,v 1.26 2017/03/21 20:06:27 kre Exp $");
#include <atf-c.h>
#include <errno.h>
@ -84,6 +84,9 @@ parsecheck(const char *datestr, const time_t *reftime, const int *zoff,
ATF_CHECK_MSG((t = parsedate(datestr, reftime, zoff)) != -1,
"parsedate(%s) returned -1\n", argstr);
if (t == -1)
return;
ATF_CHECK(time_to_tm(&t, &tm) != NULL);
if (year != ANY)
ATF_CHECK_MSG(tm.tm_year + 1900 == year,
@ -180,6 +183,26 @@ ATF_TC_BODY(times, tc)
ANY, ANY, ANY, 0, 0, 0);
parsecheck("noon", NULL, NULL, localtime_r,
ANY, ANY, ANY, 12, 0, 0);
atf_tc_expect_fail("PR lib/52101");
parsecheck("12:30 am", NULL, NULL, localtime_r,
ANY, ANY, ANY, 0, 30, 0);
parsecheck("12:30 pm", NULL, NULL, localtime_r,
ANY, ANY, ANY, 12, 20, 0);
/*
* Technically, these are invalid, noon and midnight
* are neither am, nor pm, but this is what people expect...
*/
parsecheck("12:00:00 am", NULL, NULL, localtime_r,
ANY, ANY, ANY, 0, 0, 0);
parsecheck("12:00:00 pm", NULL, NULL, localtime_r,
ANY, ANY, ANY, 12, 0, 0);
parsecheck("12am", NULL, NULL, localtime_r,
ANY, ANY, ANY, 0, 0, 0);
parsecheck("12pm", NULL, NULL, localtime_r,
ANY, ANY, ANY, 12, 0, 0);
}
ATF_TC(dsttimes);