Merge branch 'ab/sanitize-leak-ci'

CI learns to run the leak sanitizer builds.

* 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
This commit is contained in:
Junio C Hamano 2021-10-11 10:21:47 -07:00
Родитель 62bff959c7 956d2e4639
Коммит 859a585bdf
14 изменённых файлов: 56 добавлений и 3 удалений

3
.github/workflows/main.yml поставляемый
Просмотреть файл

@ -232,6 +232,9 @@ jobs:
- jobname: linux-gcc-default
cc: gcc
pool: ubuntu-latest
- jobname: linux-leaks
cc: gcc
pool: ubuntu-latest
env:
CC: ${{matrix.vector.cc}}
jobname: ${{matrix.vector.jobname}}

Просмотреть файл

@ -1214,6 +1214,9 @@ PTHREAD_CFLAGS =
SPARSE_FLAGS ?=
SP_EXTRA_FLAGS = -Wno-universal-initializer
# For informing GIT-BUILD-OPTIONS of the SANITIZE=leak target
SANITIZE_LEAK =
# For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will
# usually result in less CPU usage at the cost of higher peak memory.
# Setting it to 0 will feed all files in a single spatch invocation.
@ -1258,6 +1261,7 @@ BASIC_CFLAGS += -DSHA1DC_FORCE_ALIGNED_ACCESS
endif
ifneq ($(filter leak,$(SANITIZERS)),)
BASIC_CFLAGS += -DSUPPRESS_ANNOTATED_LEAKS
SANITIZE_LEAK = YesCompiledWithIt
endif
ifneq ($(filter address,$(SANITIZERS)),)
NO_REGEX = NeededForASAN
@ -2797,6 +2801,7 @@ GIT-BUILD-OPTIONS: FORCE
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
@echo SANITIZE_LEAK=\''$(subst ','\'',$(subst ','\'',$(SANITIZE_LEAK)))'\' >>$@+
@echo X=\'$(X)\' >>$@+
ifdef TEST_OUTPUT_DIRECTORY
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+

Просмотреть файл

@ -12,7 +12,7 @@ UBUNTU_COMMON_PKGS="make libssl-dev libcurl4-openssl-dev libexpat-dev
libemail-valid-perl libio-socket-ssl-perl libnet-smtp-ssl-perl"
case "$jobname" in
linux-clang|linux-gcc)
linux-clang|linux-gcc|linux-leaks)
sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
sudo apt-get -q update
sudo apt-get -q -y install language-pack-is libsvn-perl apache2 \

Просмотреть файл

@ -183,7 +183,7 @@ export GIT_TEST_CLONE_2GB=true
export SKIP_DASHED_BUILT_INS=YesPlease
case "$jobname" in
linux-clang|linux-gcc)
linux-clang|linux-gcc|linux-leaks)
if [ "$jobname" = linux-gcc ]
then
export CC=gcc-8
@ -233,4 +233,11 @@ linux-musl)
;;
esac
case "$jobname" in
linux-leaks)
export SANITIZE=leak
export GIT_TEST_PASSING_SANITIZE_LEAK=true
;;
esac
MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"

Просмотреть файл

@ -366,6 +366,13 @@ excluded as so much relies on it, but this might change in the future.
GIT_TEST_SPLIT_INDEX=<boolean> forces split-index mode on the whole
test suite. Accept any boolean values that are accepted by git-config.
GIT_TEST_PASSING_SANITIZE_LEAK=<boolean> when compiled with
SANITIZE=leak will run only those tests that have whitelisted
themselves as passing with no memory leaks. Tests can be whitelisted
by setting "TEST_PASSES_SANITIZE_LEAK=true" before sourcing
"test-lib.sh" itself at the top of the test script. This test mode is
used by the "linux-leaks" CI target.
GIT_TEST_PROTOCOL_VERSION=<n>, when set, makes 'protocol.version'
default to n.

Просмотреть файл

@ -2,6 +2,7 @@
test_description='detect unwritable repository and fail correctly'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '
@ -21,7 +22,7 @@ test_expect_success POSIXPERM,SANITY 'write-tree should notice unwritable reposi
test_must_fail git write-tree
'
test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository' '
test_expect_success POSIXPERM,SANITY,!SANITIZE_LEAK 'commit should notice unwritable repository' '
test_when_finished "chmod 775 .git/objects .git/objects/??" &&
chmod a-w .git/objects .git/objects/?? &&
test_must_fail git commit -m second

Просмотреть файл

@ -1,6 +1,8 @@
#!/bin/sh
test_description='test hashmap and string hash functions'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_hashmap() {

Просмотреть файл

@ -1,6 +1,8 @@
#!/bin/sh
test_description='test oidmap'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# This purposefully is very similar to t0011-hashmap.sh

Просмотреть файл

@ -2,6 +2,7 @@
test_description='test env--helper'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

Просмотреть файл

@ -2,6 +2,7 @@
test_description='Test advise_if_enabled functionality'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'advice should be printed when config variable is unset' '

Просмотреть файл

@ -5,6 +5,7 @@
test_description='git stripspace'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
t40='A quick brown fox jumps over the lazy do'

Просмотреть файл

@ -5,6 +5,7 @@
test_description='Test string list functionality'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_split () {

Просмотреть файл

@ -2,6 +2,7 @@
test_description='git bugreport'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# Headers "[System Info]" will be followed by a non-empty line if we put some

Просмотреть файл

@ -1381,6 +1381,26 @@ then
test_done
fi
# skip non-whitelisted tests when compiled with SANITIZE=leak
if test -n "$SANITIZE_LEAK"
then
if test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
then
# We need to see it in "git env--helper" (via
# test_bool_env)
export TEST_PASSES_SANITIZE_LEAK
if ! test_bool_env TEST_PASSES_SANITIZE_LEAK false
then
skip_all="skipping $this_test under GIT_TEST_PASSING_SANITIZE_LEAK=true"
test_done
fi
fi
elif test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
then
error "GIT_TEST_PASSING_SANITIZE_LEAK=true has no effect except when compiled with SANITIZE=leak"
fi
# Last-minute variable setup
USER_HOME="$HOME"
HOME="$TRASH_DIRECTORY"
@ -1534,6 +1554,7 @@ test -z "$NO_PYTHON" && test_set_prereq PYTHON
test -n "$USE_LIBPCRE2" && test_set_prereq PCRE
test -n "$USE_LIBPCRE2" && test_set_prereq LIBPCRE2
test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
test -n "$SANITIZE_LEAK" && test_set_prereq SANITIZE_LEAK
if test -z "$GIT_TEST_CHECK_CACHE_TREE"
then