1

I am running the unit tests from bitcoin source using make check, and would like to debug the tests using LogPrint in the bitcoin source files. I read in the Test Docs that logs are only output to test_framework.log, but I'm unable to locate this file. Where should I be able to find it? Or perhaps there is a better approach?

1 Answer 1

3

You are confusing the two kinds of tests. Unit tests are compiled into a separate binary and run by make check. Functional tests are testing the RPC commands and have to be run explicitly using the test_runner.py script. test_framework.log is only created by the functional tests. The documentation for the unit tests can be found here.

To print messages in the unit tests, you cannot use LogPrintf. Instead use BOOST_TEST_MESSAGE and BOOST_CHECK_MESSAGE to print messages from the tests. You will have to run the test binary directly (src/test/test_bitcoin) with --log_level=all to see the messages.

To print from the source files themselves, you could use fprintf() and print your messages to stderr.

3
  • Ok, that makes more sense, I think this will allow printing messages from the test files, but what about the source files? Eg. net_processing.cpp
    – JBaczuk
    Jun 25, 2018 at 13:33
  • You can use fprintf. Updated the answer
    – Andrew Chow
    Jun 25, 2018 at 20:40
  • nit: The test_runner.py script allows you to run all functional tests in parallel but you don't have to use it. Sep 10, 2020 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.