summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2019-11-01 09:13:42 +0100
committerPetr Štetiar <ynezz@true.cz>2019-11-14 17:11:08 +0100
commita6e8bbefd8609a51d3e6e1e7ddd8902c14b940ab (patch)
treeccc1f56f87ea66ff9a5c0c9dc8cfb30811dad002
parent0ca93fec701a6779384c62e01fae2267922ded7a (diff)
downloaduci-a6e8bbefd8609a51d3e6e1e7ddd8902c14b940ab.tar.gz
cmake: add unit testing option and shunit2 tests
For convenient tests invocation. Signed-off-by: Petr Štetiar <ynezz@true.cz>
-rw-r--r--CMakeLists.txt5
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/shunit2/CMakeLists.txt7
3 files changed, 13 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 578c021..5720a5f 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 0000000..b7a7ccb
--- /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 0000000..42cb43f
--- /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>")