Merge branch 'maint'
[platform/upstream/automake.git] / t / tap-doc.sh
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 that an example given in the documentation really works.
18 # See section "Simple Tests" subsection "Script-based Testsuites".
19
20 am_parallel_tests=yes
21 . ./defs || Exit 1
22
23 fetch_tap_driver
24
25 cat >> configure.ac <<END
26 AC_PROG_CC
27 AC_OUTPUT
28 END
29
30 cat > Makefile.am << 'END'
31 TESTS = foo.sh zardoz.tap bar.sh mu.tap
32 TEST_EXTENSIONS = .sh .tap
33 TAP_LOG_DRIVER = $(srcdir)/tap-driver
34 ## Ensure the test scripts are run in the correct order.
35 mu.log: bar.log
36 bar.log: zardoz.log
37 zardoz.log: foo.log
38 END
39
40 cat > foo.sh <<'END'
41 #!/bin/sh
42 exit 0
43 END
44
45 cat > bar.sh <<'END'
46 #!/bin/sh
47 exit 77
48 END
49
50 cat > zardoz.tap << 'END'
51 #!/bin/sh
52 echo 1..4
53 echo 'ok 1 - Daemon started'
54 echo 'ok 2 - Daemon responding'
55 echo 'ok 3 - Daemon uses /proc # SKIP /proc is not mounted'
56 echo 'ok 4 - Daemon stopped'
57 END
58
59 cat > mu.tap << 'END'
60 #!/bin/sh
61 echo 1..2
62 echo 'ok'
63 echo 'not ok # TODO frobnication not yet implemented'
64 END
65
66 chmod a+x *.sh *.tap
67
68 $ACLOCAL
69 $AUTOCONF
70 $AUTOMAKE -a
71
72 ./configure
73
74 $MAKE check >stdout || { cat stdout; Exit 1; }
75 cat stdout
76
77 cat > exp <<'END'
78 PASS: foo.sh
79 PASS: zardoz.tap 1 - Daemon started
80 PASS: zardoz.tap 2 - Daemon responding
81 SKIP: zardoz.tap 3 - Daemon uses /proc # SKIP /proc is not mounted
82 PASS: zardoz.tap 4 - Daemon stopped
83 SKIP: bar.sh
84 PASS: mu.tap 1
85 XFAIL: mu.tap 2 # TODO frobnication not yet implemented
86 END
87
88 sed -n '/^PASS: foo\.sh/,/^XFAIL: mu\.tap/p' stdout > t
89 cat t
90 # Strip extra "informative" lines that could be printed by Solaris
91 # Distributed Make.
92 LC_ALL=C $EGREP -v ' --> ([0-9][0-9]* job|[Jj]ob output)' t > got
93
94 cat exp
95 cat got
96 diff exp got
97
98 :