Skip to content

Commit

Permalink
Adapt tests so they can be run against installed binaries
Browse files Browse the repository at this point in the history
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
  • Loading branch information
smcv authored and rh-atomic-bot committed Nov 29, 2016
1 parent 21c6736 commit 3e65988
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/test-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

16 changes: 8 additions & 8 deletions tests/test-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3e65988

Please sign in to comment.