Skip to content

Commit

Permalink
Merge pull request #31815 from vespa-engine/balder/single-gtest-runne…
Browse files Browse the repository at this point in the history
…r-for-vespalib-util

Gather all gtests in tests/util in single gtest runner binary.
  • Loading branch information
baldersheim authored Jul 2, 2024
2 parents 1734978 + 0f0ff5c commit e0ff928
Show file tree
Hide file tree
Showing 31 changed files with 38 additions and 161 deletions.
13 changes: 1 addition & 12 deletions vespalib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,21 +196,10 @@ vespa_define_module(
src/tests/tutorial/threads
src/tests/typify
src/tests/unwind_message
src/tests/util/bfloat16
src/tests/util/cgroup_resource_limits
src/tests/util/file_area_freelist
src/tests/util/generation_hold_list
src/tests/util/generationhandler
src/tests/util
src/tests/util/generationhandler_stress
src/tests/util/hamming
src/tests/util/md5
src/tests/util/memory_trap
src/tests/util/mmap_file_allocator
src/tests/util/mmap_file_allocator_factory
src/tests/util/rcuvector
src/tests/util/size_literals
src/tests/util/static_string
src/tests/util/string_escape
src/tests/valgrind
src/tests/visit_ranges
src/tests/wakeup
Expand Down
26 changes: 26 additions & 0 deletions vespalib/src/tests/util/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

# Runner for unit tests written in gtest.
# NOTE: All new test classes should be added here.
vespa_add_executable(vespalib_util_gtest_runner_test_app TEST
SOURCES
gtest_runner.cpp
bfloat16_test.cpp
cgroup_resource_limits_test.cpp
file_area_freelist_test.cpp
generation_hold_list_test.cpp
generationhandler_test.cpp
memory_trap_test.cpp
mmap_file_allocator_factory_test.cpp
mmap_file_allocator_test.cpp
rcuvector_test.cpp
size_literals_test.cpp
static_string_test.cpp
string_escape_test.cpp
DEPENDS
vespalib
onnxruntime
GTest::GTest
)

vespa_add_test( NAME vespalib_util_gtest_runner_test_app COMMAND vespalib_util_gtest_runner_test_app)
12 changes: 0 additions & 12 deletions vespalib/src/tests/util/bfloat16/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,3 @@ TEST(OnnxBFloat16Test, has_same_encoding) {
printf("floats that are NaN in both vespalib and onnx: %d (0x%04x)\n", nan_count, nan_count);
printf("total count (OK + NaN): %d (0x%04x)\n", ok_count + nan_count, ok_count + nan_count);
}

GTEST_MAIN_RUN_ALL_TESTS()
9 changes: 0 additions & 9 deletions vespalib/src/tests/util/cgroup_resource_limits/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ class CGroupResourceLimitsTest : public ::testing::Test
protected:
CGroupResourceLimitsTest();
~CGroupResourceLimitsTest();
void check_limits(const std::string &name, const std::optional<uint64_t>& memory_limit, const std::optional<uint32_t>& cpu_limit);
void check_limits(std::string_view name, const std::optional<uint64_t>& memory_limit, const std::optional<uint32_t>& cpu_limit);
};

CGroupResourceLimitsTest::CGroupResourceLimitsTest() = default;
CGroupResourceLimitsTest::~CGroupResourceLimitsTest() = default;

void
CGroupResourceLimitsTest::check_limits(const std::string &base, const std::optional<uint64_t>& memory_limit, const std::optional<uint32_t>& cpu_limit)
CGroupResourceLimitsTest::check_limits(std::string_view subdir, const std::optional<uint64_t>& memory_limit, const std::optional<uint32_t>& cpu_limit)
{
std::string base = "cgroup_resource_limits/" + subdir;
auto src_base = TEST_PATH(base);
CGroupResourceLimits cg_limits(src_base + "/cgroup", src_base + "/self");
EXPECT_EQ(memory_limit, cg_limits.get_memory_limit());
Expand Down Expand Up @@ -73,5 +74,3 @@ TEST_F(CGroupResourceLimitsTest, cgroup_v2_container)
}

}

