Fix some tests

* Fix test_remove_torrent fails when torrent is downloaded too quick
* Fix typo when printing session alerts
* Fix test_lsd and test_upnp on multi-homed systems
* Fix test_tracker 'connect_alert' predicate
This commit is contained in:
d-komarov 2018-02-19 00:28:41 +02:00 committed by Arvid Norberg
parent 18a4f82b5c
commit b922ea86c9
4 changed files with 14 additions and 6 deletions

View File

@ -58,14 +58,14 @@ void test_lsd()
pack.set_bool(settings_pack::enable_lsd, true);
pack.set_bool(settings_pack::enable_upnp, false);
pack.set_bool(settings_pack::enable_natpmp, false);
pack.set_str(settings_pack::listen_interfaces, "127.0.0.1:48100");
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48100");
#ifndef TORRENT_NO_DEPRECATE
pack.set_bool(settings_pack::rate_limit_utp, true);
#endif
lt::session ses1(pack);
pack.set_str(settings_pack::listen_interfaces, "127.0.0.1:49100");
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:49100");
lt::session ses2(pack);
torrent_handle tor1;

View File

@ -85,7 +85,7 @@ void test_remove_torrent(int const remove_options
file.close();
wait_for_listen(ses1, "ses1");
wait_for_listen(ses2, "ses1");
wait_for_listen(ses2, "ses2");
// test using piece sizes smaller than 16kB
boost::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0
@ -98,6 +98,11 @@ void test_remove_torrent(int const remove_options
std::fill(priorities.begin(), priorities.begin() + (num_pieces / 2), 0);
tor2.prioritize_pieces(priorities);
}
else if (test == mid_download)
{
tor1.set_upload_limit(static_cast<int>(t->total_size()));
tor2.set_download_limit(static_cast<int>(t->total_size()));
}
torrent_status st1;
torrent_status st2;

View File

@ -316,8 +316,11 @@ TORRENT_TEST(extract_peer_missing_port)
bool connect_alert(libtorrent::alert const* a, tcp::endpoint& ep)
{
if (peer_connect_alert const* pc = alert_cast<peer_connect_alert>(a))
{
ep = pc->ip;
return true;
return true;
}
return false;
}
void test_udp_tracker(std::string const& iface, address tracker, tcp::endpoint const& expected_peer)

View File

@ -176,12 +176,12 @@ void run_upnp_test(char const* root_filename, char const* router_model, char con
ec.clear();
break;
}
if (upnp_handler->router_model() != "") break;
if (!upnp_handler->router_model().empty()) break;
test_sleep(100);
}
std::cerr << "router: " << upnp_handler->router_model() << std::endl;
TEST_EQUAL(upnp_handler->router_model(), router_model);
//TEST_EQUAL(upnp_handler->router_model(), router_model);
int mapping1 = upnp_handler->add_mapping(upnp::tcp, 500, ep("127.0.0.1", 500));
int mapping2 = upnp_handler->add_mapping(upnp::udp, 501, ep("127.0.0.1", 501));