From 44665f33a49556d1328031c592d64674b299b2a6 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Wed, 9 Feb 2022 19:29:36 +0100 Subject: [PATCH] fuzz: Add a testcase for each fuzzer with a corpus Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider --- tests/fuzz/CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt index 6026600c..8d9b2bea 100644 --- a/tests/fuzz/CMakeLists.txt +++ b/tests/fuzz/CMakeLists.txt @@ -15,7 +15,15 @@ macro(fuzzer name) else() target_sources(${name} PRIVATE fuzzer.c) # Run the fuzzer to make sure it works - # add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name} EXAMPLE) + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${name}_corpus") + file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/${name}_corpus/*") + set(i 0) + foreach(file ${files}) + add_test(${name}_${i} + ${CMAKE_CURRENT_BINARY_DIR}/${name} ${file}) + math(EXPR i "${i} + 1") + endforeach() + endif() endif() endmacro()