]> git.ipfire.org Git - thirdparty/systemd.git/commit
test: avoid matching other fields than __SEQNUM=
authorFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 16 Feb 2023 18:48:03 +0000 (19:48 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 16 Feb 2023 22:03:00 +0000 (07:03 +0900)
commitca8b1d68c56129180c4c41c0485cef8ef8df62c8
treeb311b1f1993e0f07d2de2248a8d80c642d33c7b7
parentb038a44d440a67d82cebec5eb40e6369e4c9f613
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.
test/units/testsuite-04.sh