Skip to content

Commit 106621b

Browse files
[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)
1 parent c2fab5a commit 106621b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libc/test/UnitTest/LibcTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ int Test::runTests(const TestOptions &Options) {
159159
}
160160

161161
tlog << green << "[ RUN ] " << reset << TestName << '\n';
162-
[[maybe_unused]] const auto start_time = clock();
162+
[[maybe_unused]] const uint64_t start_time = clock();
163163
RunContext Ctx;
164164
T->SetUp();
165165
T->setContext(&Ctx);
166166
T->Run();
167167
T->TearDown();
168-
[[maybe_unused]] const auto end_time = clock();
168+
[[maybe_unused]] const uint64_t end_time = clock();
169169
switch (Ctx.status()) {
170170
case RunContext::RunResult::Fail:
171171
tlog << red << "[ FAILED ] " << reset << TestName << '\n';

0 commit comments

Comments
 (0)