tests: Port to glib-tap.mk, make make check run all of the tests

OSTree's code for testing predates the `glib-tap.mk` making its
way into GLib.  Let's switch to it, as it provides a number
of advantages.

By far the biggest advantage is that `make check` can start to run
most of the tests *in addition* to having them work installed.

This commit keeps the installed tests working, but `make check` turns
out to be really broken because...our TAP usage has bitrotted to say
the least.  Fix that all up.

Do some hacks so that the tests work uninstalled as well - in
particular, `glib-tap.mk` and the bits encoded into
`g_test_build_filename()` assume *recursive* Automake (blah).  Work
around that by creating a symlink when installed to loop back.
This commit is contained in:
Colin Walters committed 2016-03-03 08:50:19 -05:00
1 parent 6d73a620e1
commit d25212f04a
48 files changed
+980 -173

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@
set -euo pipefail
echo "1..10"
echo "1..16"
function validate_bootloader() {
(cd ${test_tmpdir};
+1 -1
View File
@@ -19,7 +19,7 @@
set -euo pipefail
echo "1..48"
echo "1..49"
$OSTREE checkout test2 checkout-test2
echo "ok checkout"
+1
View File
@@ -0,0 +1 @@
trusted/pubring.gpg
Regular → Executable
+26
View File
@@ -18,10 +18,35 @@
# Boston, MA 02111-1307, USA.
SRCDIR=$(dirname $0)
_cleanup_tmpdir () {
if test -n "${LIBTEST_SKIP_CLEANUP:-}"; then
echo "Skipping cleanup of ${test_tmpdir}"
else if test -f ${test_tmpdir}/.test; then
rm ${test_tmpdir} -rf
fi
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 /var/tmp/test.XXXXXX)
touch ${test_tmpdir}/.test
trap _cleanup_tmpdir EXIT
cd ${test_tmpdir}
export PATH=${G_TEST_BUILDDIR}:${PATH}
fi
test_tmpdir=$(pwd)
export G_DEBUG=fatal-warnings
# Also, unbreak `tar` inside `make check`...Automake will inject
# TAR_OPTIONS: --owner=0 --group=0 --numeric-owner presumably so that
# tarballs are predictable, except we don't want this in our tests.
unset TAR_OPTIONS
# Don't flag deployments as immutable so that test harnesses can
# easily clean up.
export OSTREE_SYSROOT_DEBUG=mutable-deployments
@@ -33,6 +58,7 @@ export TEST_GPG_KEYID_3="DF444D67"
# GPG when creating signatures demands a writable
# homedir in order to create lockfiles. Work around
# this by copying locally.
echo "Copying gpghome to ${test_tmpdir}"
cp -a ${SRCDIR}/gpghome ${test_tmpdir}
export TEST_GPG_KEYHOME=${test_tmpdir}/gpghome
export OSTREE_GPG_HOME=${test_tmpdir}/gpghome/trusted
+2
View File
@@ -35,6 +35,8 @@ function verify_initial_contents() {
assert_file_has_content baz/cow '^moo$'
}
echo "1..11"
# Try both syntaxes
repo_init
${CMD_PREFIX} ostree --repo=repo pull origin main
+1 -5
View File
@@ -21,14 +21,10 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..1"
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
echo "ok setup"
echo "1..2"
echo "1..3"
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
Regular → Executable
View File
File mode changed.
-4
View File
@@ -21,13 +21,9 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..1"
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
echo "ok setup"
echo "1..2"
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
Regular → Executable
+1 -5
View File
@@ -21,14 +21,10 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..1"
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
echo "ok setup"
echo "1..1"
echo "1..3"
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
+1 -5
View File
@@ -21,14 +21,10 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..1"
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
echo "ok setup"
echo "1..3"
echo "1..4"
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos file://$(pwd)/testos-repo
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull testos testos/buildmaster/x86_64-runtime
-4
View File
@@ -21,11 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..1"
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
echo "ok setup"
. $(dirname $0)/admin-test.sh
-4
View File
@@ -22,11 +22,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..1"
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "uboot"
echo "ok setup"
. $(dirname $0)/admin-test.sh
-4
View File
@@ -22,13 +22,9 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..1"
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
echo "ok setup"
echo "1..5"
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
Regular → Executable
+5 -6
View File
@@ -21,12 +21,14 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..1"
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
echo "ok setup"
# If parallel is not installed, skip the test
if ! parallel --help >/dev/null 2>&1; then
echo "1..0 # SKIP no /usr/bin/parallel"
exit 0
fi
echo "1..1"
@@ -40,9 +42,6 @@ echo "rev=${rev}"
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
assert_has_dir sysroot/boot/ostree/testos-${bootcsum}
# If parallel is not installed, skip the test
parallel --help >/dev/null 2>&1 || exit 77
parallel_cmd=parallel
if parallel --help | grep -q -e --no-notice; then
parallel_cmd="${parallel_cmd} --no-notice"
View File
File mode changed.
-4
View File
@@ -21,13 +21,9 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..1"
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
echo "ok setup"
echo "1..2"
cd ${test_tmpdir}
-4
View File
@@ -21,13 +21,9 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..1"
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
echo "ok setup"
echo "1..2"
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
-1
View File
@@ -24,7 +24,6 @@ set -euo pipefail
echo '1..11'
setup_test_repository "archive-z2"
echo "ok setup"
. ${SRCDIR}/archive-test.sh
+1 -1
View File
@@ -20,7 +20,7 @@
set -euo pipefail
echo "1..1"
echo "1..4"
. $(dirname $0)/libtest.sh
-3
View File
@@ -19,11 +19,8 @@
set -euo pipefail
echo "1..1"
. $(dirname $0)/libtest.sh
setup_test_repository "bare"
echo "ok setup"
. $(dirname $0)/basic-test.sh
+7 -2
View File
@@ -20,11 +20,14 @@
set -euo pipefail
if ! ostree --version | grep -q -e '\+gpgme'; then
exit 77
echo "1..0 #SKIP no gpg support compiled in"
exit 0
fi
. $(dirname $0)/libtest.sh
echo "1..1"
keyid="472CDAFA"
oldpwd=`pwd`
mkdir ostree-srv
@@ -122,10 +125,12 @@ assert_file_has_content show 'Found 1 signature'
# Delete the signature from the commit so the detached metadata is empty,
# then pull and verify the signature is also deleted on the client side.
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo gpg-sign --gpg-homedir=${SRCDIR}/gpghome --delete main $keyid
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo gpg-sign --gpg-homedir=${test_tmpdir}/gpghome --delete main $keyid
${CMD_PREFIX} ostree --repo=repo pull origin main
if ${CMD_PREFIX} ostree --repo=repo show main | grep -o 'Found [[:digit:]] signature'; then
assert_not_reached
fi
rm -rf repo gnomerepo-files
echo "ok"
+1 -1
View File
@@ -24,7 +24,7 @@ set -euo pipefail
bindatafiles="bash true ostree"
morebindatafiles="false ls"
echo '1..3'
echo '1..7'
mkdir repo
${CMD_PREFIX} ostree --repo=repo init --mode=archive-z2
Regular → Executable
+6 -1
View File
@@ -21,11 +21,14 @@
set -euo pipefail
if ! ostree --version | grep -q -e '\+gpgme'; then
exit 77
echo "1..0 #SKIP no gpgme support compiled in"
exit 0
fi
. $(dirname $0)/libtest.sh
echo "1..1"
setup_test_repository "archive-z2"
export OSTREE_GPG_SIGN="${OSTREE} gpg-sign --gpg-homedir=${TEST_GPG_KEYHOME}"
@@ -74,3 +77,5 @@ assert_file_has_content test2-delete 'Signatures deleted: 2'
if ${OSTREE} show test2 | grep -o 'Found [[:digit:]] signature'; then
assert_not_reached
fi
echo "ok"
+1 -1
View File
@@ -66,7 +66,7 @@ test_fixture_setup (TestFixture *fixture,
* taken into account, which contains additional data like revocation
* certificates for certain test cases. */
homedir = g_test_build_filename (G_TEST_DIST, "gpg-verify-data", NULL);
homedir = g_test_build_filename (G_TEST_DIST, "tests/gpg-verify-data", NULL);
g_setenv ("GNUPGHOME", homedir, TRUE);
result = g_initable_new (OSTREE_TYPE_GPG_VERIFY_RESULT,
+4 -3
View File
@@ -20,13 +20,14 @@
set -euo pipefail
if ! ostree --version | grep -q -e '\+libarchive'; then
exit 77
echo "1..0 #SKIP no libarchive support compiled in"
exit 0
fi
echo "1..7"
. $(dirname $0)/libtest.sh
echo "1..7"
setup_test_repository "bare"
cd ${test_tmpdir}
mkdir foo
Regular → Executable
+2
View File
@@ -35,3 +35,5 @@ ${CMD_PREFIX} ostree --repo=repo pull origin main --subpath /baz
${CMD_PREFIX} ostree fsck --repo=repo >fsck.out
assert_file_has_content fsck.out 'Verifying content integrity of 0 commit objects'
assert_file_has_content fsck.out '1 partial commits not verified'
echo "ok"
Regular → Executable
View File
File mode changed.
-2
View File
@@ -23,6 +23,4 @@ set -euo pipefail
setup_fake_remote_repo1 "archive-z2"
echo '1..2'
. ${SRCDIR}/pull-test.sh
Regular → Executable
View File
File mode changed.
+2
View File
@@ -39,3 +39,5 @@ if ${CMD_PREFIX} ostree --repo=repo pull origin main 2>pulllog.txt 1>&2; then
assert_not_reached "pull unexpectedly succeeded!"
fi
assert_file_has_content pulllog.txt "exceeded maximum"
echo "ok"
+2 -1
View File
@@ -23,6 +23,8 @@ set -euo pipefail
setup_fake_remote_repo1 "archive-z2"
echo '1..9'
# And another web server acting as the metalink server
cd ${test_tmpdir}
mkdir metalink-data
@@ -37,7 +39,6 @@ summary_path=${test_tmpdir}/ostree-srv/gnomerepo/summary
echo -n broken > ${summary_path}.bad
echo '1..1'
cd ${test_tmpdir}
cat > metalink-valid-summary.xml <<EOF
+2
View File
@@ -21,6 +21,8 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..5"
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
setup_fake_remote_repo1 "archive-z2" "${COMMIT_SIGN}"
Regular → Executable
+2 -2
View File
@@ -25,8 +25,6 @@ setup_fake_remote_repo1 "archive-z2"
echo '1..1'
echo "SUBDIR TEST"
repopath=${test_tmpdir}/ostree-srv/gnomerepo
cp -a ${repopath} ${repopath}.orig
@@ -49,3 +47,5 @@ assert_has_file repo/state/${rev}.commitpartial
${CMD_PREFIX} ostree --repo=repo pull origin main
assert_not_has_file repo/state/${rev}.commitpartial
${CMD_PREFIX} ostree --repo=repo fsck
echo "ok"
Regular → Executable
+2
View File
@@ -21,6 +21,8 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..5"
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
setup_fake_remote_repo1 "archive-z2" "${COMMIT_SIGN}"
Regular → Executable
View File
File mode changed.
+1 -1
View File
@@ -21,7 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo '1..3'
echo '1..13'
setup_test_repository "bare"
$OSTREE remote add origin http://example.com/ostree/gnome
+4
View File
@@ -26,6 +26,8 @@ unset OSTREE_GPG_HOME
setup_fake_remote_repo1 "archive-z2"
echo "1..1"
cd ${test_tmpdir}
mkdir repo
${OSTREE} init
@@ -140,3 +142,5 @@ if ${OSTREE} pull R2:main >/dev/null 2>&1; then
assert_not_reached "(key3/R2) GPG verification unexpectedly succeeded"
fi
${OSTREE} pull R3:main >/dev/null
echo "ok"
+3 -2
View File
@@ -23,12 +23,13 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_test_repository "bare"
echo "ok setup"
echo '1..2'
echo '1..1'
repopath=${test_tmpdir}/ostree-srv/gnomerepo
${CMD_PREFIX} ostree --repo=repo checkout -U --subpath=/ test2 checkedout
${CMD_PREFIX} ostree --repo=repo checkout -U --subpath=/firstfile test2 checkedout2
echo "ok"
+2
View File
@@ -36,3 +36,5 @@ chmod a+x test2-checkout/abinary
rm -rf test2-checkout
$OSTREE checkout test2 test2-checkout
test -u test2-checkout/abinary
echo "ok"
+1 -1
View File
@@ -34,7 +34,7 @@ function assertNotEquals(a, b) {
}
function libtestExec(shellCode) {
let testdatadir = GLib.getenv("TESTDATADIR");
let testdatadir = GLib.getenv("G_TEST_SRCDIR");
let libtestPath = GLib.build_filenamev([testdatadir, 'libtest.sh'])
let proc = GSystem.Subprocess.new_simple_argv(['bash', '-c',
'. ' + GLib.shell_quote(libtestPath) + '; ' + shellCode],