summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2016-11-29 10:16:30 +0000
committerAtomic Bot <atomic-devel@projectatomic.io>2016-11-29 11:13:33 +0000
commit3e659884a2f6079bd72929181e7bddf7d2b5da1d (patch)
treedff215cdf78db41da87cb3cfdb5b1dbf6072ab24
parent21c67366b4933be6542e5b5315460e5deb083b70 (diff)
downloadbubblewrap-3e659884a2f6079bd72929181e7bddf7d2b5da1d.tar.gz
Adapt tests so they can be run against installed binaries
Look for bwrap on PATH by default, but allow it to be overridden with BWRAP, and set that variable in TESTS_ENVIRONMENT so we are testing the just-built version in "make check". Signed-off-by: Simon McVittie <smcv@debian.org> Closes: #120 Approved by: alexlarsson
-rw-r--r--Makefile.am2
-rwxr-xr-xtests/test-basic.sh2
-rwxr-xr-xtests/test-run.sh16
3 files changed, 10 insertions, 10 deletions
diff --git a/Makefile.am b/Makefile.am
index b20e866..f080fb1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,7 +30,7 @@ test_bwrap_SOURCES=
include Makefile-docs.am
TESTS = tests/test-basic.sh tests/test-run.sh
-TESTS_ENVIRONMENT = PATH=$$(cd $(top_builddir) && pwd):$${PATH}
+TESTS_ENVIRONMENT = BWRAP=$(abs_top_builddir)/test-bwrap
EXTRA_DIST += $(TESTS)
diff --git a/tests/test-basic.sh b/tests/test-basic.sh
index 7fab54c..1f17089 100755
--- a/tests/test-basic.sh
+++ b/tests/test-basic.sh
@@ -30,6 +30,6 @@ assert_file_has_content () {
# At the moment we're testing in Travis' container infrastructure
# which also uses PR_SET_NO_NEW_PRIVS...but let's at least
# verify --help works!
-test-bwrap --help >out.txt 2>&1
+"${BWRAP:-bwrap}" --help >out.txt 2>&1
assert_file_has_content out.txt "--lock-file"
diff --git a/tests/test-run.sh b/tests/test-run.sh
index c14813d..5b15922 100755
--- a/tests/test-run.sh
+++ b/tests/test-run.sh
@@ -47,35 +47,35 @@ if test -x `dirname $UNREADABLE`; then
fi
# Default arg, bind whole host fs to /, tmpfs on /tmp
-BWRAP="test-bwrap --bind / / --tmpfs /tmp"
+RUN="${BWRAP:-bwrap} --bind / / --tmpfs /tmp"
-if ! $BWRAP true; then
+if ! $RUN true; then
skip Seems like bwrap is not working at all. Maybe setuid is not working
fi
for ALT in "" "--unshare-user" "--unshare-pid" "--unshare-user --unshare-pid"; do
# Test fuse fs as bind source
if [ x$FUSE_DIR != x ]; then
- $BWRAP $ALT --proc /proc --dev /dev --bind $FUSE_DIR /tmp/foo true
+ $RUN $ALT --proc /proc --dev /dev --bind $FUSE_DIR /tmp/foo true
fi
# no --dev => no devpts => no map_root workaround
- $BWRAP $ALT --proc /proc true
+ $RUN $ALT --proc /proc true
# No network
- $BWRAP $ALT --unshare-net --proc /proc --dev /dev true
+ $RUN $ALT --unshare-net --proc /proc --dev /dev true
# Unreadable file
echo -n "expect EPERM: "
- if $BWRAP $ALT --unshare-net --proc /proc --bind /etc/shadow /tmp/foo cat /etc/shadow; then
+ if $RUN $ALT --unshare-net --proc /proc --bind /etc/shadow /tmp/foo cat /etc/shadow; then
assert_not_reached Could read /etc/shadow
fi
# Unreadable dir
if [ x$UNREADABLE != x ]; then
echo -n "expect EPERM: "
- if $BWRAP $ALT --unshare-net --proc /proc --dev /dev --bind $UNREADABLE /tmp/foo cat /tmp/foo ; then
+ if $RUN $ALT --unshare-net --proc /proc --dev /dev --bind $UNREADABLE /tmp/foo cat /tmp/foo ; then
assert_not_reached Could read $UNREADABLE
fi
fi
# bind dest in symlink (https://github.com/projectatomic/bubblewrap/pull/119)
- $BWRAP $ALT --dir /tmp/dir --symlink dir /tmp/link --bind /etc /tmp/link true
+ $RUN $ALT --dir /tmp/dir --symlink dir /tmp/link --bind /etc /tmp/link true
done
echo OK