@@ -477,14 +477,25 @@ install_module(toxcore DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tox)
477477#
478478################################################################################
479479
480+ add_library (test_util STATIC
481+ toxcore/DHT_test_util.cc
482+ toxcore/DHT_test_util.hh
483+ toxcore/crypto_core_test_util.cc
484+ toxcore/crypto_core_test_util.hh
485+ toxcore/network_test_util.cc
486+ toxcore/network_test_util.hh
487+ toxcore/test_util.cc
488+ toxcore/test_util.hh)
489+
480490function (unit_test subdir target )
481491 add_executable (unit_${target} _test ${subdir} /${target} _test.cc)
492+ target_link_libraries (unit_${target} _test PRIVATE test_util)
482493 if (TARGET toxcore_static)
483494 target_link_libraries (unit_${target} _test PRIVATE toxcore_static)
484495 else ()
485496 target_link_libraries (unit_${target} _test PRIVATE toxcore_shared)
486497 endif ()
487- target_link_libraries (unit_${target} _test PRIVATE GTest::GTest GTest::Main )
498+ target_link_libraries (unit_${target} _test PRIVATE GTest::gtest GTest::gtest_main GTest::gmock )
488499 set_target_properties (unit_${target} _test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS} " )
489500 add_test (NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target} _test)
490501 set_property (TEST ${target} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${target} .profraw" )
@@ -504,6 +515,7 @@ if(GTEST_FOUND)
504515 unit_test(toxcore mem)
505516 unit_test(toxcore mono_time)
506517 unit_test(toxcore ping_array)
518+ unit_test(toxcore test_util)
507519 unit_test(toxcore tox)
508520 unit_test(toxcore util)
509521endif ()
0 commit comments