GTEST_MAIN_RUN_ALL_TESTS()
9 changes: 0 additions & 9 deletions vespalib/src/tests/util/file_area_freelist/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,3 @@ TEST_F(FileAreaFreeListTest, can_use_part_of_free_area)
EXPECT_EQ(5, _freelist.alloc(1));
EXPECT_EQ(bad_offset, _freelist.alloc(1));
}


GTEST_MAIN_RUN_ALL_TESTS()
9 changes: 0 additions & 9 deletions vespalib/src/tests/util/generation_hold_list/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,3 @@ TEST_F(IntHoldListTest, reclaim_all_calls_callback_for_all_elements)
assert_reclaim_all({3, 5});
assert_reclaim_all({});
}

GTEST_MAIN_RUN_ALL_TESTS()
4 changes: 0 additions & 4 deletions vespalib/src/tests/util/generationhandler/.gitignore

This file was deleted.

9 changes: 0 additions & 9 deletions vespalib/src/tests/util/generationhandler/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,3 @@ TEST_F(GenerationHandlerTest, require_that_generation_can_grow_large)
}

}

GTEST_MAIN_RUN_ALL_TESTS()
8 changes: 8 additions & 0 deletions vespalib/src/tests/util/gtest_runner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <vespa/vespalib/gtest/gtest.h>

#include <vespa/log/log.h>
LOG_SETUP("vespalib_util_gtest_runner");

GTEST_MAIN_RUN_ALL_TESTS()
9 changes: 0 additions & 9 deletions vespalib/src/tests/util/memory_trap/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,3 @@ TEST_F(MemoryTrapTest, read_from_hw_backed_trap_crashes_process) {
do_not_optimize_away(dummy); // never reached
},"");
}

GTEST_MAIN_RUN_ALL_TESTS()
1 change: 0 additions & 1 deletion vespalib/src/tests/util/mmap_file_allocator/.gitignore

This file was deleted.

9 changes: 0 additions & 9 deletions vespalib/src/tests/util/mmap_file_allocator/CMakeLists.txt

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,3 @@ TEST(MmapFileAllocatorFactoryTest, nonempty_dir_gives_allocator)
MmapFileAllocatorFactory::instance().setup("");
std::filesystem::remove_all(std::filesystem::path(basedir));
}

GTEST_MAIN_RUN_ALL_TESTS()
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,3 @@ TEST_P(MmapFileAllocatorTest, reuse_file_offset_works)
EXPECT_EQ(0, memcmp(buf.data, world.c_str(), world.size() + 1));
}
}

GTEST_MAIN_RUN_ALL_TESTS()
5 changes: 0 additions & 5 deletions vespalib/src/tests/util/rcuvector/.gitignore

This file was deleted.

9 changes: 0 additions & 9 deletions vespalib/src/tests/util/rcuvector/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -516,5 +516,3 @@ TEST(RcuVectorTest, single_writer_four_readers)
StressFixture f;
f.run_test(20000, 4);
}

GTEST_MAIN_RUN_ALL_TESTS()
9 changes: 0 additions & 9 deletions vespalib/src/tests/util/size_literals/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,3 @@ TEST(SizeLiteralsTest, simple_usage)
EXPECT_TRUE(is_size_t(v42g));
EXPECT_TRUE(is_size_t(v42t));
}

GTEST_MAIN_RUN_ALL_TESTS()
9 changes: 0 additions & 9 deletions vespalib/src/tests/util/static_string/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ TEST(StaticStringViewTest, with_null_byte) {
std::string expect("foo\0bar", 7);
EXPECT_EQ(value.view(), expect);
}

GTEST_MAIN_RUN_ALL_TESTS()
9 changes: 0 additions & 9 deletions vespalib/src/tests/util/string_escape/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,3 @@ TEST(StringEscapeTest, control_characters_are_escaped_in_content) {
EXPECT_EQ(xml_content_escaped(stringref("\x00", 1)), "&#0;");
EXPECT_EQ(xml_content_escaped("\x1f"), "&#31;");
}

GTEST_MAIN_RUN_ALL_TESTS()

0 comments on commit e0ff928

Please sign in to comment.