From e3a3f1567a9e59bb4aa5ed3277fcab5d1ec7ff6f Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 23 Jan 2017 15:32:16 -0500 Subject: [PATCH] tests: Fold test-basic.sh into test-run.sh It was never that useful, just a quick stub to get Travis going, which we don't use right now. Let's just move it into the `test-run.sh`. Closes: #163 Approved by: alexlarsson --- Makefile.am | 2 +- tests/test-basic.sh | 35 ----------------------------------- tests/test-run.sh | 8 +++++++- 3 files changed, 8 insertions(+), 37 deletions(-) delete mode 100755 tests/test-basic.sh diff --git a/Makefile.am b/Makefile.am index f080fb18..6f5afde1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,7 +29,7 @@ test_bwrap_SOURCES= include Makefile-docs.am -TESTS = tests/test-basic.sh tests/test-run.sh +TESTS = tests/test-run.sh TESTS_ENVIRONMENT = BWRAP=$(abs_top_builddir)/test-bwrap EXTRA_DIST += $(TESTS) diff --git a/tests/test-basic.sh b/tests/test-basic.sh deleted file mode 100755 index 1f17089b..00000000 --- a/tests/test-basic.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -set -xeuo pipefail - -srcd=$(cd $(dirname $0) && pwd) -bn=$(basename $0) -tempdir=$(mktemp -d /var/tmp/tap-test.XXXXXX) -touch ${tempdir}/.testtmp -function cleanup () { - if test -n "${TEST_SKIP_CLEANUP:-}"; then - echo "Skipping cleanup of ${test_tmpdir}" - else if test -f ${tempdir}/.test; then - rm "${tempdir}" -rf - fi - fi -} -trap cleanup EXIT -cd ${tempdir} - -assert_not_reached () { - echo $@ 1>&2; exit 1 -} - -assert_file_has_content () { - if ! grep -q -e "$2" "$1"; then - echo 1>&2 "File '$1' doesn't match regexp '$2'"; exit 1 - fi -} - -# 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! -"${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 fbeb099f..9f90c647 100755 --- a/tests/test-run.sh +++ b/tests/test-run.sh @@ -17,6 +17,8 @@ function cleanup () { trap cleanup EXIT cd ${tempdir} +: "${BWRAP:=bwrap}" + skip () { echo $@ 1>&2; exit 77 } @@ -47,12 +49,16 @@ if test -x `dirname $UNREADABLE`; then fi # Default arg, bind whole host fs to /, tmpfs on /tmp -RUN="${BWRAP:-bwrap} --bind / / --tmpfs /tmp" +RUN="${BWRAP} --bind / / --tmpfs /tmp" if ! $RUN true; then skip Seems like bwrap is not working at all. Maybe setuid is not working fi +# Test help +${BWRAP} --help > help.txt +assert_file_has_content help.txt "usage: bwrap" + for ALT in "" "--unshare-user-try" "--unshare-pid" "--unshare-user-try --unshare-pid"; do # Test fuse fs as bind source if [ x$FUSE_DIR != x ]; then