Extend SANITIZE=leak checking and declare more tests "currently leak-free".
* ab/leak-check:
CI: use "GIT_TEST_SANITIZE_LEAK_LOG=true" in linux-leaks
upload-pack: fix a memory leak in create_pack_file()
leak tests: mark passing SANITIZE=leak tests as leak-free
leak tests: don't skip some tests under SANITIZE=leak
test-lib: have the "check" mode for SANITIZE=leak consider leak logs
test-lib: add a GIT_TEST_PASSING_SANITIZE_LEAK=check mode
test-lib: simplify by removing test_external
tests: move copy/pasted PERL + Test::More checks to a lib-perl.sh
t/Makefile: don't remove test-results in "clean-except-prove-cache"
test-lib: add a SANITIZE=leak logging mode
t/README: reword the "GIT_TEST_PASSING_SANITIZE_LEAK" description
test-lib: add a --invert-exit-code switch
test-lib: fix GIT_EXIT_OK logic errors, use BAIL_OUT
test-lib: don't set GIT_EXIT_OK before calling test_atexit_handler
test-lib: use $1, not $@ in test_known_broken_{ok,failure}_
@ -366,12 +366,47 @@ excluded as so much relies on it, but this might change in the future.
@@ -366,12 +366,47 @@ excluded as so much relies on it, but this might change in the future.
GIT_TEST_SPLIT_INDEX=<boolean> forces split-index mode on the whole
test suite. Accept any boolean values that are accepted by git-config.
GIT_TEST_PASSING_SANITIZE_LEAK=<boolean> when compiled with
SANITIZE=leak will run only those tests that have whitelisted
themselves as passing with no memory leaks. Tests can be whitelisted
by setting "TEST_PASSES_SANITIZE_LEAK=true" before sourcing
"test-lib.sh" itself at the top of the test script. This test mode is
used by the "linux-leaks" CI target.
GIT_TEST_PASSING_SANITIZE_LEAK=true skips those tests that haven't
declared themselves as leak-free by setting
"TEST_PASSES_SANITIZE_LEAK=true" before sourcing "test-lib.sh". This
test mode is used by the "linux-leaks" CI target.
GIT_TEST_PASSING_SANITIZE_LEAK=check checks that our
"TEST_PASSES_SANITIZE_LEAK=true" markings are current. Rather than
skipping those tests that haven't set "TEST_PASSES_SANITIZE_LEAK=true"
before sourcing "test-lib.sh" this mode runs them with
"--invert-exit-code". This is used to check that there's a one-to-one
mapping between "TEST_PASSES_SANITIZE_LEAK=true" and those tests that
pass under "SANITIZE=leak". This is especially useful when testing a
series that fixes various memory leaks with "git rebase -x".
GIT_TEST_SANITIZE_LEAK_LOG=true will log memory leaks to
"test-results/$TEST_NAME.leak/trace.*" files. The logs include a
"dedup_token" (see +"ASAN_OPTIONS=help=1 ./git") and other options to
make logs +machine-readable.
With GIT_TEST_SANITIZE_LEAK_LOG=true we'll look at the leak logs
before exiting and exit on failure if the logs showed that we had a
memory leak, even if the test itself would have otherwise passed. This
allows us to catch e.g. missing &&-chaining. This is especially useful
when combined with "GIT_TEST_PASSING_SANITIZE_LEAK", see below.
GIT_TEST_PASSING_SANITIZE_LEAK=check when combined with "--immediate"
will run to completion faster, and result in the same failing
tests. The only practical reason to run
GIT_TEST_PASSING_SANITIZE_LEAK=check without "--immediate" is to
combine it with "GIT_TEST_SANITIZE_LEAK_LOG=true". If we stop at the
first failing test case our leak logs won't show subsequent leaks we
might have run into.
GIT_TEST_PASSING_SANITIZE_LEAK=(true|check) will not catch all memory
leaks unless combined with GIT_TEST_SANITIZE_LEAK_LOG=true. Some tests
run "git" (or "test-tool" etc.) without properly checking the exit
code, or git will invoke itself and fail to ferry the abort() exit
code to the original caller. When the two modes are combined we'll
look at the "test-results/$TEST_NAME.leak/trace.*" files at the end of
the test run to see if had memory leaks which the test itself didn't
catch.
GIT_TEST_PROTOCOL_VERSION=<n>, when set, makes 'protocol.version'
default to n.
@ -935,32 +970,6 @@ see test-lib-functions.sh for the full list and their options.
@@ -935,32 +970,6 @@ see test-lib-functions.sh for the full list and their options.
@ -7,6 +7,7 @@ Ensures that checkout -m on a resolved file restores the conflicted file'
@@ -7,6 +7,7 @@ Ensures that checkout -m on a resolved file restores the conflicted file'
@ -17,6 +17,7 @@ outside the repository. Two instances for which this can occur are tested:
@@ -17,6 +17,7 @@ outside the repository. Two instances for which this can occur are tested:
@ -5,6 +5,7 @@ test_description='combined diff show only paths that are different to all parent
@@ -5,6 +5,7 @@ test_description='combined diff show only paths that are different to all parent
@ -7,6 +7,7 @@ test_description='git apply should not get confused with type changes.
@@ -7,6 +7,7 @@ test_description='git apply should not get confused with type changes.
'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup repository and commits' '