diff --git a/vespalib/CMakeLists.txt b/vespalib/CMakeLists.txt index 49e0438fec44..8bbe08fcfc97 100644 --- a/vespalib/CMakeLists.txt +++ b/vespalib/CMakeLists.txt @@ -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 diff --git a/vespalib/src/tests/util/CMakeLists.txt b/vespalib/src/tests/util/CMakeLists.txt new file mode 100644 index 000000000000..a65ac04061b4 --- /dev/null +++ b/vespalib/src/tests/util/CMakeLists.txt @@ -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) diff --git a/vespalib/src/tests/util/bfloat16/CMakeLists.txt b/vespalib/src/tests/util/bfloat16/CMakeLists.txt deleted file mode 100644 index 72d6c8720d68..000000000000 --- a/vespalib/src/tests/util/bfloat16/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -if(EXISTS /opt/vespa-deps/include/onnxruntime/onnxruntime_cxx_api.h) -vespa_add_executable(vespalib_bfloat16_test_app TEST - SOURCES - bfloat16_test.cpp - DEPENDS - vespalib - onnxruntime - GTest::GTest -) -vespa_add_test(NAME vespalib_bfloat16_test_app COMMAND vespalib_bfloat16_test_app) -endif() diff --git a/vespalib/src/tests/util/bfloat16/bfloat16_test.cpp b/vespalib/src/tests/util/bfloat16_test.cpp similarity index 99% rename from vespalib/src/tests/util/bfloat16/bfloat16_test.cpp rename to vespalib/src/tests/util/bfloat16_test.cpp index 196c5f98c9eb..8b21cbad3095 100644 --- a/vespalib/src/tests/util/bfloat16/bfloat16_test.cpp +++ b/vespalib/src/tests/util/bfloat16_test.cpp @@ -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() diff --git a/vespalib/src/tests/util/cgroup_resource_limits/CMakeLists.txt b/vespalib/src/tests/util/cgroup_resource_limits/CMakeLists.txt deleted file mode 100644 index d7e99fcde29e..000000000000 --- a/vespalib/src/tests/util/cgroup_resource_limits/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_cgroup_resource_limits_test_app TEST - SOURCES - cgroup_resource_limits_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_cgroup_resource_limits_test_app COMMAND vespalib_cgroup_resource_limits_test_app) diff --git a/vespalib/src/tests/util/cgroup_resource_limits/cgroup_resource_limits_test.cpp b/vespalib/src/tests/util/cgroup_resource_limits_test.cpp similarity index 88% rename from vespalib/src/tests/util/cgroup_resource_limits/cgroup_resource_limits_test.cpp rename to vespalib/src/tests/util/cgroup_resource_limits_test.cpp index 38e8467ff356..2528c56d2115 100644 --- a/vespalib/src/tests/util/cgroup_resource_limits/cgroup_resource_limits_test.cpp +++ b/vespalib/src/tests/util/cgroup_resource_limits_test.cpp @@ -12,15 +12,16 @@ class CGroupResourceLimitsTest : public ::testing::Test protected: CGroupResourceLimitsTest(); ~CGroupResourceLimitsTest(); - void check_limits(const std::string &name, const std::optional& memory_limit, const std::optional& cpu_limit); + void check_limits(std::string_view name, const std::optional& memory_limit, const std::optional& cpu_limit); }; CGroupResourceLimitsTest::CGroupResourceLimitsTest() = default; CGroupResourceLimitsTest::~CGroupResourceLimitsTest() = default; void -CGroupResourceLimitsTest::check_limits(const std::string &base, const std::optional& memory_limit, const std::optional& cpu_limit) +CGroupResourceLimitsTest::check_limits(std::string_view subdir, const std::optional& memory_limit, const std::optional& 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()); @@ -73,5 +74,3 @@ TEST_F(CGroupResourceLimitsTest, cgroup_v2_container) } } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/file_area_freelist/CMakeLists.txt b/vespalib/src/tests/util/file_area_freelist/CMakeLists.txt deleted file mode 100644 index 30303eaed21d..000000000000 --- a/vespalib/src/tests/util/file_area_freelist/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_file_area_freelist_test_app TEST - SOURCES - file_area_freelist_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_file_area_freelist_test_app COMMAND vespalib_file_area_freelist_test_app) diff --git a/vespalib/src/tests/util/file_area_freelist/file_area_freelist_test.cpp b/vespalib/src/tests/util/file_area_freelist_test.cpp similarity index 98% rename from vespalib/src/tests/util/file_area_freelist/file_area_freelist_test.cpp rename to vespalib/src/tests/util/file_area_freelist_test.cpp index 470680e0f8f4..90161b76d495 100644 --- a/vespalib/src/tests/util/file_area_freelist/file_area_freelist_test.cpp +++ b/vespalib/src/tests/util/file_area_freelist_test.cpp @@ -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() diff --git a/vespalib/src/tests/util/generation_hold_list/CMakeLists.txt b/vespalib/src/tests/util/generation_hold_list/CMakeLists.txt deleted file mode 100644 index bf607a6fec64..000000000000 --- a/vespalib/src/tests/util/generation_hold_list/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_generation_hold_list_test_app TEST - SOURCES - generation_hold_list_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_generation_hold_list_test_app COMMAND vespalib_generation_hold_list_test_app) diff --git a/vespalib/src/tests/util/generation_hold_list/generation_hold_list_test.cpp b/vespalib/src/tests/util/generation_hold_list_test.cpp similarity index 98% rename from vespalib/src/tests/util/generation_hold_list/generation_hold_list_test.cpp rename to vespalib/src/tests/util/generation_hold_list_test.cpp index 2d8da9614338..e7bbe40856d8 100644 --- a/vespalib/src/tests/util/generation_hold_list/generation_hold_list_test.cpp +++ b/vespalib/src/tests/util/generation_hold_list_test.cpp @@ -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() diff --git a/vespalib/src/tests/util/generationhandler/.gitignore b/vespalib/src/tests/util/generationhandler/.gitignore deleted file mode 100644 index c98a32727d92..000000000000 --- a/vespalib/src/tests/util/generationhandler/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.depend -Makefile -generationhandler_test -vespalib_generationhandler_test_app diff --git a/vespalib/src/tests/util/generationhandler/CMakeLists.txt b/vespalib/src/tests/util/generationhandler/CMakeLists.txt deleted file mode 100644 index 10cb0b000609..000000000000 --- a/vespalib/src/tests/util/generationhandler/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_generationhandler_test_app TEST - SOURCES - generationhandler_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_generationhandler_test_app COMMAND vespalib_generationhandler_test_app) diff --git a/vespalib/src/tests/util/generationhandler/generationhandler_test.cpp b/vespalib/src/tests/util/generationhandler_test.cpp similarity index 99% rename from vespalib/src/tests/util/generationhandler/generationhandler_test.cpp rename to vespalib/src/tests/util/generationhandler_test.cpp index 383a46fbef94..5b2a69f95ea0 100644 --- a/vespalib/src/tests/util/generationhandler/generationhandler_test.cpp +++ b/vespalib/src/tests/util/generationhandler_test.cpp @@ -133,5 +133,3 @@ TEST_F(GenerationHandlerTest, require_that_generation_can_grow_large) } } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/gtest_runner.cpp b/vespalib/src/tests/util/gtest_runner.cpp new file mode 100644 index 000000000000..c2e1d07b60c0 --- /dev/null +++ b/vespalib/src/tests/util/gtest_runner.cpp @@ -0,0 +1,8 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include + +#include +LOG_SETUP("vespalib_util_gtest_runner"); + +GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/memory_trap/CMakeLists.txt b/vespalib/src/tests/util/memory_trap/CMakeLists.txt deleted file mode 100644 index cc38296a9282..000000000000 --- a/vespalib/src/tests/util/memory_trap/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_util_memory_trap_test_app TEST - SOURCES - memory_trap_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_util_memory_trap_test_app COMMAND vespalib_util_memory_trap_test_app) diff --git a/vespalib/src/tests/util/memory_trap/memory_trap_test.cpp b/vespalib/src/tests/util/memory_trap_test.cpp similarity index 98% rename from vespalib/src/tests/util/memory_trap/memory_trap_test.cpp rename to vespalib/src/tests/util/memory_trap_test.cpp index a220e81f3a34..d963792e8573 100644 --- a/vespalib/src/tests/util/memory_trap/memory_trap_test.cpp +++ b/vespalib/src/tests/util/memory_trap_test.cpp @@ -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() diff --git a/vespalib/src/tests/util/mmap_file_allocator/.gitignore b/vespalib/src/tests/util/mmap_file_allocator/.gitignore deleted file mode 100644 index a18e9aac5895..000000000000 --- a/vespalib/src/tests/util/mmap_file_allocator/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mmap-file-allocator-factory-dir diff --git a/vespalib/src/tests/util/mmap_file_allocator/CMakeLists.txt b/vespalib/src/tests/util/mmap_file_allocator/CMakeLists.txt deleted file mode 100644 index c671b4df5728..000000000000 --- a/vespalib/src/tests/util/mmap_file_allocator/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_mmap_file_allocator_test_app TEST - SOURCES - mmap_file_allocator_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_mmap_file_allocator_test_app COMMAND vespalib_mmap_file_allocator_test_app) diff --git a/vespalib/src/tests/util/mmap_file_allocator_factory/.gitignore b/vespalib/src/tests/util/mmap_file_allocator_factory/.gitignore deleted file mode 100644 index a18e9aac5895..000000000000 --- a/vespalib/src/tests/util/mmap_file_allocator_factory/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mmap-file-allocator-factory-dir diff --git a/vespalib/src/tests/util/mmap_file_allocator_factory/CMakeLists.txt b/vespalib/src/tests/util/mmap_file_allocator_factory/CMakeLists.txt deleted file mode 100644 index 03fbd04821b8..000000000000 --- a/vespalib/src/tests/util/mmap_file_allocator_factory/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_mmap_file_allocator_factory_test_app TEST - SOURCES - mmap_file_allocator_factory_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_mmap_file_allocator_factory_test_app COMMAND vespalib_mmap_file_allocator_factory_test_app) diff --git a/vespalib/src/tests/util/mmap_file_allocator_factory/mmap_file_allocator_factory_test.cpp b/vespalib/src/tests/util/mmap_file_allocator_factory_test.cpp similarity index 98% rename from vespalib/src/tests/util/mmap_file_allocator_factory/mmap_file_allocator_factory_test.cpp rename to vespalib/src/tests/util/mmap_file_allocator_factory_test.cpp index bda19a143d38..394ecd2df274 100644 --- a/vespalib/src/tests/util/mmap_file_allocator_factory/mmap_file_allocator_factory_test.cpp +++ b/vespalib/src/tests/util/mmap_file_allocator_factory_test.cpp @@ -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() diff --git a/vespalib/src/tests/util/mmap_file_allocator/mmap_file_allocator_test.cpp b/vespalib/src/tests/util/mmap_file_allocator_test.cpp similarity index 99% rename from vespalib/src/tests/util/mmap_file_allocator/mmap_file_allocator_test.cpp rename to vespalib/src/tests/util/mmap_file_allocator_test.cpp index cf6227de4db5..e986c9766433 100644 --- a/vespalib/src/tests/util/mmap_file_allocator/mmap_file_allocator_test.cpp +++ b/vespalib/src/tests/util/mmap_file_allocator_test.cpp @@ -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() diff --git a/vespalib/src/tests/util/rcuvector/.gitignore b/vespalib/src/tests/util/rcuvector/.gitignore deleted file mode 100644 index 2c1661a84614..000000000000 --- a/vespalib/src/tests/util/rcuvector/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.depend -Makefile -rcuvector_test -vespalib_rcuvector_test_app - diff --git a/vespalib/src/tests/util/rcuvector/CMakeLists.txt b/vespalib/src/tests/util/rcuvector/CMakeLists.txt deleted file mode 100644 index ddc572ca825b..000000000000 --- a/vespalib/src/tests/util/rcuvector/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_rcuvector_test_app TEST - SOURCES - rcuvector_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_rcuvector_test_app COMMAND vespalib_rcuvector_test_app) diff --git a/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp b/vespalib/src/tests/util/rcuvector_test.cpp similarity index 99% rename from vespalib/src/tests/util/rcuvector/rcuvector_test.cpp rename to vespalib/src/tests/util/rcuvector_test.cpp index 134c697bd3f2..28b8bcdad06e 100644 --- a/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp +++ b/vespalib/src/tests/util/rcuvector_test.cpp @@ -516,5 +516,3 @@ TEST(RcuVectorTest, single_writer_four_readers) StressFixture f; f.run_test(20000, 4); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/size_literals/CMakeLists.txt b/vespalib/src/tests/util/size_literals/CMakeLists.txt deleted file mode 100644 index 0c32d81482cd..000000000000 --- a/vespalib/src/tests/util/size_literals/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_size_literals_test_app TEST - SOURCES - size_literals_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_size_literals_test_app COMMAND vespalib_size_literals_test_app) diff --git a/vespalib/src/tests/util/size_literals/size_literals_test.cpp b/vespalib/src/tests/util/size_literals_test.cpp similarity index 97% rename from vespalib/src/tests/util/size_literals/size_literals_test.cpp rename to vespalib/src/tests/util/size_literals_test.cpp index 93a0ee5cdb7f..8356ebc03517 100644 --- a/vespalib/src/tests/util/size_literals/size_literals_test.cpp +++ b/vespalib/src/tests/util/size_literals_test.cpp @@ -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() diff --git a/vespalib/src/tests/util/static_string/CMakeLists.txt b/vespalib/src/tests/util/static_string/CMakeLists.txt deleted file mode 100644 index 508466d4c732..000000000000 --- a/vespalib/src/tests/util/static_string/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_static_string_test_app TEST - SOURCES - static_string_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_static_string_test_app COMMAND vespalib_static_string_test_app) diff --git a/vespalib/src/tests/util/static_string/static_string_test.cpp b/vespalib/src/tests/util/static_string_test.cpp similarity index 97% rename from vespalib/src/tests/util/static_string/static_string_test.cpp rename to vespalib/src/tests/util/static_string_test.cpp index daaf7c0dae87..4d4baf459b33 100644 --- a/vespalib/src/tests/util/static_string/static_string_test.cpp +++ b/vespalib/src/tests/util/static_string_test.cpp @@ -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() diff --git a/vespalib/src/tests/util/string_escape/CMakeLists.txt b/vespalib/src/tests/util/string_escape/CMakeLists.txt deleted file mode 100644 index 86885fc66ef4..000000000000 --- a/vespalib/src/tests/util/string_escape/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_util_string_escape_test_app TEST - SOURCES - string_escape_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_util_string_escape_test_app COMMAND vespalib_util_string_escape_test_app) diff --git a/vespalib/src/tests/util/string_escape/string_escape_test.cpp b/vespalib/src/tests/util/string_escape_test.cpp similarity index 98% rename from vespalib/src/tests/util/string_escape/string_escape_test.cpp rename to vespalib/src/tests/util/string_escape_test.cpp index 313fc5eac608..053fd6d7d779 100644 --- a/vespalib/src/tests/util/string_escape/string_escape_test.cpp +++ b/vespalib/src/tests/util/string_escape_test.cpp @@ -40,5 +40,3 @@ TEST(StringEscapeTest, control_characters_are_escaped_in_content) { EXPECT_EQ(xml_content_escaped(stringref("\x00", 1)), "�"); EXPECT_EQ(xml_content_escaped("\x1f"), ""); } - -GTEST_MAIN_RUN_ALL_TESTS()