]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/kyua/doc/kyua-debug.1
Follow up to r359385
[FreeBSD/FreeBSD.git] / contrib / kyua / doc / kyua-debug.1
1 .\" Copyright 2012 The Kyua Authors.
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions are
6 .\" met:
7 .\"
8 .\" * Redistributions of source code must retain the above copyright
9 .\"   notice, this list of conditions and the following disclaimer.
10 .\" * Redistributions in binary form must reproduce the above copyright
11 .\"   notice, this list of conditions and the following disclaimer in the
12 .\"   documentation and/or other materials provided with the distribution.
13 .\" * Neither the name of Google Inc. nor the names of its contributors
14 .\"   may be used to endorse or promote products derived from this software
15 .\"   without specific prior written permission.
16 .\"
17 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 .Dd October 13, 2014
29 .Dt KYUA-DEBUG 1
30 .Os
31 .Sh NAME
32 .Nm "kyua debug"
33 .Nd Executes a single test case with facilities for debugging
34 .Sh SYNOPSIS
35 .Nm
36 .Op Fl -build-root Ar path
37 .Op Fl -kyuafile Ar file
38 .Op Fl -stdout Ar path
39 .Op Fl -stderr Ar path
40 .Ar test_case
41 .Sh DESCRIPTION
42 The
43 .Nm
44 command provides a mechanism to execute a single test case bypassing some
45 of the Kyua infrastructure and allowing the user to poke into the execution
46 behavior of the test.
47 .Pp
48 The test case to run is selected by providing a test filter, described below in
49 .Sx Test filters ,
50 that matches a single test case.
51 The test case is executed and its result is printed as the last line of the
52 output of the tool.
53 .Pp
54 The test executed by
55 .Nm
56 is run under a controlled environment as described in
57 .Sx Test isolation .
58 .Pp
59 At the moment, the
60 .Nm
61 command allows the following aspects of a test case execution to be
62 tweaked:
63 .Bl -bullet
64 .It
65 Redirection of the test case's stdout and stderr to the console (the
66 default) or to arbitrary files.
67 See the
68 .Fl -stdout
69 and
70 .Fl -stderr
71 options below.
72 .El
73 .Pp
74 The following subcommand options are recognized:
75 .Bl -tag -width XX
76 .It Fl -build-root Ar path
77 Specifies the build root in which to find the test programs referenced
78 by the Kyuafile, if different from the Kyuafile's directory.
79 See
80 .Sx Build directories
81 below for more information.
82 .It Fl -kyuafile Ar file , Fl k Ar file
83 Specifies the Kyuafile to process.
84 Defaults to
85 .Pa Kyuafile
86 file in the current directory.
87 .It Fl -stderr Ar path
88 Specifies the file to which to send the standard error of the test
89 program's body.
90 The default is
91 .Pa /dev/stderr ,
92 which is a special character device that redirects the output to
93 standard error on the console.
94 .It Fl -stdout Ar path
95 Specifies the file to which to send the standard output of the test
96 program's body.
97 The default is
98 .Pa /dev/stdout ,
99 which is a special character device that redirects the output to
100 standard output on the console.
101 .El
102 .Pp
103 For example, consider the following Kyua session:
104 .Bd -literal -offset indent
105 $ kyua test
106 kernel/fs:mkdir  ->  passed
107 kernel/fs:rmdir  ->  failed: Invalid argument
108
109 1/2 passed (1 failed)
110 .Ed
111 .Pp
112 At this point, we do not have a lot of information regarding the
113 failure of the
114 .Sq kernel/fs:rmdir
115 test.
116 We can run this test through the
117 .Nm
118 command to inspect its output a bit closer, hoping that the test case is
119 kind enough to log its progress:
120 .Bd -literal -offset indent
121 $ kyua debug kernel/fs:rmdir
122 Trying rmdir('foo')
123 Trying rmdir(NULL)
124 kernel/fs:rmdir  ->  failed: Invalid argument
125 .Ed
126 .Pp
127 Luckily, the offending test case was printing status lines as it
128 progressed, so we could see the last attempted call and we can know match
129 the failure message to the problem.
130 .Ss Build directories
131 .\" Copyright 2012 The Kyua Authors.
132 .\" All rights reserved.
133 .\"
134 .\" Redistribution and use in source and binary forms, with or without
135 .\" modification, are permitted provided that the following conditions are
136 .\" met:
137 .\"
138 .\" * Redistributions of source code must retain the above copyright
139 .\"   notice, this list of conditions and the following disclaimer.
140 .\" * Redistributions in binary form must reproduce the above copyright
141 .\"   notice, this list of conditions and the following disclaimer in the
142 .\"   documentation and/or other materials provided with the distribution.
143 .\" * Neither the name of Google Inc. nor the names of its contributors
144 .\"   may be used to endorse or promote products derived from this software
145 .\"   without specific prior written permission.
146 .\"
147 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
148 .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
149 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
150 .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
151 .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
152 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
153 .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
154 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
155 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
156 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
157 .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
158 .Em Build directories
159 (or object directories, target directories, product directories, etc.) is
160 the concept that allows a developer to keep the source tree clean from
161 build products by asking the build system to place such build products
162 under a separate subtree.
163 .Pp
164 Most build systems today support build directories.
165 For example, the GNU Automake/Autoconf build system exposes such concept when
166 invoked as follows:
167 .Bd -literal -offset indent
168 $ cd my-project-1.0
169 $ mkdir build
170 $ cd build
171 $ ../configure
172 $ make
173 .Ed
174 .Pp
175 Under such invocation, all the results of the build are left in the
176 .Pa my-project-1.0/build/
177 subdirectory while maintaining the contents of
178 .Pa my-project-1.0/
179 intact.
180 .Pp
181 Because build directories are an integral part of most build systems, and
182 because they are a tool that developers use frequently,
183 .Nm
184 supports build directories too.
185 This manifests in the form of
186 .Nm
187 being able to run tests from build directories while reading the (often
188 immutable) test suite definition from the source tree.
189 .Pp
190 One important property of build directories is that they follow (or need to
191 follow) the exact same layout as the source tree.
192 For example, consider the following directory listings:
193 .Bd -literal -offset indent
194 src/Kyuafile
195 src/bin/ls/
196 src/bin/ls/Kyuafile
197 src/bin/ls/ls.c
198 src/bin/ls/ls_test.c
199 src/sbin/su/
200 src/sbin/su/Kyuafile
201 src/sbin/su/su.c
202 src/sbin/su/su_test.c
203
204 obj/bin/ls/
205 obj/bin/ls/ls*
206 obj/bin/ls/ls_test*
207 obj/sbin/su/
208 obj/sbin/su/su*
209 obj/sbin/su/su_test*
210 .Ed
211 .Pp
212 Note how the directory layout within
213 .Pa src/
214 matches that of
215 .Pa obj/ .
216 The
217 .Pa src/
218 directory contains only source files and the definition of the test suite
219 (the Kyuafiles), while the
220 .Pa obj/
221 directory contains only the binaries generated during a build.
222 .Pp
223 All commands that deal with the workspace support the
224 .Fl -build-root Ar path
225 option.
226 When this option is provided, the directory specified by the
227 option is considered to be the root of the build directory.
228 For example, considering our previous fake tree layout, we could invoke
229 .Nm
230 as any of the following:
231 .Bd -literal -offset indent
232 $ kyua debug --kyuafile=src/Kyuafile --build-root=obj
233 $ cd src && kyua debug --build-root=../obj
234 .Ed
235 .Ss Test filters
236 .\" Copyright 2012 The Kyua Authors.
237 .\" All rights reserved.
238 .\"
239 .\" Redistribution and use in source and binary forms, with or without
240 .\" modification, are permitted provided that the following conditions are
241 .\" met:
242 .\"
243 .\" * Redistributions of source code must retain the above copyright
244 .\"   notice, this list of conditions and the following disclaimer.
245 .\" * Redistributions in binary form must reproduce the above copyright
246 .\"   notice, this list of conditions and the following disclaimer in the
247 .\"   documentation and/or other materials provided with the distribution.
248 .\" * Neither the name of Google Inc. nor the names of its contributors
249 .\"   may be used to endorse or promote products derived from this software
250 .\"   without specific prior written permission.
251 .\"
252 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
253 .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
254 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
255 .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
256 .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
257 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
258 .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
259 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
260 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
261 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262 .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
263 A
264 .Em test filter
265 is a string that is used to match test cases or test programs in a test suite.
266 Filters have the following form:
267 .Bd -literal -offset indent
268 test_program_name[:test_case_name]
269 .Ed
270 .Pp
271 Where
272 .Sq test_program_name
273 is the name of a test program or a subdirectory in the test suite, and
274 .Sq test_case_name
275 is the name of a test case.
276 .Ss Test isolation
277 .\" Copyright 2014 The Kyua Authors.
278 .\" All rights reserved.
279 .\"
280 .\" Redistribution and use in source and binary forms, with or without
281 .\" modification, are permitted provided that the following conditions are
282 .\" met:
283 .\"
284 .\" * Redistributions of source code must retain the above copyright
285 .\"   notice, this list of conditions and the following disclaimer.
286 .\" * Redistributions in binary form must reproduce the above copyright
287 .\"   notice, this list of conditions and the following disclaimer in the
288 .\"   documentation and/or other materials provided with the distribution.
289 .\" * Neither the name of Google Inc. nor the names of its contributors
290 .\"   may be used to endorse or promote products derived from this software
291 .\"   without specific prior written permission.
292 .\"
293 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
294 .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
295 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
296 .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
297 .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
298 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
299 .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
300 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
301 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
302 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
303 .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
304 The test programs and test cases run by
305 .Nm
306 are all executed in a deterministic environment.
307 This known, clean environment serves to make the test execution as
308 reproducible as possible and also to prevent clashes between tests that may,
309 for example, create auxiliary files with overlapping names.
310 .Pp
311 For plain test programs and for TAP test programs, the whole test program
312 is run under a single instance of the environment described in this page.
313 For ATF test programs (see
314 .Xr atf 7 ) ,
315 each individual test case
316 .Em and
317 test cleanup routine are executed in separate environments.
318 .Bl -tag -width XX
319 .It Process space
320 Each test is executed in an independent processes.
321 Corollary: the test can do whatever it wants to the current process (such
322 as modify global variables) without having to undo such changes.
323 .It Session and process group
324 The test is executed in its own session and its own process group.
325 There is no controlling terminal attached to the session.
326 .Pp
327 Should the test spawn any children, the children should maintain the same
328 session and process group.
329 Modifying any of these settings prevents
330 .Nm
331 from being able to kill any stray subprocess as part of the cleanup phase.
332 If modifying these settings is necessary, or if any subprocess started by
333 the test decides to use a different process group or session, it is the
334 responsibility of the test to ensure those subprocesses are forcibly
335 terminated during cleanup.
336 .It Work directory
337 The test is executed in a temporary directory automatically created by the
338 runtime engine.
339 Corollary: the test can write to its current directory
340 without needing to clean any files and/or directories it creates.
341 The runtime engine takes care to recursively delete the temporary directories
342 after the execution of a test case.
343 Any file systems mounted within the temporary directory are also unmounted.
344 .It Home directory
345 The
346 .Va HOME
347 environment variable is set to the absolute path of the work directory.
348 .It Umask
349 The value of the umask is set to 0022.
350 .It Environment
351 The
352 .Va LANG ,
353 .Va LC_ALL ,
354 .Va LC_COLLATE ,
355 .Va LC_CTYPE ,
356 .Va LC_MESSAGES ,
357 .Va LC_MONETARY ,
358 .Va LC_NUMERIC
359 and
360 .Va LC_TIME
361 variables are unset.
362 .Pp
363 The
364 .Va TZ
365 variable is set to
366 .Sq UTC .
367 .Pp
368 The
369 .Va TMPDIR
370 variable is set to the absolute path of the work directory.
371 This is to prevent the test from mistakenly using a temporary directory
372 outside of the automatically-managed work directory, should the test use the
373 .Xr mktemp 3
374 familiy of functions.
375 .It Process limits
376 The maximum soft core size limit is raised to its corresponding hard limit.
377 This is a simple, best-effort attempt at allowing tests to dump core for
378 further diagnostic purposes.
379 .It Configuration varibles
380 The test engine may pass run-time configuration variables to the test program
381 via the environment.
382 The name of the configuration variable is prefixed with
383 .Sq TEST_ENV_
384 so that a configuration variable of the form
385 .Sq foo=bar
386 becomes accessible in the environment as
387 .Sq TEST_ENV_foo=bar .
388 .El
389 .Sh EXIT STATUS
390 The
391 .Nm
392 command returns 0 if the test case passes or 1 if the test case fails.
393 .Pp
394 Additional exit codes may be returned as described in
395 .Xr kyua 1 .
396 .Sh SEE ALSO
397 .Xr kyua 1 ,
398 .Xr kyuafile 5