[libc-commits] [libc] [libc][NFC] Fix printed test time in 32-bit systems (PR #98922)
via libc-commits
libc-commits at lists.llvm.org
Mon Jul 15 09:07:50 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Mikhail R. Gadelha (mikhailramalho)
<details>
<summary>Changes</summary>
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)
---
Full diff: https://github.com/llvm/llvm-project/pull/98922.diff
1 Files Affected:
- (modified) libc/test/UnitTest/LibcTest.cpp (+2-2)
``````````diff
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';
``````````
</details>
https://github.com/llvm/llvm-project/pull/98922
More information about the libc-commits
mailing list