Makefile: add SANITIZE=leak flag to GIT-BUILD-OPTIONS

When SANITIZE=leak is specified we'll now add a SANITIZE_LEAK flag to GIT-BUILD-OPTIONS, this can then be picked up by the test-lib.sh, which sets a SANITIZE_LEAK prerequisite. We can then skip specific tests that are known to fail under SANITIZE=leak, add one such annotation to t0004-unwritable.sh, which now passes under SANITIZE=leak. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Sep 23, 2021 at 11:20 UTC 2cdc292b3160e2bd80c3a9d24eff3afe29a2a46d
3 files changed +7 -1
Makefile
+5
@@ -1221,6 +1221,9 @@ PTHREAD_CFLAGS =
1221 SPARSE_FLAGS ?=
1222 SP_EXTRA_FLAGS = -Wno-universal-initializer
1223
1224 +# For informing GIT-BUILD-OPTIONS of the SANITIZE=leak target
1225 +SANITIZE_LEAK =
1226 +
1227 # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will
1228 # usually result in less CPU usage at the cost of higher peak memory.
1229 # Setting it to 0 will feed all files in a single spatch invocation.
@@ -1265,6 +1268,7 @@ BASIC_CFLAGS += -DSHA1DC_FORCE_ALIGNED_ACCESS
1268 endif
1269 ifneq ($(filter leak,$(SANITIZERS)),)
1270 BASIC_CFLAGS += -DSUPPRESS_ANNOTATED_LEAKS
1271 +SANITIZE_LEAK = YesCompiledWithIt
1272 endif
1273 ifneq ($(filter address,$(SANITIZERS)),)
1274 NO_REGEX = NeededForASAN
@@ -2812,6 +2816,7 @@ GIT-BUILD-OPTIONS: FORCE
2816 @echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
2817 @echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
2818 @echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
2819 + @echo SANITIZE_LEAK=\''$(subst ','\'',$(subst ','\'',$(SANITIZE_LEAK)))'\' >>$@+
2820 @echo X=\'$(X)\' >>$@+
2821 ifdef TEST_OUTPUT_DIRECTORY
2822 @echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
t/t0004-unwritable.sh
+1 -1
@@ -21,7 +21,7 @@ test_expect_success POSIXPERM,SANITY 'write-tree should notice unwritable reposi
21 test_must_fail git write-tree
22 '
23
24 -test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository' '
24 +test_expect_success POSIXPERM,SANITY,!SANITIZE_LEAK 'commit should notice unwritable repository' '
25 test_when_finished "chmod 775 .git/objects .git/objects/??" &&
26 chmod a-w .git/objects .git/objects/?? &&
27 test_must_fail git commit -m second
t/test-lib.sh
+1
@@ -1533,6 +1533,7 @@ test -z "$NO_PYTHON" && test_set_prereq PYTHON
1533 test -n "$USE_LIBPCRE2" && test_set_prereq PCRE
1534 test -n "$USE_LIBPCRE2" && test_set_prereq LIBPCRE2
1535 test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
1536 +test -n "$SANITIZE_LEAK" && test_set_prereq SANITIZE_LEAK
1537
1538 if test -z "$GIT_TEST_CHECK_CACHE_TREE"
1539 then