1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

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.
This commit is contained in:
Lennart Poettering 2023-02-08 11:29:49 +01:00
parent 262299dccb
commit 4601c7aa8f
9 changed files with 24 additions and 0 deletions

View File

@ -7,4 +7,13 @@ TEST_DESCRIPTION="Journal-related tests"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
local workspace="${1:?}"
mkdir -p "$workspace/test-journals/"
cp -av "${TEST_BASE_DIR:?}/test-journals/"* "$workspace/test-journals/"
inst_binary unzstd
}
do_test "$@"

Binary file not shown.

Binary file not shown.

View File

@ -275,4 +275,19 @@ journalctl --sync
SEQNUM2=$(journalctl -o export -n 1 | grep -Ea "^__SEQNUM=" | cut -d= -f2)
test "$SEQNUM2" -gt "$SEQNUM1"
JTMP="/var/tmp/jtmp-$RANDOM"
mkdir "$JTMP"
( cd /test-journals/1 && for f in *.zst ; do unzstd < "$f" > "$JTMP/${f%.zst}" ; done )
journalctl --directory="$JTMP" --list-boots --output=json > /tmp/lb1
diff -u /tmp/lb1 - <<'EOF'
[{"index":-3,"boot_id":"5ea5fc4f82a14186b5332a788ef9435e","first_entry":1666569600994371,"last_entry":1666584266223608},{"index":-2,"boot_id":"bea6864f21ad4c9594c04a99d89948b0","first_entry":1666584266731785,"last_entry":1666584347230411},{"index":-1,"boot_id":"4c708e1fd0744336be16f3931aa861fb","first_entry":1666584348378271,"last_entry":1666584354649355},{"index":0,"boot_id":"35e8501129134edd9df5267c49f744a4","first_entry":1666584356661527,"last_entry":1666584438086856}]
EOF
rm -rf "$JTMP"
rm /tmp/lb1
touch /testok