Cleanup build system for tests and add generic 'build_tests' target.
authorHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 25 Apr 2018 07:42:05 +0000 (09:42 +0200)
committerHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 25 Apr 2018 07:42:05 +0000 (09:42 +0200)
tests/CMakeLists.txt
tests/common/CMakeLists.txt
tests/config/CMakeLists.txt
tests/rfc5444/CMakeLists.txt
tests/rfc5444/interop2010/CMakeLists.txt
tests/rfc5444/special/CMakeLists.txt

index d9cb75d..73676b4 100644 (file)
@@ -1,6 +1,30 @@
 # add test directories
 include_directories(.)
 
+function (oonf_create_test executable source libraries objects)
+    # create executable
+    message ("Test ${executable}: source=${source} libs=${libraries}")
+    ADD_EXECUTABLE(${executable} ${source} ${objects})
+
+    add_dependencies(build_tests ${executable})
+
+    TARGET_LINK_LIBRARIES(${executable} ${libraries})
+    TARGET_LINK_LIBRARIES(${executable} static_cunit)
+
+    # link regex for windows and android
+    IF (WIN32 OR ANDROID)
+        TARGET_LINK_LIBRARIES(${executable} oonf_regex)
+    ENDIF(WIN32 OR ANDROID)
+
+    # link extra win32 libs
+    IF(WIN32)
+        SET_TARGET_PROPERTIES(${executable} PROPERTIES ENABLE_EXPORTS true)
+        TARGET_LINK_LIBRARIES(${executable} ws2_32 iphlpapi)
+    ENDIF(WIN32)
+
+    ADD_TEST(NAME ${executable} COMMAND ${executable})
+endfunction (oonf_create_test)
+
 add_subdirectory(cunit)
 add_subdirectory(common)
 add_subdirectory(config)
index ce10534..4ec4c48 100644 (file)
@@ -1,22 +1,3 @@
-function(compile_common_test executable source)
-    # create executable
-    ADD_EXECUTABLE(${executable} ${source})
-
-    TARGET_LINK_LIBRARIES(${executable} oonf_common)
-    TARGET_LINK_LIBRARIES(${executable} static_cunit)
-    
-    # link regex for windows and android
-    IF (WIN32 OR ANDROID)
-        TARGET_LINK_LIBRARIES(${executable} oonf_regex)
-    ENDIF(WIN32 OR ANDROID)
-
-    # link extra win32 libs
-    IF(WIN32)
-        SET_TARGET_PROPERTIES(${executable} PROPERTIES ENABLE_EXPORTS true)
-        TARGET_LINK_LIBRARIES(${executable} ws2_32 iphlpapi)
-    ENDIF(WIN32)
-endfunction(compile_common_test)
-
 # just run all of these tests
 set(TESTS test_common_avl
           test_common_bitstream
@@ -24,9 +5,10 @@ set(TESTS test_common_avl
           test_common_list
           test_common_netaddr
           test_common_string
-          test_common_regex)
+          test_common_regex
+          )
+set (LIBS oonf_common)
 
 foreach(TEST ${TESTS})
-    compile_common_test(${TEST} ${TEST}.c)
-    ADD_TEST(NAME ${TEST} COMMAND ${TEST})
+    oonf_create_test(${TEST} ${TEST}.c "oonf_common" "")
 endforeach(TEST)
index e2aa9b9..4b6d3f8 100644 (file)
@@ -1,31 +1,12 @@
-function(compile_config_test executable source)
-    # create executable
-    ADD_EXECUTABLE(${executable} ${source})
-
-    TARGET_LINK_LIBRARIES(${executable} oonf_config)
-    TARGET_LINK_LIBRARIES(${executable} oonf_common)
-    TARGET_LINK_LIBRARIES(${executable} static_cunit)
-
-    # link regex for windows and android
-    IF (WIN32 OR ANDROID)
-        TARGET_LINK_LIBRARIES(${executable} oonf_regex)
-    ENDIF(WIN32 OR ANDROID)
-
-    # link extra win32 libs
-    IF(WIN32)
-        SET_TARGET_PROPERTIES(${executable} PROPERTIES ENABLE_EXPORTS true)
-        TARGET_LINK_LIBRARIES(${executable} ws2_32 iphlpapi)
-    ENDIF(WIN32)
-endfunction(compile_config_test)
-
 set(TESTS test_config_list
           test_config_validation
           test_config_mapping
           test_config_cmd
           test_config_default
-          test_config_delta)
+          test_config_delta
+          )
+set (LIBS oonf_common oonf_config)
 
 foreach(TEST ${TESTS})
-    compile_config_test(${TEST} ${TEST}.c)
-    ADD_TEST(NAME ${TEST} COMMAND ${TEST})
+    oonf_create_test(${TEST} "${TEST}.c" "${LIBS}" "")
 endforeach(TEST)
