HomePhabricator

Fix randomly failing scheduler_tests test

Description

Fix randomly failing scheduler_tests test

Summary:

The root cause is that the original test author was misusing threads and/or synchronization primitives. There is no guarantee that the first main thread runs before the last scheduled task. As such, sometimes, the last task runs and writes "42" into the `counter` before the `BOOST_CHECK_EQUAL(counter, 0)` line gets a chance to be evaluated in the main thread.

Port of bchn#1189.

Test Plan:

ninja all check

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D13177

Details

Provenance
CCulianuAuthored on Apr 22 2021, 18:58
FabienCommitted on Feb 27 2023, 16:16
FabienPushed on Feb 27 2023, 16:16
Reviewer
Restricted Project
Differential Revision
D13177: Fix randomly failing scheduler_tests test
Parents
rABCcde03beeb882: Remove needless timeout in functional test
Branches
Unknown
Tags
Unknown