From: "Rubén Justo" <rjusto@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Jeff King" <peff@peff.net>, "Junio C Hamano" <gitster@pobox.com>
Subject: [PATCH v2] test-lib: fix GIT_TEST_SANITIZE_LEAK_LOG
Date: Fri, 22 Sep 2023 22:38:06 +0200 [thread overview]
Message-ID: <54253e98-10d5-55ef-a3ac-1f1a8cfcdec9@gmail.com> (raw)
In-Reply-To: <68522960-edda-26d3-ddca-cee63f2d859e@gmail.com>
In the if-elses chain we have in "check_test_results_san_file_", we
consider three variables: $passes_sanitize_leak, $sanitize_leak_check
and lastly, implicitly, GIT_TEST_SANITIZE_LEAK_LOG (always set to "true"
at that point).
For the first two variables we have different considerations depending
on the value of $test_failure, which make sense. However, for the
third, GIT_TEST_SANITIZE_LEAK_LOG, we don't; regardless of
$test_failure, we use "invert_exit_code=t" to produce a non-zero
return value.
That assumes "$test_failure = 0" is always true at that point. But it
is not:
$ git checkout v2.40.1
$ make SANITIZE=leak
$ make -C t GIT_TEST_SANITIZE_LEAK_LOG=true t3200-branch.sh
...
With GIT_TEST_SANITIZE_LEAK_LOG=true, our logs revealed a memory leak, exiting with a non-zero status!
# Simulated failures as TODO & now exiting with 0 due to --invert-exit-code
We need to use "invert_exit_code=t" only when "$test_failure = 0".
Probably we have missed this because GIT_TEST_SANITIZE_LEAK_LOG is
commonly used in combination with GIT_TEST_PASSING_SANITIZE_LEAK=check,
the second variable noted above, for which we have, as already said,
different considerations depending on the value of $test_failure.
However GIT_TEST_SANITIZE_LEAK_LOG has value used on its own, as it was
documented in faececa53f (test-lib: have the "check" mode for
SANITIZE=leak consider leak logs, 2022-07-28).
Let's add the missing conditions in the if-elses chain to make it work
as expected.
Note that we're not resetting the value of "invert_exit_code" when
$test_failure is non-zero. Doing that is only needed when
GIT_TEST_PASSING_SANITIZE_LEAK=check, the second variable noted above.
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
Changes since v1:
- dropped 1/1 as it was erroneously included
- reworded the message to better capture the situation and the goal
- show a message also when $test_failure is non-zero
It is probably worth revisiting the use of "invert_exit_code=t"
in this SANITIZE_LEAK machinery. But I'll stop here.
---
t/test-lib.sh | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 5ea5d1d62a..945ede50ac 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1264,9 +1264,12 @@ check_test_results_san_file_ () {
then
say "As TEST_PASSES_SANITIZE_LEAK=true isn't set the above leak is 'ok' with GIT_TEST_PASSING_SANITIZE_LEAK=check" &&
invert_exit_code=t
- else
+ elif test "$test_failure" = 0
+ then
say "With GIT_TEST_SANITIZE_LEAK_LOG=true our logs revealed a memory leak, exit non-zero!" &&
invert_exit_code=t
+ else
+ say "With GIT_TEST_SANITIZE_LEAK_LOG=true our logs revealed a memory leak..."
fi
}
--
2.34.1
next prev parent reply other threads:[~2023-09-22 20:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-09 23:03 [PATCH 0/2] fix GIT_TEST_SANITIZE_LEAK_LOG=true Rubén Justo
2023-09-09 23:08 ` [PATCH 1/2] test-lib: prevent misuses of --invert-exit-code Rubén Justo
2023-09-10 1:59 ` Eric Sunshine
2023-09-10 22:58 ` Rubén Justo
2023-09-12 8:35 ` Jeff King
2023-09-15 0:10 ` Rubén Justo
2023-09-09 23:09 ` [PATCH 2/2] test-lib: fix GIT_TEST_SANITIZE_LEAK_LOG Rubén Justo
2023-09-12 8:27 ` Jeff King
2023-09-15 0:28 ` Rubén Justo
2023-09-15 11:29 ` Jeff King
2023-09-15 17:51 ` Junio C Hamano
2023-09-16 5:32 ` Jeff King
2023-09-15 17:49 ` Junio C Hamano
2023-09-22 20:38 ` Rubén Justo [this message]
2023-09-23 6:24 ` [PATCH v2] " Jeff King
2023-09-23 8:11 ` Rubén Justo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54253e98-10d5-55ef-a3ac-1f1a8cfcdec9@gmail.com \
--to=rjusto@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).