mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2025-12-11 17:39:01 +08:00
posix: add fuzz testing using MAVLink messages
This adds the env option PX4_FUZZ which runs the LLVM libFuzzer which throws random bytes at mavlink_receiver using MAVLink messages over UDP. The MAVLink messages that are being sent are valid, so the CRC is calculated but the payload and msgid, etc. are generally garbage, unless the fuzzing gets a msgid right by chance. As I understand it, libFuzzer watches the test coverage and will try to execute as much of the code as possible.
This commit is contained in:
@@ -130,6 +130,23 @@ elseif (CMAKE_BUILD_TYPE STREQUAL UndefinedBehaviorSanitizer)
|
||||
function(sanitizer_fail_test_on_error test_name)
|
||||
set_tests_properties(${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION "runtime error:")
|
||||
endfunction(sanitizer_fail_test_on_error)
|
||||
|
||||
elseif (CMAKE_BUILD_TYPE STREQUAL FuzzTesting)
|
||||
message(STATUS "FuzzTesting enabled")
|
||||
|
||||
add_compile_options(
|
||||
-g3
|
||||
-fsanitize=fuzzer,address,undefined
|
||||
-DFUZZTESTING
|
||||
)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=fuzzer,address,undefined" CACHE INTERNAL "" FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=fuzzer,address,undefined" CACHE INTERNAL "" FORCE)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=fuzzer,address,undefined" CACHE INTERNAL "" FORCE)
|
||||
|
||||
function(sanitizer_fail_test_on_error test_name)
|
||||
# Not sure what to do here
|
||||
endfunction(sanitizer_fail_test_on_error)
|
||||
else()
|
||||
|
||||
function(sanitizer_fail_test_on_error test_name)
|
||||
|
||||
Reference in New Issue
Block a user