HomePhabricator

sigcheckcount_tests: better macro

Description

sigcheckcount_tests: better macro

Summary:
I noticed flags & ~SCRIPT_REPORT_SIGCHECKS was not expanding in the
intended way (gcc was warning this, but not clang). Classic macro
mistake, also there are other macro gotchas - this would have been
classified as an 'unsafe macro'.

https://wiki.sei.cmu.edu/confluence/display/c/PRE01-C.+Use+parentheses+within+macros+around+parameter+names
https://wiki.sei.cmu.edu/confluence/display/c/PRE12-C.+Do+not+define+unsafe+macros

The reason for using macros here was to make sure the origin of a
test failure can be printed out, as it's quite annoying to have a
context-less failure in an inner function. Fortunately
BOOST_TEST_CONTEXT provides a much nicer and more generic way to
give context, and I use it to make a safe macro instead. Awesome!

https://www.boost.org/doc/libs/1_72_0/libs/test/doc/html/boost_test/test_output/test_tools_support_for_logging/contexts.html#boost_test.test_output.test_tools_support_for_logging.contexts.scope_bound_context

Test Plan:
ninja check

Try changing the last test's 2 to a 1, you will then see:

../src/test/sigcheckcount_tests.cpp(328): error: in "sigcheckcount_tests/test_verifyscript": check metricsRet.nSigChecks == expected_sigchecks has failed [2 != 1]
Failure occurred in a following context:
    ../src/test/sigcheckcount_tests.cpp:365

*** 1 failure is detected in the test module "Bitcoin Test Suite"

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

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

Details

Provenance
Mark Lundeberg <markblundeberg@users.noreply.github.com>Authored on Feb 4 2020, 13:58
nakihitoPushed on Feb 4 2020, 20:22
Reviewer
Restricted Project
Differential Revision
D5153: sigcheckcount_tests: better macro
Parents
rSTAGINGa325a27e7eb9: Increase timeout in avalanche test
Branches
Unknown
Tags
Unknown
References
tag: phabricator/base/16014
Tasks
T704: sigChecks implementation