Skip to content

Commit

Permalink
test: add test case for issue user journal corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
mrc0mmand committed Feb 14, 2024
1 parent 49b643e commit 8b3443f
Show file tree
Hide file tree
Showing 2 changed files with 23 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 @@ -2099,7 +2099,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
22 changes: 22 additions & 0 deletions test/units/testsuite-04.user-corrupt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/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 i in {0..10}; 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

0 comments on commit 8b3443f

Please sign in to comment.