[libc-commits] [libc] 106621b - [libc][NFC] Fix printed test time in 32-bit systems (#98922)
via libc-commits
libc-commits at lists.llvm.org
Mon Jul 15 09:16:06 PDT 2024
Author: Mikhail R. Gadelha
Date: 2024-07-15T09:16:02-07:00
New Revision: 106621b601d7dc7c4929fba293f7e5ffe6b92c58
URL: https://github.com/llvm/llvm-project/commit/106621b601d7dc7c4929fba293f7e5ffe6b92c58
DIFF: https://github.com/llvm/llvm-project/commit/106621b601d7dc7c4929fba293f7e5ffe6b92c58.diff
LOG: [libc][NFC] Fix printed test time in 32-bit systems (#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)
Added:
Modified:
libc/test/UnitTest/LibcTest.cpp
Removed:
################################################################################
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