test: Create new test library #17384

pull MarcoFalke wants to merge 2 commits into bitcoin:master from MarcoFalke:1911-testLib changing 103 files +139 −128
  1. MarcoFalke commented at 8:29 pm on November 5, 2019: member

    Sorry for clickbait, this is only a move-only scripted-diff commit and one documentation commit.

    Longer term, someone who knows something about build systems can make this an actual library. Motivation for this is that each module gets compiled for each target that includes it. For example, setup_common is compiled 27 times (for the fuzz suite) and another 3 times for the other tests (bench, unit test, gui)

  2. fanquake added the label Tests on Nov 5, 2019
  3. MarcoFalke force-pushed on Nov 5, 2019
  4. DrahtBot commented at 11:20 pm on November 5, 2019: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #15845 (wallet: Fast rescan with BIP157 block filters by MarcoFalke)

    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.

  5. laanwj commented at 10:52 am on November 6, 2019: member
    I’d be interested to know what the motivation for this is, are you planning to use this library from multiple binaries, or is it just organizational?
  6. MarcoFalke commented at 12:14 pm on November 6, 2019: member

    I’d be interested to know what the motivation for this is, are you planning to use this library from multiple binaries, or is it just organizational?

    Yes, that is the motivation that I mentioned in the readme.

    Also, we compile each file in the library (as of today) multiple times (for each target), so that should be fixed as well.

  7. MarcoFalke force-pushed on Nov 6, 2019
  8. laanwj commented at 12:32 pm on November 6, 2019: member

    Also, we compile each file in the library (as of today) multiple times (for each target), so that should be fixed as well.

    Can you give an example?

  9. MarcoFalke commented at 12:47 pm on November 6, 2019: member

    Can you give an example?

    setup_common is compiled 27 times (for the fuzz suite) and another 3 times for the other tests (bench, unit test, gui)

  10. mzumsande commented at 12:51 pm on November 6, 2019: member
    How about moving the content of src/test/util.h and src/test/util.cpp into the library as well (possibly into specific modules, much of it seems to be block and address-related)?
  11. laanwj commented at 12:54 pm on November 6, 2019: member

    setup_common is compiled 27 times (for the fuzz suite) and another 3 times for the other tests (bench, unit test, gui)

    Whoa. Yes, then it’s quite a serious issue!

  12. MarcoFalke commented at 1:11 pm on November 6, 2019: member

    How about moving the content of src/test/util.h and src/test/util.cpp into the library as well (possibly into specific modules, much of it seems to be block and address-related)?

    Good point. I think I will leave this for later, so that this changeset can be kept a move-only scripted-diff

  13. MarcoFalke commented at 1:18 pm on November 6, 2019: member
    This pull should also fix the appveyor failures: #17357 (comment)
  14. DrahtBot commented at 1:27 pm on November 6, 2019: member
    I’ve cancelled all appveyor builds, since they are about to fail anyway. Let’s see if this one passes.
  15. in src/test/lib/README.md:4 in fada0b7442 outdated
    0@@ -0,0 +1,11 @@
    1+# Test library
    2+
    3+This contains all files for the test library, which is used by all test binaries (unit tests, benchmarks, fuzzers, gui
    4+tests)
    


    jonatack commented at 2:31 pm on November 6, 2019:
    nit: missing “.” at end of sentence
  16. in src/test/lib/README.md:6 in fada0b7442 outdated
    0@@ -0,0 +1,11 @@
    1+# Test library
    2+
    3+This contains all files for the test library, which is used by all test binaries (unit tests, benchmarks, fuzzers, gui
    4+tests)
    5+
    6+Generally, the files in this folder should be well separated modules. New code should be added to existing modules or
    


    jonatack commented at 2:32 pm on November 6, 2019:
    s/well separated/well-separated/
  17. in src/test/lib/README.md:9 in fada0b7442 outdated
    0@@ -0,0 +1,11 @@
    1+# Test library
    2+
    3+This contains all files for the test library, which is used by all test binaries (unit tests, benchmarks, fuzzers, gui
    4+tests)
    5+
    6+Generally, the files in this folder should be well separated modules. New code should be added to existing modules or
    7+(when in doubt) a new module should be created.
    8+
    9+The utilities in here are compiled into a library, which does not hold any state. However, the main file `setup_common`
    


    jonatack commented at 2:33 pm on November 6, 2019:
    does this refer to setup_common.cpp, setup_common.h, or both?

    jonatack commented at 2:35 pm on November 6, 2019:
    nit: can remove the comma after “library”

    MarcoFalke commented at 3:25 pm on November 6, 2019:
    both

    jonatack commented at 10:17 am on November 7, 2019:
    You were right. A non-restrictive clause beginning with “that” would take no comma, but a non-restrictive clause beginning with “which” does take a comma.
  18. jonatack commented at 2:36 pm on November 6, 2019: member
    Concept ACK. A few suggestions for the doc below.
  19. MarcoFalke commented at 3:22 pm on November 6, 2019: member
  20. MarcoFalke force-pushed on Nov 6, 2019
  21. MarcoFalke commented at 3:28 pm on November 6, 2019: member

    Added a dot at the end of the sentence, among other minor doc fixups as requested by @jonatack

    No code changes, so the previous ci builds are still valid.

  22. ryanofsky approved
  23. ryanofsky commented at 4:26 pm on November 6, 2019: member

    Code review ACK fa6fb57837f7d0db90eb4bdf3b644ba540db1805. Seems good to separate test utilities from unit tests, since it’s natural for things like benchmarks, fuzzing, or simulation tools to depend on test utilities, but you wouldn’t want those things depending on unit tests.

    Feel free to ignore this suggestion, but I think it’d be better to rename src/test/lib directory back to src/test/util. It’s normal to see lib prefixes in library paths (especially since they get added automatically by the linker), but not really normal to see lib/ in #include strings, and not something we have for any of our other libraries.

  24. scripted-diff: test: Move setup_common to test library
    -BEGIN VERIFY SCRIPT-
     # Move files
     for f in $(git ls-files src/test/lib/); do git mv $f src/test/util/; done
     git mv src/test/setup_common.cpp                     src/test/util/
     git mv src/test/setup_common.h                       src/test/util/
     # Replace Windows paths
     sed -i -e 's|\\setup_common|\\util\\setup_common|g' $(git grep -l '\\setup_common')
     sed -i -e 's|src\\test\\lib\\|src\\test\\util\\|g'  build_msvc/test_bitcoin/test_bitcoin.vcxproj
     # Everything else
     sed -i -e 's|/setup_common|/util/setup_common|g'    $(git grep -l 'setup_common')
     sed -i -e 's|test/lib/|test/util/|g'                $(git grep -l 'test/lib/')
     # Fix include guard
     sed -i -e 's|BITCOIN_TEST_SETUP_COMMON_H|BITCOIN_TEST_UTIL_SETUP_COMMON_H|g' ./src/test/util/setup_common.h
     sed -i -e 's|BITCOIN_TEST_LIB_|BITCOIN_TEST_UTIL_|g'                     $(git grep -l 'BITCOIN_TEST_LIB_')
    -END VERIFY SCRIPT-
    faec28252c
  25. doc: Add documentation for new test/lib fa4c6fa9b1
  26. MarcoFalke force-pushed on Nov 6, 2019
  27. MarcoFalke commented at 5:02 pm on November 6, 2019: member
    Renamed to test/util/ as requested by @ryanofsky
  28. ryanofsky approved
  29. ryanofsky commented at 5:13 pm on November 6, 2019: member
    Code review ACK fa4c6fa9b1139791f45f1495d662c1c7cd2f7ed6. I didn’t realize lib was actually name of existing directory, not a new name. But in any case this looks good and nice to have one scripted diff instead of two.
  30. MarcoFalke commented at 8:56 pm on November 6, 2019: member
    Both travis and appveyor passes (so this fixes the appveyor build). Anything left to do here?
  31. practicalswift commented at 9:11 pm on November 6, 2019: contributor
    ACK fa4c6fa9b1139791f45f1495d662c1c7cd2f7ed6 – diff looks correct and Travis is happy
  32. ryanofsky commented at 9:13 pm on November 6, 2019: member

    Both travis and appveyor passes (so this fixes the appveyor build). Anything left to do here?

    This hasn’t had a ton of review, but it seems fairly safe to merge as it only affects test code.

  33. mzumsande commented at 10:01 pm on November 6, 2019: member

    I agree. I am concept ACK on both organizing all shared functions in one place, and on eventually turning this into a library. The code changes look good to me, but I didn’t test.

    Just noting that the added documentation in src/test/util/README.md describes the goal but not the reality after this PR, but I think fixing the Appveyor problem is more important than that.

  34. promag commented at 11:23 pm on November 6, 2019: member

    Also, we compile each file in the library (as of today) multiple times (for each target), so that should be fixed as well.

    And are those always compiled with the same flags etc?

  35. promag commented at 11:23 pm on November 6, 2019: member
    Scripted diff ACK.
  36. jonatack commented at 10:49 am on November 7, 2019: member
    ACK fa4c6fa9b1139791f45f1495d662c1c7cd2f7ed6 with the reserve that the commit messages (and PR description) contain the motivation for this change. Built, ran tests, light code review.
  37. MarcoFalke commented at 1:01 pm on November 7, 2019: member
    Added motivation to OP as requested by @jonatack
  38. MarcoFalke referenced this in commit 46fc4d1a24 on Nov 7, 2019
  39. MarcoFalke merged this on Nov 7, 2019
  40. MarcoFalke closed this on Nov 7, 2019

  41. MarcoFalke deleted the branch on Nov 7, 2019
  42. sidhujag referenced this in commit 72e8b5f28e on Nov 7, 2019
  43. fanquake referenced this in commit 2fb6140d58 on Nov 7, 2019
  44. deadalnix referenced this in commit 47887f4b09 on Jun 4, 2020
  45. sidhujag referenced this in commit 598c5e7c68 on Nov 10, 2020
  46. 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: 2024-12-18 21:12 UTC

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