mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
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 f28ed2c1be
.
This commit is contained in:
parent
b038a44d44
commit
ca8b1d68c5
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user