From 9c4b3ed2a70880642423ffb395a00d658a949d30 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Tue, 20 Jun 2017 14:39:05 -0700 Subject: [PATCH] Only build and run tests in variant=coverage --- CMakeLists.txt | 26 ++++++---- Jamroot | 11 ++-- example/echo-op/Jamfile | 4 +- example/http-client-ssl/Jamfile | 7 +-- example/http-client/Jamfile | 2 + example/http-crawl/Jamfile | 2 + example/server-framework/Jamfile | 2 + example/websocket-client-ssl/Jamfile | 7 +-- example/websocket-client/Jamfile | 2 + test/CMakeLists.txt | 36 +++++++------ test/Jamfile | 12 ++--- test/http/CMakeLists.txt | 30 ++++++----- test/server/CMakeLists.txt | 78 +++++++++++++++------------- 13 files changed, 123 insertions(+), 96 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05a94bb1..48b73232 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,16 +102,21 @@ endfunction() #------------------------------------------------------------------------------- if ("${VARIANT}" STREQUAL "coverage") - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") - set (CMAKE_BUILD_TYPE RELWITHDEBINFO) - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") + if (MSVC) + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") + set (CMAKE_BUILD_TYPE RELWITHDEBINFO) + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") + endif() elseif ("${VARIANT}" STREQUAL "ubasan") - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -DBEAST_NO_SLOW_TESTS=1 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/scripts/blacklist.supp") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined") - set(CMAKE_BUILD_TYPE RELWITHDEBINFO) + if (MSVC) + else() + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -DBEAST_NO_SLOW_TESTS=1 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/scripts/blacklist.supp") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined") + set(CMAKE_BUILD_TYPE RELWITHDEBINFO) + endif() elseif ("${VARIANT}" STREQUAL "debug") set(CMAKE_BUILD_TYPE DEBUG) @@ -186,5 +191,8 @@ file(GLOB_RECURSE SERVER_INCLUDES ) add_subdirectory (test) -add_subdirectory (example) +if (NOT "${VARIANT}" STREQUAL "coverage") + add_subdirectory (example) +endif() + diff --git a/Jamroot b/Jamroot index 0c436f27..18447249 100644 --- a/Jamroot +++ b/Jamroot @@ -52,19 +52,18 @@ if [ os.name ] = MACOSX using clang : : ; } -variant coverage - : +variant coverage : release - : + : "-fprofile-arcs -ftest-coverage" "-lgcov" - ; + ; variant ubasan : release : - "-DBEAST_NO_SLOW_TESTS=1 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=scripts/blacklist.supp" + "-funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=scripts/blacklist.supp" "-fsanitize=address,undefined" ; @@ -112,4 +111,4 @@ project beast ; build-project test ; -build-project example ; +#build-project example ; diff --git a/example/echo-op/Jamfile b/example/echo-op/Jamfile index 47415002..f2cb21b9 100644 --- a/example/echo-op/Jamfile +++ b/example/echo-op/Jamfile @@ -5,6 +5,8 @@ # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) # -exe echo-op/echo-op : +exe echo-op : echo_op.cpp + : + coverage:no ; diff --git a/example/http-client-ssl/Jamfile b/example/http-client-ssl/Jamfile index 47875331..6fd17bcc 100644 --- a/example/http-client-ssl/Jamfile +++ b/example/http-client-ssl/Jamfile @@ -43,7 +43,8 @@ project crypto ; -exe http-client-ssl - : +exe http-client-ssl : http_client_ssl.cpp - ; + : + coverage:no + ; diff --git a/example/http-client/Jamfile b/example/http-client/Jamfile index ce558d81..7e387a77 100644 --- a/example/http-client/Jamfile +++ b/example/http-client/Jamfile @@ -7,4 +7,6 @@ exe http-client : http_client.cpp + : + coverage:no ; diff --git a/example/http-crawl/Jamfile b/example/http-crawl/Jamfile index afb12370..9a6ce741 100644 --- a/example/http-crawl/Jamfile +++ b/example/http-crawl/Jamfile @@ -8,4 +8,6 @@ exe http-crawl : http_crawl.cpp urls_large_data.cpp + : + coverage:no ; diff --git a/example/server-framework/Jamfile b/example/server-framework/Jamfile index 73fe2bbd..6428167f 100644 --- a/example/server-framework/Jamfile +++ b/example/server-framework/Jamfile @@ -7,4 +7,6 @@ exe server-framework : main.cpp + : + coverage:no ; diff --git a/example/websocket-client-ssl/Jamfile b/example/websocket-client-ssl/Jamfile index ca5adf32..af092f27 100644 --- a/example/websocket-client-ssl/Jamfile +++ b/example/websocket-client-ssl/Jamfile @@ -43,7 +43,8 @@ project crypto ; -exe ssl-websocket-client - : +exe ssl-websocket-client : ssl_websocket_client.cpp - ; + : + coverage:no + ; diff --git a/example/websocket-client/Jamfile b/example/websocket-client/Jamfile index f09ea43a..c665aefa 100644 --- a/example/websocket-client/Jamfile +++ b/example/websocket-client/Jamfile @@ -7,4 +7,6 @@ exe websocket-client : websocket_client.cpp + : + coverage:no ; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 98981a05..ee3afd42 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,24 +6,26 @@ add_subdirectory (server) add_subdirectory (websocket) add_subdirectory (zlib) -GroupSources(extras/beast extras) -GroupSources(include/beast beast) -GroupSources(test "/") +if (NOT "${VARIANT}" STREQUAL "coverage") + GroupSources(extras/beast extras) + GroupSources(include/beast beast) + GroupSources(test "/") -add_executable (lib-tests - ${BEAST_INCLUDES} - ${EXTRAS_INCLUDES} - ../extras/beast/unit_test/main.cpp - config.cpp - core.cpp - http.cpp - version.cpp - websocket.cpp - zlib.cpp -) + add_executable (lib-tests + ${BEAST_INCLUDES} + ${EXTRAS_INCLUDES} + ../extras/beast/unit_test/main.cpp + config.cpp + core.cpp + http.cpp + version.cpp + websocket.cpp + zlib.cpp + ) -target_link_libraries(lib-tests Beast ${Boost_PROGRAM_OPTIONS_LIBRARY}) + target_link_libraries(lib-tests Beast ${Boost_PROGRAM_OPTIONS_LIBRARY}) -if (MINGW) - set_target_properties(lib-tests PROPERTIES COMPILE_FLAGS "-Wa,-mbig-obj") + if (MINGW) + set_target_properties(lib-tests PROPERTIES COMPILE_FLAGS "-Wa,-mbig-obj") + endif() endif() diff --git a/test/Jamfile b/test/Jamfile index d4387a5d..415b4d04 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -7,12 +7,12 @@ import os ; -compile config.cpp : : ; -compile core.cpp : : ; -compile http.cpp : : ; -compile version.cpp : : ; -compile websocket.cpp : : ; -compile zlib.cpp : : ; +compile config.cpp : coverage:no : ; +compile core.cpp : coverage:no : ; +compile http.cpp : coverage:no : ; +compile version.cpp : coverage:no : ; +compile websocket.cpp : coverage:no : ; +compile zlib.cpp : coverage:no : ; build-project core ; build-project http ; diff --git a/test/http/CMakeLists.txt b/test/http/CMakeLists.txt index b2067534..630230eb 100644 --- a/test/http/CMakeLists.txt +++ b/test/http/CMakeLists.txt @@ -44,18 +44,20 @@ target_link_libraries(http-tests ${Boost_CONTEXT_LIBRARY} ) -add_executable (http-bench - ${BEAST_INCLUDES} - ${EXTRAS_INCLUDES} - nodejs_parser.hpp - message_fuzz.hpp - ../../extras/beast/unit_test/main.cpp - nodejs_parser.cpp - parser_bench.cpp -) - -target_link_libraries(http-bench - Beast - ${Boost_PROGRAM_OPTIONS_LIBRARY} - ${Boost_FILESYSTEM_LIBRARY} +if (NOT "${VARIANT}" STREQUAL "coverage") + add_executable (http-bench + ${BEAST_INCLUDES} + ${EXTRAS_INCLUDES} + nodejs_parser.hpp + message_fuzz.hpp + ../../extras/beast/unit_test/main.cpp + nodejs_parser.cpp + parser_bench.cpp ) + + target_link_libraries(http-bench + Beast + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_FILESYSTEM_LIBRARY} + ) +endif() diff --git a/test/server/CMakeLists.txt b/test/server/CMakeLists.txt index 73b73dce..4989f4f7 100644 --- a/test/server/CMakeLists.txt +++ b/test/server/CMakeLists.txt @@ -1,46 +1,50 @@ # Part of Beast -GroupSources(example/server-framework framework) -GroupSources(extras/beast extras) -GroupSources(include/beast beast) +if (NOT "${VARIANT}" STREQUAL "coverage") -GroupSources(test/server "/") + GroupSources(example/server-framework framework) + GroupSources(extras/beast extras) + GroupSources(include/beast beast) -if (OPENSSL_FOUND) - include_directories(${OPENSSL_INCLUDE_DIR}) -endif() + GroupSources(test/server "/") -add_executable (server-test - ${BEAST_INCLUDES} - ${SERVER_INCLUDES} - ../../extras/beast/unit_test/main.cpp - file_body.cpp - file_service.cpp - framework.cpp - http_async_port.cpp - http_base.cpp - http_sync_port.cpp - https_ports.cpp - multi_port.cpp - rfc7231.cpp - server.cpp - service_list.cpp - ssl_certificate - ssl_stream.cpp - tests.cpp - write_msg.cpp - ws_async_port.cpp - ws_sync_port.cpp - ws_upgrade_service.cpp - wss_ports.cpp -) + if (OPENSSL_FOUND) + include_directories(${OPENSSL_INCLUDE_DIR}) + endif() -target_link_libraries(server-test - Beast - ${Boost_PROGRAM_OPTIONS_LIBRARY} - ${Boost_FILESYSTEM_LIBRARY} + add_executable (server-test + ${BEAST_INCLUDES} + ${SERVER_INCLUDES} + ../../extras/beast/unit_test/main.cpp + file_body.cpp + file_service.cpp + framework.cpp + http_async_port.cpp + http_base.cpp + http_sync_port.cpp + https_ports.cpp + multi_port.cpp + rfc7231.cpp + server.cpp + service_list.cpp + ssl_certificate + ssl_stream.cpp + tests.cpp + write_msg.cpp + ws_async_port.cpp + ws_sync_port.cpp + ws_upgrade_service.cpp + wss_ports.cpp ) -if (OPENSSL_FOUND) - target_link_libraries(server-test ${OPENSSL_LIBRARIES}) + target_link_libraries(server-test + Beast + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_FILESYSTEM_LIBRARY} + ) + + if (OPENSSL_FOUND) + target_link_libraries(server-test ${OPENSSL_LIBRARIES}) + endif() + endif()