diff options
author | Petr Štetiar <ynezz@true.cz> | 2020-10-03 09:18:17 +0200 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2020-10-03 09:46:18 +0200 |
commit | ea5bbd57d0e1f3ff5fd3b8580741c46093caa845 (patch) | |
tree | e4652d2155f0cfdac3ce835a25b8bacbb5a829f1 | |
parent | 31f78bfbf75f6b039fd71ddb0988637348f276a6 (diff) | |
download | uci-ea5bbd57d0e1f3ff5fd3b8580741c46093caa845.tar.gz |
tests: cram: add uci import testing on fuzzer corpus
Use valgrind and uci cli compiled with undefined, address and leak
sanitizers.
Signed-off-by: Petr Štetiar <ynezz@true.cz>
-rw-r--r-- | tests/cram/CMakeLists.txt | 7 | ||||
-rw-r--r-- | tests/cram/test-san_uci_import.t | 15 | ||||
-rw-r--r-- | tests/cram/test_uci_import.t | 15 |
3 files changed, 36 insertions, 1 deletions
diff --git a/tests/cram/CMakeLists.txt b/tests/cram/CMakeLists.txt index 06c7c94..175c067 100644 --- a/tests/cram/CMakeLists.txt +++ b/tests/cram/CMakeLists.txt @@ -1,6 +1,10 @@ FIND_PACKAGE(PythonInterp 3 REQUIRED) FILE(GLOB test_cases "test_*.t") +IF(CMAKE_C_COMPILER_ID STREQUAL "Clang") + FILE(GLOB test_cases_san "test-san_*.t") +ENDIF() + SET(PYTHON_VENV_DIR "${CMAKE_CURRENT_BINARY_DIR}/.venv") SET(PYTHON_VENV_PIP "${PYTHON_VENV_DIR}/bin/pip") SET(PYTHON_VENV_CRAM "${PYTHON_VENV_DIR}/bin/cram") @@ -14,8 +18,9 @@ ADD_CUSTOM_TARGET(prepare-cram-venv ALL DEPENDS ${PYTHON_VENV_CRAM}) ADD_TEST( NAME cram - COMMAND ${PYTHON_VENV_CRAM} ${test_cases} + COMMAND ${PYTHON_VENV_CRAM} ${test_cases} ${test_cases_san} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) SET_PROPERTY(TEST cram APPEND PROPERTY ENVIRONMENT "UCI_LUA=$<TARGET_FILE:uci_lua>") +SET_PROPERTY(TEST cram APPEND PROPERTY ENVIRONMENT "BUILD_BIN_DIR=$<TARGET_FILE_DIR:uci>") diff --git a/tests/cram/test-san_uci_import.t b/tests/cram/test-san_uci_import.t new file mode 100644 index 0000000..7faed22 --- /dev/null +++ b/tests/cram/test-san_uci_import.t @@ -0,0 +1,15 @@ +check that uci import is producing expected results: + + $ [ -n "$BUILD_BIN_DIR" ] && export PATH="$BUILD_BIN_DIR:$PATH" + $ export TEST_INPUTS="$TESTDIR/inputs" + $ export FUZZ_CORPUS="$TESTDIR/../fuzz/corpus" + + $ for file in $(LC_ALL=C find $FUZZ_CORPUS -type f | sort ); do + > uci-san import -f $file; \ + > done + uci-san: I/O error + uci-san: Parse error (invalid command) at line 0, byte 0 + uci-san: Parse error (invalid command) at line 1, byte 18 + uci-san: I/O error + uci-san: I/O error + [1] diff --git a/tests/cram/test_uci_import.t b/tests/cram/test_uci_import.t new file mode 100644 index 0000000..8d5ab74 --- /dev/null +++ b/tests/cram/test_uci_import.t @@ -0,0 +1,15 @@ +check that uci import is producing expected results: + + $ [ -n "$BUILD_BIN_DIR" ] && export PATH="$BUILD_BIN_DIR:$PATH" + $ export TEST_INPUTS="$TESTDIR/inputs" + $ export FUZZ_CORPUS="$TESTDIR/../fuzz/corpus" + + $ for file in $(LC_ALL=C find $FUZZ_CORPUS -type f | sort ); do + > valgrind --quiet --leak-check=full uci import -f $file; \ + > done + uci: I/O error + uci: Parse error (invalid command) at line 0, byte 0 + uci: Parse error (invalid command) at line 1, byte 18 + uci: I/O error + uci: I/O error + [1] |