git: d8c9f8089187 - main - libc: Update mktime(3) / timegm(3) tests.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Wed, 25 Jan 2023 06:22:51 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=d8c9f80891872a54d0b21933136644d915096fe3

commit d8c9f80891872a54d0b21933136644d915096fe3
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-01-25 06:21:23 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-01-25 06:22:46 +0000

    libc: Update mktime(3) / timegm(3) tests.
    
    Sponsored by:   Klara, Inc.
    Reviewed by:    ngie
    Differential Revision:  https://reviews.freebsd.org/D38177
---
 contrib/netbsd-tests/lib/libc/time/t_mktime.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/contrib/netbsd-tests/lib/libc/time/t_mktime.c b/contrib/netbsd-tests/lib/libc/time/t_mktime.c
index 1080b77eda80..63905b8bad54 100644
--- a/contrib/netbsd-tests/lib/libc/time/t_mktime.c
+++ b/contrib/netbsd-tests/lib/libc/time/t_mktime.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mktime.c,v 1.5 2012/03/18 07:33:58 jruoho Exp $ */
+/* $NetBSD: t_mktime.c,v 1.6 2017/10/27 00:55:27 kre Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -64,18 +64,16 @@ 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;
 
 	(void)memset(&tms, 0, sizeof(tms));
-	tms.tm_year = ~0;
+	tms.tm_year = -1;
+	tms.tm_mday = 1;
 
 	errno = 0;
 	t = mktime(&tms);
-	ATF_REQUIRE_ERRNO(0, t != (time_t)-1);
+	ATF_REQUIRE(t != (time_t)-1);
 }
 
 ATF_TC(timegm_epoch);
@@ -95,7 +93,7 @@ ATF_TC_BODY(timegm_epoch, tc)
 	tms.tm_year = 1970 - 1900;
 	tms.tm_mday = 1;
 	t = timegm(&tms);
-	ATF_REQUIRE_ERRNO(0, t == (time_t)0);
+	ATF_REQUIRE(t == (time_t)0);
 
 	/* one second after midnight on 1 Jan 1970 */
 	(void)memset(&tms, 0, sizeof(tms));
@@ -104,7 +102,7 @@ ATF_TC_BODY(timegm_epoch, tc)
 	tms.tm_mday = 1;
 	tms.tm_sec = 1;
 	t = timegm(&tms);
-	ATF_REQUIRE_ERRNO(0, t == (time_t)1);
+	ATF_REQUIRE(t == (time_t)1);
 
 	/*
 	 * 1969-12-31 23:59:59 = one second before the epoch.
@@ -119,7 +117,8 @@ ATF_TC_BODY(timegm_epoch, tc)
 	tms.tm_min = 59;
 	tms.tm_sec = 59;
 	t = timegm(&tms);
-	ATF_REQUIRE_ERRNO(0, t == (time_t)-1);
+	ATF_REQUIRE(t == (time_t)-1);
+	/* ATF_REQUIRE(errno == 0); does not work, errno is kept clear */
 
 	/*
 	 * Another way of getting one second before the epoch:
@@ -131,7 +130,7 @@ ATF_TC_BODY(timegm_epoch, tc)
 	tms.tm_mday = 1;
 	tms.tm_sec = -1;
 	t = timegm(&tms);
-	ATF_REQUIRE_ERRNO(0, t == (time_t)-1);
+	ATF_REQUIRE(t == (time_t)-1);
 
 	/*
 	 * Two seconds before the epoch.
@@ -142,7 +141,7 @@ ATF_TC_BODY(timegm_epoch, tc)
 	tms.tm_mday = 1;
 	tms.tm_sec = -2;
 	t = timegm(&tms);
-	ATF_REQUIRE_ERRNO(0, t == (time_t)-2);
+	ATF_REQUIRE(t == (time_t)-2);
 
 }