xref: /freebsd/contrib/kyua/doc/kyua-debug.1.in (revision 6b8222793fbb4c0e162232716bc454dad31b709f)
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 March 25, 2025
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 -pause-before-cleanup-upon-fail
39.Op Fl -pause-before-cleanup
40.Op Fl -stdout Ar path
41.Op Fl -stderr Ar path
42.Ar test_case
43.Sh DESCRIPTION
44The
45.Nm
46command provides a mechanism to execute a single test case bypassing some
47of the Kyua infrastructure and allowing the user to poke into the execution
48behavior of the test.
49.Pp
50The test case to run is selected by providing a test filter, described below in
51.Sx Test filters ,
52that matches a single test case.
53The test case is executed and its result is printed as the last line of the
54output of the tool.
55.Pp
56The test executed by
57.Nm
58is run under a controlled environment as described in
59.Sx Test isolation .
60.Pp
61At the moment, the
62.Nm
63command allows the following aspects of a test case execution to be
64tweaked:
65.Bl -bullet
66.It
67Redirection of the test case's stdout and stderr to the console (the
68default) or to arbitrary files.
69See the
70.Fl -stdout
71and
72.Fl -stderr
73options below.
74.El
75.Pp
76The following subcommand options are recognized:
77.Bl -tag -width XX
78.It Fl -build-root Ar path
79Specifies the build root in which to find the test programs referenced
80by the Kyuafile, if different from the Kyuafile's directory.
81See
82.Sx Build directories
83below for more information.
84.It Fl -kyuafile Ar file , Fl k Ar file
85Specifies the Kyuafile to process.
86Defaults to
87.Pa Kyuafile
88file in the current directory.
89.It Fl -pause-before-cleanup-upon-fail , Fl p
90Causes Kyua to pause right before the test cleanup routine is invoked if the
91test fails.
92When paused, Kyua waits for input on stdin, and any key press resumes
93execution.
94.sp
95This can be useful for debugging system or end-to-end tests
96which alter the system by creating artifacts such as files, network
97interfaces, routing entries, firewall configuration, containers, etc.
98This flag makes it possible to preserve such artifacts immediately after a test
99failure, simplifying debugging.
100Otherwise, these artifacts would be removed by the test cleanup routine or
101by Kyua built-in cleanup mechanism.
102.It Fl -pause-before-cleanup
103The unconditional variant of the previous option.
104This can be helpful for reproducing the infrastructure or fixture of a passing
105test for further development or additional analysis.
106.It Fl -stderr Ar path
107Specifies the file to which to send the standard error of the test
108program's body.
109The default is
110.Pa /dev/stderr ,
111which is a special character device that redirects the output to
112standard error on the console.
113.It Fl -stdout Ar path
114Specifies the file to which to send the standard output of the test
115program's body.
116The default is
117.Pa /dev/stdout ,
118which is a special character device that redirects the output to
119standard output on the console.
120.El
121.Pp
122For example, consider the following Kyua session:
123.Bd -literal -offset indent
124$ kyua test
125kernel/fs:mkdir  ->  passed
126kernel/fs:rmdir  ->  failed: Invalid argument
127
1281/2 passed (1 failed)
129.Ed
130.Pp
131At this point, we do not have a lot of information regarding the
132failure of the
133.Sq kernel/fs:rmdir
134test.
135We can run this test through the
136.Nm
137command to inspect its output a bit closer, hoping that the test case is
138kind enough to log its progress:
139.Bd -literal -offset indent
140$ kyua debug kernel/fs:rmdir
141Trying rmdir('foo')
142Trying rmdir(NULL)
143kernel/fs:rmdir  ->  failed: Invalid argument
144.Ed
145.Pp
146Luckily, the offending test case was printing status lines as it
147progressed, so we could see the last attempted call and we can know match
148the failure message to the problem.
149.Ss Build directories
150__include__ build-root.mdoc COMMAND=debug
151.Ss Test filters
152__include__ test-filters.mdoc
153.Ss Test isolation
154__include__ test-isolation.mdoc
155.Sh EXIT STATUS
156The
157.Nm
158command returns 0 if the test case passes or 1 if the test case fails.
159.Pp
160Additional exit codes may be returned as described in
161.Xr kyua 1 .
162.Sh SEE ALSO
163.Xr kyua 1 ,
164.Xr kyuafile 5
165