2008-08-18 22:02:50 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright (c) 2008, Arvid Norberg
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in
|
|
|
|
the documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the author nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived
|
|
|
|
from this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libtorrent/session.hpp"
|
|
|
|
#include "libtorrent/session_settings.hpp"
|
|
|
|
#include "libtorrent/hasher.hpp"
|
|
|
|
#include "libtorrent/alert_types.hpp"
|
|
|
|
#include "libtorrent/bencode.hpp"
|
2009-11-02 03:00:41 +01:00
|
|
|
#include "libtorrent/thread.hpp"
|
2009-11-26 06:45:43 +01:00
|
|
|
#include "libtorrent/time.hpp"
|
2010-02-18 05:37:02 +01:00
|
|
|
#include "libtorrent/file.hpp"
|
2015-09-18 06:23:45 +02:00
|
|
|
#include "libtorrent/torrent_info.hpp"
|
2008-08-18 22:02:50 +02:00
|
|
|
|
|
|
|
#include "test.hpp"
|
|
|
|
#include "setup_transfer.hpp"
|
2015-04-24 05:48:08 +02:00
|
|
|
#include "test_utils.hpp"
|
|
|
|
|
|
|
|
#include <boost/tuple/tuple.hpp>
|
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
2009-11-23 09:38:50 +01:00
|
|
|
#include <fstream>
|
2009-12-15 14:11:07 +01:00
|
|
|
#include <iostream>
|
2008-08-18 22:02:50 +02:00
|
|
|
|
2008-08-19 17:04:14 +02:00
|
|
|
using namespace libtorrent;
|
2014-07-06 21:18:00 +02:00
|
|
|
namespace lt = libtorrent;
|
|
|
|
|
2008-08-19 17:04:14 +02:00
|
|
|
using boost::tuples::ignore;
|
2008-08-18 22:02:50 +02:00
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
const int mask = alert::all_categories & ~(alert::performance_warning | alert::stats_notification);
|
2010-12-24 19:15:01 +01:00
|
|
|
|
2013-07-28 17:06:28 +02:00
|
|
|
int peer_disconnects = 0;
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
bool on_alert(alert const* a)
|
2013-07-28 17:06:28 +02:00
|
|
|
{
|
2015-11-27 03:18:58 +01:00
|
|
|
if (alert_cast<peer_disconnected_alert>(a))
|
2013-07-28 17:06:28 +02:00
|
|
|
++peer_disconnects;
|
2013-08-01 05:50:57 +02:00
|
|
|
else if (alert_cast<peer_error_alert>(a))
|
|
|
|
++peer_disconnects;
|
2013-08-01 18:15:02 +02:00
|
|
|
|
2013-07-28 17:06:28 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-10 11:20:55 +02:00
|
|
|
// simulate a full disk
|
2015-06-05 08:31:52 +02:00
|
|
|
struct test_storage : default_storage
|
2009-06-10 11:20:55 +02:00
|
|
|
{
|
2014-07-06 21:18:00 +02:00
|
|
|
test_storage(storage_params const& params)
|
|
|
|
: default_storage(params)
|
2015-06-05 08:31:52 +02:00
|
|
|
, m_written(0)
|
2009-06-10 11:20:55 +02:00
|
|
|
, m_limit(16 * 1024 * 2)
|
|
|
|
{}
|
2014-07-12 08:20:16 +02:00
|
|
|
|
|
|
|
virtual void set_file_priority(std::vector<boost::uint8_t> const& p
|
|
|
|
, storage_error& ec) {}
|
2009-06-10 11:20:55 +02:00
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
void set_limit(int lim)
|
2009-06-10 11:20:55 +02:00
|
|
|
{
|
2014-07-06 21:18:00 +02:00
|
|
|
mutex::scoped_lock l(m_mutex);
|
|
|
|
m_limit = lim;
|
2009-06-10 11:20:55 +02:00
|
|
|
}
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
int writev(
|
|
|
|
file::iovec_t const* bufs
|
|
|
|
, int num_bufs
|
|
|
|
, int piece_index
|
|
|
|
, int offset
|
|
|
|
, int flags
|
|
|
|
, storage_error& se)
|
2009-06-10 11:20:55 +02:00
|
|
|
{
|
2014-07-06 21:18:00 +02:00
|
|
|
mutex::scoped_lock l(m_mutex);
|
|
|
|
if (m_written >= m_limit)
|
2009-06-10 11:20:55 +02:00
|
|
|
{
|
2014-07-06 21:18:00 +02:00
|
|
|
std::cerr << "storage written: " << m_written << " limit: " << m_limit << std::endl;
|
|
|
|
error_code ec;
|
2015-11-22 20:08:32 +01:00
|
|
|
ec = error_code(boost::system::errc::no_space_on_device, generic_category());
|
2014-07-06 21:18:00 +02:00
|
|
|
se.ec = ec;
|
|
|
|
return 0;
|
2009-06-10 11:20:55 +02:00
|
|
|
}
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
for (int i = 0; i < num_bufs; ++i)
|
|
|
|
m_written += bufs[i].iov_len;
|
|
|
|
l.unlock();
|
|
|
|
return default_storage::writev(bufs, num_bufs, piece_index, offset, flags, se);
|
|
|
|
}
|
2009-06-10 11:20:55 +02:00
|
|
|
|
|
|
|
virtual ~test_storage() {}
|
|
|
|
|
|
|
|
int m_written;
|
|
|
|
int m_limit;
|
2014-07-06 21:18:00 +02:00
|
|
|
mutex m_mutex;
|
2009-06-10 11:20:55 +02:00
|
|
|
};
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
storage_interface* test_storage_constructor(storage_params const& params)
|
2009-06-10 11:20:55 +02:00
|
|
|
{
|
2014-07-06 21:18:00 +02:00
|
|
|
return new test_storage(params);
|
2009-06-10 11:20:55 +02:00
|
|
|
}
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
void test_transfer(int proxy_type, settings_pack const& sett
|
|
|
|
, bool test_disk_full = false
|
2014-02-07 09:58:52 +01:00
|
|
|
, storage_mode_t storage_mode = storage_mode_sparse)
|
2010-02-18 05:37:02 +01:00
|
|
|
{
|
2014-01-26 09:18:13 +01:00
|
|
|
static int listen_port = 0;
|
2010-02-18 05:37:02 +01:00
|
|
|
|
|
|
|
char const* test_name[] = {"no", "SOCKS4", "SOCKS5", "SOCKS5 password", "HTTP", "HTTP password"};
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
fprintf(stderr, "\n\n ==== TESTING %s proxy ==== disk-full: %s\n\n\n"
|
|
|
|
, test_name[proxy_type], test_disk_full ? "true": "false");
|
2015-06-02 03:14:52 +02:00
|
|
|
|
2009-06-21 01:23:41 +02:00
|
|
|
// in case the previous run was terminated
|
2009-10-26 02:29:39 +01:00
|
|
|
error_code ec;
|
2012-03-17 20:06:11 +01:00
|
|
|
remove_all("tmp1_transfer", ec);
|
|
|
|
remove_all("tmp2_transfer", ec);
|
|
|
|
remove_all("tmp1_transfer_moved", ec);
|
|
|
|
remove_all("tmp2_transfer_moved", ec);
|
2009-06-21 01:23:41 +02:00
|
|
|
|
2013-08-31 22:19:03 +02:00
|
|
|
// these are declared before the session objects
|
|
|
|
// so that they are destructed last. This enables
|
|
|
|
// the sessions to destruct in parallel
|
|
|
|
session_proxy p1;
|
|
|
|
session_proxy p2;
|
|
|
|
|
2015-06-05 08:31:52 +02:00
|
|
|
settings_pack pack;
|
|
|
|
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075");
|
|
|
|
pack.set_int(settings_pack::alert_mask, mask);
|
|
|
|
|
2015-06-07 23:54:08 +02:00
|
|
|
pack.set_bool(settings_pack::enable_upnp, false);
|
|
|
|
pack.set_bool(settings_pack::enable_natpmp, false);
|
|
|
|
pack.set_bool(settings_pack::enable_lsd, false);
|
|
|
|
pack.set_bool(settings_pack::enable_dht, false);
|
|
|
|
|
2015-06-05 08:31:52 +02:00
|
|
|
lt::session ses1(pack);
|
|
|
|
|
|
|
|
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:49075");
|
|
|
|
lt::session ses2(pack);
|
2014-01-26 09:36:56 +01:00
|
|
|
listen_port += 10;
|
2008-08-18 22:02:50 +02:00
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
int proxy_port = 0;
|
2010-02-18 05:37:02 +01:00
|
|
|
if (proxy_type)
|
|
|
|
{
|
2014-07-06 21:18:00 +02:00
|
|
|
proxy_port = start_proxy(proxy_type);
|
|
|
|
|
|
|
|
settings_pack pack;
|
|
|
|
pack.set_str(settings_pack::proxy_username, "testuser");
|
|
|
|
pack.set_str(settings_pack::proxy_password, "testpass");
|
2015-06-06 08:42:23 +02:00
|
|
|
pack.set_int(settings_pack::proxy_type, proxy_type);
|
2014-07-06 21:18:00 +02:00
|
|
|
pack.set_int(settings_pack::proxy_port, proxy_port);
|
2014-06-30 10:41:33 +02:00
|
|
|
|
|
|
|
// test resetting the proxy in quick succession.
|
|
|
|
// specifically the udp_socket connecting to a new
|
|
|
|
// socks5 proxy while having one connection attempt
|
|
|
|
// in progress.
|
2014-07-06 21:18:00 +02:00
|
|
|
pack.set_str(settings_pack::proxy_hostname, "5.6.7.8");
|
|
|
|
ses1.apply_settings(pack);
|
2014-06-30 10:41:33 +02:00
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
pack.set_str(settings_pack::proxy_hostname, "127.0.0.1");
|
|
|
|
ses1.apply_settings(pack);
|
|
|
|
ses2.apply_settings(pack);
|
2010-02-18 05:37:02 +01:00
|
|
|
}
|
|
|
|
|
2015-06-05 08:31:52 +02:00
|
|
|
pack = sett;
|
|
|
|
|
2010-12-24 01:37:01 +01:00
|
|
|
// we need a short reconnect time since we
|
|
|
|
// finish the torrent and then restart it
|
|
|
|
// immediately to complete the second half.
|
|
|
|
// using a reconnect time > 0 will just add
|
|
|
|
// to the time it will take to complete the test
|
2014-07-06 21:18:00 +02:00
|
|
|
pack.set_int(settings_pack::min_reconnect_time, 0);
|
|
|
|
pack.set_int(settings_pack::stop_tracker_timeout, 1);
|
|
|
|
pack.set_bool(settings_pack::announce_to_all_trackers, true);
|
|
|
|
pack.set_bool(settings_pack::announce_to_all_tiers, true);
|
|
|
|
|
2010-02-18 05:37:02 +01:00
|
|
|
// make sure we announce to both http and udp trackers
|
2014-07-06 21:18:00 +02:00
|
|
|
pack.set_bool(settings_pack::prefer_udp_trackers, false);
|
|
|
|
pack.set_bool(settings_pack::enable_outgoing_utp, false);
|
|
|
|
pack.set_bool(settings_pack::enable_incoming_utp, false);
|
2015-01-03 21:17:38 +01:00
|
|
|
pack.set_bool(settings_pack::enable_lsd, false);
|
|
|
|
pack.set_bool(settings_pack::enable_natpmp, false);
|
|
|
|
pack.set_bool(settings_pack::enable_upnp, false);
|
|
|
|
pack.set_bool(settings_pack::enable_dht, false);
|
2014-07-06 21:18:00 +02:00
|
|
|
pack.set_int(settings_pack::alert_mask, mask);
|
|
|
|
|
|
|
|
pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled);
|
|
|
|
pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_disabled);
|
|
|
|
|
|
|
|
pack.set_bool(settings_pack::allow_multiple_connections_per_ip, false);
|
|
|
|
|
2015-11-27 03:18:58 +01:00
|
|
|
// TODO: these settings_pack tests belong in their own test
|
2014-07-06 21:18:00 +02:00
|
|
|
pack.set_int(settings_pack::unchoke_slots_limit, 0);
|
|
|
|
ses1.apply_settings(pack);
|
|
|
|
TEST_CHECK(ses1.get_settings().get_int(settings_pack::unchoke_slots_limit) == 0);
|
|
|
|
|
|
|
|
pack.set_int(settings_pack::unchoke_slots_limit, -1);
|
|
|
|
ses1.apply_settings(pack);
|
|
|
|
TEST_CHECK(ses1.get_settings().get_int(settings_pack::unchoke_slots_limit) == -1);
|
|
|
|
|
|
|
|
pack.set_int(settings_pack::unchoke_slots_limit, 8);
|
|
|
|
ses1.apply_settings(pack);
|
|
|
|
TEST_CHECK(ses1.get_settings().get_int(settings_pack::unchoke_slots_limit) == 8);
|
|
|
|
|
|
|
|
ses2.apply_settings(pack);
|
2008-08-18 22:02:50 +02:00
|
|
|
|
|
|
|
torrent_handle tor1;
|
|
|
|
torrent_handle tor2;
|
|
|
|
|
2012-03-17 20:06:11 +01:00
|
|
|
create_directory("tmp1_transfer", ec);
|
|
|
|
std::ofstream file("tmp1_transfer/temporary");
|
2015-09-20 03:06:56 +02:00
|
|
|
boost::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
|
2008-08-18 22:02:50 +02:00
|
|
|
file.close();
|
|
|
|
|
2013-10-10 19:00:32 +02:00
|
|
|
TEST_CHECK(exists(combine_path("tmp1_transfer", "temporary")));
|
2010-02-18 05:37:02 +01:00
|
|
|
|
2009-06-10 11:20:55 +02:00
|
|
|
add_torrent_params addp(&test_storage_constructor);
|
2012-03-19 05:02:13 +01:00
|
|
|
addp.flags &= ~add_torrent_params::flag_paused;
|
|
|
|
addp.flags &= ~add_torrent_params::flag_auto_managed;
|
2009-06-10 11:20:55 +02:00
|
|
|
|
2014-02-07 09:58:52 +01:00
|
|
|
add_torrent_params params;
|
|
|
|
params.storage_mode = storage_mode;
|
2015-06-10 07:22:01 +02:00
|
|
|
params.flags &= ~add_torrent_params::flag_paused;
|
|
|
|
params.flags &= ~add_torrent_params::flag_auto_managed;
|
2014-02-07 09:58:52 +01:00
|
|
|
|
2010-12-24 19:15:01 +01:00
|
|
|
wait_for_listen(ses1, "ses1");
|
2014-07-06 21:18:00 +02:00
|
|
|
wait_for_listen(ses2, "ses2");
|
2010-12-24 19:15:01 +01:00
|
|
|
|
2013-07-28 17:06:28 +02:00
|
|
|
peer_disconnects = 0;
|
|
|
|
|
2008-08-18 22:02:50 +02:00
|
|
|
// test using piece sizes smaller than 16kB
|
|
|
|
boost::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0
|
2014-02-07 09:58:52 +01:00
|
|
|
, true, false, true, "_transfer", 8 * 1024, &t, false, test_disk_full?&addp:¶ms);
|
2009-06-10 11:20:55 +02:00
|
|
|
|
2013-06-18 02:33:16 +02:00
|
|
|
int num_pieces = tor2.torrent_file()->num_pieces();
|
2008-08-18 22:02:50 +02:00
|
|
|
std::vector<int> priorities(num_pieces, 1);
|
2009-04-10 10:40:13 +02:00
|
|
|
|
2009-03-30 06:55:23 +02:00
|
|
|
// also test to move the storage of the downloader and the uploader
|
|
|
|
// to make sure it can handle switching paths
|
|
|
|
bool test_move_storage = false;
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
int upload_mode_timer = 0;
|
|
|
|
|
|
|
|
wait_for_downloading(ses2, "ses2");
|
2010-02-18 05:37:02 +01:00
|
|
|
|
2013-08-04 02:02:32 +02:00
|
|
|
for (int i = 0; i < 200; ++i)
|
2008-08-18 22:02:50 +02:00
|
|
|
{
|
|
|
|
torrent_status st1 = tor1.status();
|
|
|
|
torrent_status st2 = tor2.status();
|
|
|
|
|
2013-10-14 09:09:57 +02:00
|
|
|
print_alerts(ses1, "ses1", true, true, true, &on_alert);
|
|
|
|
print_alerts(ses2, "ses2", true, true, true, &on_alert);
|
|
|
|
|
2010-10-09 21:56:10 +02:00
|
|
|
if (i % 10 == 0)
|
|
|
|
{
|
2013-06-20 07:28:42 +02:00
|
|
|
print_ses_rate(i / 10.f, &st1, &st2);
|
2010-10-09 21:56:10 +02:00
|
|
|
}
|
2008-08-18 22:02:50 +02:00
|
|
|
|
2009-03-30 06:55:23 +02:00
|
|
|
if (!test_move_storage && st2.progress > 0.25f)
|
|
|
|
{
|
|
|
|
test_move_storage = true;
|
2012-03-17 20:06:11 +01:00
|
|
|
tor1.move_storage("tmp1_transfer_moved");
|
|
|
|
tor2.move_storage("tmp2_transfer_moved");
|
2009-03-30 06:55:23 +02:00
|
|
|
std::cerr << "moving storage" << std::endl;
|
|
|
|
}
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
// wait 10 loops before we restart the torrent. This lets
|
|
|
|
// us catch all events that failed (and would put the torrent
|
|
|
|
// back into upload mode) before we restart it.
|
|
|
|
|
2015-01-15 20:13:45 +01:00
|
|
|
// TODO: factor out the disk-full test into its own unit test
|
2014-07-06 21:18:00 +02:00
|
|
|
if (test_disk_full && st2.upload_mode && ++upload_mode_timer > 10)
|
2009-06-10 11:20:55 +02:00
|
|
|
{
|
|
|
|
test_disk_full = false;
|
2014-07-06 21:18:00 +02:00
|
|
|
((test_storage*)tor2.get_storage_impl())->set_limit(16 * 1024 * 1024);
|
2014-01-24 10:31:47 +01:00
|
|
|
|
|
|
|
// if we reset the upload mode too soon, there may be more disk
|
|
|
|
// jobs failing right after, putting us back in upload mode. So,
|
|
|
|
// give the disk some time to fail all disk jobs before resetting
|
|
|
|
// upload mode to false
|
|
|
|
test_sleep(500);
|
|
|
|
|
2014-01-26 09:18:13 +01:00
|
|
|
// then we need to drain the alert queue, so the peer_disconnects
|
|
|
|
// counter doesn't get incremented by old alerts
|
|
|
|
print_alerts(ses1, "ses1", true, true, true, &on_alert);
|
|
|
|
print_alerts(ses2, "ses2", true, true, true, &on_alert);
|
|
|
|
|
2015-11-03 06:12:30 +01:00
|
|
|
lt::error_code err = tor2.status().errc;
|
|
|
|
fprintf(stderr, "error: \"%s\"\n", err.message().c_str());
|
|
|
|
TEST_CHECK(!err);
|
2009-06-19 00:32:55 +02:00
|
|
|
tor2.set_upload_mode(false);
|
2014-07-06 21:18:00 +02:00
|
|
|
|
|
|
|
// at this point we probably disconnected the seed
|
|
|
|
// so we need to reconnect as well
|
2015-04-24 05:48:08 +02:00
|
|
|
fprintf(stderr, "%s: reconnecting peer\n", time_now_string());
|
2014-07-06 21:18:00 +02:00
|
|
|
error_code ec;
|
|
|
|
tor2.connect_peer(tcp::endpoint(address::from_string("127.0.0.1", ec)
|
|
|
|
, ses1.listen_port()));
|
|
|
|
|
2013-08-18 03:08:18 +02:00
|
|
|
TEST_CHECK(tor2.status().is_finished == false);
|
2014-07-06 21:18:00 +02:00
|
|
|
fprintf(stderr, "disconnects: %d\n", peer_disconnects);
|
|
|
|
TEST_CHECK(peer_disconnects >= 2);
|
2015-04-24 05:48:08 +02:00
|
|
|
fprintf(stderr, "%s: discovered disk full mode. Raise limit and disable upload-mode\n", time_now_string());
|
2014-01-26 09:18:13 +01:00
|
|
|
peer_disconnects = 0;
|
2009-06-10 11:20:55 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
if (!test_disk_full && st2.is_seeding) break;
|
2010-12-24 01:37:01 +01:00
|
|
|
|
2008-11-02 10:03:04 +01:00
|
|
|
TEST_CHECK(st1.state == torrent_status::seeding
|
|
|
|
|| st1.state == torrent_status::checking_files);
|
2009-06-10 11:20:55 +02:00
|
|
|
TEST_CHECK(st2.state == torrent_status::downloading
|
2013-07-30 09:13:12 +02:00
|
|
|
|| st2.state == torrent_status::checking_resume_data
|
2015-11-03 06:12:30 +01:00
|
|
|
|| (test_disk_full && st2.errc));
|
2008-08-18 22:02:50 +02:00
|
|
|
|
2013-10-11 10:36:17 +02:00
|
|
|
if (!test_disk_full && peer_disconnects >= 2) break;
|
2013-07-28 17:06:28 +02:00
|
|
|
|
2013-08-04 02:02:32 +02:00
|
|
|
// if nothing is being transferred after 2 seconds, we're failing the test
|
2013-10-11 10:36:17 +02:00
|
|
|
// if (!test_disk_full && st1.upload_payload_rate == 0 && i > 20) break;
|
2013-08-04 02:02:32 +02:00
|
|
|
|
2010-02-18 05:37:02 +01:00
|
|
|
test_sleep(100);
|
2008-08-18 22:02:50 +02:00
|
|
|
}
|
|
|
|
|
2010-10-30 19:23:30 +02:00
|
|
|
TEST_CHECK(tor2.status().is_seeding);
|
2010-02-18 05:37:02 +01:00
|
|
|
|
2013-08-31 22:19:03 +02:00
|
|
|
// this allows shutting down the sessions in parallel
|
|
|
|
p1 = ses1.abort();
|
|
|
|
p2 = ses2.abort();
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
if (proxy_type) stop_proxy(proxy_port);
|
2008-08-18 22:02:50 +02:00
|
|
|
}
|
|
|
|
|
2015-06-06 08:42:23 +02:00
|
|
|
void cleanup()
|
2008-08-18 22:02:50 +02:00
|
|
|
{
|
2015-06-06 08:42:23 +02:00
|
|
|
error_code ec;
|
|
|
|
remove_all("tmp1_transfer", ec);
|
|
|
|
remove_all("tmp2_transfer", ec);
|
|
|
|
remove_all("tmp1_transfer_moved", ec);
|
|
|
|
remove_all("tmp2_transfer_moved", ec);
|
|
|
|
}
|
2008-08-18 22:02:50 +02:00
|
|
|
|
2015-06-06 08:42:23 +02:00
|
|
|
TORRENT_TEST(no_contiguous_buffers)
|
|
|
|
{
|
|
|
|
using namespace libtorrent;
|
2014-07-06 21:18:00 +02:00
|
|
|
|
|
|
|
// test no contiguous_recv_buffers
|
2015-06-06 08:42:23 +02:00
|
|
|
settings_pack p;
|
2014-07-06 21:18:00 +02:00
|
|
|
p.set_bool(settings_pack::contiguous_recv_buffer, false);
|
|
|
|
test_transfer(0, p);
|
|
|
|
|
2015-06-06 08:42:23 +02:00
|
|
|
cleanup();
|
|
|
|
}
|
|
|
|
|
2010-02-18 05:37:02 +01:00
|
|
|
// test with all kinds of proxies
|
2015-06-06 08:42:23 +02:00
|
|
|
TORRENT_TEST(socks5_pw)
|
|
|
|
{
|
|
|
|
using namespace libtorrent;
|
|
|
|
test_transfer(settings_pack::socks5_pw, settings_pack());
|
|
|
|
cleanup();
|
|
|
|
}
|
|
|
|
|
|
|
|
TORRENT_TEST(http)
|
|
|
|
{
|
|
|
|
using namespace libtorrent;
|
|
|
|
test_transfer(settings_pack::http, settings_pack());
|
|
|
|
cleanup();
|
|
|
|
}
|
2014-07-06 21:18:00 +02:00
|
|
|
|
2015-06-06 08:42:23 +02:00
|
|
|
TORRENT_TEST(http_pw)
|
|
|
|
{
|
|
|
|
using namespace libtorrent;
|
|
|
|
test_transfer(settings_pack::http_pw, settings_pack());
|
|
|
|
cleanup();
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
TORRENT_TEST(i2p)
|
|
|
|
{
|
|
|
|
using namespace libtorrent;
|
|
|
|
test_transfer(settings_pack::i2p_proxy, settings_pack());
|
|
|
|
cleanup();
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
TORRENT_TEST(disk_full)
|
|
|
|
{
|
|
|
|
using namespace libtorrent;
|
2009-06-21 01:23:41 +02:00
|
|
|
// test with a (simulated) full disk
|
2015-06-06 08:42:23 +02:00
|
|
|
test_transfer(0, settings_pack(), true);
|
|
|
|
|
|
|
|
cleanup();
|
|
|
|
}
|
2014-07-06 21:18:00 +02:00
|
|
|
|
2015-06-06 08:42:23 +02:00
|
|
|
TORRENT_TEST(allow_fast)
|
|
|
|
{
|
|
|
|
using namespace libtorrent;
|
2009-06-21 01:23:41 +02:00
|
|
|
// test allowed fast
|
2015-06-06 08:42:23 +02:00
|
|
|
settings_pack p;
|
2014-07-06 21:18:00 +02:00
|
|
|
p.set_int(settings_pack::allowed_fast_set_size, 2000);
|
|
|
|
test_transfer(0, p, false);
|
|
|
|
|
2015-06-06 08:42:23 +02:00
|
|
|
cleanup();
|
|
|
|
}
|
2014-02-07 09:58:52 +01:00
|
|
|
|
2015-06-06 08:42:23 +02:00
|
|
|
TORRENT_TEST(allocate)
|
|
|
|
{
|
|
|
|
using namespace libtorrent;
|
2014-02-07 09:58:52 +01:00
|
|
|
// test storage_mode_allocate
|
|
|
|
fprintf(stderr, "full allocation mode\n");
|
2015-06-06 08:42:23 +02:00
|
|
|
test_transfer(0, settings_pack(), false, storage_mode_allocate);
|
|
|
|
|
|
|
|
cleanup();
|
|
|
|
}
|
2014-02-07 09:58:52 +01:00
|
|
|
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2015-06-06 08:42:23 +02:00
|
|
|
TORRENT_TEST(compact)
|
|
|
|
{
|
|
|
|
using namespace libtorrent;
|
2014-02-07 09:58:52 +01:00
|
|
|
fprintf(stderr, "compact mode\n");
|
2015-06-06 08:42:23 +02:00
|
|
|
test_transfer(0, settings_pack(), false, storage_mode_compact);
|
2015-06-02 03:14:52 +02:00
|
|
|
|
2015-06-06 08:42:23 +02:00
|
|
|
cleanup();
|
2008-08-18 22:02:50 +02:00
|
|
|
}
|
2015-06-06 08:42:23 +02:00
|
|
|
#endif
|
2008-08-18 22:02:50 +02:00
|
|
|
|