Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame] | 1 | if(ENABLE_FUZZ_TARGETS) |
Michal Vasko | f9f1102 | 2022-11-18 09:02:15 +0100 | [diff] [blame] | 2 | set(fuzz_targets lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json yang_parse_module) |
Juraj Vijtiuk | f3939c9 | 2019-05-14 13:07:38 +0200 | [diff] [blame] | 3 | |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame] | 4 | if(FUZZER STREQUAL "AFL") |
| 5 | foreach(target_name IN LISTS fuzz_targets) |
| 6 | add_executable(${target_name}_fuzz_harness ${target_name}.c main.c) |
| 7 | target_link_libraries(${target_name}_fuzz_harness yang) |
| 8 | endforeach() |
| 9 | elseif() |
| 10 | foreach(target_name IN LISTS fuzz_targets) |
| 11 | add_executable(${target_name}_fuzz_harness ${target_name}.c) |
| 12 | set_source_files_properties(${target_name}.c PROPERTIES COMPILE_FLAGS "-fsanitize=fuzzer") |
| 13 | target_link_libraries(${target_name}_fuzz_harness yang "-fsanitize=fuzzer") |
| 14 | endforeach() |
| 15 | endif() |
Juraj Vijtiuk | d798942 | 2020-09-15 13:54:00 +0200 | [diff] [blame] | 16 | endif() |
| 17 | |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame] | 18 | if(ENABLE_TESTS) |
| 19 | add_executable(fuzz_regression_test fuzz_regression_test.c) |
| 20 | set(fuzz_regression_tests lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json) |
| 21 | foreach(target_name IN LISTS fuzz_regression_tests) |
| 22 | file(COPY ${CMAKE_SOURCE_DIR}/tests/fuzz/corpus/${target_name} DESTINATION ${CMAKE_BINARY_DIR}/tests/fuzz/) |
| 23 | add_executable(regress_fuzz_${target_name} ${target_name}.c main.c) |
| 24 | set_target_properties(regress_fuzz_${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests/fuzz/${target_name}") |
| 25 | target_link_libraries(regress_fuzz_${target_name} yang) |
| 26 | add_test(NAME regress_fuzz_${target_name} COMMAND fuzz_regression_test regress_fuzz_${target_name} . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fuzz/${target_name}) |
| 27 | endforeach() |
Juraj Vijtiuk | 260407e | 2020-03-18 10:32:13 +0100 | [diff] [blame] | 28 | endif() |