git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 00/15] leak test: add "check" test mode, mark leak-free tests

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 27, 2022, 23:13 UTC
Message-ID
<cover-v3-00.15-00000000000-20220727T230800Z-avarab@gmail.com>
In-Reply-To
<cover-v2-00.14-00000000000-20220720T211221Z-avarab@gmail.com>

This series adds a "check" leak-testing mode, which allows us to assert that the tests we mark as leak free and those that don't leak are one-to-one mapped to one another.

Changes since v2:
 * Should fix linux-leaks CI failures when merged with "seen"
 * Rebase on landed topic(s), including updating the mention of the
   now-landed whitelist/blacklist topic.
 * Stopped marking t6415 as leak-free. GCC at some versions and higher
   optimization levels in some versions will spot that it leaks.
 * A new commit to undo various !SANITIZE_LEAK prereqs, for leaks that
   have since been solved.
 * Note that the v2 of this marked t1500 as leak-free, but another
   topic added a leak there. That's since been fixed:
   20220726210020.3397249-1-calvinwan@google.com
1. https://lore.kernel.org/git/cover-v2-00.14-00000000000-20220720T211221Z-avarab@gmail.com/
Ævar Arnfjörð Bjarmason (15):
  test-lib: use $1, not $@ in test_known_broken_{ok,failure}_
  test-lib: don't set GIT_EXIT_OK before calling test_atexit_handler
  test-lib: fix GIT_EXIT_OK logic errors, use BAIL_OUT
  test-lib: add a --invert-exit-code switch
  t/README: reword the "GIT_TEST_PASSING_SANITIZE_LEAK" description
  test-lib: add a SANITIZE=leak logging mode
  t/Makefile: don't remove test-results in "clean-except-prove-cache"
  tests: move copy/pasted PERL + Test::More checks to a lib-perl.sh
  test-lib: simplify by removing test_external
  test-lib: add a GIT_TEST_PASSING_SANITIZE_LEAK=check mode
  test-lib: have the "check" mode for SANITIZE=leak consider leak logs
  leak tests: don't skip some tests under SANITIZE=leak
  leak tests: mark passing SANITIZE=leak tests as leak-free
  upload-pack: fix a memory leak in create_pack_file()
  CI: use "GIT_TEST_SANITIZE_LEAK_LOG=true" in linux-leaks
 ci/lib.sh                                     |   1 +
 .../netrc/t-git-credential-netrc.sh           |  18 +-
 contrib/scalar/t/Makefile                     |   2 +-
 contrib/subtree/t/Makefile                    |   2 +-
 t/Makefile                                    |   2 +-
 t/README                                      |  73 ++---
 t/lib-perl.sh                                 |  19 ++
 t/t0000-basic.sh                              |  72 +++++
 t/t0002-gitfile.sh                            |   2 +-
 t/t0004-unwritable.sh                         |   2 +-
 t/t0027-auto-crlf.sh                          |   1 +
 t/t0032-reftable-unittest.sh                  |   1 +
 t/t0033-safe-directory.sh                     |   1 +
 t/t0050-filesystem.sh                         |   1 +
 t/t0095-bloom.sh                              |   2 +
 t/t0202-gettext-perl.sh                       |  22 +-
 t/t1405-main-ref-store.sh                     |   1 +
 t/t1407-worktree-ref-store.sh                 |   1 +
 t/t1418-reflog-exists.sh                      |   1 +
 t/t1503-rev-parse-verify.sh                   |   2 +-
 t/t1701-racy-split-index.sh                   |   1 +
 t/t2006-checkout-index-basic.sh               |   1 +
 t/t2023-checkout-m.sh                         |   1 +
 t/t2205-add-worktree-config.sh                |   1 +
 t/t3001-ls-files-others-exclude.sh            |   4 +-
 t/t3012-ls-files-dedup.sh                     |   1 +
 t/t3305-notes-fanout.sh                       |   2 +-
 t/t4017-diff-retval.sh                        |   1 +
 t/t4020-diff-external.sh                      |   4 +-
 t/t4051-diff-function-context.sh              |   1 +
 t/t4057-diff-combined-paths.sh                |   1 +
 t/t4114-apply-typechange.sh                   |   1 +
 t/t4301-merge-tree-write-tree.sh              |   1 +
 t/t5315-pack-objects-compression.sh           |   1 +
 t/t5351-unpack-large-objects.sh               |   1 +
 t/t5402-post-merge-hook.sh                    |   1 +
 t/t5503-tagfollow.sh                          |   1 +
 t/t6102-rev-list-unexpected-objects.sh        |   4 +-
 t/t6404-recursive-merge.sh                    |   1 +
 t/t6405-merge-symlinks.sh                     |   1 +
 t/t6407-merge-binary.sh                       |   1 -
 t/t6408-merge-up-to-date.sh                   |   1 +
 t/t6411-merge-filemode.sh                     |   1 +
 t/t6413-merge-crlf.sh                         |   1 +
 t/t6425-merge-rename-delete.sh                |   1 +
 t/t6431-merge-criscross.sh                    |   1 +
 t/t7060-wtstatus.sh                           |   1 +
 t/t7062-wtstatus-ignorecase.sh                |   1 +
 t/t7110-reset-merge.sh                        |   1 +
 t/t7111-reset-table.sh                        |   1 +
 t/t7609-mergetool--lib.sh                     |   1 +
 t/t9100-git-svn-basic.sh                      |   1 -
 t/t9700-perl-git.sh                           |  23 +-
 t/t9901-git-web--browse.sh                    |   1 +
 t/test-lib-functions.sh                       |  89 +------
 t/test-lib.sh                                 | 250 ++++++++++++++----
 upload-pack.c                                 |   1 +
 57 files changed, 405 insertions(+), 227 deletions(-)
 create mode 100644 t/lib-perl.sh
