From edd8fa7b611df55dd523a2b1da6631e62246dd23 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Sat, 13 Jul 2024 10:56:24 +0200 Subject: [PATCH 1/2] Test that time_t is at least 8 bytes, if not, give an error message in the log * ACE/tests/Time_Value_Test.cpp: --- ACE/tests/Time_Value_Test.cpp | 56 +++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/ACE/tests/Time_Value_Test.cpp b/ACE/tests/Time_Value_Test.cpp index 2698a6994c13a..08c55e5d26127 100644 --- a/ACE/tests/Time_Value_Test.cpp +++ b/ACE/tests/Time_Value_Test.cpp @@ -96,22 +96,32 @@ run_main (int, ACE_TCHAR *[]) ACE_UINT64 ms = 0; msec_test.msec (ms); if (ms != 42555) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("msec test failed: %Q should be 42555\n"), - ms)); + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("msec test failed: %Q should be 42555\n"), + ms)); + ++ret; + } + ms = 0; ms = msec_test.get_msec (); if (ms != 42555) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("get_msec test failed: %Q should be 42555\n"), - ms)); + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("get_msec test failed: %Q should be 42555\n"), + ms)); + ++ret; + } ACE_Time_Value const msec_test2 (42, 555000); ms = 0; msec_test2.msec (ms); if (ms != 42555) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("msec const test failed: %Q should be 42555\n"), - ms)); + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("msec const test failed: %Q should be 42555\n"), + ms)); + ++ret; + } // Test setting double values ACE_Time_Value d1(10, 500000); @@ -165,13 +175,18 @@ run_main (int, ACE_TCHAR *[]) ACE_Time_Value msec_test3; msec_test3.set_msec (ms); if (msec_test3.sec () != 42) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("set_msec test failed: %d secs should be 42\n"), - msec_test3.sec ())); + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("set_msec test failed: %d secs should be 42\n"), + msec_test3.sec ())); + ++ret; + } if (msec_test3.usec () != 555000) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("set_msec test failed: %d usecs should be 555000\n"), - msec_test3.usec ())); + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("set_msec test failed: %d usecs should be 555000\n"), + msec_test3.usec ())); + } std::ostringstream ost; ost << ACE_Time_Value(1); @@ -192,6 +207,17 @@ run_main (int, ACE_TCHAR *[]) ost << ACE_Time_Value(); ACE_TEST_ASSERT( ost.str() == "0" ); + if (sizeof(time_t) < 8) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("time_t not at least 64bit, this platform will have problems after 2038\n"))); + } + else + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("time_t at least 64bit, this platform will not have problems after 2038\n"))); + } + ACE_END_TEST; return ret; From 9be41577ed2fb86d6bfbc758fdb757ffb3ce61b7 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Sun, 14 Jul 2024 09:56:56 +0200 Subject: [PATCH 2/2] Return error when platform doesn't have 64bit time_t * ACE/tests/Time_Value_Test.cpp: --- ACE/tests/Time_Value_Test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ACE/tests/Time_Value_Test.cpp b/ACE/tests/Time_Value_Test.cpp index 08c55e5d26127..98bf4cab5eb7c 100644 --- a/ACE/tests/Time_Value_Test.cpp +++ b/ACE/tests/Time_Value_Test.cpp @@ -186,6 +186,7 @@ run_main (int, ACE_TCHAR *[]) ACE_ERROR ((LM_ERROR, ACE_TEXT ("set_msec test failed: %d usecs should be 555000\n"), msec_test3.usec ())); + ++ret; } std::ostringstream ost; @@ -211,11 +212,12 @@ run_main (int, ACE_TCHAR *[]) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("time_t not at least 64bit, this platform will have problems after 2038\n"))); + ++ret; } else { ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("time_t at least 64bit, this platform will not have problems after 2038\n"))); + ACE_TEXT ("time_t is at least 64bit, this platform will not have problems after 2038\n"))); } ACE_END_TEST;