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