index ad71328..7dd517e 100644 (file)
@@ -1,34 +1,15 @@
-function(compile_rfc5444_test executable source)
-    # create executable
-    ADD_EXECUTABLE(${executable} ${source} $<TARGET_OBJECTS:oonf_static_rfc5444_api>)
-
-    TARGET_LINK_LIBRARIES(${executable} oonf_common)
-    TARGET_LINK_LIBRARIES(${executable} static_cunit)
-
-    # link regex for windows and android
-    IF (WIN32 OR ANDROID)
-        TARGET_LINK_LIBRARIES(${executable} oonf_regex)
-    ENDIF(WIN32 OR ANDROID)
-
-    # link extra win32 libs
-    IF(WIN32)
-        SET_TARGET_PROPERTIES(${executable} PROPERTIES ENABLE_EXPORTS true)
-        TARGET_LINK_LIBRARIES(${executable} ws2_32 iphlpapi)
-    ENDIF(WIN32)
-endfunction(compile_rfc5444_test)
-
-include_directories(${CMAKE_SOURCE_DIR}/src-plugins/subsystems)
-
 set(TESTS test_rfc5444_reader_blockcb
           test_rfc5444_reader_dropcontext
           test_rfc5444_writer_fragmentation
           test_rfc5444_writer_ifspecific
           test_rfc5444_writer_mandatory
-          test_rfc5444)
+          test_rfc5444
+          )
+set (LIBS oonf_common oonf_config)
 
+include_directories(${CMAKE_SOURCE_DIR}/src-plugins/subsystems)
 foreach(TEST ${TESTS})
-    compile_rfc5444_test(${TEST} ${TEST}.c)
-    ADD_TEST(NAME ${TEST} COMMAND ${TEST})
+    oonf_create_test(${TEST} "${TEST}.c" "${LIBS}" "$<TARGET_OBJECTS:oonf_static_rfc5444_api>")
 endforeach(TEST)
 
 add_subdirectory(interop2010)
index dac5d93..43fb4f1 100644 (file)
@@ -38,25 +38,10 @@ set(TEST test_rfc5444_interop2010_01.c
          test_rfc5444_interop2010_36.c
          
          test_rfc5444_interop2010_38.c
-         )
-
-# create executable
-ADD_EXECUTABLE(test_rfc5444_interop2010 ${TEST}
-                                        test_rfc5444_interop2010.c 
-                                        $<TARGET_OBJECTS:oonf_static_rfc5444_api>)
-
-TARGET_LINK_LIBRARIES(test_rfc5444_interop2010 oonf_common)
-TARGET_LINK_LIBRARIES(test_rfc5444_interop2010 static_cunit)
 
-# link regex for windows and android
-IF (WIN32 OR ANDROID)
-    TARGET_LINK_LIBRARIES(test_rfc5444_interop2010 oonf_regex)
-ENDIF(WIN32 OR ANDROID)
-
-# link extra win32 libs
-IF(WIN32)
-    SET_TARGET_PROPERTIES(test_rfc5444_interop2010 PROPERTIES ENABLE_EXPORTS true)
-    TARGET_LINK_LIBRARIES(test_rfc5444_interop2010 ws2_32 iphlpapi)
-ENDIF(WIN32)
+         test_rfc5444_interop2010.c
+         )
+set (LIBS oonf_common oonf_config)
 
-ADD_TEST(NAME test_rfc5444_interop2010 COMMAND test_rfc5444_interop2010)
+include_directories(${CMAKE_SOURCE_DIR}/src-plugins/subsystems)
+oonf_create_test("test_rfc5444_interop2010" "${TEST}" "${LIBS}" "$<TARGET_OBJECTS:oonf_static_rfc5444_api>")
index 6c4c0b1..f582659 100644 (file)
@@ -1,30 +1,11 @@
-function(compile_rfc5444_test executable source)
-    # create executable
-    ADD_EXECUTABLE(${executable} ${source}
-                                 $<TARGET_OBJECTS:oonf_static_rfc5444_api>)
-
-    TARGET_LINK_LIBRARIES(${executable} oonf_common)
-    TARGET_LINK_LIBRARIES(${executable} static_cunit)
-
-    # link regex for windows and android
-    IF (WIN32 OR ANDROID)
-        TARGET_LINK_LIBRARIES(${executable} oonf_regex)
-    ENDIF(WIN32 OR ANDROID)
-
-    # link extra win32 libs
-    IF(WIN32)
-        SET_TARGET_PROPERTIES(${executable} PROPERTIES ENABLE_EXPORTS true)
-        TARGET_LINK_LIBRARIES(${executable} ws2_32 iphlpapi)
-    ENDIF(WIN32)
-endfunction(compile_rfc5444_test)
-
 set(TESTS test_nhdp_1
           test_nhdp_2
           test_nhdp_3
           test_olsrv2_1
-)
+          )
+set (LIBS oonf_common oonf_config)
 
+include_directories(${CMAKE_SOURCE_DIR}/src-plugins/subsystems)
 foreach(TEST ${TESTS})
-    compile_rfc5444_test(${TEST} ${TEST}.c)
-    ADD_TEST(NAME ${TEST} COMMAND ${TEST})
+    oonf_create_test(${TEST} "${TEST}.c" "${LIBS}" "$<TARGET_OBJECTS:oonf_static_rfc5444_api>")
 endforeach(TEST)