1 #
2 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
3 # Use is subject to license terms.
4 #
5 # ident "@(#)README 1.5 07/08/15 SMI"
6 #
7
8 #
9 # This is free software; you can redistribute it and/or modify it
10 # under the terms of the "Artistic License" which is located in
11 # the file named "Artistic" which is included with this software.
12 #
13
14 ===============================================================================
15
16 Common Test Infrastructure (CTI) for Test Environment Toolkit (TET)
17
18 CTI for TET is a common set of tools, utilities and application interfaces
19 which support TET test development and execution.
20
21 ===============================================================================
22
23 CTI Directory Structure
24
25 Makefiles - contains the standard Makefiles that can be used with test suites
26 to define most of the building process when using make.
27
28 bin - compiled binary and shell standalone executable utilities.
29
30 examples - example test suites provided to show the use of the CTI interfaces
31 and CTI command line execution.
32
33 include - CTI header files that are to be included in code.
34
35 lib - compiled and shell script libraries that are linked or sourced into test
36 scripts to gain access to the CTI API.
37
38 src/defines - Solaris define files used to identify newer versions of Solaris.
39
40 src/lib - source code for the libraries that are built into the above lib
41 directory.
42
43 src/utils - the CTI command line utility and it's associated tools. As well
44 as the build, clean and exec tools, the kmodtool interface and setuid programs
45 for root and user test suite execution.
46
47 src/scripts - tools to assist in the building and packaging of CTI for TET.
48
49 ===============================================================================
50
51 bin/run_test.ksh (src/utils/run_test.ksh)
52
53 The run_test wrapper is used to execute test suites and passes the
54 configuration program the following arguments:
55
56 -F : Configuration parameter file (name=value pairs)
57 -S : Do the setup only
58 -E : Do the execute only using the prior setup
59 -C : Do the cleanup only for the prior setup
60 -L : Log directory
61 -R : List of remote machines (only for distributed test)
62 -I : Ignore html/sorted_result creation
63 -j : Journal file (-j - goes to stdout)
64 -s : scenario file (tcc option)
65 -x : execute mode config file (tcc option)
66
67 Following tcc options are passed directly to the 'tcc' command
68 without being processed by run_test :
69 b, c, e, i, f , g, I, l, n, t, v, y
70
71 ===============================================================================
72
73 src/scripts/build_tet.ksh
74
75 The build_tet.ksh script will build the TET-Lite and Distributed TET versions
76 of TET along with the CTI software under $TET_ROOT. If the $CODEMGR_WS
77 environment variable is set, the built code will also be copied to
78 $CODEMGR_WS/proto and be ready for package generation. The
79 /src/scripts/solpatch.ksh script is used by build_tet.ksh to patch TET so
80 newer versions of Solaris are identified during the build process.
81
82 Usage: build_tet.ksh <mode>
83
84 Where <mode> is one of the following arguments :
85 lite - to build TET Lite
86 inet - to build Distributed TET
87
88 /src/scripts/build_tet_pkg.pl
89
90 The build_tet_pkg.pl script creates TET-Lite or Distributed TET packages from
91 the built code in $CODEMGR_WS/proto and stores the packages (SUNWstc-tetlite or
92 SUNWstc-dtet) in the $CODEMGR_WS/packages directory.
93
94 Usage: build_tet_pkg.pl [-p <pkgdef_dir>] [-P <proto_dir>]
95 [-s pkg_spool_dir] mode
96
97 Where mode is one of the following arguments :
98 lite - to build the lite packages (SUNWtetlite)
99 inet - to build the distributed tet packages (SUNWdtet)
100
101 Example:
102
103 % setenv CODEMGR_WS /test/ws
104 % setenv TET_ROOT $CODEMGR_WS/src/tools/tet
105 % cd $TET_ROOT/contrib/ctitools/src/scripts
106 % build_tet.ksh inet
107 % build_tet_pkg.pl inet
108
109 The build and package scripts need to be run on sparc and i386 build servers
110 to produce sparc and i386 packages. 32-bit sparc, 64-bit sparcv9, 32-bit i386
111 and 64-bit amd64 binaries are produced. Four runs are required to produce all
112 combinations of sparc, i386, TET-Lite and Distributed TET packages.
113
114 ===============================================================================
115
116 bin/build_suite_pkg (utils/build_suite_pkg.pl)
117
118 The build_suite_pkg.pl script uses the standard Makefiles with the package
119 directive to build a package of the current test suite. Script execution can
120 be modified by supplying custom packaging files and information. This script
121 can also remove the package with -R suitename.
122
123 Usage: build_suite_pkg.pl [ -p <pkgdef_dir>] [ -P <proto_dir>]
124 [ -s <pkg_spool_dir> ] <-R | -S> suitedir
125
126 suitedir - The location of the compiled test suite.
127
128 This compilation is done with the standard makefiles by using
129 the 'package' directive, e.g :
130
131 $ /usr/ccs/bin/make package
132
133 To remove the package, e.g :
134
135 $ /usr/ccs/bin/make unpackage
136
137 ===============================================================================
138
139 Supported development CTI libraries (languages) :
140
141 CTI support libraries are written for ksh, C, Perl and java.
142
143 The ksh files to be sourced in are :
144
145 lib/ctiutils.ksh - Common tetlite CTI API interfaces.
146 lib/ctidutils.ksh - Distributed CTI API interfaces.
147
148 The C libraries are :
149
150 lib/libCommonTest.so - Common tetlite and distributed interfaces
151 depending on packages installed.
152 lib/libCommonTest_s.so - Provides a modified cti_delete() and
153 cti_deleteall() functions that use shared variables
154 with the TET libraries.
155 lib/libCommonTest_script.so - Shell script like helpers for C
156 lib/libCommonTest_thr.so - Threaded CTI interfaces.
157
158 The Perl files to be soureced in are:
159
160 lib/ctiutils.pl - Common tetlite CTI API interfaces.
161
162 The jave library :
163
164 lib/CommonTest.jar - Common tetlite and distributed interfaces
165 depending on packages installed.
166
167 ===============================================================================
168
169 bin/build_tool (Source - src/utils/build_tool.ksh)
170 bin/clean_tool (Source - src/utils/clean_tool.ksh)
171
172 The build_tool and clean_tool scripts can be used as TCC build and clean tools
173 (respectively) to support options in scenario test case names. Both scripts
174 perform shell variable expansion.
175
176 bin/exec_tool (Source - src/utils/exec_tool.ksh)
177
178 The exec_tool supports two options: su and kmod. The "su" option allows a test
179 case to be run with an arbitary UID, for example:
180
181 /foo/bar/tc1:su=root{3-5}
182 /foo/bar/tc2:su=uucp
183
184 The "kmod" or "kernel" option specifies that the test case is a kernel module.
185 This enhancement provides facilities for TET test cases to be written and run
186 directly in the kernel, for example:
187
188 /foo/bar/tc3:kmod{1,4-7,10}
189
190 The build and clean tools are simple scripts that basically strip out the above
191 options from scenario test case names such that the usual TCC build and clean
192 tools such as make can still be used.
193
194 For more detailed information, please read the comments at the top of each
195 script.
196
197 NOTE: these scripts are available in the $CTI_ROOT/bin directory.
198
199 ===============================================================================
200
201 lib/[amd64|sparcv9]/libkmodapi.a (Source - src/lib/C/kmodapi.c)
202 bin/kmodtool (Source - src/utils/kmodtool.c)
203
204 Include Files
205
206 include/kmod_support.h
207 include/tet_kmodapi.h
208
209 The kmodtool and libkmodapi.a library provide support for TET kernel test
210 cases.
211 Kernel test cases look very similar to TET user-level test cases. They can
212 call (some) TET APIs and thus use facilities provided by TET. These test
213 cases are kernel modules which run directly in the kernel, and they can be
214 specified in the same scenarios as user-level test cases.
215
216 The file src/lib/kmodapi.c contains the source for some TET APIs available in
217 the kernel. Not all TET C routines are available in the kernel. Some of them
218 like tet_fork() are not provided simply because they don't make sense in the
219 kernel.
220
221 Kernel test cases must include the header file <tet_kmodapi.h> (as opposed to
222 the standard <tet_api.h>) which is available in $CTI_ROOT/include directory.
223 They must also be linked with the archive library likmodapi.a (as opposed to
224 the standard libapi.a) located in $CTI_ROOT/lib.
225
226 The file kmodtool.c is a "fake" user-level test case which acts as a
227 proxy agent for kernel test case. To run a kernel test case, you must use
228 the $CTI_ROOT/bin/exec_tool script as the TCC exec tool. This can be done
229 by adding an entry such as :
230
231 TET_EXEC_TOOL=${TET_ROOT}/contrib/ctitools/bin/exec_tool
232
233 in tetexec.cfg. You must also specify the TET_SU_TOOL and TET_KMOD_TOOL
234 configuration variables, e.g.:
235
236 TET_SU_TOOL=${TET_ROOT}/contrib/ctitools/bin/sutool
237 TET_KMOD_TOOL=${TET_ROOT}/contrib/ctitools/bin/kmodtool
238
239 The sutool utility is needed because kmodtool needs to run as root to modload
240 the kernel test case.
241
242 When the exec_tool encounters a scenario test case name such as
243
244 /foo/bar/mytestcase:kmod
245
246 which has the "kmod" or "kernel" option set, it calls on the sutool utility
247 to start the user-level kmodtool test case as root, passing in the path
248 to the kernel test case as argument. In turn, kmodtool creates a Solaris door
249 server and then modloads the kernel test case. During the initialization
250 phase, the kernel test case sets up a kernel door server and then contacts
251 kmodtool via kmodtool's door. Thus these two doors provide a two-way
252 communication channel between the kernel test case and kmodtool.
253
254 kmodtool acts as proxy agent for the kernel test case because to the TET Test
255 Case Manager (TCM) the user-level kmodtool is the test case that it is actually
256 running. When the TCM executes a test purpose function inside kmodtool, this
257 function then forwards the request, via the door, to the test case in the
258 kernel.
259 When the call reaches the kernel door server, it in turn calls the actual test
260 purpose routine in the kernel test case. Conversely, when the kernel test case
261 calls a kernel TET API (kmodapi.c), the routine forwards the request up to
262 kmodtool's door server in userland. kmodtool's door server in turn calls the
263 actual TET API on behalf of the kernel test case.
264
265 This allows you to write test cases that run directly in the kernel and yet
266 still use many of TET's facilities, such as calling tet_getvar() from
267 inside the kernel to get configuration variables specified in tetexec.cfg,
268 or running a distributed kernel test on several remote machines with remote
269 parts doing synchronization and communication among each other. And the
270 same scenario processing facility also applies to kernel tests. For example,
271 it's possible to do this
272
273 :parallel,20:
274 /foo/bar/tc1:kernel
275 :endparallel:
276
277 which runs 20 instances of the tc1 kernel test case in parallel (this of course
278 means that all 20 instances of tc1 run within the same address space, which
279 means tc1 has to be written in such a way that these instances don't interfere
280 with each other when accessing global kernel resources). And kernel test cases
281 can be mixed and matched with userland test cases, for example:
282
283 :timed_loop,3600:
284 :distributed,1-4,7:
285 :random:
286 /foo/bar/user-tc{3,5,7}
287 /foo/bar/kernel-tc:kmod{1-3}
288 :endrandom:
289 :enddistributed:
290 :endtimed_loop:
291
292 As mentioned previously, not all TET functions are available in the kernel.
293 Some like tet_fork() are not provided because they don't make sense in the
294 kernel. While some have slightly different interfaces from the actual TET
295 version. In particular those that return an allocated buffer such as
296 tet_getvar() and tet_remgetlist(). For these routines, you must pass a
297 buffer that you allocate yourself prior to the call. This requirement was made
298 to help remind callers to deallocate those buffers when they are done and
299 to minimize the chance they forget, which would cause a kernel memory leak.
300 For a list of TET APIs available in the kernel see the the header file
301 $CTI_ROOT/include/tet_kmodapi.h.
302
303 ===============================================================================
304
305 bin/sutool (Source - src/utils/sutool.c)
306
307 sutool is a simple tool, akin to su or sudo, that allows an arbitrary command
308 to be executed as the specified user (including root). Unlike su or sudo,
309 this program does NOT ask for any password. It changes the UID, EUID,
310 saved-UID, GID, EGID, saved-GID, and supplementary group list of the process
311 to those of the specified user's prior to executing the command.
312
313 WARNING: This program is a major security risk. Do not use if security is an
314 issue and/or remove the installed binary from the package installation.
315