aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Pankov <yuripv@FreeBSD.org>2018-10-30 02:37:23 +0000
committerYuri Pankov <yuripv@FreeBSD.org>2018-10-30 02:37:23 +0000
commit281c29899f18d98535ae1e691b24fd5581f2e60b (patch)
treeb8e8db66608b982cef3da9072511cc259f4f25af
parenta37c714a0fc5dd681b02e852fe431ff56b34c626 (diff)
downloadsrc-281c29899f18d98535ae1e691b24fd5581f2e60b.tar.gz
src-281c29899f18d98535ae1e691b24fd5581f2e60b.zip
Connect libc/tests/time to the build, adding test cases for strptime()
issues fixed recently, and disabling the failing ones (mostly due to TZ parsing differences with NetBSD). Reviewed by: ngie Approved by: kib (mentor) Differential Revision: https://reviews.freebsd.org/D17546
Notes
Notes: svn path=/head/; revision=339904
-rw-r--r--contrib/netbsd-tests/lib/libc/time/t_mktime.c3
-rw-r--r--contrib/netbsd-tests/lib/libc/time/t_strptime.c37
-rw-r--r--lib/libc/tests/Makefile1
3 files changed, 36 insertions, 5 deletions
diff --git a/contrib/netbsd-tests/lib/libc/time/t_mktime.c b/contrib/netbsd-tests/lib/libc/time/t_mktime.c
index 8092361dbc36..1080b77eda80 100644
--- a/contrib/netbsd-tests/lib/libc/time/t_mktime.c
+++ b/contrib/netbsd-tests/lib/libc/time/t_mktime.c
@@ -64,6 +64,9 @@ ATF_TC_HEAD(mktime_negyear, tc)
ATF_TC_BODY(mktime_negyear, tc)
{
+#ifdef __FreeBSD__
+ atf_tc_expect_fail("needs work");
+#endif
struct tm tms;
time_t t;
diff --git a/contrib/netbsd-tests/lib/libc/time/t_strptime.c b/contrib/netbsd-tests/lib/libc/time/t_strptime.c
index 863df36e5969..00158a15512d 100644
--- a/contrib/netbsd-tests/lib/libc/time/t_strptime.c
+++ b/contrib/netbsd-tests/lib/libc/time/t_strptime.c
@@ -103,6 +103,7 @@ static struct {
const char *name;
long offs;
} zt[] = {
+#ifndef __FreeBSD__
{ "Z", 0 },
{ "UT", 0 },
{ "UTC", 0 },
@@ -173,6 +174,7 @@ static struct {
{ "EST4EDT", -14400 },
{ "Bogus", -1 },
+#endif
};
static void
@@ -188,9 +190,11 @@ ztest1(const char *name, const char *fmt, long value)
value = 0;
switch (value) {
+#ifndef __FreeBSD__
case -2:
value = -timezone;
break;
+#endif
case -1:
if (fmt[1] == 'Z')
value = 0;
@@ -210,9 +214,11 @@ static void
ztest(const char *fmt)
{
setenv("TZ", "US/Eastern", 1);
+#ifndef __FreeBSD__
ztest1("GMT", fmt, 0);
ztest1("UTC", fmt, 0);
ztest1("US/Eastern", fmt, -18000);
+#endif
for (size_t i = 0; i < __arraycount(zt); i++)
ztest1(zt[i].name, fmt, zt[i].offs);
}
@@ -228,10 +234,6 @@ ATF_TC_HEAD(common, tc)
ATF_TC_BODY(common, tc)
{
-#ifdef __FreeBSD__
- atf_tc_expect_fail("There are various issues with strptime on FreeBSD");
-#endif
-
h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %T %Y",
24, 46, 27, 23, 20, 0, 98, 2, 19);
h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %H:%M:%S %Y",
@@ -305,6 +307,10 @@ ATF_TC_BODY(day, tc)
#else
h_pass("SaturDay", "%OA", 8, -1, -1, -1, -1, -1, -1, 6, -1);
#endif
+
+#ifdef __FreeBSD__
+ h_fail("00", "%d");
+#endif
}
ATF_TC(hour);
@@ -313,7 +319,11 @@ ATF_TC_HEAD(hour, tc)
{
atf_tc_set_md_var(tc, "descr",
+#ifdef __FreeBSD__
+ "Checks strptime(3) hour conversions [HIkl]");
+#else
"Checks strptime(3) hour conversions [IH]");
+#endif
}
ATF_TC_BODY(hour, tc)
@@ -321,6 +331,10 @@ ATF_TC_BODY(hour, tc)
h_fail("00", "%I");
h_fail("13", "%I");
+#ifdef __FreeBSD__
+ h_fail("00", "%l");
+ h_fail("13", "%l");
+#endif
h_pass("00", "%H", 2, -1, -1, 0, -1, -1, -1, -1, -1);
h_pass("12", "%H", 2, -1, -1, 12, -1, -1, -1, -1, -1);
@@ -413,7 +427,18 @@ ATF_TC_BODY(seconds, tc)
h_pass("0", "%S", 1, 0, -1, -1, -1, -1, -1, -1, -1);
h_pass("59", "%S", 2, 59, -1, -1, -1, -1, -1, -1, -1);
h_pass("60", "%S", 2, 60, -1, -1, -1, -1, -1, -1, -1);
+#ifdef __FreeBSD__
+ /*
+ * (Much) older versions of the standard (up to the Issue 6) allowed for
+ * [0;61] range in %S conversion for double-leap seconds, and it's
+ * apparently what NetBSD and glibc are expecting, however current
+ * version defines allowed values to be [0;60], and that is what our
+ * strptime() implementation expects.
+ */
+ h_fail("61", "%S");
+#else
h_pass("61", "%S", 2, 61, -1, -1, -1, -1, -1, -1, -1);
+#endif
h_fail("62", "%S");
}
@@ -434,7 +459,9 @@ ATF_TC_BODY(year, tc)
h_pass("x2084y", "x%C%yy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
h_pass("x8420y", "x%y%Cy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
h_pass("%20845", "%%%C%y5", 6, -1, -1, -1, -1, -1, 184, -1, -1);
+#ifndef __FreeBSD__
h_fail("%", "%E%");
+#endif
h_pass("1980", "%Y", 4, -1, -1, -1, -1, -1, 80, -1, -1);
h_pass("1980", "%EY", 4, -1, -1, -1, -1, -1, 80, -1, -1);
@@ -467,7 +494,7 @@ ATF_TC_HEAD(Zone, tc)
ATF_TC_BODY(Zone, tc)
{
- ztest("%z");
+ ztest("%Z");
}
ATF_TP_ADD_TCS(tp)
diff --git a/lib/libc/tests/Makefile b/lib/libc/tests/Makefile
index 3e71350d82a9..11c3a635339d 100644
--- a/lib/libc/tests/Makefile
+++ b/lib/libc/tests/Makefile
@@ -20,6 +20,7 @@ TESTS_SUBDIRS+= stdlib
TESTS_SUBDIRS+= string
TESTS_SUBDIRS+= sys
TESTS_SUBDIRS+= termios
+TESTS_SUBDIRS+= time
TESTS_SUBDIRS+= tls
TESTS_SUBDIRS+= ttyio