test log improvements

This commit is contained in:
Arvid Norberg 2013-06-21 01:06:40 +00:00
parent 208321dab0
commit 6b6c06fa0b
3 changed files with 21 additions and 14 deletions

View File

@ -27,13 +27,20 @@ rule libtorrent_dependency ( properties * )
return $(result) ; return $(result) ;
} }
lib libtorrent_test
: # sources
setup_transfer.cpp
dht_server.cpp
peer_server.cpp
: # requirements
<conditional>@libtorrent_dependency
;
project project
: requirements : requirements
<conditional>@libtorrent_dependency
<source>main.cpp <source>main.cpp
<source>setup_transfer.cpp <conditional>@libtorrent_dependency
<source>dht_server.cpp <library>libtorrent_test/<link>shared
<source>peer_server.cpp
: default-build : default-build
<threading>multi <threading>multi
<invariant-checks>full <invariant-checks>full

View File

@ -109,14 +109,14 @@ bool print_alerts(libtorrent::session& ses, char const* name
if (predicate && predicate(*i)) ret = true; if (predicate && predicate(*i)) ret = true;
if (peer_disconnected_alert* p = alert_cast<peer_disconnected_alert>(*i)) if (peer_disconnected_alert* p = alert_cast<peer_disconnected_alert>(*i))
{ {
fprintf(stderr, "%s(%s): %s\n", name, print_endpoint(p->ip).c_str(), p->message().c_str()); fprintf(stderr, " %s(%s): %s\n", name, print_endpoint(p->ip).c_str(), p->message().c_str());
} }
else if ((*i)->message() != "block downloading" else if ((*i)->message() != "block downloading"
&& (*i)->message() != "block finished" && (*i)->message() != "block finished"
&& (*i)->message() != "piece finished" && (*i)->message() != "piece finished"
&& !no_output) && !no_output)
{ {
fprintf(stderr, "%s: %s\n", name, (*i)->message().c_str()); fprintf(stderr, " %s: %s\n", name, (*i)->message().c_str());
} }
TEST_CHECK(alert_cast<fastresume_rejected_alert>(*i) == 0 || allow_failed_fastresume); TEST_CHECK(alert_cast<fastresume_rejected_alert>(*i) == 0 || allow_failed_fastresume);
@ -124,7 +124,7 @@ bool print_alerts(libtorrent::session& ses, char const* name
peer_error_alert* pea = alert_cast<peer_error_alert>(*i); peer_error_alert* pea = alert_cast<peer_error_alert>(*i);
if (pea) if (pea)
{ {
fprintf(stderr, "peer error: %s\n", pea->error.message().c_str()); fprintf(stderr, " peer error: %s\n", pea->error.message().c_str());
TEST_CHECK((!handles.empty() && h.status().is_seeding) TEST_CHECK((!handles.empty() && h.status().is_seeding)
|| pea->error.message() == "connecting to peer" || pea->error.message() == "connecting to peer"
|| pea->error.message() == "closing connection to ourself" || pea->error.message() == "closing connection to ourself"
@ -167,12 +167,11 @@ void print_ses_rate(float time
, libtorrent::torrent_status const* st2 , libtorrent::torrent_status const* st2
, libtorrent::torrent_status const* st3) , libtorrent::torrent_status const* st3)
{ {
std::cerr fprintf(stderr, "%3.1fs | %dkB/s %dkB/s %d%% %d", time
<< time << "s " , int(st1->download_payload_rate / 1000)
<< int(st1->download_payload_rate / 1000.f) << "kB/s " , int(st1->upload_payload_rate / 1000)
<< int(st1->upload_payload_rate / 1000.f) << "kB/s " , int(st1->progress * 100)
<< int(st1->progress * 100) << "% " , st1->num_peers);
<< st1->num_peers;
if (st2) if (st2)
std::cerr << " : " std::cerr << " : "
<< int(st2->download_payload_rate / 1000.f) << "kB/s " << int(st2->download_payload_rate / 1000.f) << "kB/s "
@ -188,7 +187,7 @@ void print_ses_rate(float time
<< st3->num_peers << st3->num_peers
<< " cc: " << st3->connect_candidates; << " cc: " << st3->connect_candidates;
std::cerr << std::endl; fprintf(stderr, "\n");
} }
void test_sleep(int millisec) void test_sleep(int millisec)

View File

@ -298,6 +298,7 @@ def main(argv):
# a precautio to make sure a malicious repo # a precautio to make sure a malicious repo
# won't clean things outside of the test directory # won't clean things outside of the test directory
if not os.path.abspath(f).startswith(test_dir): continue if not os.path.abspath(f).startswith(test_dir): continue
print 'deleting %s' %f
os.rmdirs(f) os.rmdirs(f)
finally: finally:
# always restore current directory # always restore current directory