1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00
Commit Graph

34 Commits

Author SHA1 Message Date
Frantisek Sumsal
b003e2c7a6 test: clean up the test script even further
Most notably:
  - use `systemd-id128 new` instead of `journalctl --new-id128`
  - move all temporary files to /tmp
  - wrap repetitive checks in a function
2023-05-03 18:32:00 +02:00
Frantisek Sumsal
8077d99fd2 test: vacuum the journal after the "stress test"
To make the rest of the test significantly faster.
2023-05-03 17:37:09 +02:00
Frantisek Sumsal
23f83ba768 test: slightly extend checks on corrupted journals 2023-05-03 17:32:36 +02:00
Frantisek Sumsal
c4039ceb9e test: further extend our collection of corrupted journals
And make adding them slightly easier.

Provides coverage for b5335da7a5.
2023-05-03 17:22:37 +02:00
Frantisek Sumsal
0f69a4e9ae test: test journalctl with corrupted journals
Last month I monkey-patched journald to produce a small (64K) but valid
journal and used that as an input to four AFL fuzzers. After a month it
generated quite a nice corpora (4738 test cases) and after filtering
and minimizing it I was left with 619 unique journals with various
levels of corruption that probe the journal code.

It seems to detect past issues like systemd#26567, etc.
2023-05-01 10:14:12 +02:00
Frantisek Sumsal
de965f4893 test: clean up the test script a bit 2023-05-01 15:47:04 +09:00
Zbigniew Jędrzejewski-Szmek
128db0aa00 test: drop uses of "&& { echo 'unexpected success'; exit 1; }"
Brief is sweet.
2023-04-24 21:58:35 +02:00
Zbigniew Jędrzejewski-Szmek
a1e5bd2066 testsuite-04: remove unnecessary conditional 2023-04-24 10:06:59 +02:00
Zbigniew Jędrzejewski-Szmek
f65c2f5214 testsuite-04: remove redirection, drop whitespace after redirection op 2023-04-24 10:06:59 +02:00
Frantisek Sumsal
3a8b7e8b5f test: stop the test unit when it's not needed anymore
Otherwise it keeps printing stuff to the journal/console, adding
unnecessary noise.
2023-04-14 21:13:14 +02:00
Yu Watanabe
d23a1c52a9 test: add test case that journal file is created with the requested compression algorithm 2023-04-07 02:30:43 +09:00
Lennart Poettering
4601c7aa8f test: add test for journals without RTC
This adds a test for checking we can safely order boot IDs via the
timestamp of their most recent known entry. It takes a set of journal
files (supplied by a user) and that are partially corrupted, and ensures
we get a clear, defined order of boot IDs out of it.
2023-03-02 10:18:24 +01:00
Frantisek Sumsal
ca8b1d68c5 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.
2023-02-17 07:03:00 +09:00
Luca Boccassi
6f97aae029
Merge pull request #26213 from poettering/journal-rework-seqnum
journal sequence number rework
2023-02-15 19:58:58 +00:00
Quentin Deslandes
41b7fcc5e8 journald: fix ignored filtering patterns for delegated cgroups
If a service defines Delegate=yes, its subcgroup won't inherit the
LogFilterPatterns= option, because the option is stored on the unit's
cgroup attributes, not on the subcgroup.

Fixed by using the unit's cgroup attributes instead.
2023-02-08 16:52:51 +01:00
Lennart Poettering
f28ed2c1be test: add basic seqnum test 2023-02-08 13:52:14 +01:00
Lennart Poettering
2bc70e2e9d logs-show: show seqnum info in export+json output mode 2023-02-08 13:42:29 +01:00
Yu Watanabe
577a0fd59b test: use notice log level to make easily filter out logs from PID1 2023-02-06 22:50:03 +09:00
Quentin Deslandes
1c9c6fc7df journal: add integration tests for log filtering
Add integration tests for journald's log filtering feature.
2022-12-15 09:57:39 +00:00
Frantisek Sumsal
ca46781c5f test: add a couple of sanity tests for journalctl 2022-10-31 12:11:59 +01:00
Frantisek Sumsal
0897048500 test: use saved process PID instead of %%
As the `%%` specifier might fail if the current job (i.e. the last
background job) already finished:

```
[   61.692196] testsuite-04.sh[656]: ++ systemd-id128 new
[   61.705407] testsuite-04.sh[263]: + ID=912cb8f8ef304153a123f772bb0fe9e0
[   61.706318] testsuite-04.sh[657]: + systemd-cat -t 912cb8f8ef304153a123f772bb0fe9e0 bash -c 'echo parent; (echo child) & wait'
[   61.720940] testsuite-04.sh[263]: + PID=657
[   61.721126] testsuite-04.sh[263]: + wait %%
[   61.723014] testsuite-04.sh[263]: /usr/lib/systemd/tests/testdata/units/testsuite-04.sh: line 96: wait: %%: no such job
```
2022-06-20 17:56:09 +00:00
Zbigniew Jędrzejewski-Szmek
7b3cec95db tests: add spdx headers to scripts and Makefiles 2021-10-18 09:04:45 +02:00
Frantisek Sumsal
1c3f490f23 test: shellcheck-ify test scripts 2021-09-30 12:12:00 +02:00
Frantisek Sumsal
e7848266da test: add a testcase for issue #19895 2021-06-15 23:18:06 +01:00
Ryan Hendrickson
c2503e359a core: apply LogLevelMax to messages about units
This commit applies the filtering imposed by LogLevelMax on a unit's
processes to messages logged by PID1 about the unit as well.

The target use case for this feature is a service that runs on a timer
many times an hour, where the system administrator decides that writing
a generic success message to the journal every few minutes or seconds
adds no diagnostic value and isn't worth the clutter or disk I/O.
2021-05-03 17:48:41 +02:00
Frantisek Sumsal
ea539ad297 test: replace the obsolete `` syntax with $() 2021-04-13 12:08:01 +02:00
Frantisek Sumsal
70ad107bdf test: use an explicit no-op for file truncation 2021-04-13 12:08:01 +02:00
Frantisek Sumsal
084575ff91 test: use set -eux and set -o pipefail everywhere
This should make the scripts more robust.
2021-04-13 12:08:01 +02:00
Zbigniew Jędrzejewski-Szmek
0ee994836c TEST-*: use spacing before redirection operator, but not after
<< EOF → <<EOF
> foo < bar → >foo <bar
2021-04-08 20:21:50 +02:00
Zbigniew Jędrzejewski-Szmek
4e20fe2795 TEST-*: make failure tests actually fail on failure
Here the intent was actually correct, and the tests still pass when the check
is made effective.
2021-04-08 20:21:50 +02:00
Benjamin Robin
d38b3b74db test: Stricter test case for #15654 (Add more checks)
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
2020-05-13 21:32:45 +02:00
Benjamin Robin
c11d8fd1da test: Add a test case for #15654 2020-05-13 21:32:42 +02:00
Kumar Kartikeya Dwivedi
5c568be167 test: add a test case for #15528 2020-04-23 09:24:17 +02:00
Zbigniew Jędrzejewski-Szmek
9901a6ad2e test: convert TEST-04-JOURNAL to generic image 2020-03-28 11:46:47 +01:00