improve coverage of stop-start-test

This commit is contained in:
arvidn 2015-11-20 22:22:15 -05:00
parent c0d6b20634
commit 4a30653084
3 changed files with 25 additions and 5 deletions

View File

@ -62,7 +62,7 @@ struct test_swarm_config : swarm_config
// more slack for completion // more slack for completion
if (m_flags & stop_start_seed) if (m_flags & stop_start_seed)
{ {
TEST_CHECK(lt::clock_type::now() < m_start_time + lt::milliseconds(3700)); TEST_CHECK(lt::clock_type::now() < m_start_time + lt::milliseconds(4700));
} }
else if (m_flags & stop_start_download) else if (m_flags & stop_start_download)
{ {
@ -133,6 +133,20 @@ struct test_swarm_config : swarm_config
return swarm_config::on_alert(alert, session_idx, torrents, ses); return swarm_config::on_alert(alert, session_idx, torrents, ses);
} }
virtual void on_torrent_added(int session_index, torrent_handle h) override
{
if (m_flags & add_extra_peers)
{
for (int i = 0; i < 30; ++i)
{
char ep[30];
snprintf(ep, sizeof(ep), "60.0.0.%d", i + 1);
h.connect_peer(lt::tcp::endpoint(
lt::address_v4::from_string(ep), 6881));
}
}
}
// called for every torrent that's added (and every session that's started). // called for every torrent that's added (and every session that's started).
// this is useful to give every session a unique save path and to make some // this is useful to give every session a unique save path and to make some
// sessions seeds and others downloaders // sessions seeds and others downloaders

View File

@ -43,7 +43,8 @@ enum test_flags_t
utp_only = 64, utp_only = 64,
stop_start_download = 128, stop_start_download = 128,
stop_start_seed = 256, stop_start_seed = 256,
graceful_pause = 1024 graceful_pause = 1024,
add_extra_peers = 2048
}; };
void EXPORT simulate_swarm(int flags = 0); void EXPORT simulate_swarm(int flags = 0);

View File

@ -57,16 +57,21 @@ TORRENT_TEST(utp)
TORRENT_TEST(stop_start_download) TORRENT_TEST(stop_start_download)
{ {
simulate_swarm(stop_start_download); simulate_swarm(stop_start_download | add_extra_peers);
} }
TORRENT_TEST(stop_start_download_graceful) TORRENT_TEST(stop_start_download_graceful)
{ {
simulate_swarm(stop_start_download | graceful_pause); simulate_swarm(stop_start_download | graceful_pause | add_extra_peers);
} }
TORRENT_TEST(stop_start_seed) TORRENT_TEST(stop_start_seed)
{ {
simulate_swarm(stop_start_seed); simulate_swarm(stop_start_seed | add_extra_peers);
}
TORRENT_TEST(stop_start_seed_graceful)
{
simulate_swarm(stop_start_seed | graceful_pause | add_extra_peers);
} }
TORRENT_TEST(explicit_cache) TORRENT_TEST(explicit_cache)