From 991f0c2a45a927e4d4f1d605a517201bd1c0c51a Mon Sep 17 00:00:00 2001 From: Jakob Petsovits Date: Thu, 16 Jul 2015 01:44:27 -0400 Subject: [PATCH] Rename test_bdecode_performance to bdecode_benchmark, fix CMake issues. It's not a test as such, since it's got its own main() that takes arguments, doesn't return a result that can be directly compared against expected results, and doesn't make use of the test_common infrastructure. The CMake build attempts to build all files named test_*.cpp with test_common, whose main() and load_file() symbols clash with those that the benchmark provides. Instead of making an exception, let's rename it to something that doesn't start with "test_". Its usage message even claims it's called bdecode_benchmark, so we use that. Also, complete the file listing for test_common in CMake and use an OBJECT pseudo-library there instead of STATIC. It's just as good and jives better with having symbols provided by the executable. (Follow-up patch in the works to provide Asio symbols that way.) test_natpmp is a proper test but doesn't currently build, so exclude it from the build for now. --- CMakeLists.txt | 23 ++++++++++--------- test/Jamfile | 2 +- test/Makefile.am | 4 ++-- ..._performance.cpp => bdecode_benchmark.cpp} | 0 4 files changed, 15 insertions(+), 14 deletions(-) rename test/{test_bdecode_performance.cpp => bdecode_benchmark.cpp} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ebca9bddf..ec8b65be1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -362,22 +362,23 @@ configure_file(examples/run_cmake.sh.in examples/run_cmake.sh) # === build tests === if(build_tests) - FILE(GLOB tests RELATIVE "${PROJECT_SOURCE_DIR}" "test/test_*.cpp") - add_library(test_common STATIC test/main.cpp test/setup_transfer.cpp - test/dht_server.cpp test/udp_tracker.cpp test/peer_server.cpp - test/web_seed_suite.cpp test/test_utils.cpp) + file(GLOB tests RELATIVE "${PROJECT_SOURCE_DIR}" "test/test_*.cpp") + list(REMOVE_ITEM tests "test/test_natpmp.cpp") # doesn't build at time of writing + list(REMOVE_ITEM tests "test/test_utils.cpp") # helper file, not a test + + add_library(test_common OBJECT test/main.cpp test/test.cpp + test/setup_transfer.cpp test/dht_server.cpp test/udp_tracker.cpp + test/peer_server.cpp test/web_seed_suite.cpp test/swarm_suite.cpp + test/test_utils.cpp) enable_testing() foreach(s ${tests}) get_filename_component (sn ${s} NAME_WE) - add_executable(${sn} ${s}) - target_link_libraries(${sn} torrent-rasterbar test_common) + add_executable(${sn} ${s} $) + target_link_libraries(${sn} torrent-rasterbar) add_test(${sn} ${s}) endforeach(s) -# add_executable(test_upnp test/test_upnp.cpp) -# target_link_libraries(test_upnp torrent-rasterbar) - -# add_executable(test_natpmp test/test_natpmp.cpp) -# target_link_libraries(test_natpmp torrent-rasterbar) + add_executable(bdecode_benchmark test/bdecode_benchmark.cpp) + target_link_libraries(bdecode_benchmark torrent-rasterbar) endif() diff --git a/test/Jamfile b/test/Jamfile index 8a3274fee..6e8fd111b 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -9,7 +9,7 @@ exe test_natpmp : test_natpmp.cpp /torrent//torrent exe enum_if : enum_if.cpp /torrent//torrent : multi on full ; -exe bdecode_benchmark : test_bdecode_performance.cpp /torrent//torrent +exe bdecode_benchmark : bdecode_benchmark.cpp /torrent//torrent : release ; explicit test_natpmp ; diff --git a/test/Makefile.am b/test/Makefile.am index 7cfefc375..c40ed349f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,7 @@ AUTOMAKE_OPTIONS = subdir-objects test_programs = \ + bdecode_benchmark \ test_primitives \ test_recheck \ test_stat_cache \ @@ -8,7 +9,6 @@ test_programs = \ test_privacy \ test_priority \ test_auto_unchoke \ - test_bdecode_performance \ test_checking \ test_fast_extension \ test_http_connection \ @@ -158,13 +158,13 @@ test_primitives_SOURCES = \ test_dos_blocker.cpp \ test_upnp.cpp +bdecode_benchmark_SOURCES = bdecode_benchmark.cpp test_recheck_SOURCES = test_recheck.cpp test_stat_cache_SOURCES = test_stat_cache.cpp test_file_SOURCES = test_file.cpp test_privacy_SOURCES = test_privacy.cpp test_priority_SOURCES = test_priority.cpp test_auto_unchoke_SOURCES = test_auto_unchoke.cpp -test_bdecode_performance_SOURCES = test_bdecode_performance.cpp test_checking_SOURCES = test_checking.cpp test_fast_extension_SOURCES = test_fast_extension.cpp test_http_connection_SOURCES = test_http_connection.cpp diff --git a/test/test_bdecode_performance.cpp b/test/bdecode_benchmark.cpp similarity index 100% rename from test/test_bdecode_performance.cpp rename to test/bdecode_benchmark.cpp