automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FYI] {testsuite-work} tests: extend tests on dependency tracking with V


From: Stefano Lattarini
Subject: [FYI] {testsuite-work} tests: extend tests on dependency tracking with VPATH
Date: Sun, 1 May 2011 18:45:52 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

Reference:
 <http://lists.gnu.org/archive/html/automake-patches/2011-04/msg0014>

On Tuesday 19 April 2011, Stefano Lattarini wrote:
> Hello Ralf.
> 
> On Monday 11 April 2011, Ralf Wildenhues wrote:
> > * Ralf Wildenhues wrote on Mon, Apr 11, 2011 at 07:13:00AM CEST:
> > >     Fix hp depmode for VPATH builds with GNU make.
> > >     
> > >     * lib/depcomp: Be sure to remove VPATH-prefixed object from
> > >     dependency output when creating stub rule.
> > >     * tests/depcomp10.test: New test.
> > >     * tests/Makefile.am (TESTS): Update.
> > >     * NEWS: Update.
> > >     Report by Bruno Haible.
> > 
> > Of course I should be merging this test and depcomp9, and generalizing
> > for all depmodes, and tuning my test scripts to exercise both make and
> > gmake on all systems.  (on my TODO list)
> > 
> I hope you don't mind if I've done this for you ;-)
> 
> See the attached patch.  I've tested it with pcc, gcc-2.95, gcc-3.4,
> gcc-4.4 and the Sun C compiler, and with GNU, BSD (Debian ports) and
> Heirloom make.  Currently there is only one failure (with gcc >= 3
> and NetBSD or GNU make and depmode=tru64, which I haven't tried to
> analyze yet (in any case, it isn't a regression, so we can tackle it
> in a follow-up).  The log of this failure is attached, together with
> the content of the offending file `src/sub/.deps/subfoo.Po'.
> 
> OK for for a temporary public branch based off of master, to be merged
> back into master once the failure above is fixed?
> 
> Regards,
>   Stefano
> 
I've pushed this patch to the 'testsuite-work' branch now (after
rebasing).  The updated patch is attached, for reference.

Regards,
  Stefano
From 3c91fc9a36fb802e05d47308b7e0f3ecf3bcf77a Mon Sep 17 00:00:00 2001
Message-Id: <address@hidden>
From: Stefano Lattarini <address@hidden>
Date: Sun, 17 Apr 2011 14:28:17 +0200
Subject: [PATCH] tests: extend tests on dependency tracking with VPATH

* tests/depmod-tests.sh: New script, fulfilling a threefold role:
1. it is called to generate a Makefile.am snippet, containing the
   definition of proper lists of tests;
2. it is called to set up a directory containing some common data
   files and autotools-generated files used by the aforementioned
   tests (this is done for speed reasons only); and
3. it is called to properly run those tests, one at a time.
* tests/depcomp9.test: Delete, it's obsolete now.
* tests/depcomp10.test: Likewise.
* tests/Makefile.am ($(srcdir)/depmod-tests.am): Include this
snippet, which defines ...
(depmode_tests): ... this new macro, containing the list of the
newly generated `*.depmod' tests.
(TESTS_EXTENSIONS): Add `.depmod'.
(DEPMOD_LOG_COMPILER): Define.  It calls `depmod-tests.sh', so that
the "depmode tests" will be executed by passing that driver script
a proper parameter.
($(depmod_tests)): New dependency declaration (dummy, but required
in order to have make actually produce expected log files from the
`.depmod.log' suffix rule).
(TESTS): Add $(depmod_tests).
(EXTRA_DIST): Distribute depmod-tests.sh.
Other minor cosmetic changes and reorderings.
* bootstrap: Generate depmod-tests.am.
* tests/.gitignore: Updated.
---
 ChangeLog              |   29 +++++++
 bootstrap              |    1 +
 tests/.gitignore       |    1 +
 tests/Makefile.am      |   30 ++++++-
 tests/Makefile.in      |   45 ++++++++--
 tests/depcomp10.test   |   90 --------------------
 tests/depcomp9.test    |   92 --------------------
 tests/depmod-data.test |   30 +++++++
 tests/depmod-tests.sh  |  220 ++++++++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 343 insertions(+), 195 deletions(-)
 delete mode 100755 tests/depcomp10.test
 delete mode 100755 tests/depcomp9.test
 create mode 100755 tests/depmod-data.test
 create mode 100755 tests/depmod-tests.sh

diff --git a/ChangeLog b/ChangeLog
index b91c764..541955c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,34 @@
 2011-05-01  Stefano Lattarini  <address@hidden>
 
+       tests: extend tests on dependency tracking with VPATH
+       * tests/depmod-tests.sh: New script, fulfilling a threefold role:
+       1. it is called to generate a Makefile.am snippet, containing the
+          definition of proper lists of tests;
+       2. it is called to set up a directory containing some common data
+          files and autotools-generated files used by the aforementioned
+          tests (this is done for speed reasons only); and
+       3. it is called to properly run those tests, one at a time.
+       * tests/depcomp9.test: Delete, it's obsolete now.
+       * tests/depcomp10.test: Likewise.
+       * tests/Makefile.am ($(srcdir)/depmod-tests.am): Include this
+       snippet, which defines ...
+       (depmode_tests): ... this new macro, containing the list of the
+       newly generated `*.depmod' tests.
+       (TESTS_EXTENSIONS): Add `.depmod'.
+       (DEPMOD_LOG_COMPILER): Define.  It calls `depmod-tests.sh', so that
+       the "depmode tests" will be executed by passing that driver script
+       a proper parameter.
+       ($(depmod_tests)): New dependency declaration (dummy, but required
+       in order to have make actually produce expected log files from the
+       `.depmod.log' suffix rule).
+       (TESTS): Add $(depmod_tests).
+       (EXTRA_DIST): Distribute depmod-tests.sh.
+       Other minor cosmetic changes and reorderings.
+       * bootstrap: Generate depmod-tests.am.
+       * tests/.gitignore: Updated.
+
+2011-05-01  Stefano Lattarini  <address@hidden>
+
        tests: avoid extra test generation (for `instspc' tests)
        We don't really need to generate tons and tons of wrapper test
        scripts (presently, ~ 90) just to run what is basically a single
diff --git a/bootstrap b/bootstrap
index 41f1f4e..95e51d1 100755
--- a/bootstrap
+++ b/bootstrap
@@ -107,6 +107,7 @@ dosubst automake.in automake.tmp
 cd tests
 $BOOTSTRAP_SHELL ./gen-parallel-tests > parallel-tests.am
 $BOOTSTRAP_SHELL ./instspc-tests.sh --generate-makefile > instspc-tests.am
+$BOOTSTRAP_SHELL ./depmod-tests.sh --generate-makefile > depmod-tests.am
 cd ..
 
 # Run the autotools.
diff --git a/tests/.gitignore b/tests/.gitignore
index 026e261..c309c22 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -3,6 +3,7 @@ automake-*
 defs-static
 instspc-tests.am
 parallel-tests.am
+depmod-tests.am
 *.dir
 *.log
 *.log-t
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a5c5a63..56e5859 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,7 +18,8 @@
 
 MAINTAINERCLEANFILES =
 EXTRA_DIST = ChangeLog-old
-TEST_EXTENSIONS = .test .instspc
+
+TEST_EXTENSIONS = .test
 
 XFAIL_TESTS = \
 all.test \
@@ -64,7 +65,9 @@ EXTRA_DIST += gen-parallel-tests
 
 include $(srcdir)/instspc-tests.am
 
+TEST_EXTENSIONS += .instspc
 INSTSPC_LOG_COMPILER = $(SHELL) $(srcdir)/instspc-tests.sh
+EXTRA_DIST += instspc-tests.sh
 
 $(srcdir)/instspc-tests.am: instspc-tests.sh Makefile.am
        $(AM_V_GEN)($(am__cd) $(srcdir) \
@@ -79,10 +82,29 @@ $(instspc_tests:.instspc=.log): instspc-tests.sh 
instspc-data.log
 # expected log files from the `.instspc.log' suffix rule.
 $(instspc_tests):
 
-EXTRA_DIST += instspc-tests.sh
 XFAIL_TESTS += $(instspc_xfail_tests)
 
 
+include $(srcdir)/depmod-tests.am
+
+$(srcdir)/depmod-tests.am: depmod-tests.sh Makefile.am
+       $(AM_V_GEN)($(am__cd) $(srcdir) \
+         && $(SHELL) ./depmod-tests.sh --generate-makefile) >$@
+
+TEST_EXTENSIONS += .depmod
+DEPMOD_LOG_COMPILER = $(SHELL) $(srcdir)/depmod-tests.sh
+EXTRA_DIST += depmod-tests.sh
+
+# All `*.depmod' tests work by calling the script `depmod-tests.sh'.
+# Also, they all use shared data generated by the `depmod-data.test'
+# helper test (for reasons of speed).
+depmod-data.log: depmod-tests.sh
+$(depmod_tests:.depmod=.log): depmod-tests.sh depmod-data.log
+# This dummy declaration is required to have make actually produce
+# expected log files from the `.depmod.log' suffix rule.
+$(depmod_tests):
+
+
 # Some testsuite-influential variables should be overridable from the
 # test scripts, but not from the environment.
 # We want warning messages and explanations for skipped tests to go to
@@ -98,6 +120,7 @@ AM_TESTS_ENVIRONMENT = \
 TESTS = \
   $(handwritten_tests) \
   $(generated_tests) \
+  $(depmod_tests) \
   $(instspc_tests)
 
 EXTRA_DIST += $(handwritten_tests) $(generated_tests)
@@ -378,8 +401,7 @@ depcomp6.test \
 depcomp7.test \
 depcomp8a.test \
 depcomp8b.test \
-depcomp9.test \
-depcomp10.test \
+depmod-data.test \
 depdist.test \
 depend.test \
 depend2.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 8288973..e44b2e7 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -50,8 +50,8 @@ POST_UNINSTALL = :
 build_triplet = @build@
 DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
        $(srcdir)/aclocal.in $(srcdir)/automake.in $(srcdir)/defs \
-       $(srcdir)/defs-static.in $(srcdir)/instspc-tests.am \
-       $(srcdir)/parallel-tests.am
+       $(srcdir)/defs-static.in $(srcdir)/depmod-tests.am \
+       $(srcdir)/instspc-tests.am $(srcdir)/parallel-tests.am
 subdir = tests
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/amversion.m4 \
@@ -190,9 +190,12 @@ am__test_logs1 = $(TESTS:=.log)
 am__test_logs2 = $(am__test_logs1:.test.log=.log)
 TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
        $(TEST_LOG_FLAGS)
-TEST_LOGS = $(am__test_logs2:.instspc.log=.log)
+am__test_logs3 = $(am__test_logs2:.instspc.log=.log)
 INSTSPC_LOG_COMPILE = $(INSTSPC_LOG_COMPILER) $(AM_INSTSPC_LOG_FLAGS) \
        $(INSTSPC_LOG_FLAGS)
+TEST_LOGS = $(am__test_logs3:.depmod.log=.log)
+DEPMOD_LOG_COMPILE = $(DEPMOD_LOG_COMPILER) $(AM_DEPMOD_LOG_FLAGS) \
+       $(DEPMOD_LOG_FLAGS)
 TEST_LOGS_TMP = $(TEST_LOGS:.log=.log-t)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -288,8 +291,8 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 MAINTAINERCLEANFILES = $(parallel_tests)
 EXTRA_DIST = ChangeLog-old gen-parallel-tests instspc-tests.sh \
-       $(handwritten_tests) $(generated_tests)
-TEST_EXTENSIONS = .test .instspc
+       depmod-tests.sh $(handwritten_tests) $(generated_tests)
+TEST_EXTENSIONS = .test .instspc .depmod
 XFAIL_TESTS = all.test auxdir2.test cond17.test gcj6.test \
        override-conditional-2.test pr8365-remake-timing.test \
        yacc-dist-nobuild-subdir.test txinfo5.test \
@@ -355,6 +358,15 @@ instspc_xfail_tests = build-squote.instspc 
build-dquote.instspc \
        install-sharp.instspc install-dollar.instspc \
        install-linefeed.instspc install-a_lf_b.instspc
 INSTSPC_LOG_COMPILER = $(SHELL) $(srcdir)/instspc-tests.sh
+depmod_tests = depcomp-gcc3.depmod depcomp-gcc.depmod \
+       depcomp-hp.depmod depcomp-sgi.depmod depcomp-aix.depmod \
+       depcomp-icc.depmod depcomp-hp2.depmod depcomp-tru64.depmod \
+       depcomp-msvc7.depmod depcomp-msvc7msys.depmod \
+       depcomp-nosideeffect.depmod depcomp-dashmstdout.depmod \
+       depcomp-dashXmstdout.depmod depcomp-makedepend.depmod \
+       depcomp-cpp.depmod depcomp-msvisualcpp.depmod \
+       depcomp-msvcmsys.depmod
+DEPMOD_LOG_COMPILER = $(SHELL) $(srcdir)/depmod-tests.sh
 
 # Some testsuite-influential variables should be overridable from the
 # test scripts, but not from the environment.
@@ -371,6 +383,7 @@ AM_TESTS_ENVIRONMENT = \
 TESTS = \
   $(handwritten_tests) \
   $(generated_tests) \
+  $(depmod_tests) \
   $(instspc_tests)
 
 generated_tests = $(parallel_tests)
@@ -648,8 +661,7 @@ depcomp6.test \
 depcomp7.test \
 depcomp8a.test \
 depcomp8b.test \
-depcomp9.test \
-depcomp10.test \
+depmod-data.test \
 depdist.test \
 depend.test \
 depend2.test \
@@ -1311,8 +1323,8 @@ yflags-var-expand.test
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .html .instspc .log .test
-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/parallel-tests.am 
$(srcdir)/instspc-tests.am $(am__configure_deps)
+.SUFFIXES: .depmod .html .instspc .log .test
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/parallel-tests.am 
$(srcdir)/instspc-tests.am $(srcdir)/depmod-tests.am $(am__configure_deps)
        @for dep in $?; do \
          case '$(am__configure_deps)' in \
            *$$dep*) \
@@ -1485,6 +1497,8 @@ recheck recheck-html:
        @p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post)
 .instspc.log:
        @p='$<'; $(am__check_pre) $(INSTSPC_LOG_COMPILE) "$$tst" 
$(am__check_post)
+.depmod.log:
+       @p='$<'; $(am__check_pre) $(DEPMOD_LOG_COMPILE) "$$tst" 
$(am__check_post)
 
 distdir: $(DISTFILES)
        @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -1702,6 +1716,19 @@ $(instspc_tests:.instspc=.log): instspc-tests.sh 
instspc-data.log
 # expected log files from the `.instspc.log' suffix rule.
 $(instspc_tests):
 
+$(srcdir)/depmod-tests.am: depmod-tests.sh Makefile.am
+       $(AM_V_GEN)($(am__cd) $(srcdir) \
+         && $(SHELL) ./depmod-tests.sh --generate-makefile) >$@
+
+# All `*.depmod' tests work by calling the script `depmod-tests.sh'.
+# Also, they all use shared data generated by the `depmod-data.test'
+# helper test (for reasons of speed).
+depmod-data.log: depmod-tests.sh
+$(depmod_tests:.depmod=.log): depmod-tests.sh depmod-data.log
+# This dummy declaration is required to have make actually produce
+# expected log files from the `.depmod.log' suffix rule.
+$(depmod_tests):
+
 # Each test case depends on defs, aclocal, and automake.
 $(TEST_LOGS): defs aclocal-$(APIVERSION) automake-$(APIVERSION)
 
diff --git a/tests/depcomp10.test b/tests/depcomp10.test
deleted file mode 100755
index b278766..0000000
--- a/tests/depcomp10.test
+++ /dev/null
@@ -1,90 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# 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 2, 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 <http://www.gnu.org/licenses/>.
-
-# hp depmode should work with GNU make in VPATH mode (bug similar to
-# depcomp9.test).
-# For automake bug#8473.
-
-# Here's the bug: hp depmode will prefix VPATH to the object file name,
-# thus the second gmake will invoke depcomp with object='../../src/foo.o',
-# causing errors such as (broken on multiple lines for clarity):
-#   cpp: "", line 0: error 4066: Cannot create
-#        "../../gllib/.deps/nonblocking.TPo" file for
-#        "-M../../gllib/.deps/nonblocking.TPo" option.
-#        (No such file or directory[errno=2])
-
-required=GNUmake
-. ./defs || Exit 1
-
-mkdir src src/sub build
-
-cat >> configure.in << 'END'
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_CONFIG_FILES([src/Makefile])
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-SUBDIRS = src
-END
-
-cat > src/Makefile.am << 'END'
-AUTOMAKE_OPTIONS = subdir-objects
-bin_PROGRAMS = foo
-foo_SOURCES = foo.c foo.h sub/subfoo.c
-END
-
-cat > src/foo.h <<EOF
-extern int subfoo (void);
-EOF
-
-cat >src/foo.c <<EOF
-#include "foo.h"
-int main (void)
-{
-  return subfoo ();
-}
-EOF
-
-cat >src/sub/subfoo.c <<EOF
-#include "foo.h"
-int subfoo (void)
-{
-  return 0;
-}
-EOF
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE -a
-
-cd build
-../configure am_cv_CC_dependencies_compiler_type=hp
-# Do not error out with the first make, as the forced 'hp' depmode might
-# not actually work, but we have overridden the _AM_DEPENDENCIES tests.
-$MAKE || skip_ "forced depmode doesn't work"
-
-# We must clean and rebuild, as the actual error only happens the second
-# time the objects are built because 'depcomp' has silently messed up the
-# .Po files the first time.
-$MAKE clean
-
-$MAKE >out 2>&1 || { cat out; Exit 1; }
-cat out
-grep 'src/[._]deps' out && Exit 1
-
-:
diff --git a/tests/depcomp9.test b/tests/depcomp9.test
deleted file mode 100755
index d132354..0000000
--- a/tests/depcomp9.test
+++ /dev/null
@@ -1,92 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# 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 2, 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 <http://www.gnu.org/licenses/>.
-
-# makedepend should work in VPATH mode.
-
-# Here's the bug: makedepend will prefix VPATH to the object file name,
-# thus the second make will invoke depcomp with object='../../src/foo.o',
-# causing errors such as:
-# touch: cannot touch `../../src/.deps/foo.TPo': No such file or directory
-# makedepend: error:  cannot open "../../src/.deps/foo.TPo"
-# ../../depcomp: line 560: ../../src/.deps/foo.TPo: No such file or directory
-
-# We include subfoo only to be sure that we don't remove too much
-# from the object file name.
-
-required='makedepend'
-. ./defs || Exit 1
-
-mkdir src src/sub build
-
-cat >> configure.in << 'END'
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_CONFIG_FILES([src/Makefile])
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-SUBDIRS = src
-END
-
-cat > src/Makefile.am << 'END'
-AUTOMAKE_OPTIONS = subdir-objects
-bin_PROGRAMS = foo
-foo_SOURCES = foo.c foo.h sub/subfoo.c
-END
-
-cat > src/foo.h <<EOF
-extern int subfoo (void);
-EOF
-
-cat >src/foo.c <<EOF
-#include "foo.h"
-int main (void)
-{
-  return subfoo ();
-}
-EOF
-
-cat >src/sub/subfoo.c <<EOF
-#include "foo.h"
-int subfoo (void)
-{
-  return 0;
-}
-EOF
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE -a
-
-cd build
-../configure am_cv_CC_dependencies_compiler_type=makedepend
-
-# Do not error out with the first make, as the forced 'makedepend'
-# depmode might not actually work, but we have overridden the
-# _AM_DEPENDENCIES tests.
-$MAKE || skip_ "forced depmode doesn't work"
-
-# We must clean and rebuild, as the actual error only happens the second
-# time the objects are built because 'makedepend' has silently messed up
-# the .Po files the first time.
-$MAKE clean
-
-$MAKE >out 2>&1 || { cat out; Exit 1; }
-cat out
-grep 'src/[._]deps' out && Exit 1
-
-:
diff --git a/tests/depmod-data.test b/tests/depmod-data.test
new file mode 100755
index 0000000..fdaa52b
--- /dev/null
+++ b/tests/depmod-data.test
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# 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 2, 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 <http://www.gnu.org/licenses/>.
+
+# Helper testcase which generate input data for the other tests
+# `*.depmod'.  It basically delegates the work to the helper script
+# `depmod-test.sh'.
+
+# Ensure proper definition of $testsrcdir.
+. ./defs-static || exit 99
+
+# Sanity check.
+if test x"$testsrcdir" = x; then
+  echo "$0: \$testsrcdir not set after sourcing of ./defs-static" >&2
+  exit 99
+fi
+
+exec $SHELL $testsrcdir/depmod-tests.sh --generate-data
diff --git a/tests/depmod-tests.sh b/tests/depmod-tests.sh
new file mode 100755
index 0000000..4eb8419
--- /dev/null
+++ b/tests/depmod-tests.sh
@@ -0,0 +1,220 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# 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 2, 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 <http://www.gnu.org/licenses/>.
+
+# Driver script to generate and run tests checking that dependency
+# tracking in various flavours works with VPATH builds.
+#
+# This script fulfills a threefold role:
+#   1. It is called to generate a Makefile.am snippet, containing the
+#      definition of proper lists of tests.
+#   2. It is called to set up a directory containing some common data
+#      files and autotools-generated files used by the aforementioned
+#      tests (this is done for speed reasons only).
+#   3. It is called to properly run those tests, one at a time.
+#
+# Examples of reported failures follows ...
+
+# <http://lists.gnu.org/archive/html/automake-patches/2011-04/msg00028.html>
+#
+# Here's the bug: makedepend will prefix VPATH to the object file name,
+# thus the second make will invoke depcomp with object='../../src/foo.o',
+# causing errors such as:
+# touch: cannot touch `../../src/.deps/foo.TPo': No such file or directory
+# makedepend: error:  cannot open "../../src/.deps/foo.TPo"
+# ../../depcomp: line 560: ../../src/.deps/foo.TPo: No such file or directory
+
+# <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8473>
+# <http://lists.gnu.org/archive/html/automake-patches/2011-04/msg00079.html>
+#
+# Here's the bug: hp depmode will prefix VPATH to the object file name,
+# thus the second gmake will invoke depcomp with object='../../src/foo.o',
+# causing errors such as (broken on multiple lines for clarity):
+#   cpp: "", line 0: error 4066: Cannot create
+#        "../../gllib/.deps/nonblocking.TPo" file for
+#        "-M../../gllib/.deps/nonblocking.TPo" option.
+#        (No such file or directory[errno=2])
+
+# Be more Bourne compatible (snippet copied from `tests/defs').
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+
+set -e
+
+case $# in
+  0) echo "$0: missing argument" >&2; exit 99;;
+  1) ;;
+  *) echo "$0: too many arguments" >&2; exit 99;;
+esac
+
+case $1 in
+  --generate-makefile|--generate-data)
+    action=`expr x"$1" : x'--\(.*\)'`
+    ;;
+  depcomp-*.depmod|*/depcomp-*.depmod)
+    action=run-test
+    depmode=`expr /"$1" : '.*/depcomp-\(.*\)\.depmod'`
+    ;;
+  *)
+    echo "$0: invalid argument '$1'" >&2
+    exit 99
+    ;;
+esac
+
+# Helper subroutines for creation of input data files.
+
+create_input_data ()
+{
+  mkdir src src/sub
+
+  unindent > configure.in << 'END'
+    AC_INIT([depcomp], [1.0])
+    AM_INIT_AUTOMAKE
+    AC_CONFIG_FILES([Makefile src/Makefile])
+    AC_PROG_CC
+    AM_PROG_CC_C_O
+    AC_OUTPUT
+END
+
+  echo 'SUBDIRS = src' > Makefile.am
+
+  unindent > src/Makefile.am << 'END'
+    AUTOMAKE_OPTIONS = subdir-objects
+    bin_PROGRAMS = foo
+    foo_SOURCES = foo.c foo.h sub/subfoo.c
+END
+
+  echo 'extern int subfoo (void);' > src/foo.h
+
+  unindent > src/foo.c << 'END'
+    #include "foo.h"
+    int main (void)
+    {
+      return subfoo ();
+    }
+END
+
+  # We include subfoo only to be sure that we don't remove too much
+  # from the object file name.
+  unindent > src/sub/subfoo.c << 'END'
+    #include "foo.h"
+    int subfoo (void)
+    {
+      return 0;
+    }
+END
+
+  $ACLOCAL
+  $AUTOCONF
+  $AUTOMAKE -a
+
+  # Sanity check: make sure the cache variable we force is used
+  # by configure.
+  grep am_cv_CC_dependencies_compiler_type configure
+
+  : > success
+}
+
+# Usage: get_depmodes DEPCOMP-FILE PROGRAM-NAME
+get_depmodes ()
+{
+  # Keep this in sync with the contents of depend.m4.
+  all_depmodes=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < "$1" \
+    | grep -v '^none$' | tr "$nl" "$sp"` \
+    && test -n "$all_depmodes" || {
+      echo "$2: failed to extract list of valid depmodes from '$1'" >&2
+      exit 99
+    }
+}
+
+if test x"$action" = x"generate-makefile"; then
+  # We must generate a makefile fragment on stdout.  It must refer
+  # to all tests at once, hence the loop below.
+  get_depmodes ../lib/depcomp
+  echo '## Generated by depmode-tests.sh.  DO NOT EDIT!'
+  echo 'depmod_tests ='
+  for depmode in $all_depmodes; do
+    echo "depmod_tests += depcomp-$depmode.depmod"
+  done
+  exit 0
+fi
+
+# We'll need the full setup provided by `tests/defs'.  Temporarily disable
+# the errexit flag, since the setup code might not be prepared to deal
+# with it.  Also pre-set `$me' for `tests/defs', so that different calls
+# to `depmod-tests.sh' won't try to use the same temporary directory.
+if test x"$action" = x"generate-data"; then
+  me=depmod-data
+else
+  me=depcomp-$depmode
+fi
+set +e
+. ./defs || Exit 99
+set -e
+
+# The directory set up by the `generate-data' action should contain all
+# the files we need.  So remove the other files created by ./defs.  And
+# check we really are in a temporary `*.dir' directory in the build tree,
+# since the last thing we want is to remove some random user files!
+test -f ../defs-static && test -f ../defs || Exit 99
+case `pwd` in *.dir);; *) Exit 99;; esac
+rm -f *
+
+if test x"$action" = x"generate-data"; then
+  # We must *not* remove the test directory, since its contents must be
+  # used by following dependent tests.
+  keep_testdirs=yes
+  create_input_data
+  Exit 0
+fi
+
+get_depmodes "$top_testsrcdir/lib/depcomp" "$me"
+case " $all_depmodes " in
+  *" $depmode "*) ;;
+  *) echo "$me: invalid depmode '$depmode'" >&2; exit 99;;
+esac
+
+###  If we are still here, we have to run a test ...
+
+test -f ../depmod-data.dir/success || {
+  echo "$me: setup by depmod-data.test failed" >&2
+  Exit 99
+}
+
+../depmod-data.dir/configure am_cv_CC_dependencies_compiler_type=$depmode
+
+# Do not error out with the first make, as the depmode we've forced might
+# not actually work, but we have overridden the _AM_DEPENDENCIES tests.
+$MAKE || skip_ "forced depmode '$depmode' doesn't work"
+
+# We must clean and rebuild, as the actual error only happens the second
+# time the objects are built because 'depcomp' has silently messed up the
+# .Po files the first time.
+$MAKE clean
+
+$MAKE >out 2>&1 || { cat out; Exit 1; }
+cat out
+grep 'src/[._]deps' out && Exit 1
+
+:
-- 
1.7.2.3


reply via email to

[Prev in Thread] Current Thread [Next in Thread]