summaryrefslogtreecommitdiffstats
path: root/tests/fuzz/CMakeLists.txt
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-23 09:41:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-23 09:41:28 +0000
commit76ffd5ce84e4adb412833c8186fc6b26b656947f (patch)
tree11da7c12c05e9d2a85ec40022d43a970184bb867 /tests/fuzz/CMakeLists.txt
parentInitial commit. (diff)
downloadlibyang3-76ffd5ce84e4adb412833c8186fc6b26b656947f.tar.xz
libyang3-76ffd5ce84e4adb412833c8186fc6b26b656947f.zip
Adding upstream version 3.1.0.upstream/3.1.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/fuzz/CMakeLists.txt')
-rw-r--r--tests/fuzz/CMakeLists.txt28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt
new file mode 100644
index 0000000..3da61e1
--- /dev/null
+++ b/tests/fuzz/CMakeLists.txt
@@ -0,0 +1,28 @@
+if(ENABLE_FUZZ_TARGETS)
+ set(fuzz_targets lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json yang_parse_module)
+
+ if(FUZZER STREQUAL "AFL")
+ foreach(target_name IN LISTS fuzz_targets)
+ add_executable(${target_name}_fuzz_harness ${target_name}.c main.c)
+ target_link_libraries(${target_name}_fuzz_harness yang)
+ endforeach()
+ elseif()
+ foreach(target_name IN LISTS fuzz_targets)
+ add_executable(${target_name}_fuzz_harness ${target_name}.c)
+ set_source_files_properties(${target_name}.c PROPERTIES COMPILE_FLAGS "-fsanitize=fuzzer")
+ target_link_libraries(${target_name}_fuzz_harness yang "-fsanitize=fuzzer")
+ endforeach()
+ endif()
+endif()
+
+if(ENABLE_TESTS)
+ add_executable(fuzz_regression_test fuzz_regression_test.c)
+ set(fuzz_regression_tests lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json)
+ foreach(target_name IN LISTS fuzz_regression_tests)
+ file(COPY ${CMAKE_SOURCE_DIR}/tests/fuzz/corpus/${target_name} DESTINATION ${CMAKE_BINARY_DIR}/tests/fuzz/)
+ add_executable(regress_fuzz_${target_name} ${target_name}.c main.c)
+ set_target_properties(regress_fuzz_${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests/fuzz/${target_name}")
+ target_link_libraries(regress_fuzz_${target_name} yang)
+ add_test(NAME regress_fuzz_${target_name} COMMAND fuzz_regression_test regress_fuzz_${target_name} . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fuzz/${target_name})
+ endforeach()
+endif()