Add the Serf test suite to the CMake build.
* CMakeLists.txt: Enable testing. And APR's CFLAGS and extra libs
to the build configuration.
* test/CMakeLists.txt: Build all test programs and add all of the
serf_response tests to the suite.
git-svn-id: https://svn.apache.org/repos/asf/serf/trunk@1834270 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ea6bd7..000235a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,6 +18,7 @@
# ===================================================================
cmake_minimum_required(VERSION 3.0.2)
+enable_testing()
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build")
include(SerfVersion)
@@ -123,10 +124,14 @@
${OPENSSL_LIBRARIES}
${ZLIB_LIBRARIES}
${APR_LIBRARIES}
+ ${APR_EXTRALIBS}
${APRUTIL_LIBRARIES}
+ ${APRUTIL_EXTRALIBS}
)
list(REMOVE_DUPLICATES DEPENDENCY_LIBRARIES)
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${APR_CFLAGS}")
+
include_directories(BEFORE SYSTEM ${DEPENDENCY_INCLUDES})
include_directories(${CMAKE_SOURCE_DIR})
add_library(SerfStatic STATIC ${SOURCES})
@@ -138,4 +143,5 @@
VERSION ${SERF_VERSION}
SOVERSION ${SERF_SOVERSION})
+set(SERF_SOURCE_DIR ${CMAKE_SOURCE_DIR})
add_subdirectory(test)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index be9e77a..1bcd499 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -34,8 +34,35 @@
"MockHTTPinC/MockHTTP_server.c"
)
+set(SIMPLE_TEST_TARGETS
+ "serf_get"
+ "serf_response"
+ "serf_request"
+ "serf_spider"
+ "serf_httpd"
+ "serf_bwtp"
+)
+
add_definitions("-DMOCKHTTP_OPENSSL")
+
+foreach(TEST_TARGET ${SIMPLE_TEST_TARGETS})
+ add_executable(${TEST_TARGET} "${TEST_TARGET}.c")
+ add_dependencies(${TEST_TARGET} SerfStatic)
+ target_link_libraries(${TEST_TARGET} SerfStatic ${DEPENDENCY_LIBRARIES})
+endforeach()
+
add_executable(test_all ${TEST_ALL_SOURCES})
add_dependencies(test_all SerfStatic)
target_link_libraries(test_all SerfStatic ${DEPENDENCY_LIBRARIES})
+
+file(GLOB RESPONSE_TEST_CASES "${CMAKE_CURRENT_SOURCE_DIR}/testcases/*.response")
+foreach(TEST_CASE ${RESPONSE_TEST_CASES})
+ get_filename_component(TEST_CASE_NAME ${TEST_CASE} NAME)
+ add_test(NAME "${TEST_CASE_NAME}" COMMAND serf_response "${TEST_CASE}")
+ list(APPEND RESPONS_TESTS "${TEST_CASE_NAME}")
+endforeach()
+
add_test(NAME test_all COMMAND test_all)
+
+set_tests_properties(${RESPONS_TESTS} test_all PROPERTIES
+ ENVIRONMENT srcdir=${SERF_SOURCE_DIR})