-
Notifications
You must be signed in to change notification settings - Fork 36.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: boost unit tests don't handle assert very well #16700
Comments
Seems we need to set BOOST_TEST_CATCH_SYSTEM_ERRORS somewhere and write an handler for abort signal. EDIT:
In fact, abort signals are catched which explains why we see checkpoints, but boost seems to not call destructor |
…ests fac52da test: Set catch_system_errors=no on boost unit tests (MarcoFalke) Pull request description: Closes bitcoin#16700 Can be tested by adding an `assert(0)` and then running either `make check` or `./src/test/test_bitcoin -t bla_tests --catch_system_errors=no/yes` ACKs for top commit: practicalswift: ACK fac52da Empact: Tested ACK bitcoin@fac52da Tree-SHA512: ec00636951b2c1137aaf43610739d78d16f823f7da76a726d47f93b8b089766fb66b21504b3c5413bcf8b6b5c3db0ad74027d677db24a44487d6d79a6bdee2e0
…ests fac52da test: Set catch_system_errors=no on boost unit tests (MarcoFalke) Pull request description: Closes bitcoin#16700 Can be tested by adding an `assert(0)` and then running either `make check` or `./src/test/test_bitcoin -t bla_tests --catch_system_errors=no/yes` ACKs for top commit: practicalswift: ACK fac52da Empact: Tested ACK bitcoin@fac52da Tree-SHA512: ec00636951b2c1137aaf43610739d78d16f823f7da76a726d47f93b8b089766fb66b21504b3c5413bcf8b6b5c3db0ad74027d677db24a44487d6d79a6bdee2e0
Digging up, AFAIU the issue was solved in #18183 by setting Or otherwise do you advise to replace them by exceptions and catching them with BOOST_CHECK_THROW ? Interested in the context of #21515's test coverage. |
I think if you want to exercise a logic error during a unit test, the only way is to throw something, as an assert would abort the process. |
Thanks for the answer! Yes a lot of critical code paths with asserts aren't exercise sadly. |
Obviously that assumes the logic error is reachable during the unit test. If it is not reachable, an |
…ests fac52da test: Set catch_system_errors=no on boost unit tests (MarcoFalke) Pull request description: Closes bitcoin#16700 Can be tested by adding an `assert(0)` and then running either `make check` or `./src/test/test_bitcoin -t bla_tests --catch_system_errors=no/yes` ACKs for top commit: practicalswift: ACK fac52da Empact: Tested ACK bitcoin@fac52da Tree-SHA512: ec00636951b2c1137aaf43610739d78d16f823f7da76a726d47f93b8b089766fb66b21504b3c5413bcf8b6b5c3db0ad74027d677db24a44487d6d79a6bdee2e0
…ests fac52da test: Set catch_system_errors=no on boost unit tests (MarcoFalke) Pull request description: Closes bitcoin#16700 Can be tested by adding an `assert(0)` and then running either `make check` or `./src/test/test_bitcoin -t bla_tests --catch_system_errors=no/yes` ACKs for top commit: practicalswift: ACK fac52da Empact: Tested ACK bitcoin@fac52da Tree-SHA512: ec00636951b2c1137aaf43610739d78d16f823f7da76a726d47f93b8b089766fb66b21504b3c5413bcf8b6b5c3db0ad74027d677db24a44487d6d79a6bdee2e0
…ests fac52da test: Set catch_system_errors=no on boost unit tests (MarcoFalke) Pull request description: Closes bitcoin#16700 Can be tested by adding an `assert(0)` and then running either `make check` or `./src/test/test_bitcoin -t bla_tests --catch_system_errors=no/yes` ACKs for top commit: practicalswift: ACK fac52da Empact: Tested ACK bitcoin@fac52da Tree-SHA512: ec00636951b2c1137aaf43610739d78d16f823f7da76a726d47f93b8b089766fb66b21504b3c5413bcf8b6b5c3db0ad74027d677db24a44487d6d79a6bdee2e0
…ests fac52da test: Set catch_system_errors=no on boost unit tests (MarcoFalke) Pull request description: Closes bitcoin#16700 Can be tested by adding an `assert(0)` and then running either `make check` or `./src/test/test_bitcoin -t bla_tests --catch_system_errors=no/yes` ACKs for top commit: practicalswift: ACK fac52da Empact: Tested ACK bitcoin@fac52da Tree-SHA512: ec00636951b2c1137aaf43610739d78d16f823f7da76a726d47f93b8b089766fb66b21504b3c5413bcf8b6b5c3db0ad74027d677db24a44487d6d79a6bdee2e0
…ests fac52da test: Set catch_system_errors=no on boost unit tests (MarcoFalke) Pull request description: Closes bitcoin#16700 Can be tested by adding an `assert(0)` and then running either `make check` or `./src/test/test_bitcoin -t bla_tests --catch_system_errors=no/yes` ACKs for top commit: practicalswift: ACK fac52da Empact: Tested ACK bitcoin@fac52da Tree-SHA512: ec00636951b2c1137aaf43610739d78d16f823f7da76a726d47f93b8b089766fb66b21504b3c5413bcf8b6b5c3db0ad74027d677db24a44487d6d79a6bdee2e0
…ests fac52da test: Set catch_system_errors=no on boost unit tests (MarcoFalke) Pull request description: Closes bitcoin#16700 Can be tested by adding an `assert(0)` and then running either `make check` or `./src/test/test_bitcoin -t bla_tests --catch_system_errors=no/yes` ACKs for top commit: practicalswift: ACK fac52da Empact: Tested ACK bitcoin@fac52da Tree-SHA512: ec00636951b2c1137aaf43610739d78d16f823f7da76a726d47f93b8b089766fb66b21504b3c5413bcf8b6b5c3db0ad74027d677db24a44487d6d79a6bdee2e0
…ests fac52da test: Set catch_system_errors=no on boost unit tests (MarcoFalke) Pull request description: Closes bitcoin#16700 Can be tested by adding an `assert(0)` and then running either `make check` or `./src/test/test_bitcoin -t bla_tests --catch_system_errors=no/yes` ACKs for top commit: practicalswift: ACK fac52da Empact: Tested ACK bitcoin@fac52da Tree-SHA512: ec00636951b2c1137aaf43610739d78d16f823f7da76a726d47f93b8b089766fb66b21504b3c5413bcf8b6b5c3db0ad74027d677db24a44487d6d79a6bdee2e0
…ests fac52da test: Set catch_system_errors=no on boost unit tests (MarcoFalke) Pull request description: Closes bitcoin#16700 Can be tested by adding an `assert(0)` and then running either `make check` or `./src/test/test_bitcoin -t bla_tests --catch_system_errors=no/yes` ACKs for top commit: practicalswift: ACK fac52da Empact: Tested ACK bitcoin@fac52da Tree-SHA512: ec00636951b2c1137aaf43610739d78d16f823f7da76a726d47f93b8b089766fb66b21504b3c5413bcf8b6b5c3db0ad74027d677db24a44487d6d79a6bdee2e0
When running into an assert failure, the boost unit test framework does not shut down cleanly. It does not call the
BasicTestingSetup
destructor. Thus, the test process will never shut down. As a result of that, the failure is never passed back to the caller.On travis, this will result in frustrating and hard-to-debug timeouts: E.g. https://travis-ci.org/bitcoin/bitcoin/jobs/575909995#L3584
I see two ways to fix this:
asserts
The text was updated successfully, but these errors were encountered: