summaryrefslogtreecommitdiffstats
path: root/unit/atf-src/bootstrap/t_atf_run.at
blob: db09deb2cd24d0d992f9750a0616b1f35c7626f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
dnl
dnl Automated Testing Framework (atf)
dnl
dnl Copyright (c) 2007 The NetBSD Foundation, Inc.
dnl All rights reserved.
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions
dnl are met:
dnl 1. Redistributions of source code must retain the above copyright
dnl    notice, this list of conditions and the following disclaimer.
dnl 2. Redistributions in binary form must reproduce the above copyright
dnl    notice, this list of conditions and the following disclaimer in the
dnl    documentation and/or other materials provided with the distribution.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dnl

AT_SETUP([atf-run: execution of tests])
AT_TESTED(atf-run)

m4_define([CREATE_PASS_TEST],
[AT_CHECK([sed -e 's,@TC_NAME@,$2,g' <TEST_HELPER_NO_S(tp_pass)],
           [0], [stdout], [])
AT_CHECK([mv stdout $1], [0], [], [])
AT_CHECK([chmod +x $1], [0], [], [])
])

m4_define([CREATE_FAIL_TEST],
[AT_CHECK([sed -e 's,@TC_NAME@,$2,g' <TEST_HELPER_NO_S(tp_fail)],
           [0], [stdout], [])
AT_CHECK([mv stdout $1], [0], [], [])
AT_CHECK([chmod +x $1], [0], [], [])
])

AT_CHECK([mkdir top], [0], [], [])
AT_CHECK([mkdir top/dir1], [0], [], [])
AT_CHECK([mkdir top/dir2], [0], [], [])
AT_DATA([top/Atffile],
[Content-Type: application/X-atf-atffile; version="1"

prop: test-suite = atf

tp: dir1
tp: dir2
tp: test1
tp: test2
])
AT_DATA([top/dir1/Atffile],
[Content-Type: application/X-atf-atffile; version="1"

prop: test-suite = atf

tp: test3
])
AT_DATA([top/dir2/Atffile],
[Content-Type: application/X-atf-atffile; version="1"

prop: test-suite = atf

tp: test4
tp: test5
])
CREATE_PASS_TEST([top/test1], [tc_1])
CREATE_FAIL_TEST([top/test2], [tc_2])
CREATE_PASS_TEST([top/dir1/test3], [tc_3])
CREATE_FAIL_TEST([top/dir2/test4], [tc_4])
CREATE_PASS_TEST([top/dir2/test5], [tc_5])

AT_CHECK([cd top/dir1 && atf-run], [0], [stdout], [])
CHECK_TPS_TCR(tc_3, passed, stdout)
AT_CHECK([grep -i 'tc_@<:@1245@:>@' stdout], [1], [], [])
AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])

AT_CHECK([cd top/dir2 && atf-run], [1], [stdout], [stderr])
CHECK_TPS_TCR(tc_4, failed, stdout)
CHECK_TPS_TCR(tc_5, passed, stdout)
AT_CHECK([grep -i 'tc_@<:@123@:>@' stdout], [1], [], [])
AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])

AT_CHECK([cd top && atf-run], [1], [stdout], [stderr])
CHECK_TPS_TCR(tc_1, passed, stdout)
CHECK_TPS_TCR(tc_2, failed, stdout)
CHECK_TPS_TCR(tc_3, passed, stdout)
CHECK_TPS_TCR(tc_4, failed, stdout)
CHECK_TPS_TCR(tc_5, passed, stdout)
AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])

dnl Repeat previous but using a glob that matches everything.
AT_DATA([top/Atffile],
[Content-Type: application/X-atf-atffile; version="1"

prop: test-suite = atf

tp-glob: *
])
AT_CHECK([cd top && atf-run], [1], [stdout], [stderr])
CHECK_TPS_TCR(tc_1, passed, stdout)
CHECK_TPS_TCR(tc_2, failed, stdout)
CHECK_TPS_TCR(tc_3, passed, stdout)
CHECK_TPS_TCR(tc_4, failed, stdout)
CHECK_TPS_TCR(tc_5, passed, stdout)
AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])

dnl Repeat previous but using a glob that matches directories only.
AT_DATA([top/Atffile],
[Content-Type: application/X-atf-atffile; version="1"

prop: test-suite = atf

tp-glob: d*
])
AT_CHECK([cd top && atf-run], [1], [stdout], [stderr])
CHECK_TPS_TCR(tc_3, passed, stdout)
CHECK_TPS_TCR(tc_4, failed, stdout)
CHECK_TPS_TCR(tc_5, passed, stdout)
AT_CHECK([grep 'tc-so:ignore-me' stdout], [0], [ignore], [])
AT_CHECK([grep 'tc-se:ignore-me' stdout], [0], [ignore], [])

dnl Make sure globs do not match non-executable nor hidden files.
dnl XXX This is not really part of the bootstrap test suite.  Move to
dnl tests/atf/tools/t_atf_run.sh when it exists.
AT_CHECK([rm -rf top], [0], [], [])
AT_CHECK([mkdir top], [0], [], [])
CREATE_PASS_TEST([top/test1], [tc_1])
CREATE_PASS_TEST([top/test2], [tc_2])
CREATE_PASS_TEST([top/test3], [tc_3])
AT_CHECK([chmod -x top/test3], [0], [], [])
CREATE_PASS_TEST([top/.test4], [tc_4])
AT_CHECK([chmod -x top/.test4], [0], [], [])
AT_DATA([top/Atffile],
[Content-Type: application/X-atf-atffile; version="1"

prop: test-suite = atf

tp-glob: *
])
AT_CHECK([cd top && atf-run], [0], [stdout], [stderr])
CHECK_TPS_TCR(tc_1, passed, stdout)
CHECK_TPS_TCR(tc_2, passed, stdout)
AT_CHECK([grep -i 'tc_3' stdout], [1], [ignore], [])
AT_CHECK([grep -i 'tc_4' stdout], [1], [ignore], [])

dnl Run all test cases from a test program.
AT_CHECK([rm -rf top], [0], [], [])
AT_CHECK([mkdir top], [0], [], [])
AT_CHECK([cp TEST_HELPER_NO_S(tp_basic_sh) top])
AT_DATA([top/Atffile],
[Content-Type: application/X-atf-atffile; version="1"

prop: test-suite = atf

tp: h_tp_basic_sh
])
AT_CHECK([cd top && atf-run], [1], [stdout], [stderr])
CHECK_TPS_TCR(pass, passed, stdout)
CHECK_TPS_TCR(fail, failed, stdout)
CHECK_TPS_TCR(skip, skipped, stdout)
CHECK_TPS_TCR(default, passed, stdout)

AT_CLEANUP()

dnl vim: syntax=m4:expandtab:shiftwidth=4:softtabstop=4