summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2020-12-08 12:29:59 +0100
committerPetr Štetiar <ynezz@true.cz>2020-12-11 11:17:22 +0100
commit12df67e45bb0865edecc4f963afcec79077f213e (patch)
tree2bb5f123f66d868933f68edadd6ef905dc3c9d51 /CMakeLists.txt
parentb6e34845124ff8042526afbc7e0d66b016be8771 (diff)
downloaduclient-12df67e45bb0865edecc4f963afcec79077f213e.tar.gz
Add basic cram based unit tests
For the start just basic uclient-fetch functionality coverage. Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt24
1 files changed, 22 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 841bc0f..f0388ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,12 +16,32 @@ ELSE(BUILD_STATIC)
FIND_LIBRARY(ubox_library NAMES ubox)
ENDIF(BUILD_STATIC)
-ADD_LIBRARY(uclient SHARED uclient.c uclient-http.c uclient-utils.c)
+SET(LIB_SOURCES uclient.c uclient-http.c uclient-utils.c)
+ADD_LIBRARY(uclient SHARED ${LIB_SOURCES})
TARGET_LINK_LIBRARIES(uclient ${ubox_library} dl)
-ADD_EXECUTABLE(uclient-fetch uclient-fetch.c progress.c)
+SET(CLI_SOURCES uclient-fetch.c progress.c)
+ADD_EXECUTABLE(uclient-fetch ${CLI_SOURCES})
TARGET_LINK_LIBRARIES(uclient-fetch uclient)
+IF(UNIT_TESTING)
+ ADD_DEFINITIONS(-DUNIT_TESTING)
+ ENABLE_TESTING()
+ ADD_SUBDIRECTORY(tests)
+
+ IF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ ADD_LIBRARY(uclient-san SHARED ${LIB_SOURCES})
+ TARGET_COMPILE_OPTIONS(uclient-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
+ TARGET_LINK_OPTIONS(uclient-san PRIVATE -fsanitize=undefined,address,leak)
+ TARGET_LINK_LIBRARIES(uclient-san ${ubox_library} dl)
+
+ ADD_EXECUTABLE(uclient-fetch-san ${CLI_SOURCES})
+ TARGET_COMPILE_OPTIONS(uclient-fetch-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
+ TARGET_LINK_OPTIONS(uclient-fetch-san PRIVATE -fsanitize=undefined,address,leak)
+ TARGET_LINK_LIBRARIES(uclient-fetch-san uclient-san ${ubox_library} dl)
+ ENDIF()
+ENDIF()
+
INSTALL(FILES uclient.h uclient-utils.h
DESTINATION include/libubox
)