test: Stricter test case for #15654 (Add more checks)
authorBenjamin Robin <dev@benjarobin.fr>
Sat, 9 May 2020 10:01:07 +0000 (12:01 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 13 May 2020 19:32:45 +0000 (21:32 +0200)
Check:
 - There is only 3 messages logged with type stdout
 - Check all messages logged does not have new line: LINE_BREAK=eof
 - Check that the 3 messages are logged from a different PID
 - Check the 3 MESSAGE= content

test/units/testsuite-04.sh

index df216a06a3f7cf463848fabef7ac95a8468ea34a..3dce73b778250854dbde499123242101931540c5 100755 (executable)
@@ -94,6 +94,10 @@ systemd-cat -t "$ID" /bin/sh -c 'env echo -n "This will";echo;env echo -n "usual
 journalctl --sync
 journalctl -b -o cat -t "$ID" >/output
 cmp /expected /output
+[[ $(journalctl -b -o cat -t "$ID" --output-fields=_TRANSPORT | grep -Pc "^stdout$") -eq 3 ]]
+[[ $(journalctl -b -o cat -t "$ID" --output-fields=_LINE_BREAK | grep -Pc "^pid-change$") -eq 3 ]]
+[[ $(journalctl -b -o cat -t "$ID" --output-fields=_PID | sort -u | grep -c "^.*$") -eq 3 ]]
+[[ $(journalctl -b -o cat -t "$ID" --output-fields=MESSAGE | grep -Pc "^(This will|usually fail|and be truncated)$") -eq 3 ]]
 
 # Add new tests before here, the journald restarts below
 # may make tests flappy.