[OpenWrt-Devel] [PATCH uci 02/18] cmake: add unit testing option and shunit2 tests

Petr Štetiar ynezz at true.cz
Mon Nov 4 19:36:41 EST 2019


For convenient tests invocation.

Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
 CMakeLists.txt               | 5 +++++
 tests/CMakeLists.txt         | 1 +
 tests/shunit2/CMakeLists.txt | 7 +++++++
 3 files changed, 13 insertions(+)
 create mode 100644 tests/CMakeLists.txt
 create mode 100644 tests/shunit2/CMakeLists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 170eb0b7b887..2559b1ec1507 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,6 +43,11 @@ ADD_LIBRARY(ucimap STATIC ucimap.c)
 
 ADD_SUBDIRECTORY(lua)
 
+IF(UNIT_TESTING)
+  ENABLE_TESTING()
+  ADD_SUBDIRECTORY(tests)
+ENDIF()
+
 INSTALL(FILES uci.h uci_config.h uci_blob.h ucimap.h
 	DESTINATION include
 )
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 000000000000..b7a7ccb0e60b
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1 @@
+ADD_SUBDIRECTORY(shunit2)
diff --git a/tests/shunit2/CMakeLists.txt b/tests/shunit2/CMakeLists.txt
new file mode 100644
index 000000000000..42cb43fd37a9
--- /dev/null
+++ b/tests/shunit2/CMakeLists.txt
@@ -0,0 +1,7 @@
+ADD_TEST(
+	NAME shunit2
+	COMMAND tests.sh
+	WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+SET_PROPERTY(TEST shunit2 APPEND PROPERTY ENVIRONMENT "UCI_BIN=$<TARGET_FILE:cli>")

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list