test-history: Skip test if we cannot read from the Journal

In some OS configurations, unprivileged users cannot read back messages
that they have written to the system log. This test cannot succeed if that
happens, so skip it.

In particular, if the Journal is only in-memory rather than persisted
to disk (as it was by default in Debian 10), then there are no per-user
Journal files, only a single system-wide Journal which requires privileges
to read.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Fixes: 8b05f6b3 "Add a unit test for the history command"
(cherry picked from commit 0deb80efa8642e575ae9ae28bee49d74e6c024f3)
This commit is contained in:
Simon McVittie 2022-02-19 17:11:58 +00:00 committed by Phaedrus Leeds
parent 0956357de1
commit 841429b1f6

View File

@ -11,11 +11,21 @@ USE_SYSTEMDIR=yes
skip_without_bwrap
skip_revokefs_without_fuse
echo "1..1"
HISTORY_START_TIME=$(date +"%Y-%m-%d %H:%M:%S")
sleep 1
if ! logger "Checking whether Flatpak can use the journal..."; then
skip "Cannot write to Journal with logger"
fi
messages="$(journalctl --user --since="${HISTORY_START_TIME}" || true)"
if [ -z "$messages" ]; then
skip "Cannot read back from Journal with journalctl"
fi
echo "1..1"
mkdir -p ${TEST_DATA_DIR}/system-history-installation
mkdir -p ${FLATPAK_CONFIG_DIR}/installations.d
cat << EOF > ${FLATPAK_CONFIG_DIR}/installations.d/history-installation.conf