From c178eeba5520056aa7823e953cb02e26378ab436 Mon Sep 17 00:00:00 2001 From: Benoit Sigoure Date: Wed, 31 Oct 2007 18:15:18 +0100 Subject: [PATCH] Add a testsuite. * Makefile.am (SUBDIRS): New. * configure.ac: Adjust for the testsuite. * tests/Makefile.am: New. * tests/atlocal.in: Copy from Makefile.am. * tests/testsuite.at: New. --- ChangeLog | 9 ++ Makefile.am | 2 + configure.ac | 12 +- tests/.gitignore | 2 + tests/Makefile.am | 47 ++++++++ Makefile.am => tests/atlocal.in | 6 +- tests/testsuite.at | 243 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 319 insertions(+), 2 deletions(-) create mode 100644 tests/.gitignore create mode 100644 tests/Makefile.am copy Makefile.am => tests/atlocal.in (85%) create mode 100644 tests/testsuite.at diff --git a/ChangeLog b/ChangeLog index 88ae600..85151ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2007-10-31 Benoit Sigoure + Add a testsuite. + * Makefile.am (SUBDIRS): New. + * configure.ac: Adjust for the testsuite. + * tests/Makefile.am: New. + * tests/atlocal.in: Copy from Makefile.am. + * tests/testsuite.at: New. + +2007-10-31 Benoit Sigoure + Initial version. * ChangeLog: New. * Makefile.am: New. diff --git a/Makefile.am b/Makefile.am index 5f1c403..227f8ea 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,3 +14,5 @@ # along with this program. If not, see . ACLOCAL_AMFLAGS = -I build-aux + +SUBDIRS = . tests diff --git a/configure.ac b/configure.ac index c765872..f7b442d 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,8 @@ AC_INIT([boost-m4-test], [0.1], [tsuna@lrde.epita.fr]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([foreign]) +AC_PROG_GREP +AC_PROG_EGREP AC_PROG_CXX version=1.34 @@ -29,6 +31,14 @@ dnl BOOST_REQUIRE([plop]) dnl m4_define([b_version], [1.34]) dnl BOOST_REQUIRE(b_version) -AC_CONFIG_FILES([Makefile]) +# Initialize the test suite. +AC_CONFIG_TESTDIR([tests]) +AM_MISSING_PROG([AUTOM4TE], [autom4te]) + +AC_CONFIG_FILES([ + Makefile + tests/Makefile + tests/atlocal +]) AC_OUTPUT diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..390ceba --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,2 @@ +testsuite +package.m4 diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..877e819 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,47 @@ +# Copyright (C) 2007 Benoit Sigoure +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +EXTRA_DIST = testsuite.at $(TESTSUITE) atlocal.in package.m4 +TESTSUITE = $(srcdir)/testsuite + +$(srcdir)/package.m4: Makefile + { \ + echo '# Signature of the current package.'; \ + echo 'm4_define([AT_PACKAGE_NAME], [$(PACKAGE_NAME)])'; \ + echo 'm4_define([AT_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])'; \ + echo 'm4_define([AT_PACKAGE_VERSION], [$(PACKAGE_VERSION)])'; \ + echo 'm4_define([AT_PACKAGE_STRING], [$(PACKAGE_STRING)])'; \ + echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])'; \ + } >$(srcdir)/package.m4 + +check-local: atconfig atlocal $(TESTSUITE) + $(SHELL) $(TESTSUITE) $(TESTSUITEFLAGS) + +# Run the test suite on the *installed* tree. +installcheck-local: atconfig atlocal $(TESTSUITE) + $(SHELL) $(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS) + +clean-local: + test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean + rm -f -r autom4te.cache + +AUTOTEST = $(AUTOM4TE) --language=autotest + +$(TESTSUITE): $(srcdir)/package.m4 $(srcdir)/testsuite.at + $(AUTOTEST) -I '$(srcdir)' $@.at -o $@.tmp + mv $@.tmp $@ + +atconfig: $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status tests/$@ diff --git a/Makefile.am b/tests/atlocal.in similarity index 85% copy from Makefile.am copy to tests/atlocal.in index 5f1c403..82fb1ad 100644 --- a/Makefile.am +++ b/tests/atlocal.in @@ -1,3 +1,5 @@ +# -*- shell-script -*- vi:set ft=sh: +# @configure_input@ # Copyright (C) 2007 Benoit Sigoure # # This program is free software: you can redistribute it and/or modify @@ -13,4 +15,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -ACLOCAL_AMFLAGS = -I build-aux +GREP='@GREP@' +EGREP='@EGREP@' +abs_top_srcdir='@abs_top_srcdir@' diff --git a/tests/testsuite.at b/tests/testsuite.at new file mode 100644 index 0000000..3415781 --- /dev/null +++ b/tests/testsuite.at @@ -0,0 +1,243 @@ +# Copyright (C) 2007 Benoit Sigoure +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Most of the macros were shamelessly stolen from autoconf's own testsuite. +# Version used to steal the macros: dc51583 + +## ---------------- ## +## Utility macros. ## +## ---------------- ## + +# AT_CMP(FILE-1, FILE-2) +# ---------------------- +# Check FILE-1 and FILE-2 for equality, like `cmp FILE-1 FILE-2'. +m4_define([AT_CMP], +[m4_ifval([$2],, [m4_fatal([AT_CMP takes two arguments.])])[]dnl +AT_CHECK([$at_diff "$1" "$2"]) +])# AT_CMP + + +## ----------------------- ## +## Testing with Autoconf. ## +## ----------------------- ## + + +# AT_CHECK_M4(COMMAND, [EXIT-STATUS = 0], STDOUT, STDERR) +# ------------------------------------------------------- +# If stderr is specified, normalize the observed stderr. +# This (using GNU M4 1.4.6 or later) +# +# /usr/local/bin/m4:script.4s:1: cannot open `foo': No such file or directory +# autom4te: /usr/local/bin/m4 failed with exit status: 1 +# +# or this (GNU M4 1.4 installed as gm4) +# +# script.4s:1: /usr/local/bin/gm4: Cannot open foo: No such file or directory +# autom4te: /usr/local/bin/gm4 failed with exit status: 1 +# +# becomes +# +# m4:script.4s:1: cannot open `foo': No such file or directory +# autom4te: m4 failed with exit status: 1 +# +# We use the following sed patterns: +# +# (m4): ?(file): ?(line): +# or (file): ?(line): ?(m4): +# to m4:(file):(line): +# +# and +# m4:(file):(line): Cannot open foo: +# to m4:(file):(line): cannot open `foo': +# +# and +# autom4te: [^ ]m4 +# or autom4te: [^ ]m4.exe +# to autom4te: m4 +# +# Moreover, DJGPP error messages include the error code in brackets; +# remove the error code during normalization. +# +m4_define([AT_CHECK_M4], +[AT_CHECK([$1], [$2], [$3], + m4_case([$4], [], [], [ignore], [ignore], [stderr])) +m4_case([$4], [], [], [ignore], [], +[AT_CHECK([[sed 's/^[^:]*m4: *\([^:]*:\) *\([0-9][0-9]*: \)/m4:\1\2/ + s/^\([^:]*:\) *\([0-9][0-9]*:\)[^:]*m4: /m4:\1\2 / + s/^\(m4:[^:]*:[0-9][0-9]*: \)C\(annot open \)\([^`:]*\):/\1c\2`\3'\'':/ + s/^autom4te: [^ ]*m4 /autom4te: m4 / + s/^autom4te: [^ ]*m4\.exe /autom4te: m4 / + s/ (E[A-Z]*)$// + ' stderr >&2]], [0], [], [$4])]) +]) + + +# AT_CONFIGURE_AC(BODY) +# --------------------- +# Create a full configure.ac running BODY, +# AC_OUTPUT, and environment checking hooks. +m4_define([AT_CONFIGURE_AC], +[ +AT_DATA([aclocal.m4], []) +# FIXME: kludge so that we can find the macros we're testing (I can't think of +# anything better) +for i in "$abs_top_srcdir"/build-aux/*.m4; do + echo "m4@&t@_include([[$i]])" >>aclocal.m4 +done + +AT_DATA([configure.ac], +[[AC_INIT +AC_CONFIG_AUX_DIR($top_srcdir/build-aux)] +$1 +[AC_OUTPUT +]]) +])# AT_CONFIGURE_AC + + +# AT_CHECK_AUTOCONF(ARGS, [EXIT-STATUS = 0], STDOUT, STDERR) +# ---------------------------------------------------------- +# We always use "--force", to prevent problems with timestamps if the testsuite +# were running too fast. +m4_define([AT_CHECK_AUTOCONF], +[AT_CHECK_M4([autoconf --force $1], [$2], [$3], [$4]) +]) + + +# AT_CHECK_CONFIGURE(END-COMMAND, +# [EXIT-STATUS = 0], +# [STDOUT = IGNORE], STDERR) +# -------------------------------------------- +# `abs_top_srcdir' is needed so that `./configure' finds install-sh. +# Using --srcdir is more expensive. +m4_define([AT_CHECK_CONFIGURE], +[AT_CAPTURE_FILE([config.log])[]dnl + AT_CHECK([top_srcdir=$abs_top_srcdir ./configure $1], + [$2], + m4_default([$3], [ignore]), [$4])]) + + +# AT_CONFIG_CMP(VAR-FILE-A, VAR-FILE-B) +# ------------------------------------- +# Check the outcomes of two configure runs for equality by comparing dumps of +# their shell variables. VAR-FILE-A and VAR-FILE-B are two `set'-style shell +# variable space dumps. +# +# We permit variance between runs in the following shell variables: +# - ^as_ +# M4sh's shell name space. +# - ^ac_, excluding ^ac_cv_ +# Autoconf's private shell name space. +# - PPID [bash, zsh] +# - RANDOM [zsh] +# - SECONDS [zsh] +# - '$' [zsh] +# +# Furthermore, it is okay for a non-cache variable initialized to empty in one +# run to be unset in another run. This happens when, for example, cache update +# code tries a number of values in LIBS and eventually restores LIBS to its +# original value. If LIBS was previously unset, it will have become set and +# empty. (OTOH, cache variables indicate the result of the test even if they +# are empty, so we have to be strict about them.) +# +# Lines that do not look like `foo=bar' are probably latter lines of +# multiline values; trim them. +# +m4_define([AT_CONFIG_CMP], +[for act_file in $1 $2 +do + $SED '/^ac_cv_/ b + /^m4_defn([m4_re_word])=./ !d + /^[[^=]]*='\'''\''$/ d + /^a[[cs]]_/ d + /^PPID=/ d + /^RANDOM=/ d + /^SECONDS=/ d + /'\'\\\$\''=/ d + ' $act_file >at_config_vars-$act_file +done +AT_CMP([at_config_vars-$1], [at_config_vars-$2])[]dnl +])# AT_CONFIG_CMP + + +# AT_CHECK_MACRO(MACRO, [MACRO-USE], [ADDITIONAL-CMDS], +# [AUTOCONF-FLAGS = -W obsolete]) +# ----------------------------------------------------- +# Create a minimalist configure.ac running the macro named +# NAME-OF-THE-MACRO, check that autoconf runs on that script, +# and that the shell runs correctly the configure. +# +# We run `configure' twice, both times with a cache, and compare +# the environment after each run to detect inconsistencies. +# +# New macros are not expected to depend upon obsolete macros. +m4_define([AT_CHECK_MACRO], +[AT_SETUP([$1]) + +AT_CONFIGURE_AC([m4_default([$2], [$1])]) + +AT_CHECK_AUTOCONF([m4_default([$4], [-W obsolete])]) + +for at_run in r1 r2 +do + AT_CHECK_CONFIGURE([-C]) + cp -f state-env.after state-env.$at_run + dnl cp -f config.h config-h.$at_run + dnl AT_CHECK_ENV +done + +AT_CONFIG_CMP([state-env.r1], [state-env.r2]) + +$3 + +AT_CLEANUP[]dnl +])# AT_CHECK_MACRO + + +# AT_CHECK_MACRO_CROSS(MACRO, [MACRO-USE], [ADDITIONAL-CMDS], +# [AUTOCONF-FLAGS = -W obsolete]) +# ----------------------------------------------------------- +# Like the previous one, but creates two checks: for native +# compile and for cross-compile. +m4_define([AT_CHECK_MACRO_CROSS], +[AT_CHECK_MACRO($@) +AT_CHECK_MACRO([$1 (cross compile)], + [AT_KEYWORDS([cross]) + # Exercise the code used when cross-compiling. + cross_compiling=yes + ac_tool_warned=yes + m4_default([$2], [$1])], + [$3], [$4]) +]) + +## ----------------------- ## +## Launch the test suite. ## +## ----------------------- ## + +AT_INIT +AT_COPYRIGHT( +[Copyright (C) 2007 Benoit Sigoure +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.]) + +AT_BANNER([Boost headers]) + +AT_CHECK_MACRO([BOOST_REQUIRE]) +AT_CHECK_MACRO([BOOST_REQUIRE 0.0], [BOOST_REQUIRE([0.0])]) +AT_CHECK_MACRO([BOOST_REQUIRE 1.0], [BOOST_REQUIRE([1.0])]) +AT_CHECK_MACRO([BOOST_REQUIRE 1.1.1], [BOOST_REQUIRE([1.1.1])]) + +AT_CHECK_MACRO([BOOST_REQUIRE $var 0.0], [var=0.0; BOOST_REQUIRE([$var])]) +AT_CHECK_MACRO([BOOST_REQUIRE $var 1.0], [var=1.0; BOOST_REQUIRE([$var])]) +AT_CHECK_MACRO([BOOST_REQUIRE $var 1.1.1], [var=1.1.1; BOOST_REQUIRE([$var])]) -- 2.11.4.GIT