]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: use journalctl -n option instead of piping to head
authorNick Rosbrook <enr0n@ubuntu.com>
Mon, 19 Jan 2026 21:09:12 +0000 (16:09 -0500)
committerNick Rosbrook <enr0n@ubuntu.com>
Fri, 30 Jan 2026 14:30:20 +0000 (09:30 -0500)
On Ubuntu's test infrastructure for the development series, this test
often fails when piping the journal output to head. The cause is
unclear, but possibly related to Ubuntu's use of uutils coreutils.

Workaround this by just using journalctl's -n flag, which removes the
need for piping output to head.

test/units/TEST-04-JOURNAL.journal.sh

index de3b45eaee5bb0533a6de565b0727fdaecd9761b..03613b5805df917a75cd6afff31631c183339432 100755 (executable)
@@ -69,12 +69,12 @@ journalctl -b -t "$ID" --truncate-newline | grep -v TAIL >/dev/null
 journalctl -b -1 -b all -m >/dev/null
 
 # -b always behaves like -b0
-journalctl -q -b-1 -b0 | head -1 >/tmp/expected
-journalctl -q -b-1 -b | head -1 >/tmp/output
+journalctl -q -b-1 -b0 -n+1 >/tmp/expected
+journalctl -q -b-1 -b -n+1 >/tmp/output
 diff /tmp/expected /tmp/output
 # ... even when another option follows (both of these should fail due to -m)
-{ journalctl -ball -b0 -m 2>&1 || :; } | head -1 >/tmp/expected
-{ journalctl -ball -b  -m 2>&1 || :; } | head -1 >/tmp/output
+{ journalctl -ball -b0 -n+1 -m 2>&1 || :; } >/tmp/expected
+{ journalctl -ball -b  -n+1 -m 2>&1 || :; } >/tmp/output
 diff /tmp/expected /tmp/output
 
 # https://github.com/systemd/systemd/issues/13708