Skip to content

Commit 6da44da

Browse files
committed
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
2 parents 04f5a52 + 8c1d669 commit 6da44da

File tree

3 files changed

+20
-47
lines changed

3 files changed

+20
-47
lines changed

ci/lib.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ linux-musl)
370370
linux-leaks|linux-reftable-leaks)
371371
export SANITIZE=leak
372372
export GIT_TEST_PASSING_SANITIZE_LEAK=true
373-
export GIT_TEST_SANITIZE_LEAK_LOG=true
374373
;;
375374
linux-asan-ubsan)
376375
export SANITIZE=address,undefined

t/README

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -382,33 +382,9 @@ mapping between "TEST_PASSES_SANITIZE_LEAK=true" and those tests that
382382
pass under "SANITIZE=leak". This is especially useful when testing a
383383
series that fixes various memory leaks with "git rebase -x".
384384

385-
GIT_TEST_SANITIZE_LEAK_LOG=true will log memory leaks to
386-
"test-results/$TEST_NAME.leak/trace.*" files. The logs include a
387-
"dedup_token" (see +"ASAN_OPTIONS=help=1 ./git") and other options to
388-
make logs +machine-readable.
389-
390-
With GIT_TEST_SANITIZE_LEAK_LOG=true we'll look at the leak logs
391-
before exiting and exit on failure if the logs showed that we had a
392-
memory leak, even if the test itself would have otherwise passed. This
393-
allows us to catch e.g. missing &&-chaining. This is especially useful
394-
when combined with "GIT_TEST_PASSING_SANITIZE_LEAK", see below.
395-
396385
GIT_TEST_PASSING_SANITIZE_LEAK=check when combined with "--immediate"
397386
will run to completion faster, and result in the same failing
398-
tests. The only practical reason to run
399-
GIT_TEST_PASSING_SANITIZE_LEAK=check without "--immediate" is to
400-
combine it with "GIT_TEST_SANITIZE_LEAK_LOG=true". If we stop at the
401-
first failing test case our leak logs won't show subsequent leaks we
402-
might have run into.
403-
404-
GIT_TEST_PASSING_SANITIZE_LEAK=(true|check) will not catch all memory
405-
leaks unless combined with GIT_TEST_SANITIZE_LEAK_LOG=true. Some tests
406-
run "git" (or "test-tool" etc.) without properly checking the exit
407-
code, or git will invoke itself and fail to ferry the abort() exit
408-
code to the original caller. When the two modes are combined we'll
409-
look at the "test-results/$TEST_NAME.leak/trace.*" files at the end of
410-
the test run to see if had memory leaks which the test itself didn't
411-
catch.
387+
tests.
412388

413389
GIT_TEST_PROTOCOL_VERSION=<n>, when set, makes 'protocol.version'
414390
default to n.

t/test-lib.sh

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,9 +1269,12 @@ check_test_results_san_file_ () {
12691269
then
12701270
say "As TEST_PASSES_SANITIZE_LEAK=true isn't set the above leak is 'ok' with GIT_TEST_PASSING_SANITIZE_LEAK=check" &&
12711271
invert_exit_code=t
1272-
else
1273-
say "With GIT_TEST_SANITIZE_LEAK_LOG=true our logs revealed a memory leak, exit non-zero!" &&
1272+
elif test "$test_failure" = 0
1273+
then
1274+
say "Our logs revealed a memory leak, exit non-zero!" &&
12741275
invert_exit_code=t
1276+
else
1277+
say "Our logs revealed a memory leak..."
12751278
fi
12761279
}
12771280

@@ -1575,33 +1578,28 @@ then
15751578
test_done
15761579
fi
15771580

1578-
if test_bool_env GIT_TEST_SANITIZE_LEAK_LOG false
1581+
if ! mkdir -p "$TEST_RESULTS_SAN_DIR"
15791582
then
1580-
if ! mkdir -p "$TEST_RESULTS_SAN_DIR"
1581-
then
1582-
BAIL_OUT "cannot create $TEST_RESULTS_SAN_DIR"
1583-
fi &&
1584-
TEST_RESULTS_SAN_FILE="$TEST_RESULTS_SAN_DIR/$TEST_RESULTS_SAN_FILE_PFX"
1583+
BAIL_OUT "cannot create $TEST_RESULTS_SAN_DIR"
1584+
fi &&
1585+
TEST_RESULTS_SAN_FILE="$TEST_RESULTS_SAN_DIR/$TEST_RESULTS_SAN_FILE_PFX"
15851586

1586-
# In case "test-results" is left over from a previous
1587-
# run: Only report if new leaks show up.
1588-
TEST_RESULTS_SAN_DIR_NR_LEAKS_STARTUP=$(nr_san_dir_leaks_)
1587+
# In case "test-results" is left over from a previous
1588+
# run: Only report if new leaks show up.
1589+
TEST_RESULTS_SAN_DIR_NR_LEAKS_STARTUP=$(nr_san_dir_leaks_)
15891590

1590-
# Don't litter *.leak dirs if there was nothing to report
1591-
test_atexit "rmdir \"$TEST_RESULTS_SAN_DIR\" 2>/dev/null || :"
1591+
# Don't litter *.leak dirs if there was nothing to report
1592+
test_atexit "rmdir \"$TEST_RESULTS_SAN_DIR\" 2>/dev/null || :"
1593+
1594+
prepend_var LSAN_OPTIONS : dedup_token_length=9999
1595+
prepend_var LSAN_OPTIONS : log_exe_name=1
1596+
prepend_var LSAN_OPTIONS : log_path=\"$TEST_RESULTS_SAN_FILE\"
1597+
export LSAN_OPTIONS
15921598

1593-
prepend_var LSAN_OPTIONS : dedup_token_length=9999
1594-
prepend_var LSAN_OPTIONS : log_exe_name=1
1595-
prepend_var LSAN_OPTIONS : log_path=\"$TEST_RESULTS_SAN_FILE\"
1596-
export LSAN_OPTIONS
1597-
fi
15981599
elif test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check" ||
15991600
test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
16001601
then
16011602
BAIL_OUT_ENV_NEEDS_SANITIZE_LEAK "GIT_TEST_PASSING_SANITIZE_LEAK=true"
1602-
elif test_bool_env GIT_TEST_SANITIZE_LEAK_LOG false
1603-
then
1604-
BAIL_OUT_ENV_NEEDS_SANITIZE_LEAK "GIT_TEST_SANITIZE_LEAK_LOG=true"
16051603
fi
16061604

16071605
if test "${GIT_TEST_CHAIN_LINT:-1}" != 0 &&

0 commit comments

Comments
 (0)