a2e56a4b3fa5b63ef5ddd96f0183f23f8bd646a2
[platform/upstream/automake.git] / tests / parallel-tests-exit-statuses.test
1 #! /bin/sh
2 # Copyright (C) 2011 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 features: normal and special exit statuses
18 # in the test scripts.
19
20 am_parallel_tests=yes
21 . ./defs || Exit 1
22
23 cat >> configure.in << 'END'
24 AC_OUTPUT
25 END
26
27 # $failure_statuses should be defined to the list of all integers between
28 # 1 and 255 (inclusive), excluded 77 and 99.
29 failure_statuses=`seq_ 1 255 | $EGREP -v '^(77|99)$' | tr "$nl" ' '`
30 # For debugging.
31 echo "failure_statuses: $failure_statuses"
32 # Sanity check.
33 test `for st in $failure_statuses; do echo $st; done | wc -l` -eq 253 \
34   || fatal_ "initializing list of exit statuses for simple failures"
35
36 cat > Makefile.am <<END
37 LOG_COMPILER = ./do-exit
38 fail_tests = $failure_statuses
39 TESTS = 0 77 99 $failure_statuses
40 \$(TESTS):
41 END
42
43 cat > do-exit <<'END'
44 #!/bin/sh
45 echo "$0: $1"
46 case $1 in
47   [0-9]|[0-9][0-9]|[0-9][0-9][0-9]) st=$1;;
48   */[0-9]|*/[0-9][0-9]|*/[0-9][0-9][0-9]) st=`echo x"$1" | sed 's|.*/||'`;;
49   *) st=99;;
50 esac
51 exit $st
52 END
53 chmod a+x do-exit
54
55 $ACLOCAL
56 $AUTOCONF
57 $AUTOMAKE -a
58
59 {
60   echo PASS: 0
61   echo SKIP: 77
62   echo ERROR: 99
63   for st in $failure_statuses; do
64     echo "FAIL: $st"
65   done
66 } | LC_ALL=C sort > exp-fail
67
68 sed 's/^FAIL:/XFAIL:/' exp-fail | LC_ALL=C sort > exp-xfail-1
69 sed '/^ERROR:/d' exp-xfail-1 > exp-xfail-2
70
71 sort exp-fail
72 sort exp-xfail-1
73 sort exp-xfail-2
74
75 ./configure
76
77 st=1
78 $MAKE check >stdout && st=0
79 cat stdout
80 cat test-suite.log
81 test $st -gt 0 || Exit 1
82 LC_ALL=C grep '^[A-Z][A-Z]*:' stdout | LC_ALL=C sort > got-fail
83 diff exp-fail got-fail
84
85 st=1
86 XFAIL_TESTS="$failure_statuses 99" $MAKE -e check >stdout && st=0
87 cat stdout
88 cat test-suite.log
89 test $st -gt 0 || Exit 1
90 LC_ALL=C grep '^[A-Z][A-Z]*:' stdout | LC_ALL=C sort > got-xfail-1
91 diff exp-xfail-1 got-xfail-1
92
93 st=0
94 XFAIL_TESTS="$failure_statuses" TESTS="0 77 $failure_statuses" \
95   $MAKE -e check >stdout || st=$?
96 cat stdout
97 cat test-suite.log
98 test $st -eq 0 || Exit 1
99 LC_ALL=C grep '^[A-Z][A-Z]*:' stdout | LC_ALL=C sort > got-xfail-2
100 diff exp-xfail-2 got-xfail-2
101
102 :