From 18a4f82b5c95593349b5c48cad6497cbd99ed6ff Mon Sep 17 00:00:00 2001 From: d-komarov Date: Mon, 19 Feb 2018 00:18:57 +0200 Subject: [PATCH] Fix test_transfer sync of torrent stats Evaluate torrent total blocks count only once. Equalize synchronization of 'disk.disk_blocks_in_use' check used to break cycle with TEST_CHECK statement. This makes tests that refer to web seeds execute much faster. --- test/web_seed_suite.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/web_seed_suite.cpp b/test/web_seed_suite.cpp index c9d76210b..31a754c60 100644 --- a/test/web_seed_suite.cpp +++ b/test/web_seed_suite.cpp @@ -218,22 +218,20 @@ void test_transfer(lt::session& ses, boost::shared_ptr torrent_fil if (st.is_seeding) { + boost::int64_t const total_blocks = (torrent_file->total_size() + 0x3fff) / 0x4000; // we need to sleep here a bit to let the session sync with the torrent stats // commented out because it takes such a long time for (int i = 0; i < 50; ++i) { cnt = get_counters(ses); - if (cnt["disk.read_cache_blocks"] - == (torrent_file->total_size() + 0x3fff) / 0x4000 - && cnt["disk.disk_blocks_in_use"] - == (torrent_file->total_size() + 0x3fff) / 0x4000) + if (std::abs(int(cnt["disk.read_cache_blocks"] - total_blocks)) <= 2 && + std::abs(int(cnt["disk.disk_blocks_in_use"] - total_blocks)) <= 2) break; fprintf(stdout, "cache_size: %d/%d\n", int(cnt["disk.read_cache_blocks"]) , int(cnt["disk.disk_blocks_in_use"])); test_sleep(100); } - TEST_CHECK(std::abs(int(cnt["disk.disk_blocks_in_use"] - - (torrent_file->total_size() + 0x3fff) / 0x4000)) <= 2); + TEST_CHECK(std::abs(int(cnt["disk.disk_blocks_in_use"] - total_blocks)) <= 2); } }