test: add test cases for journal corruption on btrfs

For issue #24150 and #31222.
This commit is contained in:
Frantisek Sumsal
2024-02-16 03:48:18 +09:00
committed by Yu Watanabe
parent 18d4e475c7
commit 8cc42169f1
2 changed files with 37 additions and 1 deletions
+1 -1
View File
@@ -2103,7 +2103,7 @@ install_testuser() {
# create unprivileged user for user manager tests
mkdir -p "${initdir:?}/etc/sysusers.d"
cat >"$initdir/etc/sysusers.d/testuser.conf" <<EOF
u testuser 4711 "Test User" /home/testuser
u testuser 4711 "Test User" /home/testuser /bin/bash
EOF
mkdir -p "$initdir/home/testuser"
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
set -o pipefail
journalctl --rotate --vacuum-files=1
# Nuke all archived journals, so we start with a clean slate
rm -f "/var/log/journal/$(</etc/machine-id)"/system@*.journal
rm -f "/var/log/journal/$(</etc/machine-id)"/user-*@*.journal
journalctl --header | grep path
# Make sure the user instance is active when we rotate journals
systemd-run --unit user-sleep.service --user -M testuser@ sleep infinity
for _ in {0..9}; do
journalctl --rotate
journalctl --sync
SYSTEMD_LOG_LEVEL=debug journalctl -n1 -q
(! journalctl -n0 -q |& grep corrupted)
done
systemctl stop --user -M testuser@ user-sleep.service
journalctl --sync
journalctl --rotate --vacuum-files=1
# Nuke all archived journals, so we start with a clean slate
rm -f "/var/log/journal/$(</etc/machine-id)"/system@*.journal
rm -f "/var/log/journal/$(</etc/machine-id)/"user-*@*.journal
journalctl --header | grep path
for _ in {0..9}; do
journalctl --rotate --vacuum-files=1
journalctl --sync
SYSTEMD_LOG_LEVEL=debug journalctl -n1 -q
(! journalctl -n0 -q |& grep corrupted)
done