Skip to content

Commit

Permalink
test: add test cases for journal corruption on btrfs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrc0mmand authored and ayhamthemayhem committed Mar 25, 2024
1 parent 3adf257 commit 6bfd244
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/test-functions
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
36 changes: 36 additions & 0 deletions test/units/testsuite-04.journal-corrupt.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6bfd244

Please sign in to comment.