git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] maintenance tests: fix systemd v2.34.0-rc* test regression

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 10, 2021, 03:52 UTC
Message-ID
<patch-v2-1.1-44f0cafa16e-20211110T035103Z-avarab@gmail.com>
In-Reply-To
<patch-1.1-90172a8ddcc-20211102T142351Z-avarab@gmail.com>

Fix tests added in b681b191f92 (maintenance: add support for systemd timers on Linux, 2021-09-04) to run successfully on 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 on 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>
---

This test is still broken in rc2, this patch fixes it. The only update is a commit message grammar fix pointed out by Eric Sunshine, thanks!

Range-diff against v1:
1:  90172a8ddcc ! 1:  44f0cafa16e maintenance tests: fix systemd v2.34.0-rc* test regression
    @@ Commit message
         maintenance tests: fix systemd v2.34.0-rc* test regression
     
         Fix tests added in b681b191f92 (maintenance: add support for systemd
    -    timers on Linux, 2021-09-04) to run successfully no systems where
    +    timers on Linux, 2021-09-04) to run successfully on 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.
    @@ Commit message
     
         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
    +    emits on 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].
     
 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.34.0.rc2.791.gdbfcf909579
Previous: Eric SunshineNext: Johannes Schindelin
Message 11 of 32 in “What's cooking in git.git (Oct 2021, #06; Mon, 25)”
  1. Junio C HamanoOct 26, 2021
  2. Jeff KingOct 26, 2021
  3. Junio C HamanoOct 27, 2021
  4. Kaartic SivaraamOct 31, 2021
  5. Jeff KingNov 1, 2021
  6. 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, Oct 26, 2021
  7. Ævar Arnfjörð BjarmasonOct 26, 2021
  8. Eric SunshineOct 26, 2021
  9. maintenance tests: fix systemd v2.34.0-rc* test regressionÆvar Arnfjörð Bjarmason, Nov 2, 2021
  10. Eric SunshineNov 3, 2021
  11. maintenance tests: fix systemd v2.34.0-rc* test regressionÆvar Arnfjörð Bjarmason, Nov 10, 2021
  12. Johannes SchindelinNov 10, 2021
  13. Ævar Arnfjörð BjarmasonNov 10, 2021
  14. Junio C HamanoNov 11, 2021
  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, Oct 26, 2021
  16. Jeff KingOct 27, 2021
  17. Junio C HamanoOct 27, 2021
  18. Jeff KingOct 28, 2021
  19. Junio C HamanoOct 28, 2021
  20. Jeff KingOct 28, 2021
  21. tb/plug-pack-bitmap-leaks (was: What's cooking in git.git (Oct 2021, #06; Mon, 25))Ævar Arnfjörð Bjarmason, Oct 26, 2021
  22. Taylor BlauOct 26, 2021
  23. jc/branch-copy-doc (was: What's cooking in git.git (Oct 2021, #06; Mon, 25))Ævar Arnfjörð Bjarmason, Oct 26, 2021
  24. Derrick StoleeOct 26, 2021
  25. Ævar Arnfjörð BjarmasonOct 26, 2021
  26. Victoria DyeOct 26, 2021
  27. Junio C HamanoOct 26, 2021
  28. Junio C HamanoOct 26, 2021
  29. Derrick StoleeOct 26, 2021
  30. regression in ns/tmp-objdir and ns/batched-fsyncNeeraj Singh, Oct 26, 2021
  31. Martin ÅgrenOct 27, 2021
  32. Junio C HamanoOct 28, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.