blob: 3da61e1c164a706c2c7fa3a9576b194ea587f135 [file] [log] [blame]
Michal Vaskob9878502022-11-11 10:00:05 +01001if(ENABLE_FUZZ_TARGETS)
Michal Vaskof9f11022022-11-18 09:02:15 +01002 set(fuzz_targets lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json yang_parse_module)
Juraj Vijtiukf3939c92019-05-14 13:07:38 +02003
Michal Vaskob9878502022-11-11 10:00:05 +01004 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 Vijtiukd7989422020-09-15 13:54:00 +020016endif()
17
Michal Vaskob9878502022-11-11 10:00:05 +010018if(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 Vijtiuk260407e2020-03-18 10:32:13 +010028endif()