aboutsummaryrefslogtreecommitdiff
path: root/tests/fuzz/CMakeLists.txt
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2020-04-27 18:44:14 +0200
committerAndreas Schneider <asn@cryptomilk.org>2020-05-05 14:23:06 +0200
commit62a0229f16cdde7291dcfe8cc81847631281baef (patch)
tree330dc4b48cb4d494020d985dbda2e7dceed1f3b5 /tests/fuzz/CMakeLists.txt
parent5411e0821fdd460820460e9a35fdffb554dc9e24 (diff)
downloadlibssh-62a0229f16cdde7291dcfe8cc81847631281baef.tar.gz
libssh-62a0229f16cdde7291dcfe8cc81847631281baef.tar.xz
libssh-62a0229f16cdde7291dcfe8cc81847631281baef.zip
fuzz: Simplify definition of fuzzing targets and build them also with gcc
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'tests/fuzz/CMakeLists.txt')
-rw-r--r--tests/fuzz/CMakeLists.txt39
1 files changed, 18 insertions, 21 deletions
diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt
index bfbf9c4e..5982e81c 100644
--- a/tests/fuzz/CMakeLists.txt
+++ b/tests/fuzz/CMakeLists.txt
@@ -1,26 +1,23 @@
project(fuzzing CXX)
-if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
- add_executable(ssh_client_fuzzer ssh_client_fuzzer.cpp)
- target_link_libraries(ssh_client_fuzzer
+macro(fuzzer name)
+ add_executable(${name} ${name}.cpp)
+ target_link_libraries(${name}
PRIVATE
ssh::static)
- set_target_properties(ssh_client_fuzzer
- PROPERTIES
- COMPILE_FLAGS "-fsanitize=fuzzer"
- LINK_FLAGS "-fsanitize=fuzzer")
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ set_target_properties(${name}
+ PROPERTIES
+ COMPILE_FLAGS "-fsanitize=fuzzer"
+ LINK_FLAGS "-fsanitize=fuzzer")
+ # Run the fuzzer to make sure it works
+ add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name} -runs=1)
+ else()
+ target_sources(${name} PRIVATE fuzzer.c)
+ # Run the fuzzer to make sure it works
+ # add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name} EXAMPLE)
+ endif()
+endmacro()
-
- add_executable(ssh_server_fuzzer ssh_server_fuzzer.cpp)
- target_link_libraries(ssh_server_fuzzer
- PRIVATE
- ssh::static)
- set_target_properties(ssh_server_fuzzer
- PROPERTIES
- COMPILE_FLAGS "-fsanitize=fuzzer"
- LINK_FLAGS "-fsanitize=fuzzer")
-
- # Run the fuzzer to make sure it works
- add_test(ssh_client_fuzzer ${CMAKE_CURRENT_BINARY_DIR}/ssh_client_fuzzer -runs=1)
- add_test(ssh_server_fuzzer ${CMAKE_CURRENT_BINARY_DIR}/ssh_server_fuzzer -runs=1)
-endif()
+fuzzer(ssh_client_fuzzer)
+fuzzer(ssh_server_fuzzer)