From 841429b1f65a92db6d33ca142ab20e66bd46bbff Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 19 Feb 2022 17:11:58 +0000 Subject: [PATCH] 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 Fixes: 8b05f6b3 "Add a unit test for the history command" (cherry picked from commit 0deb80efa8642e575ae9ae28bee49d74e6c024f3) --- tests/test-history.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test-history.sh b/tests/test-history.sh index baa89350..c4eb4365 100755 --- a/tests/test-history.sh +++ b/tests/test-history.sh @@ -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