Skip to content

Commit d852b2f

Browse files
igchorguptask
authored andcommitted
Fix tests and benchmarks compilation
Compilation of some of the tests was failing with: "undefined reference to `facebook::cachelib::test_util::getRandomAsciiStr[abi:cxx11](unsigned int)'" Fix this by linking those tests with common/TestUtils.cpp Also, for some reason specyfing sources as in add_library(common_test_support INTERFACE [sources...]) did not work. Using target_sources works fine.
1 parent cc66f6c commit d852b2f

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

cachelib/allocator/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ if (BUILD_TESTS)
8181
${DATASTRUCT_TESTS_THRIFT_FILES}
8282
./nvmcache/tests/NvmTestBase.cpp
8383
./memory/tests/TestBase.cpp
84+
../common/TestUtils.cpp
8485
)
8586
add_dependencies(allocator_test_support thrift_generated_files)
8687
target_link_libraries (allocator_test_support PUBLIC

cachelib/benchmarks/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ add_thrift_file(DATATYPEBENCH DataTypeBench.thrift frozen2)
1717
if (BUILD_TESTS)
1818
add_library (benchmark_test_support
1919
${DATATYPEBENCH_THRIFT_FILES}
20+
../common/TestUtils.cpp
2021
)
2122

2223
add_dependencies(benchmark_test_support thrift_generated_files)

cachelib/common/CMakeLists.txt

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,19 @@ install(TARGETS cachelib_common
4747

4848

4949
if (BUILD_TESTS)
50-
add_library (common_test_utils STATIC
51-
TestUtils.cpp
52-
)
53-
target_link_libraries (common_test_utils PUBLIC
50+
add_library (common_test_support INTERFACE)
51+
target_link_libraries (common_test_support INTERFACE
5452
cachelib_common
53+
common_test_utils
5554
gflags
5655
GTest::gtest
5756
GTest::gtest_main
5857
)
59-
add_library (common_test_support OBJECT
58+
target_sources(common_test_support INTERFACE
59+
TestUtils.cpp
6060
hothash/HotHashDetectorTest.cpp
6161
piecewise/GenericPiecesTest.cpp
62-
piecewise/RequestRangeTest.cpp
63-
)
64-
target_link_libraries (common_test_support PUBLIC
65-
cachelib_common
66-
common_test_utils
67-
gflags
68-
GTest::gtest
69-
GTest::gtest_main
70-
)
62+
piecewise/RequestRangeTest.cpp)
7163

7264
function (ADD_TEST SOURCE_FILE)
7365
# Add any additional libraries BEFORE the "common_test_support" to ensure

cachelib/compact_cache/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ if (BUILD_TESTS)
2323
GTest::gtest
2424
GTest::gmock
2525
)
26+
target_sources(compact_cache_test_support INTERFACE ../common/TestUtils.cpp)
2627

2728
function (ADD_TEST SOURCE_FILE)
2829
generic_add_test("compact-cache-test" "${SOURCE_FILE}"

0 commit comments

Comments
 (0)