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.
This commit is contained in:
d-komarov 2018-02-19 00:18:57 +02:00 committed by Arvid Norberg
parent 41b3d437de
commit 18a4f82b5c
1 changed files with 4 additions and 6 deletions

View File

@ -218,22 +218,20 @@ void test_transfer(lt::session& ses, boost::shared_ptr<torrent_info> 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);
}
}