automake-patches
[Top][All Lists]
Advanced

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

[FYI] {maint} tests: more coverage about BUILT_SOURCES


From: Stefano Lattarini
Subject: [FYI] {maint} tests: more coverage about BUILT_SOURCES
Date: Sat, 27 Oct 2012 15:46:21 +0200

Basically a backport of some tests from Automake-NG.

* t/built-sources-check.sh: Sync it with the version in the ng/master
branch.  Accordingly, move part of the checks out ...
* t/built-sources-install.sh: ... into this new test, synced from
ng/master as well.
* t/built-sources-subdir.sh: Minor tweaks and enhancements to sync it
with the version in ng/master.
* t/built-sources-cond.sh: New test, synced from ng/master.
* t/built-sources-fork-bomb.sh: Likewise.
* t/built-sources.sh: Likewise.
* t/list-of-tests.mk: Update.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 t/built-sources-check.sh     | 16 +-------
 t/built-sources-cond.sh      | 91 ++++++++++++++++++++++++++++++++++++++++++++
 t/built-sources-fork-bomb.sh | 70 ++++++++++++++++++++++++++++++++++
 t/built-sources-install.sh   | 69 +++++++++++++++++++++++++++++++++
 t/built-sources-subdir.sh    | 21 +++-------
 t/built-sources.sh           | 68 +++++++++++++++++++++++++++++++++
 t/list-of-tests.mk           |  4 ++
 7 files changed, 310 insertions(+), 29 deletions(-)
 create mode 100755 t/built-sources-cond.sh
 create mode 100755 t/built-sources-fork-bomb.sh
 create mode 100755 t/built-sources-install.sh
 create mode 100755 t/built-sources.sh

diff --git a/t/built-sources-check.sh b/t/built-sources-check.sh
index 3e4ce96..d4d3c51 100755
--- a/t/built-sources-check.sh
+++ b/t/built-sources-check.sh
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Make sure 'check:' and 'install:' honor $(BUILT_SOURCES).
+# Make sure 'check:' honors $(BUILT_SOURCES).
 # PR/359.
 
 # For gen-testsuite-part: ==> try-with-serial-tests <==
@@ -63,18 +63,6 @@ cat stdout
 grep '^PASS: subrun\.sh *$' stdout
 grep 'PASS.*echo\.sh' stdout && exit 1
 
-# check should depend directly on $(BUILT_SOURCES) (similar tests
-# are in check.sh and check2.sh).
-$EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' Makefile.in
-$EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' dir/Makefile.in
-
-$MAKE clean
-# Sanity checks
-test ! -e command1.inc
-test ! -e dir/command2.inc
-# Now make sure these two files are rebuilt during make install.
-$MAKE install
-test -f command1.inc
-test -f dir/command2.inc
+$MAKE distcheck
 
 :
