xref: /netbsd-src/external/bsd/kyua-cli/dist/doc/kyuafile.5.in (revision 6b3a42af15b5e090c339512c790dd68f3d11a9d8)
1*6b3a42afSjmmv.\" Copyright 2012 Google Inc.
2*6b3a42afSjmmv.\" All rights reserved.
3*6b3a42afSjmmv.\"
4*6b3a42afSjmmv.\" Redistribution and use in source and binary forms, with or without
5*6b3a42afSjmmv.\" modification, are permitted provided that the following conditions are
6*6b3a42afSjmmv.\" met:
7*6b3a42afSjmmv.\"
8*6b3a42afSjmmv.\" * Redistributions of source code must retain the above copyright
9*6b3a42afSjmmv.\"   notice, this list of conditions and the following disclaimer.
10*6b3a42afSjmmv.\" * Redistributions in binary form must reproduce the above copyright
11*6b3a42afSjmmv.\"   notice, this list of conditions and the following disclaimer in the
12*6b3a42afSjmmv.\"   documentation and/or other materials provided with the distribution.
13*6b3a42afSjmmv.\" * Neither the name of Google Inc. nor the names of its contributors
14*6b3a42afSjmmv.\"   may be used to endorse or promote products derived from this software
15*6b3a42afSjmmv.\"   without specific prior written permission.
16*6b3a42afSjmmv.\"
17*6b3a42afSjmmv.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18*6b3a42afSjmmv.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19*6b3a42afSjmmv.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20*6b3a42afSjmmv.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21*6b3a42afSjmmv.\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22*6b3a42afSjmmv.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23*6b3a42afSjmmv.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24*6b3a42afSjmmv.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25*6b3a42afSjmmv.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26*6b3a42afSjmmv.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27*6b3a42afSjmmv.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*6b3a42afSjmmv.Dd February 9, 2013
29*6b3a42afSjmmv.Dt KYUAFILE 5
30*6b3a42afSjmmv.Os
31*6b3a42afSjmmv.Sh NAME
32*6b3a42afSjmmv.Nm Kyuafile
33*6b3a42afSjmmv.Nd Test suite description files
34*6b3a42afSjmmv.Sh SYNOPSIS
35*6b3a42afSjmmv.Fn atf_test_program "string name" "[string test_suite]" "[string metadata]"
36*6b3a42afSjmmv.Fn include "string path"
37*6b3a42afSjmmv.Fn plain_test_program "string name" "[string test_suite]" "[string metadata]"
38*6b3a42afSjmmv.Fn syntax "int version"
39*6b3a42afSjmmv.Fn test_suite "string name"
40*6b3a42afSjmmv.Sh DESCRIPTION
41*6b3a42afSjmmvA test suite is a collection of test programs and is represented by a
42*6b3a42afSjmmvhierarchical layout of test binaries on the file system.  Any subtree of
43*6b3a42afSjmmvthe file system can represent a test suite, provided that it includes one
44*6b3a42afSjmmvor more
45*6b3a42afSjmmv.Nm Ns s ,
46*6b3a42afSjmmvwhich are the test suite definition files.
47*6b3a42afSjmmv.Pp
48*6b3a42afSjmmvA
49*6b3a42afSjmmv.Nm
50*6b3a42afSjmmvis a Lua script whose purpose is to describe the structure of the test
51*6b3a42afSjmmvsuite it belongs to.  To do so, the script has access to a collection of
52*6b3a42afSjmmvspecial functions provided by
53*6b3a42afSjmmv.Xr kyua 1 .
54*6b3a42afSjmmv.Pp
55*6b3a42afSjmmvA typical
56*6b3a42afSjmmv.Nm
57*6b3a42afSjmmvwill look similar to this:
58*6b3a42afSjmmv.Bd -literal -offset indent
59*6b3a42afSjmmvsyntax(2)
60*6b3a42afSjmmv
61*6b3a42afSjmmvtest_suite('first')
62*6b3a42afSjmmv
63*6b3a42afSjmmv-- Declare the test programs that are in this directory.
64*6b3a42afSjmmvatf_test_program{name='foo_test'}
65*6b3a42afSjmmvatf_test_program{name='bar_test', test_suite='second'}
66*6b3a42afSjmmvplain_test_program{name='legacy_test'}
67*6b3a42afSjmmvplain_test_program{name='legacy2_test', allowed_architectures='amd64 i386',
68*6b3a42afSjmmv                   required_files='/bin/ls', timeout=30}
69*6b3a42afSjmmv
70*6b3a42afSjmmv-- Recurse into any subdirectories that may have other tests.
71*6b3a42afSjmmvinclude('dir1/Kyuafile')
72*6b3a42afSjmmvinclude('dir2/Kyuafile')
73*6b3a42afSjmmv.Ed
74*6b3a42afSjmmv.Ss File versioning
75*6b3a42afSjmmvEvery
76*6b3a42afSjmmv.Nm
77*6b3a42afSjmmvfile starts with a call to
78*6b3a42afSjmmv.Fn syntax "int version" .
79*6b3a42afSjmmvThis call determines the specific schema used by the file so that future
80*6b3a42afSjmmvbackwards-incompatible modifications to the file can be introduced.
81*6b3a42afSjmmv.Pp
82*6b3a42afSjmmvAny new
83*6b3a42afSjmmv.Nm
84*6b3a42afSjmmvfile should set
85*6b3a42afSjmmv.Fa version
86*6b3a42afSjmmvto
87*6b3a42afSjmmv.Sq 2 .
88*6b3a42afSjmmv.Ss Test suite definition
89*6b3a42afSjmmvEvery
90*6b3a42afSjmmv.Nm
91*6b3a42afSjmmvshould define the name of the test suite it belongs to by calling the
92*6b3a42afSjmmv.Fn test_suite
93*6b3a42afSjmmvfunction at the very beginning.
94*6b3a42afSjmmvIndividual test programs can override this value in their definition, but
95*6b3a42afSjmmvthe most common style is to list a single test suite name for the whole
96*6b3a42afSjmmvfile.
97*6b3a42afSjmmv.Pp
98*6b3a42afSjmmvThe purpose of the test suite name definition is to tell
99*6b3a42afSjmmv.Xr kyua 1
100*6b3a42afSjmmvscoping for the run-time configuration variables that these programs
101*6b3a42afSjmmvaccept.
102*6b3a42afSjmmv.Ss Test program registration
103*6b3a42afSjmmvA
104*6b3a42afSjmmv.Nm
105*6b3a42afSjmmvcan register test programs by means of a variety of
106*6b3a42afSjmmv.Fn *_test_program
107*6b3a42afSjmmvfunctions, all of which take the name of a test program and a set of
108*6b3a42afSjmmvoptional metadata properties that describe such test program.
109*6b3a42afSjmmv.Pp
110*6b3a42afSjmmvThe test programs to be registered must live in the current directory; in
111*6b3a42afSjmmvother words, the various
112*6b3a42afSjmmv.Fn *_test_program
113*6b3a42afSjmmvcalls cannot reference test programs in other directories.
114*6b3a42afSjmmvThe rationale for this is to force all
115*6b3a42afSjmmv.Nm
116*6b3a42afSjmmvfiles to be self-contained, and to simplify their internal representation.
117*6b3a42afSjmmv.Pp
118*6b3a42afSjmmvATF-based test programs (those that implement the
119*6b3a42afSjmmv.Xr kyua-atf-interface 7
120*6b3a42afSjmmvinterface) can be registered with the
121*6b3a42afSjmmv.Fn atf_test_program
122*6b3a42afSjmmvtable constructor.  This function takes the
123*6b3a42afSjmmv.Fa name
124*6b3a42afSjmmvof the test program, an optional
125*6b3a42afSjmmv.Fa test_suite
126*6b3a42afSjmmvname that overrides the global test suite name and a collection of optional
127*6b3a42afSjmmvmetadata settings for all the test cases in the test program.  Any metadata
128*6b3a42afSjmmvproperties defined by the test cases themselves override the metadata values
129*6b3a42afSjmmvdefined here.
130*6b3a42afSjmmv.Pp
131*6b3a42afSjmmvPlain test programs (those that implement the
132*6b3a42afSjmmv.Xr kyua-plain-interface 7
133*6b3a42afSjmmvinterface) can be registered with the
134*6b3a42afSjmmv.Fn plain_test_program
135*6b3a42afSjmmvtable constructor.  This function takes the
136*6b3a42afSjmmv.Fa name
137*6b3a42afSjmmvof the test program an optional
138*6b3a42afSjmmv.Fa test_suite
139*6b3a42afSjmmvname that overrides the global test suite name and a collection of optional
140*6b3a42afSjmmvmetadata settings for the test program.
141*6b3a42afSjmmv.Pp
142*6b3a42afSjmmvPlease see
143*6b3a42afSjmmv.Xr kyua-tester-list 5
144*6b3a42afSjmmvfor the list of metadata properties that can be given to test programs.
145*6b3a42afSjmmvAll the properties that can be given to a test case can also be given to a test
146*6b3a42afSjmmvprogram.
147*6b3a42afSjmmv.Ss Recursion
148*6b3a42afSjmmvTo reference test programs in another subdirectory, a different
149*6b3a42afSjmmv.Nm
150*6b3a42afSjmmvmust be created in that directory and it must be included into the original
151*6b3a42afSjmmv.Nm
152*6b3a42afSjmmvby means of the
153*6b3a42afSjmmv.Fn include
154*6b3a42afSjmmvfunction.
155*6b3a42afSjmmv.Pp
156*6b3a42afSjmmvNote that each file is processed in its own Lua environment: there is no
157*6b3a42afSjmmvmechanism to pass state from one file to the other.  The reason for this is
158*6b3a42afSjmmvthat there is no such thing as a
159*6b3a42afSjmmv.Dq top-level
160*6b3a42afSjmmv.Nm
161*6b3a42afSjmmvin a test suite: the user has to be able to run the test suite from any
162*6b3a42afSjmmvdirectory in a given hierarchy, and this execution must not depend on files
163*6b3a42afSjmmvthat live in parent directories.
164*6b3a42afSjmmv.Ss Top-level Kyuafile
165*6b3a42afSjmmvEvery system has a top directory into which test suites get installed.  The
166*6b3a42afSjmmvdefault is
167*6b3a42afSjmmv.Pa __TESTSDIR__ .
168*6b3a42afSjmmvWithin this directory live test suites, each of which is in an independent
169*6b3a42afSjmmvsubdirectory.  Each subdirectory can be provided separately by independent
170*6b3a42afSjmmvthird-party packages.
171*6b3a42afSjmmv.Pp
172*6b3a42afSjmmvKyua allows running all the installed test suites at once in order to
173*6b3a42afSjmmvprovide comprehensive cross-component reports.  In order to do this, there
174*6b3a42afSjmmvis a special file in the top directory that knows how to inspect the
175*6b3a42afSjmmvsubdirectories in search for other Kyuafiles and include them.
176*6b3a42afSjmmv.Pp
177*6b3a42afSjmmvThe
178*6b3a42afSjmmv.Sx FILES
179*6b3a42afSjmmvsection includes more details on where this file lives.
180*6b3a42afSjmmv.Sh FILES
181*6b3a42afSjmmv.Bl -tag -width XX
182*6b3a42afSjmmv.It Pa __TESTSDIR__/Kyuafile .
183*6b3a42afSjmmvTop-level
184*6b3a42afSjmmv.Nm
185*6b3a42afSjmmvfor the current system.
186*6b3a42afSjmmv.It Pa __EGDIR__/Kyuafile.top .
187*6b3a42afSjmmvSample file to serve as a top-level
188*6b3a42afSjmmv.Nm .
189*6b3a42afSjmmv.El
190*6b3a42afSjmmv.Sh SEE ALSO
191*6b3a42afSjmmv.Xr kyua 1
192