mirror of
https://github.com/git-for-windows/git.git
synced 2025-12-15 12:58:18 -06:00
Merge branch 'rj/test-sanitize-leak-log-fix'
Tests that use GIT_TEST_SANITIZE_LEAK_LOG feature got their exit status inverted, which has been corrected. * rj/test-sanitize-leak-log-fix: test-lib: GIT_TEST_SANITIZE_LEAK_LOG enabled by default test-lib: fix GIT_TEST_SANITIZE_LEAK_LOG
This commit is contained in:
commit
6da44da936
@ -370,7 +370,6 @@ linux-musl)
|
|||||||
linux-leaks|linux-reftable-leaks)
|
linux-leaks|linux-reftable-leaks)
|
||||||
export SANITIZE=leak
|
export SANITIZE=leak
|
||||||
export GIT_TEST_PASSING_SANITIZE_LEAK=true
|
export GIT_TEST_PASSING_SANITIZE_LEAK=true
|
||||||
export GIT_TEST_SANITIZE_LEAK_LOG=true
|
|
||||||
;;
|
;;
|
||||||
linux-asan-ubsan)
|
linux-asan-ubsan)
|
||||||
export SANITIZE=address,undefined
|
export SANITIZE=address,undefined
|
||||||
|
|||||||
26
t/README
26
t/README
@ -382,33 +382,9 @@ mapping between "TEST_PASSES_SANITIZE_LEAK=true" and those tests that
|
|||||||
pass under "SANITIZE=leak". This is especially useful when testing a
|
pass under "SANITIZE=leak". This is especially useful when testing a
|
||||||
series that fixes various memory leaks with "git rebase -x".
|
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"
|
GIT_TEST_PASSING_SANITIZE_LEAK=check when combined with "--immediate"
|
||||||
will run to completion faster, and result in the same failing
|
will run to completion faster, and result in the same failing
|
||||||
tests. The only practical reason to run
|
tests.
|
||||||
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'
|
GIT_TEST_PROTOCOL_VERSION=<n>, when set, makes 'protocol.version'
|
||||||
default to n.
|
default to n.
|
||||||
|
|||||||
@ -1269,9 +1269,12 @@ check_test_results_san_file_ () {
|
|||||||
then
|
then
|
||||||
say "As TEST_PASSES_SANITIZE_LEAK=true isn't set the above leak is 'ok' with GIT_TEST_PASSING_SANITIZE_LEAK=check" &&
|
say "As TEST_PASSES_SANITIZE_LEAK=true isn't set the above leak is 'ok' with GIT_TEST_PASSING_SANITIZE_LEAK=check" &&
|
||||||
invert_exit_code=t
|
invert_exit_code=t
|
||||||
else
|
elif test "$test_failure" = 0
|
||||||
say "With GIT_TEST_SANITIZE_LEAK_LOG=true our logs revealed a memory leak, exit non-zero!" &&
|
then
|
||||||
|
say "Our logs revealed a memory leak, exit non-zero!" &&
|
||||||
invert_exit_code=t
|
invert_exit_code=t
|
||||||
|
else
|
||||||
|
say "Our logs revealed a memory leak..."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1575,33 +1578,28 @@ then
|
|||||||
test_done
|
test_done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test_bool_env GIT_TEST_SANITIZE_LEAK_LOG false
|
if ! mkdir -p "$TEST_RESULTS_SAN_DIR"
|
||||||
then
|
then
|
||||||
if ! mkdir -p "$TEST_RESULTS_SAN_DIR"
|
BAIL_OUT "cannot create $TEST_RESULTS_SAN_DIR"
|
||||||
then
|
fi &&
|
||||||
BAIL_OUT "cannot create $TEST_RESULTS_SAN_DIR"
|
TEST_RESULTS_SAN_FILE="$TEST_RESULTS_SAN_DIR/$TEST_RESULTS_SAN_FILE_PFX"
|
||||||
fi &&
|
|
||||||
TEST_RESULTS_SAN_FILE="$TEST_RESULTS_SAN_DIR/$TEST_RESULTS_SAN_FILE_PFX"
|
|
||||||
|
|
||||||
# In case "test-results" is left over from a previous
|
# In case "test-results" is left over from a previous
|
||||||
# run: Only report if new leaks show up.
|
# run: Only report if new leaks show up.
|
||||||
TEST_RESULTS_SAN_DIR_NR_LEAKS_STARTUP=$(nr_san_dir_leaks_)
|
TEST_RESULTS_SAN_DIR_NR_LEAKS_STARTUP=$(nr_san_dir_leaks_)
|
||||||
|
|
||||||
# Don't litter *.leak dirs if there was nothing to report
|
# Don't litter *.leak dirs if there was nothing to report
|
||||||
test_atexit "rmdir \"$TEST_RESULTS_SAN_DIR\" 2>/dev/null || :"
|
test_atexit "rmdir \"$TEST_RESULTS_SAN_DIR\" 2>/dev/null || :"
|
||||||
|
|
||||||
|
prepend_var LSAN_OPTIONS : dedup_token_length=9999
|
||||||
|
prepend_var LSAN_OPTIONS : log_exe_name=1
|
||||||
|
prepend_var LSAN_OPTIONS : log_path=\"$TEST_RESULTS_SAN_FILE\"
|
||||||
|
export LSAN_OPTIONS
|
||||||
|
|
||||||
prepend_var LSAN_OPTIONS : dedup_token_length=9999
|
|
||||||
prepend_var LSAN_OPTIONS : log_exe_name=1
|
|
||||||
prepend_var LSAN_OPTIONS : log_path=\"$TEST_RESULTS_SAN_FILE\"
|
|
||||||
export LSAN_OPTIONS
|
|
||||||
fi
|
|
||||||
elif test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check" ||
|
elif test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check" ||
|
||||||
test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
|
test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
|
||||||
then
|
then
|
||||||
BAIL_OUT_ENV_NEEDS_SANITIZE_LEAK "GIT_TEST_PASSING_SANITIZE_LEAK=true"
|
BAIL_OUT_ENV_NEEDS_SANITIZE_LEAK "GIT_TEST_PASSING_SANITIZE_LEAK=true"
|
||||||
elif test_bool_env GIT_TEST_SANITIZE_LEAK_LOG false
|
|
||||||
then
|
|
||||||
BAIL_OUT_ENV_NEEDS_SANITIZE_LEAK "GIT_TEST_SANITIZE_LEAK_LOG=true"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "${GIT_TEST_CHAIN_LINT:-1}" != 0 &&
|
if test "${GIT_TEST_CHAIN_LINT:-1}" != 0 &&
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user