From d4738cca16e4566d136d62cd80207427682269b9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 17 May 2016 10:17:46 +0100 Subject: tests: skip running flatpak at build time if bwrap doesn't work Distribution autobuilders are often more locked-down than the environment in which the distribution binaries actually run. Signed-off-by: Simon McVittie --- tests/libtest.sh | 11 +++++++++++ tests/test-builder.sh | 2 ++ tests/test-run.sh | 2 ++ 3 files changed, 15 insertions(+) diff --git a/tests/libtest.sh b/tests/libtest.sh index 4180de7..aeae41c 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -192,6 +192,17 @@ run_sh () { ${CMD_PREFIX} flatpak run --command=bash ${ARGS-} org.test.Hello -c "$*" } +skip_without_bwrap () { + if [ -z "${FLATPAK_BWRAP:-}" ]; then + # running installed-tests: assume we know what we're doing + : + elif ! "$FLATPAK_BWRAP" --ro-bind / / /bin/true > bwrap-result 2>&1; then + sed -e 's/^/# /' < bwrap-result + echo "1..0 # SKIP Cannot run bwrap" + exit 0 + fi +} + sed s#@testdir@#${test_builddir}# ${test_srcdir}/session.conf.in > session.conf eval `dbus-launch --config-file=session.conf --sh-syntax` diff --git a/tests/test-builder.sh b/tests/test-builder.sh index 19b44c6..f4b19be 100755 --- a/tests/test-builder.sh +++ b/tests/test-builder.sh @@ -21,6 +21,8 @@ set -euo pipefail . $(dirname $0)/libtest.sh +skip_without_bwrap + echo "1..3" setup_repo diff --git a/tests/test-run.sh b/tests/test-run.sh index 09b3ec5..4f3dc44 100755 --- a/tests/test-run.sh +++ b/tests/test-run.sh @@ -21,6 +21,8 @@ set -euo pipefail . $(dirname $0)/libtest.sh +skip_without_bwrap + echo "1..7" setup_repo -- cgit v1.2.1