diff --git a/t/built-sources-cond.sh b/t/built-sources-cond.sh
new file mode 100755
index 0000000..ac78a97
--- /dev/null
+++ b/t/built-sources-cond.sh
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Interaction of BUILT_SOURCES with conditionals.
+
+. ./defs || exit 1
+
+cat >> configure.ac <<'END'
+AM_CONDITIONAL([COND1], [test $cond1 = yes])
+AM_CONDITIONAL([COND2], [test $cond2 = yes])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if COND1
+BUILT_SOURCES = a
+else
+BUILT_SOURCES = b
+endif
+if COND2
+BUILT_SOURCES += c
+endif
+
+a b c:
+       echo who cares > $@
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+cleanup ()
+{
+  # Files in $(BUILT_SOURCES) should be automatically removed
+  # upon maintainer-clean.
+  $MAKE maintainer-clean
+  test ! -f a
+  test ! -f b
+  test ! -f c
+}
+
+./configure cond1=yes cond2=yes
+
+$MAKE
+test -f a
+test ! -f b
+test -f c
+
+cleanup
+
+./configure cond1=no cond2=yes
+
+$MAKE
+test ! -f a
+test -f b
+test -f c
+
+cleanup
+
+./configure cond1=yes cond2=no
+
+$MAKE
+test -f a
+test ! -f b
+test ! -f c
+
+cleanup
+
+./configure cond1=no cond2=no
+
+$MAKE
+test ! -f a
+test -f b
+test ! -f c
+
+cleanup
+
+:
diff --git a/t/built-sources-fork-bomb.sh b/t/built-sources-fork-bomb.sh
new file mode 100755
index 0000000..fac3750
--- /dev/null
+++ b/t/built-sources-fork-bomb.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Due to how the handling of $(BUILT_SOURCES) is implemented in Automake-NG,
+# a recursive make call in the recipe of any $(BUILT_SOURCES) (or of any of
+# its prerequisites) might cause an infinite recursion (complete with fork
+# bomb, yuck) if not handled correctly.  Verify that this doesn't happen.
+# For more background, see:
+# <http://lists.gnu.org/archive/html/help-smalltalk/2012-08/msg00027.html>
+# <http://lists.gnu.org/archive/html/automake-patches/2012-08/msg00052.html>
+# Backported to improve coverage of mainline Automake.
+
+required=GNUmake
+. ./defs || exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+BUILT_SOURCES = foo
+.PHONY: build-foo
+build-foo:
+       echo OK > foo
+foo:
+       $(MAKE) build-foo
+
+# If the bug is still present, we want this test to fail, not to actually
+# go fork bomb and potentially crash the user machine.  Take care of that.
+
+is_too_deep := $(shell test $(MAKELEVEL) -lt 10 && echo no)
+
+## Extra indentation here required to avoid confusing Automake.
+ ifeq ($(is_too_deep),no)
+   # All is ok.
+ else
+   $(error ::OOPS:: Recursion too deep, $(MAKELEVEL) levels)
+ endif
+END
+
+$ACLOCAL
+$AUTOMAKE -Wno-portability
+$AUTOCONF
+
+./configure
+
+$MAKE -n foo >output 2>&1 || { cat output; exit 1; }
+cat output
+test ! -f foo
+# Guard against possible infinite recursion.
+$FGREP '::OOPS::' output && exit 1
+
+$MAKE foo >output 2>&1 || { cat output; exit 1; }
+cat output
+$MAKE foo
+# Guard against possible infinite recursion.
+$FGREP '::OOPS::' output && exit 1
+
+:
diff --git a/t/built-sources-install.sh b/t/built-sources-install.sh
new file mode 100755
index 0000000..2f53bb5
--- /dev/null
+++ b/t/built-sources-install.sh
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Make sure 'install:' honors $(BUILT_SOURCES).
+# PR/359.
+
+. ./defs || exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([dir/Makefile])
+AC_OUTPUT
+END
+
+mkdir dir
+
+cat > Makefile.am << 'END'
+BUILT_SOURCES = built1
+SUBDIRS = dir
+built1:
+       echo ok > $@
+CLEANFILES = built1
+install-data-hook:
+       $(MKDIR_P) $(DESTDIR)$(prefix)/dir2
+       cp built1 $(DESTDIR)$(prefix)/built1
+       cp dir/built2 $(DESTDIR)$(prefix)/dir2/built3
+uninstall-hook:
+       rm -f $(DESTDIR)$(prefix)/built1
+       rm -f $(DESTDIR)$(prefix)/dir2/built3
+       rmdir $(DESTDIR)$(prefix)/dir2
+installcheck-local:
+       test -f $(prefix)/built1
+       test -f $(prefix)/dir2/built3
+END
+
+cat > dir/Makefile.am << 'END'
+BUILT_SOURCES = built2
+built2:
+## The next line ensures that command1.inc has been built before
+## recurring into the subdir.
+       cp ../built1 $@
+CLEANFILES = built2
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure --prefix "$(pwd)/inst"
+
+# Now make sure these two files are rebuilt during make install.
+$MAKE install
+test -f built1
+test -f dir/built2
+$MAKE installcheck
+$MAKE distcheck
+
+:
diff --git a/t/built-sources-subdir.sh b/t/built-sources-subdir.sh
index 84f65a6..cc162bb 100755
--- a/t/built-sources-subdir.sh
+++ b/t/built-sources-subdir.sh
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Make sure when using SUBDIR that all BUILT_SOURCES are built.
+# Make sure when using SUBDIRS that all BUILT_SOURCES are built.
 # A bug occurred where subdirs do not have all-recursive or
 # all-recursive-am which depended on BUILT_SOURCES.
 
