From aa58f26985f31cade83faee8c8ae5863a60a83ee Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 23 Jun 2013 17:36:00 +0000 Subject: [PATCH] fix dynamic linking of test library on windows --- test/Jamfile | 7 +++++++ test/main.cpp | 3 +-- test/setup_transfer.cpp | 4 +++- test/setup_transfer.hpp | 43 +++++++++++++++++++++++++--------------- test/test_primitives.cpp | 10 +++++----- 5 files changed, 43 insertions(+), 24 deletions(-) diff --git a/test/Jamfile b/test/Jamfile index 5c4af465e..1cad17be5 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -12,8 +12,15 @@ lib libtorrent_test setup_transfer.cpp dht_server.cpp peer_server.cpp + : # requirements /torrent//torrent/shared/shared/on + # this is used to determine whether + # symbols are exported or imported + shared:TORRENT_BUILDING_TEST_SHARED + + : # default build + shared ; project diff --git a/test/main.cpp b/test/main.cpp index 8f33e962e..b4c6dbf23 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -35,11 +35,10 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include // for exit() +#include "setup_transfer.hpp" // for tests_failure int test_main(); -extern bool tests_failure; - #include "libtorrent/assert.hpp" #include "libtorrent/file.hpp" #include diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index a4013ad8c..d2d41d260 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "setup_transfer.hpp" + #include "libtorrent/session.hpp" #include "libtorrent/hasher.hpp" #include "libtorrent/http_parser.hpp" @@ -533,7 +535,7 @@ int start_tracker() } boost::detail::atomic_count g_udp_tracker_requests(0); -boost::detail::atomic_count g_http_tracker_requests(0); +boost::detail::atomic_count g_http_tracker_requests(0); void on_udp_receive(error_code const& ec, size_t bytes_transferred, udp::endpoint const* from, char* buffer, udp::socket* sock) { diff --git a/test/setup_transfer.hpp b/test/setup_transfer.hpp index 7c9f5745d..be20f3adb 100644 --- a/test/setup_transfer.hpp +++ b/test/setup_transfer.hpp @@ -35,6 +35,13 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/session.hpp" #include +#include "libtorrent/config.hpp" + +#ifdef TORRENT_BUILDING_TEST_SHARED +#define EXPORT BOOST_SYMBOL_EXPORT +#else +#define EXPORT BOOST_SYMBOL_IMPORT +#endif namespace libtorrent { @@ -43,47 +50,51 @@ namespace libtorrent struct session_status; } -std::auto_ptr TORRENT_EXPORT wait_for_alert(libtorrent::session& ses, int type); +extern EXPORT bool tests_failure; -void TORRENT_EXPORT print_ses_rate(float time +void EXPORT report_failure(char const* err, char const* file, int line); + +std::auto_ptr EXPORT wait_for_alert(libtorrent::session& ses, int type); + +void EXPORT print_ses_rate(float time , libtorrent::torrent_status const* st1 , libtorrent::torrent_status const* st2 , libtorrent::torrent_status const* st3 = NULL); -bool TORRENT_EXPORT print_alerts(libtorrent::session& ses, char const* name +bool EXPORT print_alerts(libtorrent::session& ses, char const* name , bool allow_disconnects = false , bool allow_no_torrents = false , bool allow_failed_fastresume = false , bool (*)(libtorrent::alert*) = 0 , bool no_output = false); -void TORRENT_EXPORT wait_for_listen(libtorrent::session& ses, char const* name); -void TORRENT_EXPORT test_sleep(int millisec); +void EXPORT wait_for_listen(libtorrent::session& ses, char const* name); +void EXPORT test_sleep(int millisec); -extern boost::detail::atomic_count g_udp_tracker_requests; -extern boost::detail::atomic_count g_http_tracker_requests; +extern EXPORT boost::detail::atomic_count g_udp_tracker_requests; +extern EXPORT boost::detail::atomic_count g_http_tracker_requests; -void TORRENT_EXPORT create_random_files(std::string const& path, const int file_sizes[], int num_files); +void EXPORT create_random_files(std::string const& path, const int file_sizes[], int num_files); -boost::intrusive_ptr TORRENT_EXPORT create_torrent(std::ostream* file = 0 +boost::intrusive_ptr EXPORT create_torrent(std::ostream* file = 0 , int piece_size = 16 * 1024, int num_pieces = 13, bool add_tracker = true, bool encrypted = false); boost::tuple -TORRENT_EXPORT setup_transfer(libtorrent::session* ses1, libtorrent::session* ses2 +EXPORT setup_transfer(libtorrent::session* ses1, libtorrent::session* ses2 , libtorrent::session* ses3, bool clear_files, bool use_metadata_transfer = true , bool connect = true, std::string suffix = "", int piece_size = 16 * 1024 , boost::intrusive_ptr* torrent = 0, bool super_seeding = false , libtorrent::add_torrent_params const* p = 0, bool stop_lsd = true, bool encrypted_torrent = false); -int TORRENT_EXPORT start_web_server(bool ssl = false, bool chunked = false); -void TORRENT_EXPORT stop_web_server(); -int TORRENT_EXPORT start_proxy(int type); -void TORRENT_EXPORT stop_proxy(int port); +int EXPORT start_web_server(bool ssl = false, bool chunked = false); +void EXPORT stop_web_server(); +int EXPORT start_proxy(int type); +void EXPORT stop_proxy(int port); -void TORRENT_EXPORT stop_tracker(); -int TORRENT_EXPORT start_tracker(); +void EXPORT stop_tracker(); +int EXPORT start_tracker(); #endif diff --git a/test/test_primitives.cpp b/test/test_primitives.cpp index 2cbc0fe38..688118552 100644 --- a/test/test_primitives.cpp +++ b/test/test_primitives.cpp @@ -71,11 +71,11 @@ namespace libtorrent { TORRENT_EXPORT std::string sanitize_path(std::string const& p); #ifndef TORRENT_DISABLE_DHT - namespace dht - { - TORRENT_EXPORT libtorrent::dht::node_id generate_id_impl( - address const& ip_, boost::uint32_t r); - } +// namespace dht +// { +// TORRENT_EXPORT libtorrent::dht::node_id generate_id_impl( +// address const& ip_, boost::uint32_t r); +// } #endif }