[libc-commits] [libc] [libc][NFC] Fix printed test time in 32-bit systems (PR #98922)
Mikhail R. Gadelha via libc-commits
libc-commits at lists.llvm.org
Mon Jul 15 09:07:21 PDT 2024
https://github.com/mikhailramalho created https://github.com/llvm/llvm-project/pull/98922
clock() returns a clock_t, which is a long and might overflow in 32-bit systems when the test takes a long time to run. Changing it to uint64_t fixes this issue. Before:
[ RUN ] LlvmLibcHashTest.Avalanche
[ OK ] LlvmLibcHashTest.Avalanche (18446744073709551138 ms)
After this patch:
[ RUN ] LlvmLibcHashTest.Avalanche
[ OK ] LlvmLibcHashTest.Avalanche (4154 ms)
>From c74b49e08e74cfa66e93823408a494ac3644b150 Mon Sep 17 00:00:00 2001
From: "Mikhail R. Gadelha" <mikhail at igalia.com>
Date: Mon, 15 Jul 2024 13:03:29 -0300
Subject: [PATCH] [libc][NFC] Fix printed test time in 32-bit systems
clock() returns a clock_t, which is a long and might overflow in 32-bit
systems when the test takes a long time to run. Changing it to uint64_t
fixes this issue. Before:
[ RUN ] LlvmLibcHashTest.Avalanche
[ OK ] LlvmLibcHashTest.Avalanche (18446744073709551138 ms)
After this patch:
[ RUN ] LlvmLibcHashTest.Avalanche
[ OK ] LlvmLibcHashTest.Avalanche (4154 ms)
---
libc/test/UnitTest/LibcTest.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libc/test/UnitTest/LibcTest.cpp b/libc/test/UnitTest/LibcTest.cpp
index 72aeaf20e1dac..ad5722f99a436 100644
--- a/libc/test/UnitTest/LibcTest.cpp
+++ b/libc/test/UnitTest/LibcTest.cpp
@@ -159,13 +159,13 @@ int Test::runTests(const TestOptions &Options) {
}
tlog << green << "[ RUN ] " << reset << TestName << '\n';
- [[maybe_unused]] const auto start_time = clock();
+ [[maybe_unused]] const uint64_t start_time = clock();
RunContext Ctx;
T->SetUp();
T->setContext(&Ctx);
T->Run();
T->TearDown();
- [[maybe_unused]] const auto end_time = clock();
+ [[maybe_unused]] const uint64_t end_time = clock();
switch (Ctx.status()) {
case RunContext::RunResult::Fail:
tlog << red << "[ FAILED ] " << reset << TestName << '\n';
More information about the libc-commits
mailing list