chore: speed up some tests when running under qemu

This commit is contained in:
Marcus Holland-Moritz 2025-08-18 21:19:33 +02:00
parent f56fbd15de
commit 5e487f9860
3 changed files with 25 additions and 3 deletions

View File

@ -574,6 +574,10 @@ if(WITH_TESTS)
add_executable(${test} test/${test}.cpp)
endif()
if(CMAKE_CROSSCOMPILING)
target_compile_definitions(${test} PRIVATE DWARFS_TEST_CROSS_COMPILE)
endif()
target_link_libraries(
${test} PRIVATE dwarfs_test_helpers gmock gtest gtest_main
)

View File

@ -921,7 +921,8 @@ TEST_P(file_scanner, inode_ordering) {
opts.metadata.no_create_timestamp = true;
auto input = std::make_shared<test::os_access_mock>();
#if defined(DWARFS_TEST_RUNNING_ON_ASAN) || defined(DWARFS_TEST_RUNNING_ON_TSAN)
#if defined(DWARFS_TEST_RUNNING_ON_ASAN) || \
defined(DWARFS_TEST_RUNNING_ON_TSAN) || defined(DWARFS_TEST_CROSS_COMPILE)
static constexpr int dim{7};
#else
static constexpr int dim{14};

View File

@ -2054,7 +2054,11 @@ TEST(mkdwarfs_test, pack_modes_random) {
auto mode_arg = fmt::format("{}", fmt::join(modes, ","));
auto t = mkdwarfs_tester::create_empty();
t.add_test_file_tree();
#ifdef DWARFS_TEST_CROSS_COMPILE
t.add_random_file_tree({.avg_size = 128.0, .dimension = 10});
#else
t.add_random_file_tree({.avg_size = 128.0, .dimension = 16});
#endif
ASSERT_EQ(
0, t.run({"-i", "/", "-o", "-", "-l1", "--pack-metadata=" + mode_arg}))
<< t.err();
@ -2245,7 +2249,11 @@ TEST_P(mkdwarfs_progress_test, basic) {
t.add_root_dir();
t.add_random_file_tree({
#ifdef DWARFS_TEST_CROSS_COMPILE
.avg_size = 2.0 * 1024 * 1024,
#else
.avg_size = 20.0 * 1024 * 1024,
#endif
.dimension = 2,
#ifndef _WIN32
// Windows can't deal with non-UTF-8 filenames
@ -4095,7 +4103,16 @@ TEST(mkdwarfs_test, change_block_size) {
return t;
};
for (int lg_block_size = 10; lg_block_size <= 26; ++lg_block_size) {
#ifdef DWARFS_TEST_CROSS_COMPILE
static constexpr int kMinBlockSize = 14;
static constexpr int kMaxBlockSize = 20;
#else
static constexpr int kMinBlockSize = 10;
static constexpr int kMaxBlockSize = 26;
#endif
for (int lg_block_size = kMinBlockSize; lg_block_size <= kMaxBlockSize;
++lg_block_size) {
auto t = rebuild_tester(image);
ASSERT_EQ(0, t.run({"-i", image_file, "-o", "-", "-S",
std::to_string(lg_block_size), "-C", "zstd:level=5",
@ -4143,7 +4160,7 @@ TEST(mkdwarfs_test, change_block_size) {
EXPECT_EQ(1 << lg_block_size, hist[1]["block_size"].get<int>());
}
if (lg_block_size == 10) {
if (lg_block_size == kMinBlockSize) {
auto t3 = rebuild_tester(t2.out());
ASSERT_EQ(
0, t3.run({"-i", image_file, "-o", "-", "-S20", "-C", "zstd:level=5",