1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 18:55:40 +03:00
Commit Graph

13 Commits

Author SHA1 Message Date
Yu Watanabe
ff4240fc22 test: wait for verbose-success.service finished
Otherwise, the command 'echo' may not be invoked yet.

Follow-up for 25aa35d465.
2024-01-05 13:08:10 +01:00
Sergei Zhmylev
25aa35d465 journalctl: add --exclude-identifier option 2024-01-04 23:21:39 +01:00
Frantisek Sumsal
4207a5577a journalctl: don't skip over messages not matching the cursor
When --after-cursor=/--cursor-file= is used together with a journal
filter, we still skipped over the first matching entry even if it wasn't
the entry the cursor points at, thus missing one "valid" entry
completely. Let's fix this by checking if the entry cursor after seeking
matches the user provided cursor, and skip to the next entry only when
the cursors match.

Resolves: #30288
2023-12-07 13:31:25 +09:00
Yu Watanabe
a93be359ae sd-journal: fix corrupted journal handling of generic_array_bisect()
Let's consider the following case:
- the direction is down,
- no cached entry,
- the array has 5 entry objects,
- the function test_object() reutns TEST_LEFT for the 1st object,
- the 2nd, 3rd, and 4th objects are broken, so generic_array_bisect_step()
  returns TEST_RIGHT for the object.

Then, previously, generic_array_bisect_step() updated the values like the following:
  0th: (m = 5, left = 0, right = 4, i = 4) -> (m = 4, left = 0, right = 3, RIGHT)
  1st: (m = 4, left = 0, right = 3, i = 1) -> (m = 4, left = 2, right = 3, LEFT)
  2nd: (m = 4, left = 2, right = 3, i = 2) -> (m = 2, left = 2, right = 1, RIGHT) <- ouch!!
So, assert(left < right) in generic_array_bisect() was triggered.
See issue #30210.

In such situation, there is no matching entry in the array. By returning
TEST_GOTO_PREVIOUS, generic_array_bisect() handles the result so.

Fixes a bug introduced by ab8f553d1e.

Fixes #30210.
2023-12-01 09:56:10 +09:00
Yu Watanabe
ab8f553d1e sd-journal: rework generic_array_bisect()
- Rename generic_array_bisect_one() -> generic_array_bisect_step(), as there
  is also generic_array_bisect_plus_one(), so the original name is confusing.
- Make generic_array_bisect_step() return TEST_GOTO_NEXT or TEST_GOTO_PREVIOUS
  when the current array does not contain any matching entries.
- Make generic_array_bisect_step() symmetric with respect to the direction
  we are going to, except for the journal corruption handling.
- Make generic_array_bisect_step() gracefully handle journal corruptions,
  so the corruption handling in the caller side can be mostly dropped.
- Especially, when the last entry in an array is corrupted, previously
  we tried to find a valid entry sequentially from the end of the array,
  but now we anyway bisect the array. That should improve performance of
  reading corrupted journal files.
- Return earlier when no entry linked to the chained array (n == 0).
- Add many comments.

No behavior change unless journal is corrupted.
2023-11-04 11:01:30 +09:00
Lennart Poettering
8525de1365 test: extend some existing tests with varlinkctl lines, to test varlinkctl + new PCRExtend service 2023-10-06 11:49:38 +02:00
Yu Watanabe
185e201690 journalctl: find boot ID more gracefully in corrupted journal
In discover_next_boot(), first we find a new boot ID based on the value
stored in the entry object. Then, find the tail (or head when we are going
upwards) entry of the boot based on the _BOOT_ID= field data.

If boot IDs of an entry in the entry object and _BOOT_ID field data
are inconsistent, which may happen on corrupted journal, then previously
discover_next_boot() failed with -ENODATA.

This makes the function check if the two boot IDs in each entry are
consistent, and skip the entry if not.

Fixes the failure of `journalctl -b -1` for 'truncated' journal:
https://github.com/systemd/systemd/pull/29334#issuecomment-1736567951
2023-10-02 10:59:33 +09:00
Zbigniew Jędrzejewski-Szmek
1c5d54b2df test: use 'until' instead of 'while !'
In general, it's better to avoid a negation. And "!" is special, because it is
used for history expansion, i.e. the same command would behave differently if
pasted on the command line.

Inspired by 4a899c5a23.
2023-09-06 19:54:29 +01:00
Yu Watanabe
627cdcc785 tree-wide: fix typos reported by Fossies Codespell report 2023-07-12 10:14:50 +09:00
Frantisek Sumsal
51a05be9a2 test: cover a couple of missed code paths in journalctl/journald 2023-06-21 17:08:55 +02:00
Frantisek Sumsal
e46b313a62 test: clean up the new test case a bit
Follow-up to 61cecfa0d8.
2023-06-16 09:56:32 +02:00
zhmylove
61cecfa0d8 journalctl: add --truncate-newline option 2023-06-16 09:31:47 +02:00
Frantisek Sumsal
9457dd8bae test: split TEST-04 into smaller chunks 2023-06-14 20:28:20 +02:00