2 dnl Automated Testing Framework (atf)
4 dnl Copyright (c) 2007, 2008 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 dnl XXX The 9 number used below is a hack used to simplify these tests.
34 dnl The correct fix could be to make the auxiliary test programs be real
35 dnl test programs instead of two-liners creted from here.
37 m4_define([CREATE_PASS_TEST],
39 #! @S|@(atf-config -t atf_shell)
40 echo "Content-Type: application/X-atf-tcs; version=\"1\"" >&9
42 echo 'tcs-count: 1' >&9
43 echo 'tc-start: $2' >&9
46 echo 'tc-end: $2, passed' >&9
49 AT_CHECK([chmod +x $1], [0], [], [])
52 m4_define([CREATE_FAIL_TEST],
54 #! @S|@(atf-config -t atf_shell)
55 echo "Content-Type: application/X-atf-tcs; version=\"1\"" >&9
57 echo 'tcs-count: 1' >&9
58 echo 'tc-start: $2' >&9
61 echo 'tc-end: $2, failed, No reason' >&9
64 AT_CHECK([chmod +x $1], [0], [], [])
67 AT_CHECK([mkdir top], [0], [], [])
68 AT_CHECK([mkdir top/dir1], [0], [], [])
69 AT_CHECK([mkdir top/dir2], [0], [], [])
70 AT_DATA([top/Atffile],
71 [Content-Type: application/X-atf-atffile; version="1"
73 prop: test-suite = atf
80 AT_DATA([top/dir1/Atffile],
81 [Content-Type: application/X-atf-atffile; version="1"
83 prop: test-suite = atf
87 AT_DATA([top/dir2/Atffile],
88 [Content-Type: application/X-atf-atffile; version="1"
90 prop: test-suite = atf
95 CREATE_PASS_TEST([top/test1], [tc_1])
96 CREATE_FAIL_TEST([top/test2], [tc_2])
97 CREATE_PASS_TEST([top/dir1/test3], [tc_3])
98 CREATE_FAIL_TEST([top/dir2/test4], [tc_4])
99 CREATE_PASS_TEST([top/dir2/test5], [tc_5])
101 AT_CHECK([cd top/dir1 && atf-run], [0], [stdout], [])
102 CHECK_TPS_TCR(tc_3, passed, stdout)
103 AT_CHECK([grep -i 'tc_@<:@1245@:>@' stdout], [1], [], [])
104 AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
105 AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])
107 AT_CHECK([cd top/dir2 && atf-run], [1], [stdout], [stderr])
108 CHECK_TPS_TCR(tc_4, failed, stdout)
109 CHECK_TPS_TCR(tc_5, passed, stdout)
110 AT_CHECK([grep -i 'tc_@<:@123@:>@' stdout], [1], [], [])
111 AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
112 AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])
114 AT_CHECK([cd top && atf-run], [1], [stdout], [stderr])
115 CHECK_TPS_TCR(tc_1, passed, stdout)
116 CHECK_TPS_TCR(tc_2, failed, stdout)
117 CHECK_TPS_TCR(tc_3, passed, stdout)
118 CHECK_TPS_TCR(tc_4, failed, stdout)
119 CHECK_TPS_TCR(tc_5, passed, stdout)
120 AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
121 AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])
123 dnl Repeat previous but using a glob that matches everything.
124 AT_DATA([top/Atffile],
125 [Content-Type: application/X-atf-atffile; version="1"
127 prop: test-suite = atf
131 AT_CHECK([cd top && atf-run], [1], [stdout], [stderr])
132 CHECK_TPS_TCR(tc_1, passed, stdout)
133 CHECK_TPS_TCR(tc_2, failed, stdout)
134 CHECK_TPS_TCR(tc_3, passed, stdout)
135 CHECK_TPS_TCR(tc_4, failed, stdout)
136 CHECK_TPS_TCR(tc_5, passed, stdout)
137 AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
138 AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])
140 dnl Repeat previous but using a glob that matches directories only.
141 AT_DATA([top/Atffile],
142 [Content-Type: application/X-atf-atffile; version="1"
144 prop: test-suite = atf
148 AT_CHECK([cd top && atf-run], [1], [stdout], [stderr])
149 CHECK_TPS_TCR(tc_3, passed, stdout)
150 CHECK_TPS_TCR(tc_4, failed, stdout)
151 CHECK_TPS_TCR(tc_5, passed, stdout)
152 AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
153 AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])
155 dnl Make sure globs do not match non-executatble nor hidden files.
156 dnl XXX This is not really part of the bootstrap test suite. Move to
157 dnl tests/atf/tools/t_atf_run.sh when it exists.
158 AT_CHECK([rm -rf top], [0], [], [])
159 AT_CHECK([mkdir top], [0], [], [])
160 CREATE_PASS_TEST([top/test1], [tc_1])
161 CREATE_PASS_TEST([top/test2], [tc_2])
162 CREATE_PASS_TEST([top/test3], [tc_3])
163 AT_CHECK([chmod -x top/test3], [0], [], [])
164 CREATE_PASS_TEST([top/.test4], [tc_4])
165 AT_CHECK([chmod -x top/.test4], [0], [], [])
166 AT_DATA([top/Atffile],
167 [Content-Type: application/X-atf-atffile; version="1"
169 prop: test-suite = atf
173 AT_CHECK([cd top && atf-run], [0], [stdout], [stderr])
174 CHECK_TPS_TCR(tc_1, passed, stdout)
175 CHECK_TPS_TCR(tc_2, passed, stdout)
176 AT_CHECK([grep -i 'tc_3' stdout], [1], [ignore], [])
177 AT_CHECK([grep -i 'tc_4' stdout], [1], [ignore], [])
181 dnl vim: syntax=m4:expandtab:shiftwidth=4:softtabstop=4