mirror of https://github.com/oxen-io/lokinet
Add cmake "check" target to run all tests
Renames the cmake Catch2 test target to "catch" (instead of "check") and adds a "rungtest" for gtest (because the "gtest" target is already taken by the gtest library itself), and then repurposes the "check" target to run both test suite binaries. Also updates the top-level Makefile to do the same thing, except that there the gtest target is just "gtest" instead of "rungtest".
This commit is contained in:
parent
98c34d995b
commit
561bfe24c0
18
Makefile
18
Makefile
|
@ -179,7 +179,6 @@ release-compile: release-configure
|
|||
$(TARGETS): release-compile
|
||||
|
||||
release: $(TARGETS)
|
||||
make -C '$(BUILD_ROOT)' test
|
||||
make -C '$(BUILD_ROOT)' check
|
||||
|
||||
shadow-configure: clean
|
||||
|
@ -219,13 +218,16 @@ testnet: $(TESTNET_VENV)
|
|||
$(PYTHON3) $(REPO)/contrib/testnet/genconf.py --bin=$(TESTNET_EXE) --svc=$(TESTNET_SERVERS) --clients=$(TESTNET_CLIENTS) --dir=$(TESTNET_ROOT) --out $(TESTNET_CONF) --ifname=$(TESTNET_IFNAME) --baseport=$(TESTNET_BASEPORT) --ip=$(TESTNET_IP) --netid=$(TESTNET_NETID) --lokid='$(TESTNET_VENV)/bin/python $(REPO)/contrib/testnet/lokid.py'
|
||||
LLARP_DEBUG=$(TESTNET_DEBUG) supervisord -n -d $(TESTNET_ROOT) -l $(TESTNET_LOG) -c $(TESTNET_CONF)
|
||||
|
||||
$(TEST_EXE): debug
|
||||
gtest: debug
|
||||
test x$(CROSS) = xOFF && $(MAKE) -C $(BUILD_ROOT) rungtest || test x$(CROSS) = xON
|
||||
|
||||
gtest: $(TEST_EXE)
|
||||
test x$(CROSS) = xOFF && $(TEST_EXE) || test x$(CROSS) = xON
|
||||
catch: debug
|
||||
test x$(CROSS) = xOFF && $(MAKE) -C $(BUILD_ROOT) catch || test x$(CROSS) = xON
|
||||
|
||||
test: gtest
|
||||
$(MAKE) -C $(BUILD_ROOT) check
|
||||
check: debug
|
||||
test x$(CROSS) = xOFF && $(MAKE) -C $(BUILD_ROOT) check || test x$(CROSS) = xON
|
||||
|
||||
test: check
|
||||
|
||||
static-configure: $(LIBUV_PREFIX) $(LIBCURL_PREFIX)
|
||||
(test x$(TOOLCHAIN) = x && $(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Release -DSTATIC_LINK=ON -DRELEASE_MOTTO="$(shell cat motto.txt)" -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT='$(LIBUV_PREFIX)' -DLIBCURL_ROOT='$(LIBCURL_PREFIX)' ) || (test x$(TOOLCHAIN) != x && $(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Release -DSTATIC_LINK=ON -DRELEASE_MOTTO="$(shell cat motto.txt)" -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT='$(LIBUV_PREFIX)' -DLIBCURL_ROOT='$(LIBCURL_PREFIX)' -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN) -DNATIVE_BUILD=OFF )
|
||||
|
@ -309,7 +311,7 @@ coverage-config: clean
|
|||
|
||||
coverage: coverage-config
|
||||
$(MAKE) -C $(BUILD_ROOT)
|
||||
test x$(CROSS) = xOFF && $(TEST_EXE) || true # continue even if tests fail
|
||||
test x$(CROSS) = xOFF && $(MAKE) -C $(BUILD_ROOT) check || true # continue even if tests fail
|
||||
mkdir -p "$(COVERAGE_OUTDIR)"
|
||||
ifeq ($(CLANG),OFF)
|
||||
gcovr -r . --branches --html --html-details -o "$(COVERAGE_OUTDIR)/lokinet.html"
|
||||
|
@ -346,7 +348,7 @@ debian: debian-configure
|
|||
cp $(EXE) lokinet
|
||||
|
||||
debian-test:
|
||||
test x$(CROSS) = xOFF && $(TEST_EXE) || test x$(CROSS) = xON
|
||||
test x$(CROSS) = xOFF && $(MAKE) -C $(BUILD_ROOT) check || test x$(CROSS) = xON
|
||||
|
||||
install:
|
||||
DESTDIR=$(DESTDIR) $(MAKE) -C '$(BUILD_ROOT)' install
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set(TEST_EXE testAll)
|
||||
set(CHECK_EXE checkAll)
|
||||
set(GTEST_EXE testAll)
|
||||
set(CATCH_EXE catchAll)
|
||||
|
||||
|
||||
list(APPEND TEST_SRC
|
||||
# Old gtest-based tests; new tests should use Catch2, instead.
|
||||
list(APPEND GTEST_SRC
|
||||
config/test_llarp_config_config.cpp
|
||||
config/test_llarp_config_ini.cpp
|
||||
crypto/test_llarp_crypto_types.cpp
|
||||
|
@ -45,39 +45,44 @@ list(APPEND TEST_SRC
|
|||
util/thread/test_llarp_util_thread_pool.cpp
|
||||
)
|
||||
|
||||
add_executable(${TEST_EXE}
|
||||
add_executable(${GTEST_EXE}
|
||||
# helpers
|
||||
main.cpp
|
||||
crypto/mock_crypto.cpp
|
||||
dht/mock_context.cpp
|
||||
test_util.cpp
|
||||
# actual test cases
|
||||
${TEST_SRC}
|
||||
${GTEST_SRC}
|
||||
)
|
||||
|
||||
target_link_libraries(${TEST_EXE} PUBLIC gmock gtest ${STATIC_LIB})
|
||||
target_include_directories(${TEST_EXE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(${GTEST_EXE} PUBLIC gmock gtest ${STATIC_LIB})
|
||||
target_include_directories(${GTEST_EXE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(${TEST_EXE} PUBLIC absl::variant)
|
||||
target_link_libraries(${GTEST_EXE} PUBLIC absl::variant)
|
||||
else()
|
||||
target_sources(${TEST_EXE} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/win32/test.rc")
|
||||
target_link_libraries(${TEST_EXE} PUBLIC ws2_32 iphlpapi shlwapi)
|
||||
target_sources(${GTEST_EXE} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/win32/test.rc")
|
||||
target_link_libraries(${GTEST_EXE} PUBLIC ws2_32 iphlpapi shlwapi)
|
||||
endif(NOT WIN32)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
target_link_directories(${TEST_EXE} PRIVATE /usr/local/lib)
|
||||
target_link_directories(${GTEST_EXE} PRIVATE /usr/local/lib)
|
||||
endif()
|
||||
|
||||
add_subdirectory(Catch2)
|
||||
|
||||
add_executable(${CHECK_EXE}
|
||||
add_executable(${CATCH_EXE}
|
||||
nodedb/test_nodedb.cpp
|
||||
path/test_path.cpp
|
||||
util/test_llarp_util_str.cpp
|
||||
check_main.cpp)
|
||||
|
||||
target_link_libraries(${CHECK_EXE} PUBLIC ${STATIC_LIB} Catch2::Catch2)
|
||||
target_include_directories(${CHECK_EXE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(${CATCH_EXE} PUBLIC ${STATIC_LIB} Catch2::Catch2)
|
||||
target_include_directories(${CATCH_EXE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_custom_target(check COMMAND ${CHECK_EXE})
|
||||
# Custom targets to invoke the different test suites:
|
||||
add_custom_target(catch COMMAND ${CATCH_EXE})
|
||||
add_custom_target(rungtest COMMAND ${GTEST_EXE})
|
||||
|
||||
# Add a custom "check" target that runs all the test suites:
|
||||
add_custom_target(check DEPENDS rungtest catch)
|
||||
|
|
Loading…
Reference in New Issue