From: Frantisek Sumsal Date: Thu, 16 Feb 2023 18:48:03 +0000 (+0100) Subject: test: avoid matching other fields than __SEQNUM= X-Git-Tag: v254-rc1~1259 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca8b1d68c56129180c4c41c0485cef8ef8df62c8;p=thirdparty%2Fsystemd.git test: avoid matching other fields than __SEQNUM= The current unanchored grep sometimes matches MESSAGE=/_CMDLINE= fields that contain "__SEQNUM=" instead of just the __SEQNUM= field, causing spurious test fails: [ 721.546372] testsuite-04.sh[1013]: ++ cut -d= -f2 [ 721.555858] testsuite-04.sh[1011]: ++ journalctl -o export -n 1 [ 721.573037] testsuite-04.sh[1012]: ++ grep -a __SEQNUM= [ 721.767294] testsuite-04.sh[562]: + SEQNUM1='495773 [ 721.769671] testsuite-04.sh[562]: ++ grep -a __SEQNUM [ 721.771323] testsuite-04.sh[562]: grep -a __SEQNUM' [ 721.772938] testsuite-04.sh[562]: + systemd-cat echo yo [ 721.921413] testsuite-04.sh[562]: + journalctl --sync [ 722.088945] testsuite-04.sh[1018]: ++ journalctl -o export -n 1 [ 722.104040] testsuite-04.sh[1019]: ++ grep -a __SEQNUM= [ 722.117239] testsuite-04.sh[1020]: ++ cut -d= -f2 [ 722.314936] testsuite-04.sh[562]: + SEQNUM2=495786 [ 722.317906] testsuite-04.sh[562]: + test 495786 -gt '495773 [ 722.319737] testsuite-04.sh[562]: ++ grep -a __SEQNUM [ 722.321609] testsuite-04.sh[562]: grep -a __SEQNUM' [ 722.323536] testsuite-04.sh[562]: /usr/lib/systemd/tests/testdata/units/testsuite-04.sh: line 276: test: 495773 [ 722.325744] testsuite-04.sh[562]: ++ grep -a __SEQNUM [ 722.327498] testsuite-04.sh[562]: grep -a __SEQNUM: integer expression expected [ 722.329528] testsuite-04.sh[562]: + journalctl --rotate --vacuum-size=16M $ build/journalctl --file /var/tmp/systemd-test.0HpVjt/system.journal -o export | grep -a __SEQNUM= ... __SEQNUM=214849 __SEQNUM=214850 MESSAGE=++ grep -a __SEQNUM= _CMDLINE=grep -a __SEQNUM= __SEQNUM=214851 ... __SEQNUM=214860 MESSAGE=++ grep -a __SEQNUM= _CMDLINE=grep -a __SEQNUM= __SEQNUM=214861 __SEQNUM=214862 __SEQNUM=214863 ... Let's anchor the expression to avoid this. Follow-up to f28ed2c1be7. --- diff --git a/test/units/testsuite-04.sh b/test/units/testsuite-04.sh index 3cde55cacb7..3bf7577a0e9 100755 --- a/test/units/testsuite-04.sh +++ b/test/units/testsuite-04.sh @@ -269,10 +269,10 @@ fi # Check that the seqnum field at least superficially works systemd-cat echo "ya" journalctl --sync -SEQNUM1=$(journalctl -o export -n 1 | grep -a __SEQNUM= | cut -d= -f2) +SEQNUM1=$(journalctl -o export -n 1 | grep -Ea "^__SEQNUM=" | cut -d= -f2) systemd-cat echo "yo" journalctl --sync -SEQNUM2=$(journalctl -o export -n 1 | grep -a __SEQNUM= | cut -d= -f2) +SEQNUM2=$(journalctl -o export -n 1 | grep -Ea "^__SEQNUM=" | cut -d= -f2) test "$SEQNUM2" -gt "$SEQNUM1" touch /testok