tests: Unify some tmpdir code, add ability for C to use libtest.sh

I want to be able to easily test the C API on actual data in an OSTree
repo.  The shell `libtest.sh` has code to generate it.  Bridge the two
worlds by introducing a little `libostreetest` library which has a C
API which spawns a shell that runs things in `libtest.sh`.

Yes, this is about as beautiful as it sounds, which is to say, it's
not.  But it works!

Note while we were here, I realized we were actually now creating
*two* tmpdirs per test in `make check` because the tap driver was
already doing that.  Unify it so we know the C code can rely on it.
This commit is contained in:
Colin Walters committed 2016-03-03 18:03:32 -05:00
1 parent 12db46e5af
commit ebd0370976
6 files changed
+216 -29

No files matched your search

+14 -4
View File
@@ -1,12 +1,22 @@
#! /bin/bash
# run a GTest in tap mode. The test binary is passed as $1
#
# Run a test in tap mode, ensuring we have a temporary directory. We
# always use /var/tmp becuase we might want to use user xattrs, which
# aren't available on tmpfs.
#
# The test binary is passed as $1
srcd=$(cd $(dirname $1) && pwd)
bn=$(basename $1)
tempdir=$(mktemp -d)
tempdir=$(mktemp -d /var/tmp/tap-test.XXXXXX)
touch ${tempdir}/.testtmp
function cleanup () {
rm "${tempdir}" -rf
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}