Range-diff against v2:
 1:  e53cf647b44 =  1:  65930cc1445 test-lib: use $1, not $@ in test_known_broken_{ok,failure}_
 2:  00af775bd0d =  2:  242f3c9ed20 test-lib: don't set GIT_EXIT_OK before calling test_atexit_handler
 3:  419bc2c6a6e =  3:  385d5c52d5a test-lib: fix GIT_EXIT_OK logic errors, use BAIL_OUT
 4:  668c25f4d7e =  4:  f3144af2190 test-lib: add a --invert-exit-code switch
 5:  a26cb02db0a !  5:  80a36a47b37 t/README: reword the "GIT_TEST_PASSING_SANITIZE_LEAK" description
    @@ Commit message
         t/README: reword the "GIT_TEST_PASSING_SANITIZE_LEAK" description
     
         Reword the documentation added in 956d2e4639b (tests: add a test mode
    -    for SANITIZE=leak, run it in CI, 2021-09-23) for brevity, and to avoid
    -    a merge conflict with another topic, per [1].
    +    for SANITIZE=leak, run it in CI, 2021-09-23) for brevity.
     
    -    1. https://lore.kernel.org/git/220719.86lespun6l.gmgdl@evledraar.gmail.com/
    +    The comment added in the same commit was also misleading: We skip
    +    certain tests if SANITIZE=leak and GIT_TEST_PASSING_SANITIZE_LEAK=true,
    +    not if we're compiled with SANITIZE=leak. Let's just remove the
    +    comment, the control flow here is obvious enough that the code can
    +    speak for itself.
     
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
    @@ t/README: excluded as so much relies on it, but this might change in the future.
      
      GIT_TEST_PROTOCOL_VERSION=<n>, when set, makes 'protocol.version'
      default to n.
    +
    + ## t/test-lib.sh ##
    +@@ t/test-lib.sh: then
    + 	test_done
    + fi
    + 
    +-# skip non-whitelisted tests when compiled with SANITIZE=leak
    + if test -n "$SANITIZE_LEAK"
    + then
    + 	if test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
 6:  f1acf762899 !  6:  4f9b2396c15 test-lib: add a SANITIZE=leak logging mode
    @@ t/test-lib.sh: then
     +	BAIL_OUT "$1 has no effect except when compiled with SANITIZE=leak"
     +}
     +
    - # skip non-whitelisted tests when compiled with SANITIZE=leak
      if test -n "$SANITIZE_LEAK"
      then
    + 	if test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
     @@ t/test-lib.sh: then
      			test_done
      		fi
 7:  0723e90df7b =  7:  c7ea6dc013b t/Makefile: don't remove test-results in "clean-except-prove-cache"
 8:  987d9d0e98c =  8:  53ea78bf417 tests: move copy/pasted PERL + Test::More checks to a lib-perl.sh
 9:  20bd31615e4 =  9:  871d266f435 test-lib: simplify by removing test_external
