HomePhabricator

Fix undeterministic call to shouldPoll() in Avalanche tests

Description

Fix undeterministic call to shouldPoll() in Avalanche tests

Summary:
These tests pass consistently with make check but fail ninja check consistently with the following setup:

gcc 8.1.0
clang 7.0.1
boost 1.58.0

The failure occurs at step i = 9, where registerPoll() is called, setting inflight to 10
and then immediately after, the call to shouldPoll() returns false.

Based on reading of the test, it seems clear that shouldPoll() should be evaluated before registerPoll() is called, but apparently compiler differences evaluate the BOOST_CHECK_EQUAL macro differently.

Before writing this diff, I attempted to write the test in such a way as to evaluate registerPoll() and shouldPoll(), in that order, in intermediate variables, as this is the expected order of evaluation when reading the BOOST_CHECK_EQUAL call. This test fails for ninja and make as expected:

-        BOOST_CHECK_EQUAL(vrinflight.registerPoll(), vrinflight.shouldPoll());
+        bool rp = vrinflight.registerPoll();
+        bool sp = vrinflight.shouldPoll();
+        BOOST_CHECK_EQUAL(rp, sp);

Test Plan:

make check
ninja check

Reviewers: deadalnix, Fabien, #bitcoin_abc

Reviewed By: deadalnix, #bitcoin_abc

Subscribers: teamcity, schancel

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

Details

Provenance
jasonbcoxAuthored on Feb 5 2019, 23:54
jasonbcoxPushed on Feb 6 2019, 18:57
Reviewer
Restricted Project
Differential Revision
D2504: Fix undeterministic call to shouldPoll() in Avalanche tests
Parents
rABCb1eb229c4c3f: Fix script error description
Branches
Unknown
Tags
Unknown