xref: /illumos-gate/usr/src/man/man8/ktest.8 (revision 6e4a39cc9c0ca330a6d67580711b9a9d3c37df37)
108855964SRyan Zezeski.\"
208855964SRyan Zezeski.\" This file and its contents are supplied under the terms of the
308855964SRyan Zezeski.\" Common Development and Distribution License ("CDDL"), version 1.0.
408855964SRyan Zezeski.\" You may only use this file in accordance with the terms of version
508855964SRyan Zezeski.\" 1.0 of the CDDL.
608855964SRyan Zezeski.\"
708855964SRyan Zezeski.\" A full copy of the text of the CDDL should have accompanied this
808855964SRyan Zezeski.\" source.  A copy of the CDDL is also available via the Internet at
908855964SRyan Zezeski.\" http://www.illumos.org/license/CDDL.
1008855964SRyan Zezeski.\"
1108855964SRyan Zezeski.\"
12*6e4a39ccSPatrick Mooney.\" Copyright 2025 Oxide Computer Company
1308855964SRyan Zezeski.\"
14*6e4a39ccSPatrick Mooney.Dd February 12, 2025
1508855964SRyan Zezeski.Dt KTEST 8
1608855964SRyan Zezeski.Os
1708855964SRyan Zezeski.Sh NAME
1808855964SRyan Zezeski.Nm ktest
1908855964SRyan Zezeski.Nd list and run kernel tests
2008855964SRyan Zezeski.Sh SYNOPSIS
2108855964SRyan Zezeski.Nm ktest Cm help
2208855964SRyan Zezeski.Pp
23*6e4a39ccSPatrick Mooney.Nm Cm list
2408855964SRyan Zezeski.Op Fl H
2508855964SRyan Zezeski.Op Oo Fl p Oc Fl o Ar field Ns Op ,...
2608855964SRyan Zezeski.Op Ar triple...
2708855964SRyan Zezeski.Pp
28*6e4a39ccSPatrick Mooney.Nm Cm run
2908855964SRyan Zezeski.Op Fl H
30*6e4a39ccSPatrick Mooney.Op Fl n
3108855964SRyan Zezeski.Op Oo Fl p Oc Fl o Ar field Ns Op ,...
3208855964SRyan Zezeski.Op -i Ar input
3308855964SRyan Zezeski.Ar triple...
3408855964SRyan Zezeski.Pp
35*6e4a39ccSPatrick Mooney.Nm Cm load
36*6e4a39ccSPatrick Mooney.Op Fl a
37*6e4a39ccSPatrick Mooney.Op Ar name
38*6e4a39ccSPatrick Mooney.Nm Cm unload
39*6e4a39ccSPatrick Mooney.Op Fl a
40*6e4a39ccSPatrick Mooney.Op Ar name
4108855964SRyan Zezeski.Sh DESCRIPTION
4208855964SRyan ZezeskiThe
4308855964SRyan Zezeski.Nm
4408855964SRyan Zezeskifacility provides in situ kernel testing by running test code in
4508855964SRyan Zezeskikernel context; essentially unit tests for the kernel.
4608855964SRyan ZezeskiThe
4708855964SRyan Zezeski.Nm
4808855964SRyan Zezeskicommand is used to list or run registered kernel tests.
4908855964SRyan ZezeskiThe
5008855964SRyan Zezeski.Nm
5108855964SRyan Zezeskicommand interacts with the in-kernel ktest facility by way of the
5208855964SRyan Zezeski.Pa /dev/ktest
5308855964SRyan Zezeskipseudo device.
5408855964SRyan ZezeskiA process must run in the Global Zone and have the
5508855964SRyan Zezeski.Sy PRIV_SYS_DEVICES
5608855964SRyan Zezeskiprivilege in order to access the device.
57*6e4a39ccSPatrick Mooney.Sh SUBCOMMANDS
58*6e4a39ccSPatrick Mooney.Nm ktest help
59*6e4a39ccSPatrick Mooney.Bd -ragged -offset 2m
60*6e4a39ccSPatrick MooneyPrint command usage.
61*6e4a39ccSPatrick Mooney.Ed
62*6e4a39ccSPatrick Mooney.Pp
63*6e4a39ccSPatrick MooneyThe
64*6e4a39ccSPatrick Mooney.Cm list
65*6e4a39ccSPatrick Mooneyand
66*6e4a39ccSPatrick Mooney.Cm run
67*6e4a39ccSPatrick Mooneysubcommands share the options described in
68*6e4a39ccSPatrick Mooney.Sx OUTPUT OPTIONS .
69*6e4a39ccSPatrick Mooney.Pp
70*6e4a39ccSPatrick Mooney.Nm Cm list
71*6e4a39ccSPatrick Mooney.Op Fl H
72*6e4a39ccSPatrick Mooney.Op Oo Fl p Oc Fl o Ar field Ns Op ,...
73*6e4a39ccSPatrick Mooney.Op Ar triple...
74*6e4a39ccSPatrick Mooney.Bd -ragged -offset 2m
75*6e4a39ccSPatrick MooneyList all registered tests.
76*6e4a39ccSPatrick MooneyOne or more triples may be specified to narrow the listing.
77*6e4a39ccSPatrick Mooney.Pp
78*6e4a39ccSPatrick Mooney.Ed
79*6e4a39ccSPatrick Mooney.Pp
80*6e4a39ccSPatrick Mooney.Nm Cm run
81*6e4a39ccSPatrick Mooney.Op Fl H
82*6e4a39ccSPatrick Mooney.Op Fl n
83*6e4a39ccSPatrick Mooney.Op Oo Fl p Oc Fl o Ar field Ns Op ,...
84*6e4a39ccSPatrick Mooney.Op Fl i Ar file
85*6e4a39ccSPatrick Mooney.Ar triple...
86*6e4a39ccSPatrick Mooney.Bd -ragged -offset 2m
87*6e4a39ccSPatrick MooneyRun registered tests.
88*6e4a39ccSPatrick MooneyOne or more triples may be specified to limit which tests are run.
89*6e4a39ccSPatrick MooneyAt least one triple must be specified.
90*6e4a39ccSPatrick Mooney.Bl -tag -width Ds
91*6e4a39ccSPatrick Mooney.It Fl i Ar file
92*6e4a39ccSPatrick MooneySpecify a
93*6e4a39ccSPatrick Mooney.Ar file
94*6e4a39ccSPatrick Mooneyto act as the input stream for all tests requiring one.
95*6e4a39ccSPatrick Mooney.It Fl n
96*6e4a39ccSPatrick MooneyOmit tests which require input when none provided via
97*6e4a39ccSPatrick Mooney.Fl i .
98*6e4a39ccSPatrick Mooney.El
99*6e4a39ccSPatrick Mooney.Ed
100*6e4a39ccSPatrick Mooney.Pp
101*6e4a39ccSPatrick Mooney.Nm Cm load
102*6e4a39ccSPatrick Mooney.Op Fl a
103*6e4a39ccSPatrick Mooney.Op Ar name
104*6e4a39ccSPatrick Mooney.Bd -ragged -offset 2m
105*6e4a39ccSPatrick MooneyLoad one or more ktest modules to make their tests available to
106*6e4a39ccSPatrick Mooney.Cm list
107*6e4a39ccSPatrick Mooneyand
108*6e4a39ccSPatrick Mooney.Cm run .
109*6e4a39ccSPatrick Mooney.Bl -tag -width Ds
110*6e4a39ccSPatrick Mooney.It Fl a
111*6e4a39ccSPatrick MooneyLoad all available modules
112*6e4a39ccSPatrick Mooney.It Ar name
113*6e4a39ccSPatrick MooneyLoad a specific module
114*6e4a39ccSPatrick Mooney.El
115*6e4a39ccSPatrick Mooney.Ed
116*6e4a39ccSPatrick Mooney.Pp
117*6e4a39ccSPatrick Mooney.Nm Cm unload
118*6e4a39ccSPatrick Mooney.Op Fl a
119*6e4a39ccSPatrick Mooney.Op Ar name
120*6e4a39ccSPatrick Mooney.Bd -ragged -offset 2m
121*6e4a39ccSPatrick MooneyUnload one or more ktest modules.
122*6e4a39ccSPatrick Mooney.Bl -tag -width Ds
123*6e4a39ccSPatrick Mooney.It Fl a
124*6e4a39ccSPatrick MooneyUnload all modules
125*6e4a39ccSPatrick Mooney.It Ar name
126*6e4a39ccSPatrick MooneyUnoad a specific module
127*6e4a39ccSPatrick Mooney.El
128*6e4a39ccSPatrick Mooney.Ed
129*6e4a39ccSPatrick Mooney.Sh OUTPUT
130*6e4a39ccSPatrick MooneyAvailable tests and the results of running said tests are emitted by the
131*6e4a39ccSPatrick Mooney.Cm list
132*6e4a39ccSPatrick Mooneyand
133*6e4a39ccSPatrick Mooney.Cm run
134*6e4a39ccSPatrick Mooneycommands, respectively.
135*6e4a39ccSPatrick Mooney.Ss OPTIONS
136*6e4a39ccSPatrick MooneyOutput from the
137*6e4a39ccSPatrick Mooney.Cm list
138*6e4a39ccSPatrick Mooneyand
139*6e4a39ccSPatrick Mooney.Cm run
140*6e4a39ccSPatrick Mooneycommands is controlled by the following options:
141*6e4a39ccSPatrick Mooney.Bl -tag -width Ar
142*6e4a39ccSPatrick Mooney.It Fl H
143*6e4a39ccSPatrick MooneyOmit column headers when printing output.
144*6e4a39ccSPatrick Mooney.It Fl o Ar field Ns Op ,...
145*6e4a39ccSPatrick MooneyA case-insensitive, comma-separated list of output fields to display.
146*6e4a39ccSPatrick Mooney.Pp
147*6e4a39ccSPatrick MooneyThe available fields and their contents are described in
148*6e4a39ccSPatrick Mooney.Sx FIELDS
149*6e4a39ccSPatrick Mooneysection below.
150*6e4a39ccSPatrick Mooney.It Fl p
151*6e4a39ccSPatrick MooneyDisplay in a machine-parsable format and elide test stats output when
152*6e4a39ccSPatrick Mooneyexecuting the
153*6e4a39ccSPatrick Mooney.Cm run
154*6e4a39ccSPatrick Mooneycommand.
155*6e4a39ccSPatrick Mooney.Pp
156*6e4a39ccSPatrick MooneyThe
157*6e4a39ccSPatrick Mooney.Fl o
158*6e4a39ccSPatrick Mooneyoption is required with
159*6e4a39ccSPatrick Mooney.Fl p .
160*6e4a39ccSPatrick Mooney.El
161*6e4a39ccSPatrick Mooney.Ss FIELDS
16208855964SRyan ZezeskiThe following is a list of output fields used by the
16308855964SRyan Zezeski.Nm
16408855964SRyan Zezeskicommand along with their meanings.
16508855964SRyan Zezeski.Bl -tag -offset 4m -width 8m
16608855964SRyan Zezeski.It Sy MODULE
16708855964SRyan ZezeskiThe module name of the test.
16808855964SRyan ZezeskiThis is typically the same name as the module-under-test.
16908855964SRyan Zezeski.It Sy SUITE
17008855964SRyan ZezeskiThe suite name of the test.
17108855964SRyan Zezeski.It Sy TEST
17208855964SRyan ZezeskiThe name of the test.
17308855964SRyan Zezeski.It Sy INPUT
17408855964SRyan ZezeskiFor the
17508855964SRyan Zezeski.Sy list
17608855964SRyan Zezeskicommand this indicates if the test requires an input stream: [Y]es or [N]o.
17708855964SRyan ZezeskiFor the
17808855964SRyan Zezeski.Sy run
179*6e4a39ccSPatrick Mooneycommand, it is the path to the input stream.
180*6e4a39ccSPatrick Mooney.El
181*6e4a39ccSPatrick MooneyThe following fields are only applicable to the
182*6e4a39ccSPatrick Mooney.Cm run
183*6e4a39ccSPatrick Mooneycommand.
184*6e4a39ccSPatrick Mooney.Bl -tag -offset 4m -width 8m
18508855964SRyan Zezeski.It Sy LINE
18608855964SRyan ZezeskiThe source code line number that produced the test
18708855964SRyan Zezeski.Sy RESULT .
18808855964SRyan ZezeskiAll
18908855964SRyan Zezeski.Sy PASS
19008855964SRyan Zezeskiand
19108855964SRyan Zezeski.Sy NONE
19208855964SRyan Zezeskiresults have a value of 0.
19308855964SRyan ZezeskiUpon detection of multiple results this value indicates the line that
19408855964SRyan Zezeskioverwrote the previous result and the
19508855964SRyan Zezeski.Sy RESULT
19608855964SRyan Zezeskifield contains a message with the line number of the previous result.
19708855964SRyan Zezeski.It Sy RESULT
19808855964SRyan ZezeskiThe test result.
19908855964SRyan ZezeskiThe
200*6e4a39ccSPatrick Mooney.Sx TEST RESULTS
20108855964SRyan Zezeskisection explains the different types of results.
20208855964SRyan Zezeski.It Sy REASON
20308855964SRyan ZezeskiAdditional context when the test result is one of
20408855964SRyan Zezeski.Sy FAIL ,
20508855964SRyan Zezeski.Sy ERROR ,
20608855964SRyan Zezeskior
20708855964SRyan Zezeski.Sy SKIP .
20808855964SRyan Zezeski.El
20908855964SRyan Zezeski.Ss TEST RESULTS
21008855964SRyan ZezeskiThe different types of results that a test can produce.
21108855964SRyan Zezeski.Bl -tag -offset 4m -width 8m
21208855964SRyan Zezeski.It Sy PASS
21308855964SRyan ZezeskiThe test passed.
21408855964SRyan Zezeski.It Sy FAIL
21508855964SRyan ZezeskiThe test had a logical failure (one of its assertions failed).
21608855964SRyan Zezeski.It Sy ERROR
21708855964SRyan ZezeskiThe test had an unexpected, non-logical error.
21808855964SRyan ZezeskiThis is typically caused by a failure to acquire resources or an error
21908855964SRyan Zezeskiattempting some operation that is tangential to the logic under test.
22008855964SRyan Zezeski.It Sy SKIP
22108855964SRyan ZezeskiThe test decided to skip itself because it lacks the context required to run
22208855964SRyan Zezeskithe test.
22308855964SRyan ZezeskiFor example, some type of missing resource or hardware.
22408855964SRyan Zezeski.It Sy NONE
22508855964SRyan ZezeskiThe test failed to produce a result.
22608855964SRyan ZezeskiThis is a bug in the test and should be fixed.
22708855964SRyan Zezeski.El
22808855964SRyan Zezeski.Sh EXIT STATUS
22908855964SRyan ZezeskiThe following exit values are returned:
23008855964SRyan Zezeski.Bl -tag -width indent
23108855964SRyan Zezeski.It 0
23208855964SRyan ZezeskiSuccessful completion of the command.
23308855964SRyan ZezeskiFor the
23408855964SRyan Zezeski.Sy run
235*6e4a39ccSPatrick Mooneycommand, this also indicates that all tests produced a PASS or SKIP result.
23608855964SRyan Zezeski.It 1
23708855964SRyan ZezeskiAn error occurred while executing the command.
23808855964SRyan ZezeskiFor the
23908855964SRyan Zezeski.Sy run
240*6e4a39ccSPatrick Mooneycommand, this also indicates that one or more tests produced
24108855964SRyan Zezeskia result other than PASS or SKIP.
24208855964SRyan Zezeski.It 2
24308855964SRyan ZezeskiAn invalid combination of command line options or arguments were
24408855964SRyan Zezeskispecified.
24508855964SRyan Zezeski.El
24608855964SRyan Zezeski.Sh EXAMPLES
24708855964SRyan Zezeski.Ss List all Tests
24808855964SRyan ZezeskiList all tests registered with the ktest framework.
24908855964SRyan Zezeski.Bd -literal -offset ident
25008855964SRyan Zezeskiktest list
25108855964SRyan Zezeski.Ed
25208855964SRyan Zezeski.Ss Run all Tests
25308855964SRyan ZezeskiRun all tests registered with the ktest framework.
25408855964SRyan Zezeski.Bd -literal -offset ident
25508855964SRyan Zezeskiktest run '*'
25608855964SRyan Zezeski.Ed
25708855964SRyan Zezeski.Ss Run specific test module
25808855964SRyan ZezeskiThis example runs only tests registered under the
25908855964SRyan Zezeski.Sy mac
26008855964SRyan Zezeskitest module.
26108855964SRyan ZezeskiThis includes all suites under the
26208855964SRyan Zezeski.Sy mac
26308855964SRyan Zezeskimodule and all tests under each suite.
26408855964SRyan Zezeski.Bd -literal -offset ident
26508855964SRyan Zezeskiktest run 'mac::'
26608855964SRyan Zezeski.Ed
26708855964SRyan Zezeski.Ss Run a test with an input file
26808855964SRyan ZezeskiExecute a specific test which requires an input stream.
26908855964SRyan Zezeski.Bd -literal -offset ident
27008855964SRyan Zezeskiktest run -i data.pcap mac:checksum:mac_sw_cksum_ipv4_snoop_test
27108855964SRyan Zezeski.Ed
27208855964SRyan Zezeski.Sh INTERFACE STABILITY
27308855964SRyan ZezeskiThe command syntax is
27408855964SRyan Zezeski.Sy Uncommitted .
27508855964SRyan ZezeskiThe output format is
27608855964SRyan Zezeski.Sy Uncommitted .
277