summaryrefslogtreecommitdiffhomepage
path: root/tests/fuzz
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2021-03-19 17:04:29 +0100
committerJo-Philipp Wich <jo@mein.io>2021-04-23 00:42:30 +0200
commitdf73b25de218833588a9770f6beb9e4a2908bcb7 (patch)
treedc28a1b956ad7699a13914f896f37295242a4c1e /tests/fuzz
parent41d33d0b2b09efb7b3cddefa2793cf2133a7b5dc (diff)
tests: add more tests
* add cram based tests * test under either valgrind or LLVM sanitizers * add libFuzzer template Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'tests/fuzz')
-rw-r--r--tests/fuzz/CMakeLists.txt16
-rw-r--r--tests/fuzz/corpus/.keep0
-rw-r--r--tests/fuzz/test-fuzz.c9
3 files changed, 25 insertions, 0 deletions
diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt
new file mode 100644
index 0000000..384e7e0
--- /dev/null
+++ b/tests/fuzz/CMakeLists.txt
@@ -0,0 +1,16 @@
+MACRO(ADD_FUZZER_TEST name)
+ ADD_EXECUTABLE(${name} ${name}.c)
+ TARGET_COMPILE_OPTIONS(${name} PRIVATE -g -O1 -fno-omit-frame-pointer -fsanitize=fuzzer,address,leak,undefined)
+ TARGET_INCLUDE_DIRECTORIES(${name} PRIVATE ${PROJECT_SOURCE_DIR})
+ TARGET_LINK_OPTIONS(${name} PRIVATE -stdlib=libc++ -fsanitize=fuzzer,address,leak,undefined)
+ ADD_TEST(
+ NAME ${name}
+ COMMAND ${name} -max_len=256 -timeout=10 -max_total_time=300 ${CMAKE_CURRENT_SOURCE_DIR}/corpus
+ )
+ENDMACRO(ADD_FUZZER_TEST)
+
+FILE(GLOB test_cases "test-*.c")
+FOREACH(test_case ${test_cases})
+ GET_FILENAME_COMPONENT(test_case ${test_case} NAME_WE)
+ ADD_FUZZER_TEST(${test_case})
+ENDFOREACH(test_case)
diff --git a/tests/fuzz/corpus/.keep b/tests/fuzz/corpus/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/fuzz/corpus/.keep
diff --git a/tests/fuzz/test-fuzz.c b/tests/fuzz/test-fuzz.c
new file mode 100644
index 0000000..40649e2
--- /dev/null
+++ b/tests/fuzz/test-fuzz.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <limits.h>
+
+int LLVMFuzzerTestOneInput(const uint8_t *input, size_t size)
+{
+ return 0;
+}