fix no-deprecated build. extend .travis.yml to build the 3 test configurations too. rename README to README.rst

This commit is contained in:
arvidn 2015-06-05 02:31:52 -04:00
parent f11b054bae
commit 15dd15d0d6
23 changed files with 116 additions and 114 deletions

View File

@ -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

20
LICENSE
View File

@ -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

View File

@ -124,6 +124,7 @@ EXTRA_DIST = \
CMakeLists.txt \
setup.py \
LICENSE \
README.rst \
$(DOCS_PAGES) \
$(DOCS_IMAGES) \
$(ED25519_SOURCE)

View File

@ -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`__.

View File

@ -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<boost::shared_ptr<peer_connection> > connection_map;
#if TORRENT_HAS_BOOST_UNORDERED
typedef boost::unordered_map<sha1_hash, boost::shared_ptr<torrent> > torrent_map;

View File

@ -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();

View File

@ -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
};

View File

@ -619,7 +619,7 @@ namespace libtorrent
{
return TORRENT_SYNC_CALL_RET(std::vector<torrent_handle>, 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);

View File

@ -1956,10 +1956,5 @@ TORRENT_TEST(dht)
TEST_EQUAL(to_hex(target_id.to_string()), "e5f96f6f38320f0f33959cb4d3d656452117aadb");
}
#else
TORRENT_TEST(dht)
{}
#endif

View File

@ -389,9 +389,10 @@ boost::shared_ptr<torrent_info> setup_peer(stream_socket& s, sha1_hash& ih
{
boost::shared_ptr<torrent_info> 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<int> allowed_fast;
allowed_fast.push_back(0);
allowed_fast.push_back(1);

View File

@ -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<announce_entry>::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<char> buf;
bencode(std::back_inserter(buf), session_state);

View File

@ -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;

View File

@ -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 <boost/tuple/tuple.hpp>
#include "test.hpp"
#include "setup_transfer.hpp"
#include <iostream>
@ -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

View File

@ -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

View File

@ -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";

View File

@ -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");

View File

@ -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;

View File

@ -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
}

View File

@ -256,17 +256,16 @@ TORRENT_TEST(udp_tracker)
int prev_udp_announces = num_udp_announces();
boost::scoped_ptr<lt::session> 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<lt::session> 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<lt::session> 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<lt::session> s(new lt::session(pack));
error_code ec;
remove_all("tmp2_tracker", ec);

View File

@ -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

View File

@ -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.

View File

@ -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;

View File

@ -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)