Module Name:    src
Committed By:   kre
Date:           Tue Mar 21 20:06:27 UTC 2017

Modified Files:
        src/tests/lib/libutil: t_parsedate.c

Log Message:
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...


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/tests/lib/libutil/t_parsedate.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libutil/t_parsedate.c
diff -u src/tests/lib/libutil/t_parsedate.c:1.25 src/tests/lib/libutil/t_parsedate.c:1.26
--- src/tests/lib/libutil/t_parsedate.c:1.25	Wed Jun 22 15:01:38 2016
+++ src/tests/lib/libutil/t_parsedate.c	Tue Mar 21 20:06:27 2017
@@ -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 ti
 
 	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);

Reply via email to