From 15dd15d0d68f7ec77f8ff0ea7f8785c6544c0792 Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 5 Jun 2015 02:31:52 -0400 Subject: [PATCH] fix no-deprecated build. extend .travis.yml to build the 3 test configurations too. rename README to README.rst --- .travis.yml | 11 ++++---- LICENSE | 20 ------------- Makefile.am | 1 + README => README.rst | 8 +++++- include/libtorrent/aux_/session_impl.hpp | 3 ++ include/libtorrent/session.hpp | 2 +- include/libtorrent/settings_pack.hpp | 10 +++---- src/session.cpp | 2 +- test/test_dht.cpp | 5 ---- test/test_fast_extension.cpp | 9 +++--- test/test_magnet.cpp | 9 ++---- test/test_metadata_extension.cpp | 21 +++++++------- test/test_pex.cpp | 9 +++--- test/test_priority.cpp | 11 ++++++-- test/test_read_piece.cpp | 8 +++--- test/test_recheck.cpp | 5 +++- test/test_remap_files.cpp | 36 ++++++++++++++++-------- test/test_ssl.cpp | 4 +-- test/test_tracker.cpp | 17 ++++++----- test/test_trackers_extension.cpp | 7 ++--- test/test_transfer.cpp | 19 ++++++++----- test/test_utp.cpp | 10 +++---- test/test_web_seed_redirect.cpp | 3 +- 23 files changed, 116 insertions(+), 114 deletions(-) rename README => README.rst (79%) diff --git a/.travis.yml b/.travis.yml index 141756e87..0e70cb074 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,18 @@ language: cpp before_script: - - if [ $TRAVIS_OS_NAME == linux ]; then sudo add-apt-repository -y ppa:boost-latest/ppa; sudo apt-get update -qq; sudo apt-get install libboost1.54-all-dev; fi + - if [ $TRAVIS_OS_NAME == linux ]; then sudo add-apt-repository -y ppa:boost-latest/ppa; sudo apt-get update -qq; fi + - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install libboost1.54-all-dev; fi - if [ $TRAVIS_OS_NAME == osx ]; then sudo brew install boost boost-build; fi - echo "using gcc ;" >~/user-config.jam - echo "using clang ;" >>~/user-config.jam script: - cd test - - bjam -j2 $CC - - bjam -j2 variant=test_debug $CC - - bjam -j2 variant=test_release $CC - - bjam -j2 variant=test_barebones $CC + - bjam -j2 warnings=off $CC + - bjam -j2 variant=test_debug warnings=off -l600 $CC + - bjam -j2 variant=test_release warnings=off -l600 $CC + - bjam -j2 variant=test_barebones warnings=off -l600 $CC compiler: - gcc diff --git a/LICENSE b/LICENSE index ace31db32..70c6c1546 100644 --- a/LICENSE +++ b/LICENSE @@ -58,26 +58,6 @@ format: ------------------------------------------------------------------------------ -GeoIP.c - -Copyright (C) 2006 MaxMind LLC - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - ------------------------------------------------------------------------------- - Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization diff --git a/Makefile.am b/Makefile.am index ab44a3c50..5d5e20bff 100644 --- a/Makefile.am +++ b/Makefile.am @@ -124,6 +124,7 @@ EXTRA_DIST = \ CMakeLists.txt \ setup.py \ LICENSE \ + README.rst \ $(DOCS_PAGES) \ $(DOCS_IMAGES) \ $(ED25519_SOURCE) diff --git a/README b/README.rst similarity index 79% rename from README rename to README.rst index c74f4a172..b5b122ff3 100644 --- a/README +++ b/README.rst @@ -1,3 +1,6 @@ +libtorrent +---------- + libtorrent is an open source C++ library implementing the BitTorrent protocol, along with most popular extensions, making it suitable for real world deployment. It is configurable to be able to fit both servers and embedded @@ -9,10 +12,13 @@ See `libtorrent.org`__ for more detailed build and usage instructions. .. __: http://libtorrent.org -To build with boost-build, run: +To build with boost-build, make sure boost and boost-build is installed and run: b2 +In the libtorrent root. To build the examples, run ``b2`` in the ``examples`` +directory. + See `building.html`__ for more details on how to build and which configuration options are available. For python bindings, see `the python docs`__. diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index b8ca455b8..7eed2b199 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -95,6 +95,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_class_type_filter.hpp" #include "libtorrent/kademlia/dht_observer.hpp" #include "libtorrent/resolver.hpp" +#include "libtorrent/invariant_check.hpp" #if TORRENT_COMPLETE_TYPES_REQUIRED #include "libtorrent/peer_connection.hpp" @@ -170,7 +171,9 @@ namespace libtorrent #ifdef TORRENT_DEBUG // friend class ::libtorrent::peer_connection; #endif +#if TORRENT_USE_INVARIANT_CHECKS friend class libtorrent::invariant_access; +#endif typedef std::set > connection_map; #if TORRENT_HAS_BOOST_UNORDERED typedef boost::unordered_map > torrent_map; diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 485a14379..0c142c3fc 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -188,7 +188,7 @@ namespace libtorrent // nat-pmp) and default plugins (ut_metadata, ut_pex and smart_ban). The // default is to start those features. If you do not want them to start, // pass 0 as the flags parameter. - session(settings_pack const& pack + session(settings_pack const& pack = settings_pack() , int flags = start_default_features | add_default_plugins) { TORRENT_CFG(); diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 8dd30d69f..36a379c10 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -90,7 +90,7 @@ namespace libtorrent std::string get_str(int name) const; int get_int(int name) const; bool get_bool(int name) const; - + // setting names (indices) are 16 bits. The two most significant // bits indicate what type the setting has. (string, int, bool) enum type_bases @@ -269,7 +269,7 @@ namespace libtorrent // cause is to have to re-read it once we want to calculate the piece // hash dont_flush_write_cache, - + // ``explicit_read_cache`` defaults to 0. If set to something greater // than 0, the disk read cache will not be evicted by cache misses and // will explicitly be controlled based on the rarity of pieces. Rare @@ -466,7 +466,7 @@ namespace libtorrent // If you're using I2P, it might make sense to enable anonymous mode // as well. anonymous_mode, - + // specifies whether downloads from web seeds is reported to the // tracker or not. Defaults to on. Turning it off also excludes web // seed traffic from other stats and download rate reporting via the @@ -510,7 +510,7 @@ namespace libtorrent // connections to peers whose port is < 1024. This is a safety // precaution to avoid being part of a DDoS attack no_connect_privileged_ports, - + // ``smooth_connects`` is true by default, which means the number of // connection attempts per second may be limited to below the // ``connection_speed``, in case we're close to bump up against the @@ -1572,7 +1572,7 @@ namespace libtorrent // and if an outgoing encrypted connection fails, a non- encrypted // connection will be tried. pe_enabled, - + // only non-encrypted connections are allowed. pe_disabled }; diff --git a/src/session.cpp b/src/session.cpp index 5ed8ad823..c0fcd7b52 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -619,7 +619,7 @@ namespace libtorrent { return TORRENT_SYNC_CALL_RET(std::vector, get_torrents); } - + torrent_handle session::find_torrent(sha1_hash const& info_hash) const { return TORRENT_SYNC_CALL_RET1(torrent_handle, find_torrent_handle, info_hash); diff --git a/test/test_dht.cpp b/test/test_dht.cpp index 934053fd7..0b3e0503d 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -1956,10 +1956,5 @@ TORRENT_TEST(dht) TEST_EQUAL(to_hex(target_id.to_string()), "e5f96f6f38320f0f33959cb4d3d656452117aadb"); } -#else - -TORRENT_TEST(dht) -{} - #endif diff --git a/test/test_fast_extension.cpp b/test/test_fast_extension.cpp index a1614a35d..ff4cc1fa8 100644 --- a/test/test_fast_extension.cpp +++ b/test/test_fast_extension.cpp @@ -389,9 +389,10 @@ boost::shared_ptr setup_peer(stream_socket& s, sha1_hash& ih { boost::shared_ptr t = ::create_torrent(); ih = t->info_hash(); - ses.reset(new lt::session(fingerprint("LT", 0, 1, 0, 0) - , std::make_pair(48900, 49000), "0.0.0.0", session::add_default_plugins - , alert::all_categories)); + settings_pack sett; + sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48900"); + sett.set_int(settings_pack::alert_mask, alert::all_categories); + ses.reset(new lt::session(sett, session::add_default_plugins)); error_code ec; add_torrent_params p; @@ -434,7 +435,7 @@ void test_reject_fast() print_session_log(*ses); send_have_all(s); print_session_log(*ses); - + std::vector allowed_fast; allowed_fast.push_back(0); allowed_fast.push_back(1); diff --git a/test/test_magnet.cpp b/test/test_magnet.cpp index 02caa6f47..a0657f1de 100644 --- a/test/test_magnet.cpp +++ b/test/test_magnet.cpp @@ -41,7 +41,7 @@ namespace lt = libtorrent; void test_remove_url(std::string url) { - lt::session s(fingerprint("LT",0,0,0,0), 0); + lt::session s; add_torrent_params p; p.url = url; p.save_path = "."; @@ -61,8 +61,6 @@ TORRENT_TEST(magnet) session_proxy p2; { // test session state load/restore - lt::session* s = new lt::session(fingerprint("LT",0,0,0,0), 0); - settings_pack pack; pack.set_str(settings_pack::user_agent, "test"); pack.set_int(settings_pack::tracker_receive_timeout, 1234); @@ -75,7 +73,7 @@ TORRENT_TEST(magnet) pack.set_bool(settings_pack::close_redundant_connections, false); pack.set_int(settings_pack::auto_scrape_interval, 235); pack.set_int(settings_pack::auto_scrape_min_interval, 62); - s->apply_settings(pack); + lt::session* s = new lt::session(pack); TEST_EQUAL(pack.get_str(settings_pack::user_agent), "test"); TEST_EQUAL(pack.get_int(settings_pack::tracker_receive_timeout), 1234); @@ -114,7 +112,6 @@ TORRENT_TEST(magnet) for (std::vector::iterator i = trackers.begin() , end(trackers.end()); i != end; ++i) trackers_set.insert(i->url); - TEST_CHECK(trackers_set.count("http://1") == 1); TEST_CHECK(trackers_set.count("http://2") == 1); @@ -165,7 +162,7 @@ TORRENT_TEST(magnet) p1 = s->abort(); delete s; - s = new lt::session(fingerprint("LT",0,0,0,0), 0); + s = new lt::session(); std::vector buf; bencode(std::back_inserter(buf), session_state); diff --git a/test/test_metadata_extension.cpp b/test/test_metadata_extension.cpp index 4b61cc656..6fff18956 100644 --- a/test/test_metadata_extension.cpp +++ b/test/test_metadata_extension.cpp @@ -90,15 +90,6 @@ void test_transfer(int flags session_proxy p1; session_proxy p2; - // TODO: it would be nice to test reversing - // which session is making the connection as well - lt::session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48100, 49000), "0.0.0.0", 0); - lt::session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49100, 50000), "0.0.0.0", 0); - ses1.add_extension(constructor); - ses2.add_extension(constructor); - torrent_handle tor1; - torrent_handle tor2; - settings_pack pack; pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_forced); pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_forced); @@ -120,8 +111,16 @@ void test_transfer(int flags pack.set_bool(settings_pack::enable_outgoing_tcp, true); } - ses1.apply_settings(pack); - ses2.apply_settings(pack); + // TODO: it would be nice to test reversing + // which session is making the connection as well + pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48100"); + lt::session ses1(pack); + pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:49100"); + lt::session ses2(pack); + ses1.add_extension(constructor); + ses2.add_extension(constructor); + torrent_handle tor1; + torrent_handle tor2; lt::session* downloader = &ses2; lt::session* seed = &ses1; diff --git a/test/test_pex.cpp b/test/test_pex.cpp index 23820f533..67c58e484 100644 --- a/test/test_pex.cpp +++ b/test/test_pex.cpp @@ -30,6 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "test.hpp" + #ifndef TORRENT_DISABLE_EXTENSIONS #include "libtorrent/session.hpp" @@ -40,7 +42,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/ip_filter.hpp" #include -#include "test.hpp" #include "setup_transfer.hpp" #include @@ -144,9 +145,11 @@ void test_pex() p2 = ses2.abort(); p3 = ses3.abort(); } +#endif // TORRENT_DISABLE_EXTENSIONS TORRENT_TEST(pex) { +#ifndef TORRENT_DISABLE_EXTENSIONS using namespace libtorrent; // in case the previous run was terminated @@ -160,9 +163,7 @@ TORRENT_TEST(pex) remove_all("tmp1_pex", ec); remove_all("tmp2_pex", ec); remove_all("tmp3_pex", ec); +#endif // TORRENT_DISABLE_EXTENSIONS } -#else -TORRENT_TEST(pex) {} -#endif // TORRENT_DISABLE_EXTENSIONS diff --git a/test/test_priority.cpp b/test/test_priority.cpp index 6ede7d42e..28a33babe 100644 --- a/test/test_priority.cpp +++ b/test/test_priority.cpp @@ -86,10 +86,15 @@ void test_transfer(settings_pack const& sett) remove_all("tmp1_priority_moved", ec); remove_all("tmp2_priority_moved", ec); - lt::session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48075, 49000), "0.0.0.0", 0, mask); - lt::session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49075, 50000), "0.0.0.0", 0, mask); - settings_pack pack = sett; + pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); + pack.set_int(settings_pack::alert_mask, mask); + + lt::session ses1(pack); + + pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:49075"); + pack.set_int(settings_pack::alert_mask, mask); + lt::session ses2(pack); // we need a short reconnect time since we // finish the torrent and then restart it diff --git a/test/test_read_piece.cpp b/test/test_read_piece.cpp index 51f691f86..a1cb80f39 100644 --- a/test/test_read_piece.cpp +++ b/test/test_read_piece.cpp @@ -62,12 +62,12 @@ void test_read_piece(int flags) create_directory(combine_path("tmp1_read_piece", "test_torrent"), ec); if (ec) fprintf(stderr, "ERROR: creating directory test_torrent: (%d) %s\n" , ec.value(), ec.message().c_str()); - + file_storage fs; std::srand(10); int piece_size = 0x4000; - static const int file_sizes[] ={ 100000, 10000 }; + static const int file_sizes[] = { 100000, 10000 }; create_random_files(combine_path("tmp1_read_piece", "test_torrent") , file_sizes, 2); @@ -87,10 +87,10 @@ void test_read_piece(int flags) fprintf(stderr, "generated torrent: %s tmp1_read_piece/test_torrent\n" , to_hex(ti->info_hash().to_string()).c_str()); - lt::session ses(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48000, 49000), "0.0.0.0", 0); settings_pack sett; + sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48000"); sett.set_int(settings_pack::alert_mask, alert::all_categories); - ses.apply_settings(sett); + lt::session ses(sett); add_torrent_params p; p.save_path = "tmp1_read_piece"; diff --git a/test/test_recheck.cpp b/test/test_recheck.cpp index cb7777513..7fd7aaec8 100644 --- a/test/test_recheck.cpp +++ b/test/test_recheck.cpp @@ -69,7 +69,10 @@ void wait_for_complete(lt::session& ses, torrent_handle h) TORRENT_TEST(recheck) { error_code ec; - lt::session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48675, 49000), "0.0.0.0", 0, mask); + settings_pack sett; + sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48675"); + sett.set_int(settings_pack::alert_mask, mask); + lt::session ses1(sett); create_directory("tmp1_recheck", ec); if (ec) fprintf(stderr, "create_directory: %s\n", ec.message().c_str()); std::ofstream file("tmp1_recheck/temporary"); diff --git a/test/test_remap_files.cpp b/test/test_remap_files.cpp index 13298d2aa..0e5e323e6 100644 --- a/test/test_remap_files.cpp +++ b/test/test_remap_files.cpp @@ -71,10 +71,14 @@ void test_remap_files_gather(storage_mode_t storage_mode = storage_mode_sparse) session_proxy p1; session_proxy p2; - lt::session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48075, 49000) - , "0.0.0.0", 0, alert_mask); - lt::session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49075, 50000) - , "0.0.0.0", 0, alert_mask); + settings_pack sett; + sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); + sett.set_int(settings_pack::alert_mask, alert_mask); + + lt::session ses1(sett); + + sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:49075"); + lt::session ses2(sett); torrent_handle tor1; torrent_handle tor2; @@ -224,10 +228,15 @@ void test_remap_files_scatter(storage_mode_t storage_mode = storage_mode_sparse) session_proxy p1; session_proxy p2; - lt::session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48075, 49000) - , "0.0.0.0", 0, alert_mask); - lt::session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49075, 50000) - , "0.0.0.0", 0, alert_mask); + settings_pack sett; + sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); + sett.set_int(settings_pack::alert_mask, alert_mask); + + lt::session ses1(sett); + + sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:49075"); + sett.set_int(settings_pack::alert_mask, alert_mask); + lt::session ses2(sett); torrent_handle tor1; torrent_handle tor2; @@ -357,10 +366,13 @@ void test_remap_files_prio(storage_mode_t storage_mode = storage_mode_sparse) session_proxy p1; session_proxy p2; - lt::session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48075, 49000) - , "0.0.0.0", 0, alert_mask); - lt::session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49075, 50000) - , "0.0.0.0", 0, alert_mask); + settings_pack sett; + sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); + sett.set_int(settings_pack::alert_mask, alert_mask); + lt::session ses1(sett); + + sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:49075"); + lt::session ses2(sett); torrent_handle tor1; torrent_handle tor2; diff --git a/test/test_ssl.cpp b/test/test_ssl.cpp index baad4b756..44b74f39e 100644 --- a/test/test_ssl.cpp +++ b/test/test_ssl.cpp @@ -580,9 +580,9 @@ void test_malicious_peer() TORRENT_TEST(ssl) { +#ifdef TORRENT_USE_OPENSSL using namespace libtorrent; -#ifdef TORRENT_USE_OPENSSL test_malicious_peer(); for (int utp = 0; utp < 2; ++utp) @@ -594,9 +594,7 @@ TORRENT_TEST(ssl) error_code ec; remove_all("tmp1_ssl", ec); remove_all("tmp2_ssl", ec); - #endif // TORRENT_USE_OPENSSL } - diff --git a/test/test_tracker.cpp b/test/test_tracker.cpp index 07a6c3d03..88bfa6f69 100644 --- a/test/test_tracker.cpp +++ b/test/test_tracker.cpp @@ -256,17 +256,16 @@ TORRENT_TEST(udp_tracker) int prev_udp_announces = num_udp_announces(); - boost::scoped_ptr s(new lt::session( - fingerprint("LT", 0, 1, 0, 0) - , std::make_pair(48875, 49800), "0.0.0.0", 0, alert_mask)); - settings_pack pack; #ifndef TORRENT_NO_DEPRECATE pack.set_int(settings_pack::half_open_limit, 1); #endif pack.set_bool(settings_pack::announce_to_all_trackers, true); pack.set_bool(settings_pack::announce_to_all_tiers, true); - s->apply_settings(pack); + pack.set_int(settings_pack::alert_mask, alert_mask); + pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48875"); + + boost::scoped_ptr s(new lt::session(pack)); error_code ec; remove_all("tmp1_tracker", ec); @@ -322,9 +321,6 @@ TORRENT_TEST(try_next) int udp_port = start_udp_tracker(); int prev_udp_announces = num_udp_announces(); - boost::scoped_ptr s( - new lt::session(fingerprint("LT", 0, 1, 0, 0) - , std::make_pair(39775, 39800), "0.0.0.0", 0, alert_mask)); settings_pack pack; #ifndef TORRENT_NO_DEPRECATE @@ -334,7 +330,10 @@ TORRENT_TEST(try_next) pack.set_bool(settings_pack::announce_to_all_tiers, false); pack.set_int(settings_pack::tracker_completion_timeout, 2); pack.set_int(settings_pack::tracker_receive_timeout, 1); - s->apply_settings(pack); + pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:39775"); + pack.set_int(settings_pack::alert_mask, alert_mask); + + boost::scoped_ptr s(new lt::session(pack)); error_code ec; remove_all("tmp2_tracker", ec); diff --git a/test/test_trackers_extension.cpp b/test/test_trackers_extension.cpp index b8e976e4d..9974e92b1 100644 --- a/test/test_trackers_extension.cpp +++ b/test/test_trackers_extension.cpp @@ -30,8 +30,6 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef TORRENT_DISABLE_EXTENSIONS - #include "libtorrent/session.hpp" #include "libtorrent/hasher.hpp" #include "libtorrent/thread.hpp" @@ -49,6 +47,7 @@ using boost::tuples::ignore; TORRENT_TEST(trackers_extension) { +#ifndef TORRENT_DISABLE_EXTENSIONS using namespace libtorrent; namespace lt = libtorrent; @@ -129,9 +128,7 @@ TORRENT_TEST(trackers_extension) // this allows shutting down the sessions in parallel p1 = ses1.abort(); p2 = ses2.abort(); +#endif // TORRENT_DISABLE_EXTENSIONS } -#else -TORRENT_TEST(trackers_extension) { } -#endif // TORRENT_DISABLE_EXTENSIONS diff --git a/test/test_transfer.cpp b/test/test_transfer.cpp index 474365596..0d9ac0917 100644 --- a/test/test_transfer.cpp +++ b/test/test_transfer.cpp @@ -73,11 +73,11 @@ bool on_alert(alert const* a) } // simulate a full disk -struct test_storage : default_storage +struct test_storage : default_storage { test_storage(storage_params const& params) : default_storage(params) - , m_written(0) + , m_written(0) , m_limit(16 * 1024 * 2) {} @@ -156,10 +156,14 @@ void test_transfer(int proxy_type, settings_pack const& sett session_proxy p1; session_proxy p2; - lt::session ses1(fingerprint("LT", 0, 1, 0, 0) - , std::make_pair(48075 + listen_port, 49000), "0.0.0.0", 0, mask); - lt::session ses2(fingerprint("LT", 0, 1, 0, 0) - , std::make_pair(49075 + listen_port, 50000), "0.0.0.0", 0, mask); + settings_pack pack; + pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); + pack.set_int(settings_pack::alert_mask, mask); + + lt::session ses1(pack); + + pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:49075"); + lt::session ses2(pack); listen_port += 10; int proxy_port = 0; @@ -185,7 +189,8 @@ void test_transfer(int proxy_type, settings_pack const& sett ses2.apply_settings(pack); } - settings_pack pack = sett; + pack = sett; + // we need a short reconnect time since we // finish the torrent and then restart it // immediately to complete the second half. diff --git a/test/test_utp.cpp b/test/test_utp.cpp index dab5424a2..c516a65d6 100644 --- a/test/test_utp.cpp +++ b/test/test_utp.cpp @@ -63,9 +63,6 @@ void test_transfer() session_proxy p1; session_proxy p2; - lt::session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48885, 49930), "0.0.0.0", 0); - lt::session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49885, 50930), "0.0.0.0", 0); - settings_pack pack; pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled); pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_disabled); @@ -76,8 +73,11 @@ void test_transfer() pack.set_bool(settings_pack::prefer_udp_trackers, false); pack.set_bool(settings_pack::utp_dynamic_sock_buf, true); pack.set_int(settings_pack::min_reconnect_time, 1); - ses1.apply_settings(pack); - ses2.apply_settings(pack); + pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48885"); + lt::session ses1(pack); + + pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:49885"); + lt::session ses2(pack); torrent_handle tor1; torrent_handle tor2; diff --git a/test/test_web_seed_redirect.cpp b/test/test_web_seed_redirect.cpp index e65890436..ec65aab64 100644 --- a/test/test_web_seed_redirect.cpp +++ b/test/test_web_seed_redirect.cpp @@ -87,11 +87,10 @@ TORRENT_TEST(web_seed_redirect) , buf.size(), ec)); { - libtorrent::session ses(fingerprint(" ", 0,0,0,0), 0); settings_pack settings; settings.set_int(settings_pack::max_queued_disk_bytes, 256 * 1024); settings.set_int(settings_pack::alert_mask, ~(alert::progress_notification | alert::stats_notification)); - ses.apply_settings(settings); + libtorrent::session ses(settings); // disable keep-alive because otherwise the test will choke on seeing // the disconnect (from the redirect)