10:  78a47d2b348 ! 10:  32564b8fcb3 test-lib: add a GIT_TEST_PASSING_SANITIZE_LEAK=check mode
    @@ t/README: declared themselves as leak-free by setting
     
      ## t/test-lib.sh ##
     @@ t/test-lib.sh: BAIL_OUT_ENV_NEEDS_SANITIZE_LEAK () {
    - # skip non-whitelisted tests when compiled with SANITIZE=leak
    + 
      if test -n "$SANITIZE_LEAK"
      then
     -	if test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
11:  8cc6ab390db = 11:  fb7e5e1b4cb test-lib: have the "check" mode for SANITIZE=leak consider leak logs
 -:  ----------- > 12:  6df9078e266 leak tests: don't skip some tests under SANITIZE=leak
12:  e3c8909207b ! 13:  28255ac3239 leak tests: mark passing SANITIZE=leak tests as leak-free
    @@ t/t6413-merge-crlf.sh: test_description='merge conflict in crlf repo
      
      test_expect_success setup '
     
    - ## t/t6415-merge-dir-to-symlink.sh ##
    -@@ t/t6415-merge-dir-to-symlink.sh: test_description='merging when a directory was replaced with a symlink'
    - GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
    - export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
    - 
    -+TEST_PASSES_SANITIZE_LEAK=true
    - . ./test-lib.sh
    - 
    - test_expect_success 'create a commit where dir a/b changed to symlink' '
    -
      ## t/t6425-merge-rename-delete.sh ##
     @@ t/t6425-merge-rename-delete.sh: test_description='Merge-recursive rename/delete conflict message'
      GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
13:  07b6572aea9 = 14:  c1436269c64 upload-pack: fix a memory leak in create_pack_file()
14:  eaa35d1bc59 = 15:  e4acdb18ec2 CI: use "GIT_TEST_SANITIZE_LEAK_LOG=true" in linux-leaks
-- 
2.37.1.1127.g4ecf1c08f67
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 32 of 57 in “leak test: add "check" test mode, mark leak-free tests”
  1. 00/10 leak test: add "check" test mode, mark leak-free testsÆvar Arnfjörð Bjarmason, Jul 19, 2022
  2. 01/10 test-lib.sh: use $1, not $@ in test_known_broken_{ok,failure}_Ævar Arnfjörð Bjarmason, Jul 19, 2022
  3. 02/10 test-lib.sh: don't set GIT_EXIT_OK before calling test_atexit_handlerÆvar Arnfjörð Bjarmason, Jul 19, 2022
  4. 03/10 test-lib.sh: fix GIT_EXIT_OK logic errors, use BAIL_OUTÆvar Arnfjörð Bjarmason, Jul 19, 2022
  5. 04/10 test-lib.sh: add a --invert-exit-code switchÆvar Arnfjörð Bjarmason, Jul 19, 2022
  6. 07/10 test-lib.sh: add a GIT_TEST_PASSING_SANITIZE_LEAK=check modeÆvar Arnfjörð Bjarmason, Jul 19, 2022
  7. Derrick StoleeJul 20, 2022
  8. 06/10 test-lib: add a SANITIZE=leak logging modeÆvar Arnfjörð Bjarmason, Jul 19, 2022
  9. 05/10 t/README: reword the "GIT_TEST_PASSING_SANITIZE_LEAK" descriptionÆvar Arnfjörð Bjarmason, Jul 19, 2022
  10. Derrick StoleeJul 20, 2022
  11. 09/10 leak tests: mark passing SANITIZE=leak tests as leak-freeÆvar Arnfjörð Bjarmason, Jul 19, 2022
  12. Derrick StoleeJul 20, 2022
  13. 08/10 test-lib: have the "check" mode for SANITIZE=leak consider leak logsÆvar Arnfjörð Bjarmason, Jul 19, 2022
  14. Derrick StoleeJul 20, 2022
  15. 10/10 log tests: don't use "exit 1" outside a sub-shellÆvar Arnfjörð Bjarmason, Jul 19, 2022
  16. Junio C HamanoJul 20, 2022
  17. 00/14 leak test: add "check" test mode, mark leak-free testsÆvar Arnfjörð Bjarmason, Jul 20, 2022
  18. 01/14 test-lib: use $1, not $@ in test_known_broken_{ok,failure}_Ævar Arnfjörð Bjarmason, Jul 20, 2022
  19. 02/14 test-lib: don't set GIT_EXIT_OK before calling test_atexit_handlerÆvar Arnfjörð Bjarmason, Jul 20, 2022
  20. 03/14 test-lib: fix GIT_EXIT_OK logic errors, use BAIL_OUTÆvar Arnfjörð Bjarmason, Jul 20, 2022
  21. 04/14 test-lib: add a --invert-exit-code switchÆvar Arnfjörð Bjarmason, Jul 20, 2022
  22. 05/14 t/README: reword the "GIT_TEST_PASSING_SANITIZE_LEAK" descriptionÆvar Arnfjörð Bjarmason, Jul 20, 2022
  23. 06/14 test-lib: add a SANITIZE=leak logging modeÆvar Arnfjörð Bjarmason, Jul 20, 2022
  24. 07/14 t/Makefile: don't remove test-results in "clean-except-prove-cache"Ævar Arnfjörð Bjarmason, Jul 20, 2022
  25. 08/14 tests: move copy/pasted PERL + Test::More checks to a lib-perl.shÆvar Arnfjörð Bjarmason, Jul 20, 2022
  26. 10/14 test-lib: add a GIT_TEST_PASSING_SANITIZE_LEAK=check modeÆvar Arnfjörð Bjarmason, Jul 20, 2022
  27. 09/14 test-lib: simplify by removing test_externalÆvar Arnfjörð Bjarmason, Jul 20, 2022
  28. 11/14 test-lib: have the "check" mode for SANITIZE=leak consider leak logsÆvar Arnfjörð Bjarmason, Jul 20, 2022
  29. 12/14 leak tests: mark passing SANITIZE=leak tests as leak-freeÆvar Arnfjörð Bjarmason, Jul 20, 2022
  30. 13/14 upload-pack: fix a memory leak in create_pack_file()Ævar Arnfjörð Bjarmason, Jul 20, 2022
  31. 14/14 CI: use "GIT_TEST_SANITIZE_LEAK_LOG=true" in linux-leaksÆvar Arnfjörð Bjarmason, Jul 20, 2022
  32. 00/15 leak test: add "check" test mode, mark leak-free testsÆvar Arnfjörð Bjarmason, Jul 27, 2022
  33. 01/15 test-lib: use $1, not $@ in test_known_broken_{ok,failure}_Ævar Arnfjörð Bjarmason, Jul 27, 2022
  34. 02/15 test-lib: don't set GIT_EXIT_OK before calling test_atexit_handlerÆvar Arnfjörð Bjarmason, Jul 27, 2022
  35. 03/15 test-lib: fix GIT_EXIT_OK logic errors, use BAIL_OUTÆvar Arnfjörð Bjarmason, Jul 27, 2022
  36. 05/15 t/README: reword the "GIT_TEST_PASSING_SANITIZE_LEAK" descriptionÆvar Arnfjörð Bjarmason, Jul 27, 2022
  37. 04/15 test-lib: add a --invert-exit-code switchÆvar Arnfjörð Bjarmason, Jul 27, 2022
  38. 06/15 test-lib: add a SANITIZE=leak logging modeÆvar Arnfjörð Bjarmason, Jul 27, 2022
  39. 07/15 t/Makefile: don't remove test-results in "clean-except-prove-cache"Ævar Arnfjörð Bjarmason, Jul 27, 2022
  40. t/Makefile: remove 'test-results' on 'make clean'SZEDER Gábor, Sep 20, 2022
  41. Jeff KingSep 20, 2022
  42. SZEDER GáborSep 20, 2022
  43. Jeff KingSep 20, 2022
  44. t/Makefile: remove 'test-results' on 'make clean'SZEDER Gábor, Sep 20, 2022
  45. Ævar Arnfjörð BjarmasonSep 21, 2022
  46. Junio C HamanoSep 21, 2022
  47. Junio C HamanoSep 21, 2022
  48. Ævar Arnfjörð BjarmasonSep 26, 2022
  49. Junio C HamanoSep 26, 2022
  50. 08/15 tests: move copy/pasted PERL + Test::More checks to a lib-perl.shÆvar Arnfjörð Bjarmason, Jul 27, 2022
  51. 09/15 test-lib: simplify by removing test_externalÆvar Arnfjörð Bjarmason, Jul 27, 2022
  52. 10/15 test-lib: add a GIT_TEST_PASSING_SANITIZE_LEAK=check modeÆvar Arnfjörð Bjarmason, Jul 27, 2022
  53. 12/15 leak tests: don't skip some tests under SANITIZE=leakÆvar Arnfjörð Bjarmason, Jul 27, 2022
  54. 11/15 test-lib: have the "check" mode for SANITIZE=leak consider leak logsÆvar Arnfjörð Bjarmason, Jul 27, 2022
  55. 13/15 leak tests: mark passing SANITIZE=leak tests as leak-freeÆvar Arnfjörð Bjarmason, Jul 27, 2022
  56. 15/15 CI: use "GIT_TEST_SANITIZE_LEAK_LOG=true" in linux-leaksÆvar Arnfjörð Bjarmason, Jul 27, 2022
  57. 14/15 upload-pack: fix a memory leak in create_pack_file()Ævar Arnfjörð Bjarmason, Jul 27, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.