Install tests

Matching https://live.gnome.org/GnomeGoals/InstalledTests
This commit is contained in:
Colin Walters 2013-05-01 15:26:21 -04:00
parent c60c70e9a9
commit e9a181c67d
12 changed files with 72 additions and 29 deletions

49
Makefile-tests.am Normal file
View File

@ -0,0 +1,49 @@
# Makefile for tests code
#
# Copyright (C) 2013 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 BUILDOPT_INSTALL_TESTS
insttestdir=$(pkglibexecdir)/installed-tests
testfiles = t0000-basic \
t0001-archive \
t0002-archivez \
t0003-log \
t0004-remote-add \
t0005-corruption \
t0006-libarchive \
t0011-pull-archive-z \
$(NULL)
insttest_SCRIPTS = $(addprefix tests/,$(testfiles:=.sh))
insttest_DATA = tests/archive-test.sh \
tests/pull-test.sh \
tests/libtest.sh \
$(NULL)
%.test: tests/%.sh Makefile
$(AM_V_GEN) (echo '[Test]' > $@.tmp; \
echo 'Exec=$(pkglibexecdir)/installed-tests/$(notdir $<)' >> $@.tmp; \
echo 'Type=session' >> $@.tmp; \
echo 'Output=TAP' >> $@.tmp; \
mv $@.tmp $@)
testmetadir = $(datadir)/installed-tests/$(PACKAGE)
testmeta_DATA = $(testfiles:=.test)
endif

View File

@ -84,6 +84,8 @@ include Makefile-libostree.am
include Makefile-ostree.am
include Makefile-switchroot.am
include Makefile-triggers.am
include Makefile-tests.am
# Docbook generation copied from systemd/Makefile.am
#

View File

@ -33,6 +33,12 @@ AC_ARG_ENABLE(triggers-only,
enable_triggers_only=no)
AM_CONDITIONAL(TRIGGERS_ONLY, test x$enable_triggers_only != xno)
AC_ARG_ENABLE(installed_tests,
AS_HELP_STRING([--enable-installed-tests],
[Install test programs (default: no)]),,
[enable_installed_tests=no])
AM_CONDITIONAL(BUILDOPT_INSTALL_TESTS, test x$enable_installed_tests = xyes)
AC_CHECK_HEADER([attr/xattr.h],,[AC_MSG_ERROR([You must have attr/xattr.h from libattr])])
PKG_PROG_PKG_CONFIG

View File

@ -17,14 +17,8 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
cd `dirname $0`
SRCDIR=`pwd`
cd -
TMPDIR=${TMPDIR:-/tmp}
export TMPDIR
test_tmpdir=`mktemp -d "$TMPDIR/ostree-tests.XXXXXXXXXX"`
cd "$test_tmpdir"
touch "$test_tmpdir/.test$$"
SRCDIR=$(dirname $0)
test_tmpdir=$(pwd)
export G_DEBUG=fatal-warnings
@ -36,14 +30,6 @@ 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"
fi
die () {
if test -z "$OT_TESTS_DEBUG"; then
test -f "$test_tmpdir/.test$$" && rm -rf "$test_tmpdir"
else
echo "Temporary files saved in $test_tmpdir"
fi
}
assert_streq () {
test "$1" = "$2" || (echo 1>&2 "$1 != $2"; exit 1)
}
@ -110,6 +96,9 @@ setup_test_repository () {
}
setup_fake_remote_repo1() {
if ! test -x ${SRCDIR}/run-apache; then
exit 77
fi
mode=$1
shift
oldpwd=`pwd`
@ -170,5 +159,3 @@ EOF
export OSTREE="ostree --repo=repo"
}
trap 'die' EXIT

View File

@ -21,7 +21,7 @@ set -e
echo "1..30"
. libtest.sh
. $(dirname $0)/libtest.sh
setup_test_repository "bare"
echo "ok setup"
@ -218,4 +218,3 @@ echo "ok subdir enoent"
cd ${test_tmpdir}
$OSTREE checkout test2 --allow-noent --subpath /enoent 2>/dev/null
echo "ok subdir noent"

View File

@ -19,7 +19,7 @@
set -e
. libtest.sh
. $(dirname $0)/libtest.sh
echo '1..11'

View File

@ -19,7 +19,7 @@
set -e
. libtest.sh
. $(dirname $0)/libtest.sh
echo '1..11'

View File

@ -19,7 +19,7 @@
set -e
. libtest.sh
. $(dirname $0)/libtest.sh
echo "1..1"

View File

@ -19,7 +19,7 @@
set -e
. libtest.sh
. $(dirname $0)/libtest.sh
echo '1..2'

View File

@ -21,7 +21,7 @@ set -e
echo "1..1"
. libtest.sh
. $(dirname $0)/libtest.sh
setup_test_repository "bare"
$OSTREE checkout test2 checkout-test2

View File

@ -21,7 +21,7 @@ set -e
echo "1..7"
. libtest.sh
. $(dirname $0)/libtest.sh
setup_test_repository "bare"
cd ${test_tmpdir}

View File

@ -19,10 +19,10 @@
set -e
. libtest.sh
echo '1..2'
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2"
echo '1..2'
. ${SRCDIR}/pull-test.sh