From: Petr Štetiar Date: Sat, 3 Oct 2020 07:18:17 +0000 (+0200) Subject: tests: cram: add uci import testing on fuzzer corpus X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=ea5bbd57d0e1f3ff5fd3b8580741c46093caa845;p=project%2Fuci.git 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 --- 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=$") +SET_PROPERTY(TEST cram APPEND PROPERTY ENVIRONMENT "BUILD_BIN_DIR=$") 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]