Browse Source

cmake: add unit testing option and shunit2 tests

For convenient tests invocation.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
Petr Štetiar 4 years ago
parent
commit
a6e8bbefd8
3 changed files with 13 additions and 0 deletions
  1. 5 0
      CMakeLists.txt
  2. 1 0
      tests/CMakeLists.txt
  3. 7 0
      tests/shunit2/CMakeLists.txt

+ 5 - 0
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
 )

+ 1 - 0
tests/CMakeLists.txt

@@ -0,0 +1 @@
+ADD_SUBDIRECTORY(shunit2)

+ 7 - 0
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>")