Skip to content

Commit 2d33e4f

Browse files
authored
Adjust func-memory test to be shorter. (#780)
Some CI pipelines were occasionally timing out due to the func-memory test taking too long. This change reduces the number of iterations from 100 to 50 for each test run, which should help avoid timeouts while still providing sufficient coverage. It also adds some debug output to indicate the time taken for each test.
1 parent 9d29d82 commit 2d33e4f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/test/func/memory/memory.cc

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <array>
2+
#include <chrono>
23
#include <iostream>
34
#include <snmalloc/snmalloc.h>
45
#include <test/opt.h>
@@ -532,7 +533,7 @@ void test_consolidaton_bug()
532533
}
533534
}
534535

535-
int main(int argc, char** argv)
536+
int main(int, char**)
536537
{
537538
setup();
538539
#ifdef TEST_LIMITED
@@ -549,17 +550,17 @@ int main(int argc, char** argv)
549550
std::abort();
550551
}
551552
#endif
552-
#ifdef USE_SYSTEMATIC_TESTING
553-
opt::Opt opt(argc, argv);
554-
size_t seed = opt.is<size_t>("--seed", 0);
555-
Virtual::systematic_bump_ptr() += seed << 17;
556-
#else
557-
UNUSED(argc, argv);
558-
#endif
553+
auto start = std::chrono::steady_clock::now();
559554
#define TEST(testname) \
560-
std::cout << "Running " #testname << std::endl; \
561-
for (size_t i = 0; i < 100; i++) \
562-
testname();
555+
do \
556+
{ \
557+
auto end = std::chrono::steady_clock::now(); \
558+
auto diff_seconds = \
559+
std::chrono::duration_cast<std::chrono::seconds>(end - start).count(); \
560+
std::cout << "Running " #testname << " @ " << diff_seconds << std::endl; \
561+
for (size_t i = 0; i < 50; i++) \
562+
testname(); \
563+
} while (0);
563564

564565
TEST(test_alloc_dealloc_64k);
565566
TEST(test_random_allocation);
@@ -576,5 +577,6 @@ int main(int argc, char** argv)
576577
TEST(test_calloc_16M);
577578
TEST(test_consolidaton_bug);
578579

580+
std::cout << "Tests completeed successfully!" << std::endl;
579581
return 0;
580582
}

0 commit comments

Comments
 (0)