Merge pull request #219 from jlebon/pr/testenv-helper

Fix up libtest.sh and add testenv helper
This commit is contained in:
Colin Walters 2016-02-26 13:21:56 -05:00
commit 50fb99ed5a
3 changed files with 30 additions and 6 deletions

View File

@ -78,3 +78,12 @@ check-local:
@echo " To run them, rpm-ostree must be configured with --enable-installed-tests and installed"
@echo " *** NOTE ***"
@echo " *** NOTE ***"
testenv:
@echo "===== ENTERING TESTENV ====="
test_tmpdir=$$(mktemp -d test.XXXXXX) && \
cd $$test_tmpdir && \
sh ../tests/setup-session.sh bash && \
cd .. && \
rm -rf $$test_tmpdir
@echo "===== LEAVING TESTENV ====="

View File

@ -17,19 +17,32 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# Have we already been sourced?
if test -n "${LIBTEST_SH:-}"; then
# would be good to know when it happens
echo "INFO: Skipping subsequent sourcing of libtest.sh"
return
fi
LIBTEST_SH=1
SRCDIR=$(dirname $0)
_cleanup_tmpdir () {
if test -f ${test_tmpdir}.test; then
rm ${test_tmpdir} -rf
if test -f ${test_tmpdir}/.test; then
rm ${test_tmpdir} -rf
fi
}
# If we're running as a local test (i.e. through `make check`), then
# UNINSTALLEDTESTS=1. Otherwise (i.e. as an installed test), it's undefined, in
# which case we're already in a tmpdir.
if test -n "${UNINSTALLEDTESTS:-}"; then
test_tmpdir=$(mktemp -d test.XXXXXX)
touch ${test_tmpdir}/.test
trap _cleanup_tmpdir EXIT
cd ${test_tmpdir}
export PATH=${builddir}:${PATH}
fi
fi
test_tmpdir=$(pwd)
export G_DEBUG=fatal-warnings

View File

@ -19,12 +19,14 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
test_tmpdir=$(pwd)
set -e
. $(dirname $0)/libtest.sh
exec_binary="@LIBEXECDIR@/rpm-ostreed"
mkdir sysroot
mkdir session-services
mkdir -p sysroot
mkdir -p session-services
# Create a busconfig file with a custom <servicedir>
cat > session.conf <<EOF