From: Guilherme Maciel Ferreira Date: Sat, 21 Jan 2012 10:23:34 +0000 (-0200) Subject: Test: split test cases in N binaries. X-Git-Tag: v1.3~11^2~36 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=a72f06b655fb42fd551d75ad9c8b80c6a86cafd9;p=pingcheck Test: split test cases in N binaries. Each test in its own binary: - Allow linking of mock objects without conflicts with the original definition, which is linked in another executable; - Provide list of tests and hints on which test failed, instead of a bloated binary, which gives no hint about. --- diff --git a/test/CMakeLists.test_hoststatusanalyzer.txt b/test/CMakeLists.test_hoststatusanalyzer.txt new file mode 100644 index 0000000..5ac0172 --- /dev/null +++ b/test/CMakeLists.test_hoststatusanalyzer.txt @@ -0,0 +1,16 @@ +# compiler: creates the binaries +add_executable(test_hoststatusanalyzer + test_hoststatusanalyzer.cpp + mock_linkstatusanalyzer.cpp + ${CMAKE_SOURCE_DIR}/src/host/hoststatusanalyzer.cpp +) + +# linker: link the program against the libraries +target_link_libraries( + test_hoststatusanalyzer + ${I2NCOMMON_LIBRARIES} + ${Boost_LIBRARIES} +) + +# cmake: invocation via "make test" +add_test(test_hoststatusanalyzer test_hoststatusanalyzer) diff --git a/test/CMakeLists.test_icmpv4header.txt b/test/CMakeLists.test_icmpv4header.txt new file mode 100644 index 0000000..1e3cde4 --- /dev/null +++ b/test/CMakeLists.test_icmpv4header.txt @@ -0,0 +1,21 @@ +# compiler: creates the binaries +add_executable(test_icmpv4header + test_icmpv4header.cpp + ${CMAKE_SOURCE_DIR}/src/icmp/icmpv4header.cpp + ${CMAKE_SOURCE_DIR}/src/icmp/icmpmessage.cpp + ${CMAKE_SOURCE_DIR}/src/icmp/icmpdestinationunreachablemessage.cpp + ${CMAKE_SOURCE_DIR}/src/icmp/icmpechoreplymessage.cpp + ${CMAKE_SOURCE_DIR}/src/icmp/icmpechorequestmessage.cpp + ${CMAKE_SOURCE_DIR}/src/icmp/icmpgenericmessage.cpp + ${CMAKE_SOURCE_DIR}/src/host/messagepayload.cpp +) + +# linker: link the program against the libraries +target_link_libraries( + test_icmpv4header + ${I2NCOMMON_LIBRARIES} + ${Boost_LIBRARIES} +) + +# cmake: invocation via "make test" +add_test(test_icmpv4header test_icmpv4header) diff --git a/test/CMakeLists.test_icmpv6header.txt b/test/CMakeLists.test_icmpv6header.txt new file mode 100644 index 0000000..53e309c --- /dev/null +++ b/test/CMakeLists.test_icmpv6header.txt @@ -0,0 +1,21 @@ +# compiler: creates the binaries +add_executable(test_icmpv6header + test_icmpv6header.cpp + ${CMAKE_SOURCE_DIR}/src/icmp/icmpv6header.cpp + ${CMAKE_SOURCE_DIR}/src/icmp/icmpmessage.cpp + ${CMAKE_SOURCE_DIR}/src/icmp/icmpdestinationunreachablemessage.cpp + ${CMAKE_SOURCE_DIR}/src/icmp/icmpechoreplymessage.cpp + ${CMAKE_SOURCE_DIR}/src/icmp/icmpechorequestmessage.cpp + ${CMAKE_SOURCE_DIR}/src/icmp/icmpgenericmessage.cpp + ${CMAKE_SOURCE_DIR}/src/host/messagepayload.cpp +) + +# linker: link the program against the libraries +target_link_libraries( + test_icmpv6header + ${I2NCOMMON_LIBRARIES} + ${Boost_LIBRARIES} +) + +# cmake: invocation via "make test" +add_test(test_icmpv6header test_icmpv6header) diff --git a/test/CMakeLists.test_ipv4header.txt b/test/CMakeLists.test_ipv4header.txt new file mode 100644 index 0000000..d97cdd6 --- /dev/null +++ b/test/CMakeLists.test_ipv4header.txt @@ -0,0 +1,16 @@ +# compiler: creates the binaries +add_executable(test_ipv4header + test_ipv4header.cpp + ${CMAKE_SOURCE_DIR}/src/ip/ipv4header.cpp + ${CMAKE_SOURCE_DIR}/src/host/messagepayload.cpp +) + +# linker: link the program against the libraries +target_link_libraries( + test_ipv4header + ${I2NCOMMON_LIBRARIES} + ${Boost_LIBRARIES} +) + +# cmake: invocation via "make test" +add_test(test_ipv4header test_ipv4header) diff --git a/test/CMakeLists.test_ipv6header.txt b/test/CMakeLists.test_ipv6header.txt new file mode 100644 index 0000000..4f308bd --- /dev/null +++ b/test/CMakeLists.test_ipv6header.txt @@ -0,0 +1,16 @@ +# compiler: creates the binaries +add_executable(test_ipv6header + test_ipv6header.cpp + ${CMAKE_SOURCE_DIR}/src/ip/ipv6header.cpp + ${CMAKE_SOURCE_DIR}/src/host/messagepayload.cpp +) + +# linker: link the program against the libraries +target_link_libraries( + test_ipv6header + ${I2NCOMMON_LIBRARIES} + ${Boost_LIBRARIES} +) + +# cmake: invocation via "make test" +add_test(test_ipv6header test_ipv6header) diff --git a/test/CMakeLists.test_messagepayload.txt b/test/CMakeLists.test_messagepayload.txt new file mode 100644 index 0000000..fa555a7 --- /dev/null +++ b/test/CMakeLists.test_messagepayload.txt @@ -0,0 +1,15 @@ +# compiler: creates the binaries +add_executable(test_messagepayload + test_messagepayload.cpp + ${CMAKE_SOURCE_DIR}/src/host/messagepayload.cpp +) + +# linker: link the program against the libraries +target_link_libraries( + test_messagepayload + ${I2NCOMMON_LIBRARIES} + ${Boost_LIBRARIES} +) + +# cmake: invocation via "make test" +add_test(test_messagepayload test_messagepayload) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c1a392a..131855c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -20,49 +20,23 @@ include_directories(${CMAKE_SOURCE_DIR}/src) # compiler: include directories where the source code is located include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) -# compiler: source code from test cases -set(TESTS_SOURCES - test_messagepayload.cpp - test_hoststatusanalyzer.cpp - test_ipv4header.cpp - test_ipv6header.cpp - test_icmpv4header.cpp - test_icmpv6header.cpp -) - -# compiler: source code from mock objects -set(MOCK_SOURCES - mock_linkstatusanalyzer.cpp -) - -# compiler: source code to be tested -set(SOURCES - ${CMAKE_SOURCE_DIR}/src/host/messagepayload.cpp - ${CMAKE_SOURCE_DIR}/src/host/hoststatusanalyzer.cpp - ${CMAKE_SOURCE_DIR}/src/ip/ipv4header.cpp - ${CMAKE_SOURCE_DIR}/src/ip/ipv6header.cpp - ${CMAKE_SOURCE_DIR}/src/icmp/icmpv4header.cpp - ${CMAKE_SOURCE_DIR}/src/icmp/icmpv6header.cpp - ${CMAKE_SOURCE_DIR}/src/icmp/icmpmessage.cpp - ${CMAKE_SOURCE_DIR}/src/icmp/icmpdestinationunreachablemessage.cpp - ${CMAKE_SOURCE_DIR}/src/icmp/icmpechoreplymessage.cpp - ${CMAKE_SOURCE_DIR}/src/icmp/icmpechorequestmessage.cpp - ${CMAKE_SOURCE_DIR}/src/icmp/icmpgenericmessage.cpp -) +# cmake: enable ctest +enable_testing() -# compiler: creates the binary -add_executable(test_${TARGET} ${SOURCES} ${MOCK_SOURCES} ${TESTS_SOURCES}) +# cmake: inclusion of each test case cmake file +include(CMakeLists.test_messagepayload.txt) +include(CMakeLists.test_hoststatusanalyzer.txt) +include(CMakeLists.test_ipv4header.txt) +include(CMakeLists.test_ipv6header.txt) +include(CMakeLists.test_icmpv4header.txt) +include(CMakeLists.test_icmpv6header.txt) # cmake: add a custom "make check" target which automatically builds the binary -add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS test_${TARGET}) - -# cmake: invocation via "make test" -enable_testing() -add_test(test_${TARGET} test_${TARGET}) - -# linker: link the program against the libraries -target_link_libraries( - test_${TARGET} - ${I2NCOMMON_LIBRARIES} - ${Boost_LIBRARIES} +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS + test_messagepayload + test_hoststatusanalyzer + test_ipv4header + test_ipv6header + test_icmpv4header + test_icmpv6header ) diff --git a/test/test_hoststatusanalyzer.cpp b/test/test_hoststatusanalyzer.cpp index d795998..2e2d788 100644 --- a/test/test_hoststatusanalyzer.cpp +++ b/test/test_hoststatusanalyzer.cpp @@ -18,8 +18,8 @@ This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ +#define BOOST_TEST_MAIN #define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MESSAGE usage #include @@ -153,5 +153,3 @@ BOOST_AUTO_TEST_CASE( fail_percentage_80 ) } BOOST_AUTO_TEST_SUITE_END() - - diff --git a/test/test_icmpv4header.cpp b/test/test_icmpv4header.cpp index 4fe3940..5a3af8a 100644 --- a/test/test_icmpv4header.cpp +++ b/test/test_icmpv4header.cpp @@ -18,6 +18,7 @@ This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ +#define BOOST_TEST_MAIN #define BOOST_TEST_DYN_LINK #include diff --git a/test/test_icmpv6header.cpp b/test/test_icmpv6header.cpp index c0415b6..df24a28 100644 --- a/test/test_icmpv6header.cpp +++ b/test/test_icmpv6header.cpp @@ -18,6 +18,7 @@ This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ +#define BOOST_TEST_MAIN #define BOOST_TEST_DYN_LINK #include diff --git a/test/test_ipv4header.cpp b/test/test_ipv4header.cpp index 9931d65..fda1f3b 100644 --- a/test/test_ipv4header.cpp +++ b/test/test_ipv4header.cpp @@ -18,6 +18,7 @@ This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ +#define BOOST_TEST_MAIN #define BOOST_TEST_DYN_LINK #include diff --git a/test/test_ipv6header.cpp b/test/test_ipv6header.cpp index 5e8a030..c6053c7 100644 --- a/test/test_ipv6header.cpp +++ b/test/test_ipv6header.cpp @@ -18,6 +18,7 @@ This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ +#define BOOST_TEST_MAIN #define BOOST_TEST_DYN_LINK #include