This is needed for the next commit.
Also, it doesn't really test anything novel. wait_for_debug_log is
inherently racy, so will randomly terminate at the exact point or later.
So the randomization is already sufficiently covered by the existing
test.
This is a partial backport of core#24192
https://github.com/bitcoin/bitcoin/pull/24192/commits/fa4595deb334f14dac9ba481d786a823e0f0fde1
Depends on D12617