[PATCH uci 4/6] tests: cram: add uci import testing on fuzzer corpus
Petr Štetiar
ynezz at true.cz
Sat Oct 3 03:48:28 EDT 2020
Use valgrind and uci cli compiled with undefined, address and leak
sanitizers.
Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
tests/cram/CMakeLists.txt | 7 ++++++-
tests/cram/test-san_uci_import.t | 15 +++++++++++++++
tests/cram/test_uci_import.t | 15 +++++++++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 tests/cram/test-san_uci_import.t
create mode 100644 tests/cram/test_uci_import.t
diff --git a/tests/cram/CMakeLists.txt b/tests/cram/CMakeLists.txt
index 06c7c9419c7e..175c0671a558 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 000000000000..7faed221f93e
--- /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 000000000000..8d5ab74ed4e7
--- /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]
More information about the openwrt-devel
mailing list