| 1 |
# Copyright (c) 2022-2023 David Linder |
| 2 |
# Copyright (c) 2020-2021 Tobias Heider <[email protected]> |
| 3 |
# |
| 4 |
# Permission to use, copy, modify, and distribute this software for any |
| 5 |
# purpose with or without fee is hereby granted, provided that the above |
| 6 |
# copyright notice and this permission notice appear in all copies. |
| 7 |
# |
| 8 |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 |
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 |
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 |
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 |
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 |
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 |
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 |
|
| 16 |
|
| 17 |
set(SRCS) |
| 18 |
list(APPEND SRCS |
| 19 |
common.c |
| 20 |
test_parser_fuzz.c |
| 21 |
) |
| 22 |
|
| 23 |
set(CMAKE_C_COMPILER clang) |
| 24 |
add_executable(test_libfuzzer ${SRCS}) |
| 25 |
|
| 26 |
target_include_directories(test_libfuzzer |
| 27 |
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../iked |
| 28 |
) |
| 29 |
|
| 30 |
# when using clusterfuzz we need static linking and clusterfuzz' compiler arguments |
| 31 |
if (DEFINED ENV{CLUSTERFUZZLITE}) |
| 32 |
target_link_libraries(test_libfuzzer |
| 33 |
"-lm -Wl,-Bstatic -lssl -lcrypto -levent" compat iked-shared $ENV{LIB_FUZZING_ENGINE} |
| 34 |
) |
| 35 |
else() |
| 36 |
string(APPEND CMAKE_C_FLAGS " -fsanitize=fuzzer") |
| 37 |
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fsanitize=fuzzer") |
| 38 |
target_link_libraries(test_libfuzzer |
| 39 |
PRIVATE event crypto ssl compat iked-shared |
| 40 |
) |
| 41 |
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/corpus) |
| 42 |
configure_file(run_test.sh run_test.sh COPYONLY) |
| 43 |
configure_file(test_libfuzzer.dict fuzz.dict COPYONLY) |
| 44 |
endif() |
| 45 |
|
| 46 |
target_compile_options(test_libfuzzer PRIVATE ${CFLAGS}) |
| 47 |
|