git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Lénaïc Huard" <lenaic@lhuard.fr>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH] maintenance tests: fix systemd v2.34.0-rc* test regression
Date: Tue,  2 Nov 2021 15:24:59 +0100	[thread overview]
Message-ID: <patch-1.1-90172a8ddcc-20211102T142351Z-avarab@gmail.com> (raw)
In-Reply-To: <211026.8635oo11jk.gmgdl@evledraar.gmail.com>

Fix tests added in b681b191f92 (maintenance: add support for systemd
timers on Linux, 2021-09-04) to run successfully no systems where
systemd-analyze is installed, but on which there's a discrepancy
between a FILE argument of "/lib/systemd/system/basic.target" and
"systemd/user/git-maintenance@.service" succeeding.

There was an attempt to work around previous breakage in these tests
in 670e5973992 (maintenance: fix test t7900-maintenance.sh,
2021-09-27), as noted in my [1] that commit is wrong about its
assumption that we can use "/lib/systemd/system/basic.target" as a
canary.argument.

To fix this let's adjust this test to test what it really should be
testing: If we've got systemd-analyze reporting anything useful, we
should use it to check the syntax of our just-generated
"systemd/user/git-maintenance@.service" file.

Even on systems where this previously succeeded we weren't effectively
doing that, because "systemd-analyze" will pass various syntax errors
by and exit with a status code of 0, e.g. if the "[Unit]" section is
replaced with a nonsensical "[HlaghUnfUnf]" section.

To do that ignore whatever exit code we get from "systemd-analyze
verify", and filter its stderr output to extract the sorts of lines it
emits no note syntax warnings and errors. We need to filter out
"Failed to load", which would be emitted e.g. on the
gcc135.fsffrance.org test box[1].

We also need to pipe this output to FD's 5 & 6, to avoid mixing up the
trace output with our own output under "-x".

1. https://lore.kernel.org/git/211026.8635oo11jk.gmgdl@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---

Junio: I think you'll want this in v2.34.0 per the report in
<211026.8635oo11jk.gmgdl@evledraar.gmail.com>.

 t/t7900-maintenance.sh | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index 74aa6384755..5fe2ea03c1d 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -20,15 +20,16 @@ test_xmllint () {
 	fi
 }
 
-test_lazy_prereq SYSTEMD_ANALYZE '
-	systemd-analyze verify /lib/systemd/system/basic.target
-'
-
 test_systemd_analyze_verify () {
-	if test_have_prereq SYSTEMD_ANALYZE
-	then
-		systemd-analyze verify "$@"
-	fi
+	# Ignoring any errors from systemd-analyze is intentional
+	systemd-analyze verify "$@" >systemd.out 2>systemd.err;
+
+	cat systemd.out >&5 &&
+	sed -n \
+		-e '/^Failed to load/d' \
+		-e '/git-maintenance@i*\.service:/x' \
+		<systemd.err >&6 &&
+	rm systemd.out systemd.err
 }
 
 test_expect_success 'help text' '
@@ -697,7 +698,11 @@ test_expect_success 'start and stop Linux/systemd maintenance' '
 	# start registers the repo
 	git config --get --global --fixed-value maintenance.repo "$(pwd)" &&
 
-	test_systemd_analyze_verify "systemd/user/git-maintenance@.service" &&
+	# If we have a systemd-analyze on the system we can verify the
+	# generated file.
+	test_systemd_analyze_verify "systemd/user/git-maintenance@.service" 5>out 6>err &&
+	test_must_be_empty out &&
+	test_must_be_empty err &&
 
 	printf -- "--user enable --now git-maintenance@%s.timer\n" hourly daily weekly >expect &&
 	test_cmp expect args &&
-- 
2.33.1.1570.g069344fdd45


  parent reply	other threads:[~2021-11-02 14:25 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-26  3:48 What's cooking in git.git (Oct 2021, #06; Mon, 25) Junio C Hamano
2021-10-26  5:25 ` Jeff King
2021-10-27 17:42   ` Junio C Hamano
2021-10-31 18:36   ` Kaartic Sivaraam
2021-11-01  4:04     ` Jeff King
2021-10-26 11:02 ` pre-v2.34.0-rc0 regressions: t7900-maintenance.sh broken due to 'systemd-analyze' (was: What's cooking in git.git (Oct 2021, #06; Mon, 25)) Ævar Arnfjörð Bjarmason
2021-10-26 15:34   ` Ævar Arnfjörð Bjarmason
2021-10-26 18:43     ` Eric Sunshine
2021-11-02 14:24   ` Ævar Arnfjörð Bjarmason [this message]
2021-11-03  5:09     ` [PATCH] maintenance tests: fix systemd v2.34.0-rc* test regression Eric Sunshine
2021-11-10  3:52     ` [PATCH v2] " Ævar Arnfjörð Bjarmason
2021-11-10 13:36       ` Johannes Schindelin
2021-11-10 16:22         ` Ævar Arnfjörð Bjarmason
2021-11-11 17:45           ` Junio C Hamano
2021-10-26 11:15 ` pre-v2.34.0-rc0 regressions: 'git log' has a noisy iconv() warning (was: What's cooking in git.git (Oct 2021, #06; Mon, 25)) Ævar Arnfjörð Bjarmason
2021-10-27 11:14   ` Jeff King
2021-10-27 18:04     ` pre-v2.34.0-rc0 regressions: 'git log' has a noisy iconv() warning Junio C Hamano
2021-10-28 17:30       ` Jeff King
2021-10-28 19:02         ` Junio C Hamano
2021-10-28 19:17           ` Jeff King
2021-10-26 12:13 ` tb/plug-pack-bitmap-leaks (was: What's cooking in git.git (Oct 2021, #06; Mon, 25)) Ævar Arnfjörð Bjarmason
2021-10-26 21:04   ` Taylor Blau
2021-10-26 12:17 ` jc/branch-copy-doc " Ævar Arnfjörð Bjarmason
2021-10-26 12:42 ` What's cooking in git.git (Oct 2021, #06; Mon, 25) Derrick Stolee
2021-10-26 14:55   ` Ævar Arnfjörð Bjarmason
2021-10-26 17:27     ` Victoria Dye
2021-10-26 21:29       ` Junio C Hamano
2021-10-26 21:28   ` Junio C Hamano
2021-10-26 21:54     ` Derrick Stolee
2021-10-26 22:21 ` regression in ns/tmp-objdir and ns/batched-fsync Neeraj Singh
2021-10-27 19:17 ` What's cooking in git.git (Oct 2021, #06; Mon, 25) Martin Ågren
2021-10-28  0:06   ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=patch-1.1-90172a8ddcc-20211102T142351Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lenaic@lhuard.fr \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).