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:19
Parents
rSTAGINGcde03beeb882: Remove needless timeout in functional test
Branches
Unknown
Tags
Unknown
References
tag: phabricator/base/38079, tag: phabricator/base/38078, tag: phabricator/base/38077, tag: phabricator/base/38073

Event Timeline