don't print color output from tests (to make it work with some of the regression testing tools)
This commit is contained in:
@@ -67,17 +67,7 @@ bool tests_failure = false;
|
|||||||
|
|
||||||
void report_failure(char const* err, char const* file, int line)
|
void report_failure(char const* err, char const* file, int line)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_WINDOWS
|
fprintf(stderr, "\n***** %s:%d \"%s\" *****\n\n", file, line, err);
|
||||||
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
||||||
SetConsoleTextAttribute(out, FOREGROUND_RED);
|
|
||||||
char buffer[1024];
|
|
||||||
int len = snprintf(buffer, sizeof(buffer), "\n**** %s:%d \"%s\" ****\n\n", file, line, err);
|
|
||||||
DWORD written;
|
|
||||||
WriteFile(out, buffer, len, &written, NULL);
|
|
||||||
SetConsoleTextAttribute(out, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
|
||||||
#else
|
|
||||||
fprintf(stderr, "\033[31m %s:%d \"%s\"\033[0m\n", file, line, err);
|
|
||||||
#endif
|
|
||||||
tests_failure = true;
|
tests_failure = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,6 +140,33 @@ void wait_for_listen(libtorrent::session& ses, char const* name)
|
|||||||
} while (a);
|
} while (a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_ses_rate(libtorrent::torrent_status const* st1
|
||||||
|
, libtorrent::torrent_status const* st2
|
||||||
|
, libtorrent::torrent_status const* st3)
|
||||||
|
{
|
||||||
|
std::cerr
|
||||||
|
<< int(st1->download_payload_rate / 1000.f) << "kB/s "
|
||||||
|
<< int(st1->upload_payload_rate / 1000.f) << "kB/s "
|
||||||
|
<< int(st1->progress * 100) << "% "
|
||||||
|
<< st1->num_peers;
|
||||||
|
if (st2)
|
||||||
|
std::cerr << " : "
|
||||||
|
<< int(st2->download_payload_rate / 1000.f) << "kB/s "
|
||||||
|
<< int(st2->upload_payload_rate / 1000.f) << "kB/s "
|
||||||
|
<< int(st2->progress * 100) << "% "
|
||||||
|
<< st2->num_peers
|
||||||
|
<< " cc: " << st2->connect_candidates;
|
||||||
|
if (st3)
|
||||||
|
std::cerr << " : "
|
||||||
|
<< int(st3->download_payload_rate / 1000.f) << "kB/s "
|
||||||
|
<< int(st3->upload_payload_rate / 1000.f) << "kB/s "
|
||||||
|
<< int(st3->progress * 100) << "% "
|
||||||
|
<< st3->num_peers
|
||||||
|
<< " cc: " << st3->connect_candidates;
|
||||||
|
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
void test_sleep(int millisec)
|
void test_sleep(int millisec)
|
||||||
{
|
{
|
||||||
libtorrent::sleep(millisec);
|
libtorrent::sleep(millisec);
|
||||||
|
@@ -40,8 +40,13 @@ namespace libtorrent
|
|||||||
{
|
{
|
||||||
class alert;
|
class alert;
|
||||||
struct add_torrent_params;
|
struct add_torrent_params;
|
||||||
|
struct session_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_ses_rate(libtorrent::torrent_status const* st1
|
||||||
|
, libtorrent::torrent_status const* st2
|
||||||
|
, libtorrent::torrent_status const* st3 = NULL);
|
||||||
|
|
||||||
bool print_alerts(libtorrent::session& ses, char const* name
|
bool print_alerts(libtorrent::session& ses, char const* name
|
||||||
, bool allow_disconnects = false
|
, bool allow_disconnects = false
|
||||||
, bool allow_no_torrents = false
|
, bool allow_no_torrents = false
|
||||||
|
@@ -103,18 +103,7 @@ void test_swarm()
|
|||||||
torrent_status st2 = tor2.status();
|
torrent_status st2 = tor2.status();
|
||||||
torrent_status st3 = tor3.status();
|
torrent_status st3 = tor3.status();
|
||||||
|
|
||||||
std::cerr
|
print_ses_rate(&st1, &st2, &st3);
|
||||||
<< "\033[33m" << int(st1.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< st1.num_peers << " " << st.allowed_upload_slots << ": "
|
|
||||||
<< "\033[32m" << int(st2.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[31m" << int(st2.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st2.progress * 100) << "% "
|
|
||||||
<< st2.num_peers << " - "
|
|
||||||
<< "\033[32m" << int(st3.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[31m" << int(st3.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st3.progress * 100) << "% "
|
|
||||||
<< st3.num_peers
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
test_sleep(1000);
|
test_sleep(1000);
|
||||||
}
|
}
|
||||||
|
@@ -69,12 +69,7 @@ void test_lsd()
|
|||||||
torrent_status st1 = tor1.status();
|
torrent_status st1 = tor1.status();
|
||||||
torrent_status st2 = tor2.status();
|
torrent_status st2 = tor2.status();
|
||||||
|
|
||||||
std::cerr
|
print_ses_rate(&st1, &st2);
|
||||||
<< "\033[33m" << int(st1.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[32m" << int(st2.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[31m" << int(st2.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st2.progress * 100) << "% "
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
if (st2.is_seeding /*&& st3.is_seeding*/) break;
|
if (st2.is_seeding /*&& st3.is_seeding*/) break;
|
||||||
test_sleep(1000);
|
test_sleep(1000);
|
||||||
|
@@ -94,14 +94,7 @@ void test_transfer(bool clear_files, bool disconnect
|
|||||||
torrent_status st1 = tor1.status();
|
torrent_status st1 = tor1.status();
|
||||||
torrent_status st2 = tor2.status();
|
torrent_status st2 = tor2.status();
|
||||||
|
|
||||||
std::cerr
|
print_ses_rate(&st1, &st2);
|
||||||
<< "\033[33m" << int(st1.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< st1.num_peers << ": "
|
|
||||||
<< "\033[32m" << int(st2.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[31m" << int(st2.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st2.progress * 100) << "% "
|
|
||||||
<< st2.num_peers
|
|
||||||
<< std::endl;
|
|
||||||
if (st2.is_seeding) break;
|
if (st2.is_seeding) break;
|
||||||
test_sleep(1000);
|
test_sleep(1000);
|
||||||
}
|
}
|
||||||
|
@@ -118,18 +118,7 @@ void test_pex()
|
|||||||
st2 = tor2.status();
|
st2 = tor2.status();
|
||||||
st3 = tor3.status();
|
st3 = tor3.status();
|
||||||
|
|
||||||
std::cerr
|
print_ses_rate(&st1, &st2, &st3);
|
||||||
<< "\033[33m" << int(st1.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< st1.num_peers << ": "
|
|
||||||
<< "\033[32m" << int(st2.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[31m" << int(st2.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st2.progress * 100) << "% "
|
|
||||||
<< st2.num_peers << " - "
|
|
||||||
<< "\033[32m" << int(st3.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[31m" << int(st3.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st3.progress * 100) << "% "
|
|
||||||
<< st3.num_peers
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
// this is the success condition
|
// this is the success condition
|
||||||
if (st1.num_peers == 2 && st2.num_peers == 2 && st3.num_peers == 2)
|
if (st1.num_peers == 2 && st2.num_peers == 2 && st3.num_peers == 2)
|
||||||
|
@@ -131,18 +131,7 @@ void test_swarm(bool super_seeding = false, bool strict = false, bool seed_mode
|
|||||||
++count_dl_rates3;
|
++count_dl_rates3;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr
|
print_ses_rate(&st1, &st2, &st3);
|
||||||
<< "\033[33m" << int(st1.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< st1.num_peers << ": "
|
|
||||||
<< "\033[32m" << int(st2.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[31m" << int(st2.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st2.progress * 100) << "% "
|
|
||||||
<< st2.num_peers << " - "
|
|
||||||
<< "\033[32m" << int(st3.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[31m" << int(st3.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st3.progress * 100) << "% "
|
|
||||||
<< st3.num_peers
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
if (st2.is_seeding && st3.is_seeding) break;
|
if (st2.is_seeding && st3.is_seeding) break;
|
||||||
test_sleep(1000);
|
test_sleep(1000);
|
||||||
|
@@ -91,13 +91,7 @@ void test_rate()
|
|||||||
torrent_status st2 = tor2.status();
|
torrent_status st2 = tor2.status();
|
||||||
|
|
||||||
if (i % 10 == 0)
|
if (i % 10 == 0)
|
||||||
{
|
print_ses_rate(&st1, &st2);
|
||||||
std::cerr
|
|
||||||
<< "up: \033[33m" << st1.upload_payload_rate / 1000000.f << "MB/s "
|
|
||||||
<< " down: \033[32m" << st2.download_payload_rate / 1000000.f << "MB/s "
|
|
||||||
<< "\033[0m" << int(st2.progress * 100) << "% "
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (st2.is_seeding) break;
|
if (st2.is_seeding) break;
|
||||||
test_sleep(100);
|
test_sleep(100);
|
||||||
@@ -370,18 +364,7 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
|
|||||||
|
|
||||||
if (i % 10 == 0)
|
if (i % 10 == 0)
|
||||||
{
|
{
|
||||||
std::cerr
|
print_ses_rate(&st1, &st2);
|
||||||
<< "\033[32m" << int(st1.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[33m" << int(st1.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st1.progress * 100) << "% "
|
|
||||||
<< st1.num_peers
|
|
||||||
<< ": "
|
|
||||||
<< "\033[32m" << int(st2.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[31m" << int(st2.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st2.progress * 100) << "% "
|
|
||||||
<< st2.num_peers
|
|
||||||
<< " cc: " << st2.connect_candidates
|
|
||||||
<< std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!test_move_storage && st2.progress > 0.25f)
|
if (!test_move_storage && st2.progress > 0.25f)
|
||||||
@@ -439,7 +422,9 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
|
|||||||
print_alerts(ses2, "ses2");
|
print_alerts(ses2, "ses2");
|
||||||
torrent_status st2 = tor2.status();
|
torrent_status st2 = tor2.status();
|
||||||
if (i % 10 == 0)
|
if (i % 10 == 0)
|
||||||
std::cerr << "\033[0m" << int(st2.progress * 100) << "% " << std::endl;
|
{
|
||||||
|
std::cerr << int(st2.progress * 100) << "% " << std::endl;
|
||||||
|
}
|
||||||
if (st2.state != torrent_status::checking_files) break;
|
if (st2.state != torrent_status::checking_files) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,7 +435,6 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
|
|||||||
{
|
{
|
||||||
print_alerts(ses2, "ses2");
|
print_alerts(ses2, "ses2");
|
||||||
torrent_status st2 = tor2.status();
|
torrent_status st2 = tor2.status();
|
||||||
// std::cerr << "\033[0m" << int(st2.progress * 100) << "% " << std::endl;
|
|
||||||
TEST_CHECK(st2.state == torrent_status::finished);
|
TEST_CHECK(st2.state == torrent_status::finished);
|
||||||
test_sleep(100);
|
test_sleep(100);
|
||||||
}
|
}
|
||||||
@@ -552,20 +536,7 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
|
|||||||
torrent_status st2 = tor2.status();
|
torrent_status st2 = tor2.status();
|
||||||
|
|
||||||
if (i % 10 == 0)
|
if (i % 10 == 0)
|
||||||
{
|
print_ses_rate(&st1, &st2);
|
||||||
std::cerr
|
|
||||||
<< "\033[32m" << int(st1.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[33m" << int(st1.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st1.progress * 100) << "% "
|
|
||||||
<< st1.num_peers
|
|
||||||
<< ": "
|
|
||||||
<< "\033[32m" << int(st2.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[31m" << int(st2.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st2.progress * 100) << "% "
|
|
||||||
<< st2.num_peers
|
|
||||||
<< " cc: " << st2.connect_candidates
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tor2.status().is_finished) break;
|
if (tor2.status().is_finished) break;
|
||||||
|
|
||||||
|
@@ -115,18 +115,7 @@ void test_transfer()
|
|||||||
torrent_status st1 = tor1.status();
|
torrent_status st1 = tor1.status();
|
||||||
torrent_status st2 = tor2.status();
|
torrent_status st2 = tor2.status();
|
||||||
|
|
||||||
std::cerr
|
print_ses_rate(&st1, &st2);
|
||||||
<< "\033[32m" << int(st1.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[33m" << int(st1.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st1.progress * 100) << "% "
|
|
||||||
<< st1.num_peers
|
|
||||||
<< ": "
|
|
||||||
<< "\033[32m" << int(st2.download_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[31m" << int(st2.upload_payload_rate / 1000.f) << "kB/s "
|
|
||||||
<< "\033[0m" << int(st2.progress * 100) << "% "
|
|
||||||
<< st2.num_peers
|
|
||||||
<< " cc: " << st2.connect_candidates
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
if (st2.is_finished) break;
|
if (st2.is_finished) break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user