test: add google fuzztest to unit test build

From https://github.com/google/fuzztest.
This will now also add gtest (via cmake FetchContent)

And requires newer cmake (container updates):
CMake 3.19 or higher is required.  You are running version 3.16.3
This commit is contained in:
Beat Küng
2025-06-16 11:50:20 +02:00
parent 6daec07bbe
commit 3d1cace7b7
13 changed files with 69 additions and 116 deletions

23
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,23 @@
px4_add_git_submodule(TARGET git_fuzztest PATH "fuzztest")
message(STATUS "Adding fuzztest")
# This will also add GTest
add_subdirectory(fuzztest EXCLUDE_FROM_ALL)
# Ensure there's no -R without any filter expression since that trips newer ctest versions
if(TESTFILTER)
set(TESTFILTERARG "-R")
else()
set(TESTFILTERARG "")
endif()
add_custom_target(test_results
# antlr4_tests_NOT_BUILT gets added by fuzztest
COMMAND GTEST_COLOR=1 ${CMAKE_CTEST_COMMAND} --output-on-failure -T Test ${TESTFILTERARG} ${TESTFILTER} --exclude-regex "antlr4_tests_NOT_BUILT"
DEPENDS
px4
examples__dyn_hello
USES_TERMINAL
COMMENT "Running tests"
WORKING_DIRECTORY ${PX4_BINARY_DIR})
set_target_properties(test_results PROPERTIES EXCLUDE_FROM_ALL TRUE)

1
test/fuzztest Submodule

Submodule test/fuzztest added at 1e47f9d743