summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2016-05-17 10:17:46 +0100
committerAlexander Larsson <alexl@redhat.com>2016-05-17 18:05:12 +0200
commitd4738cca16e4566d136d62cd80207427682269b9 (patch)
tree9b1b8c2e75134af1cc7d10d3e449476452041e07
parentd6b1c9ff3c325552f6b4154f3c3cccc0a5d4ad37 (diff)
downloadxdg-app-d4738cca16e4566d136d62cd80207427682269b9.tar.gz
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 <smcv@debian.org>
-rw-r--r--tests/libtest.sh11
-rwxr-xr-xtests/test-builder.sh2
-rwxr-xr-xtests/test-run.sh2
3 files changed, 15 insertions, 0 deletions
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