diff options
author | Simon McVittie <smcv@collabora.com> | 2021-06-18 10:11:56 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2021-06-18 10:11:56 +0100 |
commit | 338ddc0eb4d84660e929d2342850e6844b2ce71f (patch) | |
tree | b504518d4592335a330652c6a2e3e68203e7913b | |
parent | e2e61475a194f3c684979dbe6928708f6c77b4e4 (diff) | |
download | bubblewrap-338ddc0eb4d84660e929d2342850e6844b2ce71f.tar.gz |
libtest-core: Separate out bubblewrap-specific parts
extract_child_pid is specific to bubblewrap and wouldn't be useful to
share with the canonical copy of libtest-core in libostree.
Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r-- | Makefile.am | 7 | ||||
-rw-r--r-- | tests/libtest-core.sh | 4 | ||||
-rw-r--r-- | tests/libtest.sh | 37 | ||||
-rwxr-xr-x | tests/test-run.sh | 2 |
4 files changed, 44 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am index d3150c9..550a6e7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,10 +45,15 @@ include Makefile-docs.am LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build-aux/tap-driver.sh LOG_COMPILER = TESTS = tests/test-run.sh -TESTS_ENVIRONMENT = BWRAP=$(abs_top_builddir)/test-bwrap +TESTS_ENVIRONMENT = \ + BWRAP=$(abs_top_builddir)/test-bwrap \ + G_TEST_BUILDDIR=$(abs_top_builddir) \ + G_TEST_SRCDIR=$(abs_top_srcdir) \ + $(NULL) EXTRA_DIST += $(TESTS) EXTRA_DIST += tests/libtest-core.sh +EXTRA_DIST += tests/libtest.sh if ENABLE_BASH_COMPLETION bashcompletiondir = $(BASH_COMPLETION_DIR) diff --git a/tests/libtest-core.sh b/tests/libtest-core.sh index abc040b..8d08dac 100644 --- a/tests/libtest-core.sh +++ b/tests/libtest-core.sh @@ -178,10 +178,6 @@ skip() { exit 0 } -extract_child_pid() { - grep child-pid "$1" | sed "s/^.*: \([0-9]*\).*/\1/" -} - report_err () { local exit_status="$?" { { local BASH_XTRACEFD=3; } 2> /dev/null diff --git a/tests/libtest.sh b/tests/libtest.sh new file mode 100644 index 0000000..41b209b --- /dev/null +++ b/tests/libtest.sh @@ -0,0 +1,37 @@ +# Source library for shell script tests. +# Add non-bubblewrap-specific code to libtest-core.sh instead. +# +# Copyright (C) 2017 Colin Walters <walters@verbum.org> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +if [ -n "${G_TEST_SRCDIR:-}" ]; then + test_srcdir="${G_TEST_SRCDIR}/tests" +else + test_srcdir=$(dirname $0) +fi + +if [ -n "${G_TEST_BUILDDIR:-}" ]; then + test_builddir="${G_TEST_BUILDDIR}/tests" +else + test_builddir=$(dirname $0) +fi + +. "${test_srcdir}/libtest-core.sh" + +extract_child_pid() { + grep child-pid "$1" | sed "s/^.*: \([0-9]*\).*/\1/" +} diff --git a/tests/test-run.sh b/tests/test-run.sh index 341f87c..b61a99e 100755 --- a/tests/test-run.sh +++ b/tests/test-run.sh @@ -7,7 +7,7 @@ PATH="$PATH:/usr/sbin:/sbin" srcd=$(cd $(dirname $0) && pwd) -. ${srcd}/libtest-core.sh +. ${srcd}/libtest.sh bn=$(basename $0) tempdir=$(mktemp -d /var/tmp/tap-test.XXXXXX) |