tests: give few aclocal tests more significant names
[automake.git] / t / built-sources-fork-bomb.sh
blobbfb1b4283d84e22c0d51f95f69b72a7b0da58fa8
1 #! /bin/sh
2 # Copyright (C) 2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Due to how the handling of $(BUILT_SOURCES) is implemented in Automake-NG,
18 # a recursive make call in the recipe of any $(BUILT_SOURCES) (or of any of
19 # its prerequisites) might cause an infinite recursion (complete with fork
20 # bomb, yuck) if not handled correctly. Verify that this doesn't happen.
21 # For more background, see:
22 # <http://lists.gnu.org/archive/html/help-smalltalk/2012-08/msg00027.html>
23 # <http://lists.gnu.org/archive/html/automake-patches/2012-08/msg00052.html>
24 # Backported to improve coverage of mainline Automake.
26 required=GNUmake
27 . test-init.sh
29 echo AC_OUTPUT >> configure.ac
31 cat > Makefile.am << 'END'
32 BUILT_SOURCES = foo
33 .PHONY: build-foo
34 build-foo:
35 echo OK > foo
36 foo:
37 $(MAKE) build-foo
39 # If the bug is still present, we want this test to fail, not to actually
40 # go fork bomb and potentially crash the user machine. Take care of that.
42 is_too_deep := $(shell test $(MAKELEVEL) -lt 10 && echo no)
44 ## Extra indentation here required to avoid confusing Automake.
45 ifeq ($(is_too_deep),no)
46 # All is ok.
47 else
48 $(error ::OOPS:: Recursion too deep, $(MAKELEVEL) levels)
49 endif
50 END
52 $ACLOCAL
53 $AUTOMAKE -Wno-portability
54 $AUTOCONF
56 ./configure
58 $MAKE -n foo >output 2>&1 || { cat output; exit 1; }
59 cat output
60 test ! -f foo
61 # Guard against possible infinite recursion.
62 $FGREP '::OOPS::' output && exit 1
64 $MAKE foo >output 2>&1 || { cat output; exit 1; }
65 cat output
66 $MAKE foo
67 # Guard against possible infinite recursion.
68 $FGREP '::OOPS::' output && exit 1