Skip to content

Commit 9d05b45

Browse files
committed
Merge branch 'ab/sanitize-leak-ci' into ab/unpack-trees-leakfix
* ab/sanitize-leak-ci: tests: add a test mode for SANITIZE=leak, run it in CI Makefile: add SANITIZE=leak flag to GIT-BUILD-OPTIONS
2 parents 106298f + 956d2e4 commit 9d05b45

14 files changed

+56
-3
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ jobs:
232232
- jobname: linux-gcc-default
233233
cc: gcc
234234
pool: ubuntu-latest
235+
- jobname: linux-leaks
236+
cc: gcc
237+
pool: ubuntu-latest
235238
env:
236239
CC: ${{matrix.vector.cc}}
237240
jobname: ${{matrix.vector.jobname}}

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,9 @@ PTHREAD_CFLAGS =
12141214
SPARSE_FLAGS ?=
12151215
SP_EXTRA_FLAGS = -Wno-universal-initializer
12161216

1217+
# For informing GIT-BUILD-OPTIONS of the SANITIZE=leak target
1218+
SANITIZE_LEAK =
1219+
12171220
# For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will
12181221
# usually result in less CPU usage at the cost of higher peak memory.
12191222
# Setting it to 0 will feed all files in a single spatch invocation.
@@ -1258,6 +1261,7 @@ BASIC_CFLAGS += -DSHA1DC_FORCE_ALIGNED_ACCESS
12581261
endif
12591262
ifneq ($(filter leak,$(SANITIZERS)),)
12601263
BASIC_CFLAGS += -DSUPPRESS_ANNOTATED_LEAKS
1264+
SANITIZE_LEAK = YesCompiledWithIt
12611265
endif
12621266
ifneq ($(filter address,$(SANITIZERS)),)
12631267
NO_REGEX = NeededForASAN
@@ -2797,6 +2801,7 @@ GIT-BUILD-OPTIONS: FORCE
27972801
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
27982802
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
27992803
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
2804+
@echo SANITIZE_LEAK=\''$(subst ','\'',$(subst ','\'',$(SANITIZE_LEAK)))'\' >>$@+
28002805
@echo X=\'$(X)\' >>$@+
28012806
ifdef TEST_OUTPUT_DIRECTORY
28022807
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+

ci/install-dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ UBUNTU_COMMON_PKGS="make libssl-dev libcurl4-openssl-dev libexpat-dev
1212
libemail-valid-perl libio-socket-ssl-perl libnet-smtp-ssl-perl"
1313

1414
case "$jobname" in
15-
linux-clang|linux-gcc)
15+
linux-clang|linux-gcc|linux-leaks)
1616
sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
1717
sudo apt-get -q update
1818
sudo apt-get -q -y install language-pack-is libsvn-perl apache2 \

ci/lib.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export GIT_TEST_CLONE_2GB=true
183183
export SKIP_DASHED_BUILT_INS=YesPlease
184184

185185
case "$jobname" in
186-
linux-clang|linux-gcc)
186+
linux-clang|linux-gcc|linux-leaks)
187187
if [ "$jobname" = linux-gcc ]
188188
then
189189
export CC=gcc-8
@@ -233,4 +233,11 @@ linux-musl)
233233
;;
234234
esac
235235

236+
case "$jobname" in
237+
linux-leaks)
238+
export SANITIZE=leak
239+
export GIT_TEST_PASSING_SANITIZE_LEAK=true
240+
;;
241+
esac
242+
236243
MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"

t/README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,13 @@ excluded as so much relies on it, but this might change in the future.
366366
GIT_TEST_SPLIT_INDEX=<boolean> forces split-index mode on the whole
367367
test suite. Accept any boolean values that are accepted by git-config.
368368

369+
GIT_TEST_PASSING_SANITIZE_LEAK=<boolean> when compiled with
370+
SANITIZE=leak will run only those tests that have whitelisted
371+
themselves as passing with no memory leaks. Tests can be whitelisted
372+
by setting "TEST_PASSES_SANITIZE_LEAK=true" before sourcing
373+
"test-lib.sh" itself at the top of the test script. This test mode is
374+
used by the "linux-leaks" CI target.
375+
369376
GIT_TEST_PROTOCOL_VERSION=<n>, when set, makes 'protocol.version'
370377
default to n.
371378

t/t0004-unwritable.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='detect unwritable repository and fail correctly'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67

78
test_expect_success setup '
@@ -21,7 +22,7 @@ test_expect_success POSIXPERM,SANITY 'write-tree should notice unwritable reposi
2122
test_must_fail git write-tree
2223
'
2324

24-
test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository' '
25+
test_expect_success POSIXPERM,SANITY,!SANITIZE_LEAK 'commit should notice unwritable repository' '
2526
test_when_finished "chmod 775 .git/objects .git/objects/??" &&
2627
chmod a-w .git/objects .git/objects/?? &&
2728
test_must_fail git commit -m second

t/t0011-hashmap.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='test hashmap and string hash functions'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
test_hashmap() {

t/t0016-oidmap.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='test oidmap'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
# This purposefully is very similar to t0011-hashmap.sh

t/t0017-env-helper.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='test env--helper'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67

78

t/t0018-advice.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='Test advise_if_enabled functionality'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67

78
test_expect_success 'advice should be printed when config variable is unset' '

0 commit comments

Comments
 (0)