[libc-commits] [libc] [libc] Fix failing mktime test case in 32-bit systems (PR #65390)

Mikhail R. Gadelha via libc-commits libc-commits at lists.llvm.org
Tue Sep 5 10:33:44 PDT 2023


https://github.com/mikhailramalho created https://github.com/llvm/llvm-project/pull/65390:

Previously, these tests expected that calling mktime with a struct tm that caused overlow to succeed with return -1
(TimeConstants::OUT_OF_RANGE_RETURN_VALUE), however, the Succeeds call expects the errno to be zero (no failure).

This patch fixes the expected calls to fail with EOVERFLOW. These tests are only enabled to 32-bit systems, and are probably not being tested on the arm32 buildbot, that's why this was not a problem before.

>From a23e8e9b555e6fde4c6fb74ddc175af55040d1c5 Mon Sep 17 00:00:00 2001
From: "Mikhail R. Gadelha" <mikhail at igalia.com>
Date: Fri, 1 Sep 2023 10:23:19 -0300
Subject: [PATCH] [libc] Fix failing mktime test case in 32-bit systems

Previously, these tests expected that calling mktime with a struct tm
that caused overlow to succeed with return -1
(TimeConstants::OUT_OF_RANGE_RETURN_VALUE), however, the Succeeds call
expects the errno to be zero (no failure).

This patch fixes the expected calls to fail with EOVERFLOW. These tests
are only enabled to 32-bit systems, and are probably not being tested on
the arm32 buildbot, that's why this was not a problem before.
---
 libc/test/src/time/mktime_test.cpp | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/libc/test/src/time/mktime_test.cpp b/libc/test/src/time/mktime_test.cpp
index 8ee18adca8e135d..6cf115e89f05ef5 100644
--- a/libc/test/src/time/mktime_test.cpp
+++ b/libc/test/src/time/mktime_test.cpp
@@ -187,8 +187,7 @@ TEST(LlvmLibcMkTime, InvalidEndOf32BitEpochYear) {
       .tm_mon = Month::JANUARY, .tm_year = tm_year(2038), .tm_wday = 0,
       .tm_yday = 0
     };
-    EXPECT_THAT(__llvm_libc::mktime(&tm_data),
-                Succeeds(TimeConstants::OUT_OF_RANGE_RETURN_VALUE));
+    EXPECT_THAT(__llvm_libc::mktime(&tm_data), Fails(EOVERFLOW));
   }
 
   {
@@ -198,8 +197,7 @@ TEST(LlvmLibcMkTime, InvalidEndOf32BitEpochYear) {
       .tm_mon = Month::JANUARY, .tm_year = tm_year(2038), .tm_wday = 0,
       .tm_yday = 0
     };
-    EXPECT_THAT(__llvm_libc::mktime(&tm_data),
-                Succeeds(TimeConstants::OUT_OF_RANGE_RETURN_VALUE));
+    EXPECT_THAT(__llvm_libc::mktime(&tm_data), Fails(EOVERFLOW));
   }
 
   {
@@ -209,8 +207,7 @@ TEST(LlvmLibcMkTime, InvalidEndOf32BitEpochYear) {
       .tm_mon = Month::JANUARY, .tm_year = tm_year(2038), .tm_wday = 0,
       .tm_yday = 0
     };
-    EXPECT_THAT(__llvm_libc::mktime(&tm_data),
-                Succeeds(TimeConstants::OUT_OF_RANGE_RETURN_VALUE));
+    EXPECT_THAT(__llvm_libc::mktime(&tm_data), Fails(EOVERFLOW));
   }
 
   {
@@ -220,8 +217,7 @@ TEST(LlvmLibcMkTime, InvalidEndOf32BitEpochYear) {
       .tm_mon = Month::JANUARY, .tm_year = tm_year(2038), .tm_wday = 0,
       .tm_yday = 0
     };
-    EXPECT_THAT(__llvm_libc::mktime(&tm_data),
-                Succeeds(TimeConstants::OUT_OF_RANGE_RETURN_VALUE));
+    EXPECT_THAT(__llvm_libc::mktime(&tm_data), Fails(EOVERFLOW));
   }
 
   {
@@ -231,8 +227,7 @@ TEST(LlvmLibcMkTime, InvalidEndOf32BitEpochYear) {
       .tm_mon = Month::FEBRUARY, .tm_year = tm_year(2038), .tm_wday = 0,
       .tm_yday = 0
     };
-    EXPECT_THAT(__llvm_libc::mktime(&tm_data),
-                Succeeds(TimeConstants::OUT_OF_RANGE_RETURN_VALUE));
+    EXPECT_THAT(__llvm_libc::mktime(&tm_data), Fails(EOVERFLOW));
   }
 
   {
@@ -242,8 +237,7 @@ TEST(LlvmLibcMkTime, InvalidEndOf32BitEpochYear) {
       .tm_mon = Month::JANUARY, .tm_year = tm_year(2039), .tm_wday = 0,
       .tm_yday = 0
     };
-    EXPECT_THAT(__llvm_libc::mktime(&tm_data),
-                Succeeds(TimeConstants::OUT_OF_RANGE_RETURN_VALUE));
+    EXPECT_THAT(__llvm_libc::mktime(&tm_data), Fails(EOVERFLOW));
   }
 }
 



More information about the libc-commits mailing list