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