From fee9f48409d21b31b209bff95e40f411e253779c Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 17 Dec 2014 18:11:47 -0500 Subject: [PATCH] tests: Enable glib-tap.mk These files were taken from json-glib, around the era of this commit: https://git.gnome.org/browse/json-glib/tree/build/autotools?id=2779d537492f1902d71cf648631238110b62b311 Unfortunately, this involved hacking it up a bit: - I couldn't easily use `nobase` for the data, so I deleted that. Test data goes in the installed-tests dir. - Delete duplicated predeclared variables; we're using nonrecursive make. - Ensure we run each test in its own tmpdir --- Makefile-tests.am | 46 ++++++++----------------------------------- buildutil/glib-tap.mk | 22 ++++++--------------- buildutil/tap-test | 12 +++++++++-- configure.ac | 4 +++- 4 files changed, 27 insertions(+), 57 deletions(-) diff --git a/Makefile-tests.am b/Makefile-tests.am index 0a0e80f5..58200b01 100644 --- a/Makefile-tests.am +++ b/Makefile-tests.am @@ -1,41 +1,11 @@ -# Makefile for tests code -# -# Copyright (C) 2013,2014 Colin Walters -# -# 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. +include $(top_srcdir)/buildutil/glib-tap.mk -if BUILDOPT_INSTALL_TESTS -insttest_PROGRAMS = +tests_shutil_CPPFLAGS = -I $(srcdir)/src +tests_shutil_CFLAGS = $(BUILDDEP_GIO_UNIX_CFLAGS) +tests_shutil_LDADD = $(BUILDDEP_GIO_UNIX_LIBS) libgsystem.la -insttestdir=$(pkglibexecdir)/installed-tests -testfiles = test-basic \ +installed_test_data = tests/libtest.sh + +test_scripts = \ + tests/test-basic.sh \ $(NULL) -insttest_SCRIPTS = $(addprefix tests/,$(testfiles:=.sh)) - -testmetadir = $(datadir)/installed-tests/$(PACKAGE) -testmeta_DATA = $(testfiles:=.test) - -insttest_DATA = 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 $@) - -endif diff --git a/buildutil/glib-tap.mk b/buildutil/glib-tap.mk index 7a634cd3..0c904163 100644 --- a/buildutil/glib-tap.mk +++ b/buildutil/glib-tap.mk @@ -6,27 +6,17 @@ TESTS_ENVIRONMENT= \ G_DEBUG=gc-friendly \ MALLOC_CHECK_=2 \ MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) -LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build/autotools/tap-driver.sh -LOG_COMPILER = $(top_srcdir)/build/autotools/tap-test +LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/buildutil/tap-driver.sh +LOG_COMPILER = $(top_srcdir)/buildutil/tap-test -NULL = - -# initialize variables for unconditional += appending -BUILT_SOURCES = -BUILT_EXTRA_DIST = -CLEANFILES = *.log *.trs -DISTCLEANFILES = -MAINTAINERCLEANFILES = -EXTRA_DIST = TESTS = installed_test_LTLIBRARIES = installed_test_PROGRAMS = installed_test_SCRIPTS = +installed_test_DATA = nobase_installed_test_DATA = -noinst_LTLIBRARIES = -noinst_PROGRAMS = noinst_SCRIPTS = noinst_DATA = @@ -115,8 +105,8 @@ installed_test_SCRIPTS += $(test_scripts) $(installed_test_scripts) \ $(test_extra_scripts) $(test_installed_extra_scripts) installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) \ $(dist_installed_test_scripts) $(dist_installed_test_extra_scripts) -nobase_installed_test_DATA += $(test_data) $(installed_test_data) -nobase_installed_test_DATA += $(dist_test_data) $(dist_installed_test_data) +installed_test_DATA += $(test_data) $(installed_test_data) +installed_test_DATA += $(dist_test_data) $(dist_installed_test_data) installed_test_LTLIBRARIES += $(test_ltlibraries) $(installed_test_ltlibraries) installed_testcases = $(test_programs) $(installed_test_programs) \ $(test_scripts) $(installed_test_scripts) \ @@ -127,7 +117,7 @@ installed_test_meta_DATA = $(installed_testcases:=.test) %.test: %$(EXEEXT) Makefile $(AM_V_GEN) (echo '[Test]' > $@.tmp; \ echo 'Type=session' >> $@.tmp; \ - echo 'Exec=$(installed_testdir)/$<' >> $@.tmp; \ + echo 'Exec=$(installed_testdir)/$(notdir $<)' >> $@.tmp; \ mv $@.tmp $@) CLEANFILES += $(installed_test_meta_DATA) diff --git a/buildutil/tap-test b/buildutil/tap-test index 481e333e..970b1c33 100755 --- a/buildutil/tap-test +++ b/buildutil/tap-test @@ -1,5 +1,13 @@ -#! /bin/sh +#! /bin/bash # run a GTest in tap mode. The test binary is passed as $1 -$1 -k --tap +srcd=$(cd $(dirname $1) && pwd) +bn=$(basename $1) +tempdir=$(mktemp -d) +function cleanup () { + rm "${tempdir}" -rf +} +trap cleanup EXIT +cd ${tempdir} +${srcd}/${bn} -k --tap diff --git a/configure.ac b/configure.ac index 225328e2..b16ca8c0 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ AC_PREREQ([2.63]) AC_INIT([rpm-ostree], [2014.114], [walters@verbum.org]) AC_CONFIG_HEADER([config.h]) -AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_MACRO_DIR([buildutil]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([1.11 -Wno-portability foreign no-define tar-ustar no-dist-gzip dist-xz]) @@ -45,6 +45,8 @@ PKG_CHECK_MODULES(PKGDEP_GIO_UNIX, [gio-unix-2.0]) PKG_CHECK_MODULES(PKGDEP_RPMOSTREE, [gio-unix-2.0 json-glib-1.0 ostree-1 >= 2014.13 libgsystem rpm hawkey]) AC_PATH_PROG([XSLTPROC], [xsltproc]) +GLIB_TESTS + GOBJECT_INTROSPECTION_REQUIRE([1.34.0]) AC_ARG_ENABLE(installed_tests,