test-lib: add GIT_SAN_OPTIONS, inherit [AL]SAN_OPTIONS
commit66c1a568703fd1e14b544da6a1dd9f34e4cc9cd1
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Sun, 27 Feb 2022 10:25:10 +0000 (27 11:25 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Feb 2022 21:35:56 +0000 (28 13:35 -0800)
tree1e0833648d7ce3a2358710ef9ba255e33a61b0ad
parente6ebfd0e8cbbd10878070c8a356b5ad1b3ca464e
test-lib: add GIT_SAN_OPTIONS, inherit [AL]SAN_OPTIONS

Change our ASAN_OPTIONS and LSAN_OPTIONS to set defaults for those
variables, rather than punting out entirely if we already have them in
the environment.

We want to take any user-provided settings over our own, but we can do
that by prepending our defaults to the variable. The libsanitizer
options parsing has "last option wins" semantics.

It's now possible to do e.g.:

    LSAN_OPTIONS=report_objects=1 ./t0006-date.sh

And not have the "report_objects=1" setting overwrite our sensible
default of "abort_on_error=1", but by prepending to the list we ensure
that:

    LSAN_OPTIONS=report_objects=1:abort_on_error=0 ./t0006-date.sh

Will take the desired "abort_on_error=0" over our default.

See b0f4c9087e1 (t: support clang/gcc AddressSanitizer, 2014-12-08)
for the original pattern being altered here, and
85b81b35ff9 (test-lib: set LSAN_OPTIONS to abort by default,
2017-09-05) for when LSAN_OPTIONS was added in addition to the
then-existing ASAN_OPTIONS.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh