From patchwork Sun Sep 19 08:03:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12504231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5A57C433EF for ; Sun, 19 Sep 2021 08:04:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8DD7560F6B for ; Sun, 19 Sep 2021 08:04:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236670AbhISIFc (ORCPT ); Sun, 19 Sep 2021 04:05:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236395AbhISIFa (ORCPT ); Sun, 19 Sep 2021 04:05:30 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E0AEC061757 for ; Sun, 19 Sep 2021 01:04:05 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id u18so21095296wrg.5 for ; Sun, 19 Sep 2021 01:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UmfaJNSmci79/WSANC9Fzd2DpGjfWml8a2d92qlzkTk=; b=QEtan+2dPsK6+5XGiOzBUJOQeJPrWg3CQGLFS/7HL2I9WKSX3c5JtvTeJ+2u61lvvK toocEOGBFY8gMb6CYOBRF1cjnWvbmotzwftyfn3cYkGXphcgRuhM57lO6d2haE8BTDFI nZiE6k38+BZBBKJJKVkRjRtLANbJS+06MRbAZGxVkWylzxBTHXt7E3dRyAfiTMh9LZD2 Wrk+nGR3lVmwUZmPcylNjJN2W9gM6ku02CORxFbCa8ovKsQovP+ARxGiTDX4FCbltozp SQmdXc4eNzDtEXbGDDhQnC/V+xyO/t43ZTiesgHqpQd9urlnSOEJRNMJJtQ5yydlXynb CQZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UmfaJNSmci79/WSANC9Fzd2DpGjfWml8a2d92qlzkTk=; b=5Ox8fA34mMog3XI5Nw+sV35/dNollAB5gYRuwhGFHQ/J9pOVjLYBbpMe2vsiz1oVb7 ySmOsXmaVJaCeRTMXQK34UUDkGH1/J5LFaJDtCe9DjQp0XLozdbd3lHZlqGfftRCGGuO Ur4jKZCYldhp/FCBRfOMil0pL+eTMsckOfChyoxf3f76ZQkmJ0SNwWA5ab0r0aX6oEfm EbGeVatezVlPB5bcfoRBwElrhJDSzBs7laWh01qfoQTQFKS8HY9Pg2TG9djZgQItB9ya e9dif5SzEssemiBrYAC0JjQDOeirncPwlC7L1jxY46td2kAoMP88MNNAhiNQCrb0J22T UIBw== X-Gm-Message-State: AOAM530WaLVzj+SrrtmDcywCppOKX2ymITg3hZ4PCf+HQzBsGHY7DTOB W1bPvWI5mmcIuCWGL9lKMxAP8UACSMnUqg== X-Google-Smtp-Source: ABdhPJwRaF5jK3O6ASgedjAZLevyv/HBwqqYtlU1KrXHLX49rOnCEAaIK144mpu10X7+OwwXi3JMkg== X-Received: by 2002:a5d:6590:: with SMTP id q16mr22194397wru.52.1632038639061; Sun, 19 Sep 2021 01:03:59 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id u23sm14887692wmc.24.2021.09.19.01.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 01:03:58 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Andrzej Hunt , =?utf-8?b?TMOpbmHDr2MgSHVhcmQ=?= , Derrick Stolee , Felipe Contreras , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?xJBvw6Bu?= =?utf-8?b?IFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?Car?= =?utf-8?q?lo_Marcelo_Arenas_Bel=C3=B3n?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v7 1/2] Makefile: add SANITIZE=leak flag to GIT-BUILD-OPTIONS Date: Sun, 19 Sep 2021 10:03:53 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1092.g44c994ea1be In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- Makefile | 5 +++++ t/t0004-unwritable.sh | 2 +- t/test-lib.sh | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b90af71a7a2..b4ad91743b5 100644 --- a/Makefile +++ b/Makefile @@ -1224,6 +1224,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. @@ -1268,6 +1271,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 @@ -2815,6 +2819,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)))'\' >>$@+ diff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh index e3137d638ee..fbdcb926b3a 100755 --- a/t/t0004-unwritable.sh +++ b/t/t0004-unwritable.sh @@ -21,7 +21,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 diff --git a/t/test-lib.sh b/t/test-lib.sh index d5ee9642548..06831086060 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1536,6 +1536,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 From patchwork Sun Sep 19 08:03:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12504227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5099AC433F5 for ; Sun, 19 Sep 2021 08:04:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3116D61212 for ; Sun, 19 Sep 2021 08:04:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236345AbhISIF1 (ORCPT ); Sun, 19 Sep 2021 04:05:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236281AbhISIF0 (ORCPT ); Sun, 19 Sep 2021 04:05:26 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC923C061574 for ; Sun, 19 Sep 2021 01:04:01 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id j134-20020a1c238c000000b0030b32367649so6853645wmj.3 for ; Sun, 19 Sep 2021 01:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9pXo4fVMYP6D38S+jS0g/OEpvWkFKLtbJYqEUp0O6c0=; b=Mjfmx3CbcMXjA/9q/IAOolnVaykBJshhG2ZNThuHMYw+jgSwJO0C4vkFBDamTKVhZV h0tLf5PuKO72VwAV5agSDSF7iyYvdvVxzFwtu2fSIkUlSRkCJV863Z5H56jsGLaweoGF 0Dgwb8pLmDG0xB96BNTfZNIIFw736eyZ83L7Qw+RXULVBTp92v/vjVVcWi7ETihbfWX2 C7WvUe+077tb3E91Cr2R/lkKkpjkAc0ZEuZN0qFxaXMS7u/KW232TZLo3xyRx82Lgtce u3O29UtGNCpCHqmwtrMpqRx6ukgYqLPLlGEhT8ODUFF4rkrmjQlBN7zZ8yMyoJxevV/t xG9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9pXo4fVMYP6D38S+jS0g/OEpvWkFKLtbJYqEUp0O6c0=; b=ZKgq3BtXO/ErCEj23f9hY0p+lsvSK2UmxQQlO9W/Le1vh57+uL+USCQIfnnzA+uh5H M7oY+/rjjGRP2zCqqNBO2tpjTmJyyeiv5sKHgkKORDLGs1GzQLI0SmhqYgT5Jb7id5FM oBxaNWkc3/i7ypRp4B9pZhtqLXjVVUoMGd5yDZ5ZgO8rWTyfgH73h6W1Ml2hJTwRRks2 7ubl8gasv35HJRSEUj7kBSPrUlVo7xhnKWNM8dEyYoQpB8b+eJUJ3ayxwos91ck/6bwF 4Sep5E1/7YlHMBFzKHsCsVpy9fdd/v4NSKDhsLZg5qZxGTQEU/DLxalCsdD2cA4mc7Jb DuMQ== X-Gm-Message-State: AOAM530okf+O4TX8/eFDtMcCs/8iqUfs/F0LH/3V6gb4RaI1jGQ9epQC JpcXDtEVZlt6ysjHeCRbrt4nnnmwD29Ntg== X-Google-Smtp-Source: ABdhPJzsOfxCKz3ADcpara0sN6zHRA09sDYTtDBwiNKVnBy7n7YQRb2vjugoAEXLwlIKmmWU+sIvmA== X-Received: by 2002:a05:600c:19d4:: with SMTP id u20mr23025106wmq.28.1632038639922; Sun, 19 Sep 2021 01:03:59 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id u23sm14887692wmc.24.2021.09.19.01.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 01:03:59 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Andrzej Hunt , =?utf-8?b?TMOpbmHDr2MgSHVhcmQ=?= , Derrick Stolee , Felipe Contreras , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?xJBvw6Bu?= =?utf-8?b?IFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?Car?= =?utf-8?q?lo_Marcelo_Arenas_Bel=C3=B3n?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v7 2/2] tests: add a test mode for SANITIZE=leak, run it in CI Date: Sun, 19 Sep 2021 10:03:54 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1092.g44c994ea1be In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org While git can be compiled with SANITIZE=leak, we have not run regression tests under that mode. Memory leaks have only been fixed as one-offs without structured regression testing. This change adds CI testing for it. We'll now build and small set of whitelisted t00*.sh tests under Linux with a new job called "linux-leaks". The CI target uses a new GIT_TEST_PASSING_SANITIZE_LEAK=true test mode. When running in that mode, we'll assert that we were compiled with SANITIZE=leak. We'll then skip all tests, except those that we've opted-in by setting "TEST_PASSES_SANITIZE_LEAK=true". A test setting "TEST_PASSES_SANITIZE_LEAK=true" setting can in turn make use of the "SANITIZE_LEAK" prerequisite, should they wish to selectively skip tests even under "GIT_TEST_PASSING_SANITIZE_LEAK=true". In the preceding commit we started doing this in "t0004-unwritable.sh" under SANITIZE=leak, now it'll combine nicely with "GIT_TEST_PASSING_SANITIZE_LEAK=true". This is how tests that don't set "TEST_PASSES_SANITIZE_LEAK=true" will be skipped under GIT_TEST_PASSING_SANITIZE_LEAK=true: $ GIT_TEST_PASSING_SANITIZE_LEAK=true ./t0001-init.sh 1..0 # SKIP skip all tests in t0001 under SANITIZE=leak, TEST_PASSES_SANITIZE_LEAK not set The intent is to add more TEST_PASSES_SANITIZE_LEAK=true annotations as follow-up change, but let's start small to begin with. It would also be possible to implement a more lightweight version of this by only relying on setting "LSAN_OPTIONS". See [1] and [2] for a discussion of that. I've opted for this approach of adding a GIT_TEST_* mode instead because it's consistent with how we handle other special test modes. Being able to add a "!SANITIZE_LEAK" prerequisite and calling "test_done" early if it isn't satisfied also means that we can more incrementally add regression tests without being forced to fix widespread and hard-to-fix leaks at the same time. We have tests that do simple checking of some tool we're interested in, but later on in the script might be stressing trace2, or common sources of leaks like "git log" in combination with the tool (e.g. the commit-graph tests). To be clear having a prerequisite could also be accomplished by using "LSAN_OPTIONS" directly. On the topic of "LSAN_OPTIONS": It would be nice to have a mode to aggregate all failures in our various scripts, see [2] for a start at doing that which sets "log_path" in "LSAN_OPTIONS". I've punted on that for now, it can be added later. As of writing this we've got major regressions between master..seen, i.e. the t000*.sh tests and more fixed since 31f9acf9ce2 (Merge branch 'ah/plugleaks', 2021-08-04) have regressed recently. See the discussion at <87czsv2idy.fsf@evledraar.gmail.com>[3] about the lack of this sort of test mode, and 0e5bba53af (add UNLEAK annotation for reducing leak false positives, 2017-09-08) for the initial addition of SANITIZE=leak. See also 09595ab381 (Merge branch 'jk/leak-checkers', 2017-09-19), 7782066f67 (Merge branch 'jk/apache-lsan', 2019-05-19) and the recent 936e58851a (Merge branch 'ah/plugleaks', 2021-05-07) for some of the past history of "one-off" SANITIZE=leak (and more) fixes. As noted in [5] we can't support this on OSX yet until Clang 14 is released, at that point we'll probably want to resurrect that "osx-leaks" job. 1. https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer 2. https://lore.kernel.org/git/YS9OT%2Fpn5rRK9cGB@coredump.intra.peff.net/ 3. https://lore.kernel.org/git/87czsv2idy.fsf@evledraar.gmail.com/ 4. https://lore.kernel.org/git/YS9ZIDpANfsh7N+S@coredump.intra.peff.net/ 5. https://lore.kernel.org/git/20210916035603.76369-1-carenas@gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Carlo Marcelo Arenas Belón --- .github/workflows/main.yml | 3 +++ ci/install-dependencies.sh | 2 +- ci/lib.sh | 9 ++++++++- ci/run-build-and-tests.sh | 2 +- t/README | 7 +++++++ t/t0004-unwritable.sh | 1 + t/t0011-hashmap.sh | 2 ++ t/t0016-oidmap.sh | 2 ++ t/t0017-env-helper.sh | 1 + t/t0018-advice.sh | 1 + t/t0030-stripspace.sh | 1 + t/t0063-string-list.sh | 1 + t/t0091-bugreport.sh | 1 + t/test-lib.sh | 20 ++++++++++++++++++++ 14 files changed, 50 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b053b01c66e..47281684782 100644 --- a/.github/workflows/main.yml +++ b/.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}} diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh index 5772081b6e5..1d0e48f4515 100755 --- a/ci/install-dependencies.sh +++ b/ci/install-dependencies.sh @@ -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 \ diff --git a/ci/lib.sh b/ci/lib.sh index 476c3f369f5..82cb17f8eea 100755 --- a/ci/lib.sh +++ b/ci/lib.sh @@ -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}" diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh index f3aba5d6cbb..ba29a93d84b 100755 --- a/ci/run-build-and-tests.sh +++ b/ci/run-build-and-tests.sh @@ -17,7 +17,7 @@ fi make case "$jobname" in -linux-gcc) +linux-gcc|linux-leaks) export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main make test export GIT_TEST_SPLIT_INDEX=yes diff --git a/t/README b/t/README index e924bd81e2d..ab84278b7eb 100644 --- a/t/README +++ b/t/README @@ -366,6 +366,13 @@ excluded as so much relies on it, but this might change in the future. GIT_TEST_SPLIT_INDEX= forces split-index mode on the whole test suite. Accept any boolean values that are accepted by git-config. +GIT_TEST_PASSING_SANITIZE_LEAK= 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=, when set, makes 'protocol.version' default to n. diff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh index fbdcb926b3a..37d68ef03be 100755 --- a/t/t0004-unwritable.sh +++ b/t/t0004-unwritable.sh @@ -2,6 +2,7 @@ test_description='detect unwritable repository and fail correctly' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t0011-hashmap.sh b/t/t0011-hashmap.sh index 5343ffd3f92..e094975b13b 100755 --- a/t/t0011-hashmap.sh +++ b/t/t0011-hashmap.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test hashmap and string hash functions' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_hashmap() { diff --git a/t/t0016-oidmap.sh b/t/t0016-oidmap.sh index 31f8276ba82..0faef1f4f11 100755 --- a/t/t0016-oidmap.sh +++ b/t/t0016-oidmap.sh @@ -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 diff --git a/t/t0017-env-helper.sh b/t/t0017-env-helper.sh index 4a159f99e44..2e42fba9567 100755 --- a/t/t0017-env-helper.sh +++ b/t/t0017-env-helper.sh @@ -2,6 +2,7 @@ test_description='test env--helper' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh diff --git a/t/t0018-advice.sh b/t/t0018-advice.sh index 39e5e4b34f8..c13057a4ca3 100755 --- a/t/t0018-advice.sh +++ b/t/t0018-advice.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' ' diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh index 0c24a0f9a37..ae1ca380c1a 100755 --- a/t/t0030-stripspace.sh +++ b/t/t0030-stripspace.sh @@ -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' diff --git a/t/t0063-string-list.sh b/t/t0063-string-list.sh index c6ee9f66b11..46d4839194b 100755 --- a/t/t0063-string-list.sh +++ b/t/t0063-string-list.sh @@ -5,6 +5,7 @@ test_description='Test string list functionality' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_split () { diff --git a/t/t0091-bugreport.sh b/t/t0091-bugreport.sh index 526304ff95b..eeedbfa9193 100755 --- a/t/t0091-bugreport.sh +++ b/t/t0091-bugreport.sh @@ -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 diff --git a/t/test-lib.sh b/t/test-lib.sh index 06831086060..9310d9d900a 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -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"