attempt to make test_priority a bit more robust

This commit is contained in:
Arvid Norberg 2013-10-14 04:37:40 +00:00
parent 01c42720e1
commit bb72af6bbe
1 changed files with 10 additions and 8 deletions

View File

@ -326,8 +326,6 @@ void test_transfer()
TEST_CHECK(std::find_if(tr.begin(), tr.end()
, boost::bind(&announce_entry::url, _1) == "http://test.com/announce") != tr.end());
peer_disconnects = 0;
// wait for the files in ses2 to be checked, i.e. the torrent
// to turn into finished state
for (int i = 0; i < 5; ++i)
@ -340,8 +338,6 @@ void test_transfer()
TEST_EQUAL(st1.state, torrent_status::seeding);
if (peer_disconnects >= 1) break;
if (st2.is_finished) break;
test_sleep(100);
@ -356,13 +352,15 @@ void test_transfer()
peer_disconnects = 0;
torrent_status st1 = tor1.status();
torrent_status st2 = tor2.status();
for (int i = 0; i < 130; ++i)
{
print_alerts(ses1, "ses1", true, true, true, &on_alert);
print_alerts(ses2, "ses2", true, true, true, &on_alert);
torrent_status st1 = tor1.status();
torrent_status st2 = tor2.status();
st1 = tor1.status();
st2 = tor2.status();
if (i % 10 == 0)
print_ses_rate(i / 10.f, &st1, &st2);
@ -372,12 +370,16 @@ void test_transfer()
TEST_EQUAL(st1.state, torrent_status::seeding);
TEST_EQUAL(st2.state, torrent_status::downloading);
if (peer_disconnects >= 1) break;
if (peer_disconnects >= 2)
{
printf("too many disconnects (%d), exiting\n", peer_disconnects);
break;
}
test_sleep(100);
}
TEST_CHECK(tor2.status().is_seeding);
TEST_CHECK(st2.is_seeding);
// this allows shutting down the sessions in parallel
p1 = ses1.abort();