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