From e515dd5c25cf8e5136675fd64f9e4e4db0ee089c Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 14 Oct 2013 07:09:57 +0000 Subject: [PATCH] unittest polishing --- test/test_auto_unchoke.cpp | 2 +- test/test_metadata_extension.cpp | 15 +++++++++++---- test/test_transfer.cpp | 6 +++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/test/test_auto_unchoke.cpp b/test/test_auto_unchoke.cpp index 8d748013e..0615476fc 100644 --- a/test/test_auto_unchoke.cpp +++ b/test/test_auto_unchoke.cpp @@ -95,7 +95,7 @@ void test_swarm() boost::tie(tor1, tor2, tor3) = setup_transfer(&ses1, &ses2, &ses3, true, false, true, "_unchoke"); session_status st = ses1.status(); - TEST_CHECK(st.allowed_upload_slots == 1); + TEST_EQUAL(st.allowed_upload_slots, 1); for (int i = 0; i < 100; ++i) { print_alerts(ses1, "ses1"); diff --git a/test/test_metadata_extension.cpp b/test/test_metadata_extension.cpp index 362d84d18..f2bed51da 100644 --- a/test/test_metadata_extension.cpp +++ b/test/test_metadata_extension.cpp @@ -106,7 +106,7 @@ void test_transfer(int flags TEST_CHECK(tor2.status().has_metadata); std::cerr << "waiting for transfer to complete\n"; - for (int i = 0; i < 20; ++i) + for (int i = 0; i < timeout * 10; ++i) { torrent_status st1 = tor1.status(); torrent_status st2 = tor2.status(); @@ -137,11 +137,18 @@ int test_main() { using namespace libtorrent; - for (int f = 0; f <= (clear_files | disconnect | full_encryption); ++f) - test_transfer(f, &create_metadata_plugin, 5); +#ifdef TORRENT_USE_VALGRIND + const int timeout = 8; +#else + const int timeout = 3; +#endif for (int f = 0; f <= (clear_files | disconnect | full_encryption); ++f) - test_transfer(f, &create_ut_metadata_plugin, 2); + test_transfer(f, &create_metadata_plugin, timeout * 2); + + + for (int f = 0; f <= (clear_files | disconnect | full_encryption); ++f) + test_transfer(f, &create_ut_metadata_plugin, timeout); error_code ec; remove_all("tmp1", ec); diff --git a/test/test_transfer.cpp b/test/test_transfer.cpp index d360e0593..3e0ddd05c 100644 --- a/test/test_transfer.cpp +++ b/test/test_transfer.cpp @@ -285,12 +285,12 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe for (int i = 0; i < 200; ++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(); + print_alerts(ses1, "ses1", true, true, true, &on_alert); + print_alerts(ses2, "ses2", true, true, true, &on_alert); + if (i % 10 == 0) { print_ses_rate(i / 10.f, &st1, &st2);