test: fix race condition in rename-test (#2612)

This commit is contained in:
Charles Kerr 2022-02-12 13:51:43 -06:00 committed by GitHub
parent 2410ad2fa6
commit cddd400f7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -102,6 +102,7 @@ static bool verifyTorrent(tr_torrent* tor, bool const* stopFlag)
changed |= hasPiece != hadPiece;
}
tor->checked_pieces_.set(piece, true);
tor->markChanged();
/* sleeping even just a few msec per second goes a long

View File

@ -437,7 +437,13 @@ protected:
EXPECT_FALSE(tr_amInEventThread(tor->session));
tr_torrentVerify(tor);
tr_wait_msec(100);
EXPECT_TRUE(waitFor([tor]() { return tor->verifyState == TR_VERIFY_NONE; }, 4000));
EXPECT_TRUE(waitFor(
[tor]()
{
auto const activity = tr_torrentGetActivity(tor);
return activity != TR_STATUS_CHECK && activity != TR_STATUS_CHECK_WAIT && tor->checked_pieces_.hasAll();
},
4000));
}
tr_session* session_ = nullptr;