diff options
author | Colin Walters <walters@verbum.org> | 2016-03-15 09:18:36 -0400 |
---|---|---|
committer | Colin Walters (automation) <walters+githubbot@verbum.org> | 2016-03-15 15:34:28 +0000 |
commit | e06ff186ce96f1aee1cf260602e59f7e5a6c3b19 (patch) | |
tree | 37778054e6a2a94ff7c11759ce8a819ffc58157d | |
parent | bf3ae2166fbe20831bc42e4778fa2ff6cd32bb78 (diff) | |
download | bubblewrap-e06ff186ce96f1aee1cf260602e59f7e5a6c3b19.tar.gz |
tests: Add a stub test framework
Imported a little bit of code from OSTree's shell `libtest.sh`. I'm
mostly doing this to test Travis and Homu, but hey, we get a little
bit of coverage.
Pull request: #21
Approved by: alexlarsson
-rw-r--r-- | Makefile.am | 3 | ||||
-rwxr-xr-x | tests/test-basic.sh | 35 |
2 files changed, 38 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 8427f99..8fc2ae9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,3 +13,6 @@ test-setcaps: bwrap sudo setcap "cap_sys_admin+ep cap_sys_chroot+ep" bwrap include Makefile-docs.am + +TESTS = tests/test-basic.sh +TESTS_ENVIRONMENT = PATH=$$(cd $(top_builddir) && pwd):$${PATH} diff --git a/tests/test-basic.sh b/tests/test-basic.sh new file mode 100755 index 0000000..7513933 --- /dev/null +++ b/tests/test-basic.sh @@ -0,0 +1,35 @@ +#!/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 --help >out.txt 2>&1 +assert_file_has_content out.txt "--lock-file" + |