0d13677c2f0c10b892e40f5fc488db97f31fc737
[platform/upstream/automake.git] / tests / parallel-tests-dry-run-2.test
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # Check parallel-tests interactions with "make -n".
18 # See also sister test 'parallel-tests-dry-run-1.test'.
19
20 am_parallel_tests=yes
21 . ./defs || Exit 1
22
23 cat >> configure.ac << 'END'
24 AC_OUTPUT
25 END
26
27 cat > Makefile.am <<'END'
28 TESTS = foo.test bar.test
29 TEST_LOG_COMPILER = $(SHELL)
30 END
31
32 $ACLOCAL
33 $AUTOMAKE -a
34 $AUTOCONF
35
36 ./configure
37
38 make_n_ ()
39 {
40   st=0
41   $MAKE -n "$@" >output 2>&1 || { cat output; ls -l; Exit 1; }
42   cat output
43   # Look out for possible errors from common tools used by recipes.
44   $EGREP -i ' (exist|permission|denied|no .*(such|file))' output && Exit 1
45   $EGREP '(mv|cp|rm|cat|grep|sed|awk): ' output && Exit 1
46   :
47 }
48
49 : > output
50
51 files='foo.log bar.log foo.trs bar.trs'
52
53 for target in check recheck test-suite.log; do
54   test ! -f foo.log
55   test ! -f foo.trs
56   test ! -f bar.log
57   test ! -f bar.trs
58   test ! -f test-suite.log
59 done
60
61 # Creative quoting below to please maintainer-check.
62 echo exit '0' > foo.test
63 echo exit '1' > bar.test
64
65 $MAKE check && Exit 1
66
67 chmod a-w .
68
69 make_n_ clean
70 test -f foo.log
71 test -f foo.trs
72 test -f foo.log
73 test -f bar.trs
74
75 # Creative quoting below to please maintainer-check.
76 cat > foo.test <<END
77 echo this is bad
78 exit 1
79 END
80 echo exit '0' > bar.test
81
82 for target in check recheck test-suite.log; do
83   make_n_ $target
84   grep '^:test-result: *FAIL' bar.trs
85   grep 'this is bad' foo.log test-suite.log && Exit 1
86   : For shells with busted 'set -e'.
87 done
88
89 chmod a-rw $files
90 if test -r foo.log; then
91   : You can still read unreadable files!  Skip these checks.
92 else
93   for target in check recheck test-suite.log; do
94     make_n_ $target
95     for f in $files; do
96       test -f $f && test ! -r $f || Exit 1
97     done
98   done
99 fi
100 chmod u+r $files
101
102 chmod u+w .
103 rm -f foo.log bar.trs
104 chmod a-w .
105 for target in check recheck test-suite.log $files; do
106   make_n_ $target
107   test ! -f foo.log
108   test -f foo.trs
109   test ! -f bar.trs
110   test -f bar.log
111 done
112
113 :