summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2016-03-31 18:29:44 +0100
committerColin Walters (automation) <walters+githubbot@verbum.org>2016-03-31 18:54:13 +0000
commitefb86ba9d32a038dd90f47f6e82f578e91b5fef5 (patch)
treee45bd9f950ecf337b4e04088903f9f1e1a745ecf
parentbdf24cdc049b421d6e5a982ee9f25502407dceca (diff)
downloadostree-efb86ba9d32a038dd90f47f6e82f578e91b5fef5.tar.gz
libtest.sh: use G_TEST_SRCDIR, G_TEST_BUILDDIR to find resources
This fixes the bug that in installed-tests that run testlib.sh under "bash -c" (i.e. the C and JS tests), $(dirname $0) is "." and we can't do the LD_PRELOAD correctly: ERROR: ld.so: object './libreaddir-rand.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. Similarly, those tests can't copy gpghome correctly. This also removes the confusing situation that SRCDIR in libtest.sh (which is ${top_srcdir}/tests) does not mean the same thing as SRCDIR in test-abi.sh (which is just ${top_srcdir}). Signed-off-by: Simon McVittie <smcv@debian.org> Closes: #234 Approved by: cgwalters
-rwxr-xr-xtests/libtest.sh18
-rwxr-xr-xtests/test-archivez.sh2
-rwxr-xr-xtests/test-delta.sh4
-rwxr-xr-xtests/test-pull-archive-z.sh2
4 files changed, 18 insertions, 8 deletions
diff --git a/tests/libtest.sh b/tests/libtest.sh
index 03b498aa..aaa553a0 100755
--- a/tests/libtest.sh
+++ b/tests/libtest.sh
@@ -17,7 +17,17 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-SRCDIR=$(dirname $0)
+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
assert_not_reached () {
echo $@ 1>&2; exit 1
@@ -54,7 +64,7 @@ export TEST_GPG_KEYID_3="DF444D67"
# homedir in order to create lockfiles. Work around
# this by copying locally.
echo "Copying gpghome to ${test_tmpdir}"
-cp -a ${SRCDIR}/gpghome ${test_tmpdir}
+cp -a "${test_srcdir}/gpghome" ${test_tmpdir}
export TEST_GPG_KEYHOME=${test_tmpdir}/gpghome
export OSTREE_GPG_HOME=${test_tmpdir}/gpghome/trusted
@@ -63,9 +73,9 @@ if test -n "${OT_TESTS_DEBUG:-}"; then
fi
if test -n "${OT_TESTS_VALGRIND:-}"; then
- CMD_PREFIX="env G_SLICE=always-malloc valgrind -q --leak-check=full --num-callers=30 --suppressions=${SRCDIR}/ostree-valgrind.supp"
+ CMD_PREFIX="env G_SLICE=always-malloc valgrind -q --leak-check=full --num-callers=30 --suppressions=${test_srcdir}/ostree-valgrind.supp"
else
- CMD_PREFIX="env LD_PRELOAD=${SRCDIR}/libreaddir-rand.so"
+ CMD_PREFIX="env LD_PRELOAD=${test_builddir}/libreaddir-rand.so"
fi
assert_streq () {
diff --git a/tests/test-archivez.sh b/tests/test-archivez.sh
index 999157de..b8793284 100755
--- a/tests/test-archivez.sh
+++ b/tests/test-archivez.sh
@@ -25,7 +25,7 @@ echo '1..11'
setup_test_repository "archive-z2"
-. ${SRCDIR}/archive-test.sh
+. ${test_srcdir}/archive-test.sh
cd ${test_tmpdir}
mkdir repo2
diff --git a/tests/test-delta.sh b/tests/test-delta.sh
index a6fd6f88..411e9b04 100755
--- a/tests/test-delta.sh
+++ b/tests/test-delta.sh
@@ -130,9 +130,9 @@ assert_streq "${totalsize_orig}" "${totalsize_swapped}"
echo 'ok generate + show endian swapped'
-tar xf ${SRCDIR}/pre-endian-deltas-repo-big.tar.xz
+tar xf ${test_srcdir}/pre-endian-deltas-repo-big.tar.xz
mv pre-endian-deltas-repo{,-big}
-tar xf ${SRCDIR}/pre-endian-deltas-repo-little.tar.xz
+tar xf ${test_srcdir}/pre-endian-deltas-repo-little.tar.xz
mv pre-endian-deltas-repo{,-little}
legacy_origrev=$(${CMD_PREFIX} ostree --repo=pre-endian-deltas-repo-big rev-parse main^)
legacy_newrev=$(${CMD_PREFIX} ostree --repo=pre-endian-deltas-repo-big rev-parse main)
diff --git a/tests/test-pull-archive-z.sh b/tests/test-pull-archive-z.sh
index 2ea23871..66f8873e 100755
--- a/tests/test-pull-archive-z.sh
+++ b/tests/test-pull-archive-z.sh
@@ -23,4 +23,4 @@ set -euo pipefail
setup_fake_remote_repo1 "archive-z2"
-. ${SRCDIR}/pull-test.sh
+. ${test_srcdir}/pull-test.sh