attempt to log more and potentially fix wait_for_downloading in unit tests

This commit is contained in:
arvidn 2015-08-26 21:47:20 -04:00 committed by arvidn
parent 8830d61cca
commit e3591c3a1c
2 changed files with 12 additions and 4 deletions

View File

@ -335,14 +335,22 @@ bool downloading_alert(libtorrent::alert const* a)
void wait_for_downloading(lt::session& ses, char const* name)
{
time_point start = clock_type::now();
downloading_done = false;
alert const* a = 0;
do
{
print_alerts(ses, name, true, true, true, &downloading_alert, false);
if (downloading_done) break;
a = ses.wait_for_alert(milliseconds(500));
if (total_seconds(clock_type::now() - start) > 10) break;
a = ses.wait_for_alert(seconds(2));
} while (a);
if (!downloading_done)
{
fprintf(stderr, "did not receive a state_changed_alert indicating "
"the torrent is downloading. waited: %d ms\n"
, int(total_milliseconds(clock_type::now() - start)));
}
}
void print_ses_rate(float time

View File

@ -212,7 +212,7 @@ void test_swarm(int flags)
while ((ret = ses1.wait_for_alert(seconds(2))))
{
fprintf(stderr, "wait returned: %d ms\n"
, total_milliseconds(clock_type::now() - start));
, int(total_milliseconds(clock_type::now() - start)));
std::vector<alert*> alerts;
ses1.pop_alerts(&alerts);
for (std::vector<alert*>::iterator i = alerts.begin()
@ -224,7 +224,7 @@ void test_swarm(int flags)
}
fprintf(stderr, "loop returned: %d ms\n"
, total_milliseconds(clock_type::now() - start));
, int(total_milliseconds(clock_type::now() - start)));
// this allows shutting down the sessions in parallel
p1 = ses1.abort();
@ -233,7 +233,7 @@ void test_swarm(int flags)
time_point end = clock_type::now();
fprintf(stderr, "time: %d ms\n", total_milliseconds(end - start));
fprintf(stderr, "time: %d ms\n", int(total_milliseconds(end - start)));
TEST_CHECK(end - start < seconds(3));
TEST_CHECK(end - start >= seconds(2));