@@ -31,14 +31,6 @@ AM_PROG_AR
 AC_OUTPUT
 END
 
-# Files required because we are using '--gnu'.
-: > INSTALL
-: > NEWS
-: > README
-: > COPYING
-: > AUTHORS
-: > ChangeLog
-
 cat > Makefile.am << 'END'
 SUBDIRS = lib
 END
@@ -47,25 +39,24 @@ cat > lib/Makefile.am << 'END'
 pkgdata_DATA =
 noinst_LIBRARIES = libfoo.a
 libfoo_a_SOURCES = foo.c
-BUILT_SOURCES=foo.h
+BUILT_SOURCES = foo.h
 foo.h:
        echo \#define FOO_DEFINE 1 >$@
+CLEANFILES = $(BUILT_SOURCES)
 END
 
 cat > lib/foo.c << 'END'
 #include <foo.h>
-int foo () { return !FOO_DEFINE;}
+int foo (void) { return !FOO_DEFINE; }
 END
 
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE --include-deps --copy --force-missing --add-missing --gnu
+$AUTOMAKE --copy --add-missing
 
 ./configure
-
-# Remove the comment to get a successful test.
-# $MAKE -C lib foo.h
 $MAKE
+$MAKE distcheck
 
 :
diff --git a/t/built-sources.sh b/t/built-sources.sh
new file mode 100755
index 0000000..5173136
--- /dev/null
+++ b/t/built-sources.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Basic test on BUILT_SOURCES.
+
+required=cc
+. ./defs || exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+BUILT_SOURCES = foo.c
+noinst_PROGRAMS = bar baz
+foo.c:
+       rm -f $@ address@hidden
+## Use printf, not echo, to avoid spurious interpretation of
+## the "\n" as a newline (seen on NetBSD 5.1).
+       printf '%s\n' '#include <stdio.h>'               >  address@hidden
+       printf '%s\n' 'int main (void)'                  >> address@hidden
+       printf '%s\n' '{               '                 >> address@hidden
+       printf '%s\n' '  printf ("%s\n", FOOMSG);'       >> address@hidden
+       printf '%s\n' '  return 0;'                      >> address@hidden
+       printf '%s\n' '}'                                >> address@hidden
+       mv -f address@hidden $@
+CLEANFILES = foo.c
+END
+
+cat > bar.c <<'END'
+#define FOOMSG "Howdy, World"
+#include "foo.c"
+END
+
+cat > baz.c <<'END'
+#define FOOMSG "Hello, Earth"
+#include "foo.c"
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE
+if cross_compiling; then :; else
+  ./bar
+  ./bar | grep 'Howdy, World'
+  ./baz
+  ./baz | grep 'Hello, Earth'
+fi
+$MAKE distcheck
+
+:
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 99612cf..84788e0 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -186,7 +186,11 @@ t/badopt.sh \
 t/badprog.sh \
 t/block.sh \
 t/built-sources-check.sh \
+t/built-sources-cond.sh \
+t/built-sources-fork-bomb.sh \
+t/built-sources-install.sh \
 t/built-sources-subdir.sh \
+t/built-sources.sh \
 t/candist.sh \
 t/canon.sh \
 t/canon2.sh \
-- 
1.8.0




reply via email to

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