Skip to content

Commit d1a7ffc

Browse files
mrc0mmandkeszybz
authored andcommitted
test: add test cases for journal corruption on btrfs
For issue systemd#24150 and systemd#31222. (cherry picked from commit 8cc4216)
1 parent 0420956 commit d1a7ffc

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

test/test-functions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2103,7 +2103,7 @@ install_testuser() {
21032103
# create unprivileged user for user manager tests
21042104
mkdir -p "${initdir:?}/etc/sysusers.d"
21052105
cat >"$initdir/etc/sysusers.d/testuser.conf" <<EOF
2106-
u testuser 4711 "Test User" /home/testuser
2106+
u testuser 4711 "Test User" /home/testuser /bin/bash
21072107
EOF
21082108

21092109
mkdir -p "$initdir/home/testuser"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: LGPL-2.1-or-later
3+
set -eux
4+
set -o pipefail
5+
6+
journalctl --rotate --vacuum-files=1
7+
# Nuke all archived journals, so we start with a clean slate
8+
rm -f "/var/log/journal/$(</etc/machine-id)"/system@*.journal
9+
rm -f "/var/log/journal/$(</etc/machine-id)"/user-*@*.journal
10+
journalctl --header | grep path
11+
12+
# Make sure the user instance is active when we rotate journals
13+
systemd-run --unit user-sleep.service --user -M testuser@ sleep infinity
14+
15+
for _ in {0..9}; do
16+
journalctl --rotate
17+
journalctl --sync
18+
SYSTEMD_LOG_LEVEL=debug journalctl -n1 -q
19+
(! journalctl -n0 -q |& grep corrupted)
20+
done
21+
22+
systemctl stop --user -M testuser@ user-sleep.service
23+
24+
journalctl --sync
25+
journalctl --rotate --vacuum-files=1
26+
# Nuke all archived journals, so we start with a clean slate
27+
rm -f "/var/log/journal/$(</etc/machine-id)"/system@*.journal
28+
rm -f "/var/log/journal/$(</etc/machine-id)/"user-*@*.journal
29+
journalctl --header | grep path
30+
31+
for _ in {0..9}; do
32+
journalctl --rotate --vacuum-files=1
33+
journalctl --sync
34+
SYSTEMD_LOG_LEVEL=debug journalctl -n1 -q
35+
(! journalctl -n0 -q |& grep corrupted)
36+
done

0 commit comments

Comments
 (0)