doc: Improve test READMEs #16953

pull fjahr wants to merge 1 commits into bitcoin:master from fjahr:debugreadme changing 2 files +50 −18
  1. fjahr commented at 1:08 PM on September 24, 2019: member

    General improvements on READMEs for unit tests and functional tests:

    • Give unit test readme a headline
    • Move general information on src/test folder to the top
    • Add information on logging and debugging unit tests
    • Improve debugging and logging information in functional testing
    • Include all available log levels in functional tests
  2. DrahtBot added the label Docs on Sep 24, 2019
  3. DrahtBot added the label Tests on Sep 24, 2019
  4. in src/test/README.md:4 in 420fb36c29 outdated
       0 | @@ -1,3 +1,25 @@
       1 | +# Unit tests
       2 | +
       3 | +The sources in this directory are unit test cases. Boost includes a
       4 | +unit testing framework, and since bitcoin already uses Boost, it makes
    


    practicalswift commented at 1:21 PM on September 24, 2019:

    Nit: s/bitcoin/Bitcoin Core/


    fjahr commented at 2:14 PM on September 24, 2019:

    done

  5. in src/test/README.md:11 in 420fb36c29 outdated
       6 | +configure some other framework (we want as few impediments to creating
       7 | +unit tests as possible).
       8 | +
       9 | +The build system is setup to compile an executable called `test_bitcoin`
      10 | +that runs all of the unit tests. The main source file is called
      11 | +setup_common.cpp.
    


    practicalswift commented at 1:21 PM on September 24, 2019:

    Nit: Use setup_common.cpp instead of "setup_common.cpp".


    fjahr commented at 2:15 PM on September 24, 2019:

    done

  6. in test/README.md:196 in 420fb36c29 outdated
     199 |  
     200 | -use the directory path to get the pid from the pid file:
     201 | +Then you can use the pid to start `gdb`:
     202 |  
     203 |  ```bash
     204 | -cat /tmp/user/1000/testo9vsdjo3/node1/regtest/bitcoind.pid
    


    MarcoFalke commented at 1:58 PM on September 24, 2019:

    Why remove? Is this way no longer possible?


    fjahr commented at 2:09 PM on September 24, 2019:

    It still works but getting the pid from within pdb is just much simpler. But I can add it back if we want to keep it in.


    MarcoFalke commented at 2:44 PM on September 24, 2019:

    Not everyone is running with pdb, so to keep the fallback would be nice


    fjahr commented at 1:31 PM on September 25, 2019:

    Hm, just curious: is there another practical way to pause a functional test besides pdb? Anyway, since it doesn't hurt, I added it back now :)


    mzumsande commented at 3:37 PM on September 25, 2019:

    I rarely use pdb but often add some manual input("Pause") breakpoints. (while running the test directly, not via test_runner).


    fjahr commented at 3:44 PM on September 25, 2019:

    @mzumsande I see. Thanks!


    MarcoFalke commented at 5:11 PM on September 25, 2019:
    import time; time.sleep(10000);
    
  7. MarcoFalke approved
  8. MarcoFalke commented at 1:59 PM on September 24, 2019: member

    LGTM

  9. fjahr force-pushed on Sep 24, 2019
  10. jamesob commented at 2:26 PM on September 24, 2019: member

    ACK

  11. in src/test/README.md:62 in 8c7c2398fc outdated
      72 | -one test file for each class or source file for which you want to create
      73 | -unit tests.  The file naming convention is `<source_filename>_tests.cpp`
      74 | -and such files should wrap their tests in a test suite
      75 | -called `<source_filename>_tests`. For an example of this pattern,
      76 | -examine `uint256_tests.cpp`.
      77 | +For debugging you can launch the test_bitcoin executable with `gbd`or `lldb` and
    


    mzumsande commented at 2:51 PM on September 24, 2019:

    typo: gdb


    fjahr commented at 1:26 PM on September 25, 2019:

    done

  12. in src/test/README.md:18 in 8c7c2398fc outdated
      13 | +### Note on adding test cases
      14 | +
      15 | +To add a new unit test file to our test suite you need
      16 | +to add the file to `src/Makefile.test.include`. The pattern is to create
      17 | +one test file for each class or source file for which you want to create
      18 | +unit tests.  The file naming convention is `<source_filename>_tests.cpp`
    


    mzumsande commented at 2:54 PM on September 24, 2019:

    typo: 2 spaces before "The"


    fjahr commented at 1:26 PM on September 25, 2019:

    done

  13. mzumsande commented at 3:16 PM on September 24, 2019: member

    Concept ACK, found two minor typos. One thing I have been missing in the unit test logging description before is whether there is a good way to view the LogPrint() messages that go to debug.log when they are invoked from a unit test.

  14. MarcoFalke commented at 3:37 PM on September 24, 2019: member

    One thing I have been missing in the unit test logging description before is whether there is a good way to view the LogPrint() messages that go to debug.log when they are invoked from a unit test.

    In theory they are written to the debug.log in the temp data dir (however that dir is deleted when the destructor of the testing setup is called).

    Usually I use LogInstance().m_print_to_console = 1; // TODO remove when debugging a test. Maybe that should be exposed by an env var?

  15. DrahtBot commented at 5:10 PM on September 24, 2019: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #8994 (Testchains: Introduce custom chain whose constructor... by jtimon)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  16. fanquake added the label Waiting for author on Sep 24, 2019
  17. fjahr force-pushed on Sep 25, 2019
  18. fjahr force-pushed on Sep 25, 2019
  19. fjahr commented at 1:35 PM on September 25, 2019: member

    One thing I have been missing in the unit test logging description before is whether there is a good way to view the LogPrint() messages that go to debug.log when they are invoked from a unit test.

    In theory they are written to the debug.log in the temp data dir (however that dir is deleted when the destructor of the testing setup is called).

    Usually I use LogInstance().m_print_to_console = 1; // TODO remove when debugging a test. Maybe that should be exposed by an env var?

    I also thought about this some time ago but did not find a simple way to do this. I will keep Marco's suggestion in mind for a follow-up!

  20. MarcoFalke commented at 6:27 PM on September 25, 2019: member

    ACK afdcfb237e0d86f65eaceff9c3abc181c6f5576e

    <details><summary>Show signature and timestamp</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    ACK afdcfb237e0d86f65eaceff9c3abc181c6f5576e
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUixVgv+IiRmzeRMPczLxZhkhHVl+Q8rzkoEJbz79Ph/CZmUXz94LhDGyPiE8Qhf
    5FiLvLWBJXtDCYSoepjRKL6U32n4u6KOMRy/qxsy4OoaAq3zeTczk+nzsr/sEw0z
    f5hCWnezEC9Pp9rjV84t5ycmgm83z+HBGnSF+Kp+2PVbdezN470SHSpNpRO9YAUI
    DRFV5PF51sm++lOz7NLEwGkQt8sND4KmRhsyp+vnjMCPmF8ZvP3MiJ9+O93DiSKx
    xv+vzTi0jjUrgDPhMGyIz4w7PG1gB6bB022NGro74aeMLRNspooDL7c/m3SkBwy3
    KDwL36dAu4HF78VuKWCJLMqWZAoMQXKWqCeh48XF/OOmFpAill6xE3OpfkRJrGvy
    RnM8V8Dd1qPPpgfLDc/Kv882hObQQFlJOJBC2QyQ/PboGLPVDnjQRoKubJ9judCj
    vQERZz6Mpml67HrrmkIF6Qe3MNDyn/f3M/zgYr9w16HfXakp8mz8dFgJ9sdRmK/f
    RGTBs7hd
    =8aLm
    -----END PGP SIGNATURE-----
    

    Timestamp of file with hash 6cad13c8512fec76fb404b4bec84bdafcb7d4e2a901dcb67122c03aa41764d54 -

    </details>

  21. MarcoFalke removed the label Waiting for author on Sep 25, 2019
  22. in src/test/README.md:21 in afdcfb237e outdated
      16 | +to add the file to `src/Makefile.test.include`. The pattern is to create
      17 | +one test file for each class or source file for which you want to create
      18 | +unit tests. The file naming convention is `<source_filename>_tests.cpp`
      19 | +and such files should wrap their tests in a test suite
      20 | +called `<source_filename>_tests`. For an example of this pattern,
      21 | +examine `uint256_tests.cpp`.
    


    jonatack commented at 10:58 AM on September 26, 2019:

    suggestion: s/examine/see/


    fjahr commented at 5:05 PM on September 26, 2019:

    done

  23. in src/test/README.md:13 in afdcfb237e outdated
       8 | +
       9 | +The build system is setup to compile an executable called `test_bitcoin`
      10 | +that runs all of the unit tests. The main source file is called
      11 | +`setup_common.cpp`.
      12 | +
      13 | +### Note on adding test cases
    


    jonatack commented at 11:08 AM on September 26, 2019:

    Perhaps place the "Adding test cases" after the other sections, as it is perhaps less frequently needed compared to running tests or debugging them.


    fjahr commented at 5:05 PM on September 26, 2019:

    done

  24. in test/README.md:198 in afdcfb237e outdated
     195 | +(pdb) self.node[1].process.pid
     196 | +```
     197 | +
     198 | +Alternatively, you can find the pid by inspecting the temp folder for the specific test
     199 | +you are running. The path to that folder is printed at the beginning of every
     200 | +test execution:
    


    jonatack commented at 11:10 AM on September 26, 2019:

    suggestion: s/test execution/test run/


    fjahr commented at 5:06 PM on September 26, 2019:

    done

  25. in src/test/README.md:9 in afdcfb237e outdated
       0 | @@ -1,3 +1,25 @@
       1 | +# Unit tests
       2 | +
       3 | +The sources in this directory are unit test cases. Boost includes a
       4 | +unit testing framework, and since Bitcoin Core already uses Boost, it makes
       5 | +sense to simply use this framework rather than require developers to
       6 | +configure some other framework (we want as few impediments to creating
       7 | +unit tests as possible).
       8 | +
       9 | +The build system is setup to compile an executable called `test_bitcoin`
    


    jonatack commented at 11:11 AM on September 26, 2019:

    nit: a "setup" is a noun, "set up" is the verb version which should be used here, e.g. "The build system is set up to compile..."


    fjahr commented at 5:06 PM on September 26, 2019:

    done

  26. jonatack commented at 11:11 AM on September 26, 2019: member

    ACK modulo a few suggestions below. Thanks for improving the test docs!

  27. michaelfolkson commented at 12:44 PM on September 26, 2019: contributor

    ACK afdcfb237e0d86f65eaceff9c3abc181c6f5576e. Nice additions.

  28. doc: Improve test READMEs 43e7d576f5
  29. fjahr force-pushed on Sep 26, 2019
  30. laanwj commented at 7:26 AM on September 30, 2019: member

    ACK 43e7d576f590e90ad7d1ba3d550671a7958f1188

  31. laanwj referenced this in commit 9edb2b6550 on Sep 30, 2019
  32. laanwj merged this on Sep 30, 2019
  33. laanwj closed this on Sep 30, 2019

  34. sidhujag referenced this in commit e88a0fcadb on Oct 2, 2019
  35. jasonbcox referenced this in commit 4dd4b5bcbd on Oct 23, 2020
  36. vijaydasmp referenced this in commit 5e2c2cf7b0 on Dec 7, 2021
  37. vijaydasmp referenced this in commit 10be2b15dd on Dec 10, 2021
  38. vijaydasmp referenced this in commit 298acbf950 on Dec 10, 2021
  39. vijaydasmp referenced this in commit 644e21ec0b on Dec 10, 2021
  40. vijaydasmp referenced this in commit 2d782f5f66 on Dec 10, 2021
  41. vijaydasmp referenced this in commit 171c924f20 on Dec 13, 2021
  42. vijaydasmp referenced this in commit 6c01ce4d67 on Dec 13, 2021
  43. vijaydasmp referenced this in commit 8ebc1d4d25 on Dec 13, 2021
  44. vijaydasmp referenced this in commit a6fcc52743 on Dec 15, 2021
  45. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 03:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me