test: add test for seqnum and seqnum ID

This commit is contained in:
Yu Watanabe
2023-12-01 12:29:11 +09:00
parent 1b7aa998ae
commit 0cf392c4e7
2 changed files with 45 additions and 1 deletions

View File

@@ -70,3 +70,47 @@ journalctl --list-boots -o json | jq -r '.[] | [.index, .boot_id, .first_entry,
assert_eq "$entry_ts" "$last_ts"
fi
done
verify_seqnum() {
if [[ "$REBOOT_COUNT" -ne "$NUM_REBOOT" ]]; then
return 0
fi
journalctl --flush
journalctl --sync
ls -lR /var/log/journal/
ls -lR /run/log/journal/
journalctl --system --header
(! journalctl --system -q -o short-monotonic -u systemd-journald.service --grep 'rotating')
set +x
previous_seqnum=0
previous_seqnum_id=
previous_boot_id=
journalctl --system -q -o json | jq -r '[.__SEQNUM, .__SEQNUM_ID, ._BOOT_ID] | @tsv' |
while read -r seqnum seqnum_id boot_id; do
if [[ -n "$previous_seqnum_id" ]]; then
if ! test "$seqnum" -gt "$previous_seqnum"; then
echo "seqnum=$seqnum is not greater than previous_seqnum=$previous_seqnum"
echo "seqnum_id=$seqnum_id, previous_seqnum_id=$previous_seqnum_id"
echo "boot_id=$boot_id, previous_boot_id=$previous_boot_id"
return 1
fi
assert_eq "$seqnum_id" "$previous_seqnum_id"
fi
previous_seqnum="$seqnum"
previous_seqnum_id="$seqnum_id"
previous_boot_id="$boot_id"
done
set -x
return 0
}
verify_seqnum

View File

@@ -3,7 +3,7 @@
set -eux
set -o pipefail
NUM_REBOOT=4
export NUM_REBOOT=4
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh