1dnl
2dnl Automated Testing Framework (atf)
3dnl
4dnl Copyright (c) 2007 The NetBSD Foundation, Inc.
5dnl All rights reserved.
6dnl
7dnl Redistribution and use in source and binary forms, with or without
8dnl modification, are permitted provided that the following conditions
9dnl are met:
10dnl 1. Redistributions of source code must retain the above copyright
11dnl    notice, this list of conditions and the following disclaimer.
12dnl 2. Redistributions in binary form must reproduce the above copyright
13dnl    notice, this list of conditions and the following disclaimer in the
14dnl    documentation and/or other materials provided with the distribution.
15dnl
16dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28dnl
29
30AT_SETUP([atf-run: execution of tests])
31AT_TESTED(atf-run)
32
33m4_define([CREATE_PASS_TEST],
34[AT_CHECK([sed -e 's,@TC_NAME@,$2,g' <TEST_HELPER_NO_S(tp_pass)],
35           [0], [stdout], [])
36AT_CHECK([mv stdout $1], [0], [], [])
37AT_CHECK([chmod +x $1], [0], [], [])
38])
39
40m4_define([CREATE_FAIL_TEST],
41[AT_CHECK([sed -e 's,@TC_NAME@,$2,g' <TEST_HELPER_NO_S(tp_fail)],
42           [0], [stdout], [])
43AT_CHECK([mv stdout $1], [0], [], [])
44AT_CHECK([chmod +x $1], [0], [], [])
45])
46
47AT_CHECK([mkdir top], [0], [], [])
48AT_CHECK([mkdir top/dir1], [0], [], [])
49AT_CHECK([mkdir top/dir2], [0], [], [])
50AT_DATA([top/Atffile],
51[Content-Type: application/X-atf-atffile; version="1"
52
53prop: test-suite = atf
54
55tp: dir1
56tp: dir2
57tp: test1
58tp: test2
59])
60AT_DATA([top/dir1/Atffile],
61[Content-Type: application/X-atf-atffile; version="1"
62
63prop: test-suite = atf
64
65tp: test3
66])
67AT_DATA([top/dir2/Atffile],
68[Content-Type: application/X-atf-atffile; version="1"
69
70prop: test-suite = atf
71
72tp: test4
73tp: test5
74])
75CREATE_PASS_TEST([top/test1], [tc_1])
76CREATE_FAIL_TEST([top/test2], [tc_2])
77CREATE_PASS_TEST([top/dir1/test3], [tc_3])
78CREATE_FAIL_TEST([top/dir2/test4], [tc_4])
79CREATE_PASS_TEST([top/dir2/test5], [tc_5])
80
81AT_CHECK([cd top/dir1 && atf-run], [0], [stdout], [])
82CHECK_TPS_TCR(tc_3, passed, stdout)
83AT_CHECK([grep -i 'tc_@<:@1245@:>@' stdout], [1], [], [])
84AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
85AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])
86
87AT_CHECK([cd top/dir2 && atf-run], [1], [stdout], [stderr])
88CHECK_TPS_TCR(tc_4, failed, stdout)
89CHECK_TPS_TCR(tc_5, passed, stdout)
90AT_CHECK([grep -i 'tc_@<:@123@:>@' stdout], [1], [], [])
91AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
92AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])
93
94AT_CHECK([cd top && atf-run], [1], [stdout], [stderr])
95CHECK_TPS_TCR(tc_1, passed, stdout)
96CHECK_TPS_TCR(tc_2, failed, stdout)
97CHECK_TPS_TCR(tc_3, passed, stdout)
98CHECK_TPS_TCR(tc_4, failed, stdout)
99CHECK_TPS_TCR(tc_5, passed, stdout)
100AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
101AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])
102
103dnl Repeat previous but using a glob that matches everything.
104AT_DATA([top/Atffile],
105[Content-Type: application/X-atf-atffile; version="1"
106
107prop: test-suite = atf
108
109tp-glob: *
110])
111AT_CHECK([cd top && atf-run], [1], [stdout], [stderr])
112CHECK_TPS_TCR(tc_1, passed, stdout)
113CHECK_TPS_TCR(tc_2, failed, stdout)
114CHECK_TPS_TCR(tc_3, passed, stdout)
115CHECK_TPS_TCR(tc_4, failed, stdout)
116CHECK_TPS_TCR(tc_5, passed, stdout)
117AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
118AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])
119
120dnl Repeat previous but using a glob that matches directories only.
121AT_DATA([top/Atffile],
122[Content-Type: application/X-atf-atffile; version="1"
123
124prop: test-suite = atf
125
126tp-glob: d*
127])
128AT_CHECK([cd top && atf-run], [1], [stdout], [stderr])
129CHECK_TPS_TCR(tc_3, passed, stdout)
130CHECK_TPS_TCR(tc_4, failed, stdout)
131CHECK_TPS_TCR(tc_5, passed, stdout)
132AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
133AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])
134
135dnl Make sure globs do not match non-executable nor hidden files.
136dnl XXX This is not really part of the bootstrap test suite.  Move to
137dnl tests/atf/tools/t_atf_run.sh when it exists.
138AT_CHECK([rm -rf top], [0], [], [])
139AT_CHECK([mkdir top], [0], [], [])
140CREATE_PASS_TEST([top/test1], [tc_1])
141CREATE_PASS_TEST([top/test2], [tc_2])
142CREATE_PASS_TEST([top/test3], [tc_3])
143AT_CHECK([chmod -x top/test3], [0], [], [])
144CREATE_PASS_TEST([top/.test4], [tc_4])
145AT_CHECK([chmod -x top/.test4], [0], [], [])
146AT_DATA([top/Atffile],
147[Content-Type: application/X-atf-atffile; version="1"
148
149prop: test-suite = atf
150
151tp-glob: *
152])
153AT_CHECK([cd top && atf-run], [0], [stdout], [stderr])
154CHECK_TPS_TCR(tc_1, passed, stdout)
155CHECK_TPS_TCR(tc_2, passed, stdout)
156AT_CHECK([grep -i 'tc_3' stdout], [1], [ignore], [])
157AT_CHECK([grep -i 'tc_4' stdout], [1], [ignore], [])
158
159dnl Run all test cases from a test program.
160AT_CHECK([rm -rf top], [0], [], [])
161AT_CHECK([mkdir top], [0], [], [])
162AT_CHECK([cp TEST_HELPER_NO_S(tp_basic_sh) top])
163AT_DATA([top/Atffile],
164[Content-Type: application/X-atf-atffile; version="1"
165
166prop: test-suite = atf
167
168tp: h_tp_basic_sh
169])
170AT_CHECK([cd top && atf-run], [1], [stdout], [stderr])
171CHECK_TPS_TCR(pass, passed, stdout)
172CHECK_TPS_TCR(fail, failed, stdout)
173CHECK_TPS_TCR(skip, skipped, stdout)
174CHECK_TPS_TCR(default, passed, stdout)
175
176AT_CLEANUP()
177
178dnl vim: syntax=m4:expandtab:shiftwidth=4:softtabstop=4
179