Home | History | Annotate | only in /test/ontest-stc2/src/suites/net/nc
Up to higher level directory
NameDateSize
include/19-Nov-2008
Makefile19-Nov-20081.3K
README19-Nov-200813.1K
src/19-Nov-2008
STC.INFO19-Nov-20084.1K
Targetdirs19-Nov-20081.7K
tests/19-Nov-2008
tet_scen19-Nov-20081.7K

README

      1 #
      2 # CDDL HEADER START
      3 #
      4 # The contents of this file are subject to the terms of the
      5 # Common Development and Distribution License (the "License").
      6 # You may not use this file except in compliance with the License.
      7 #
      8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9 # or http://www.opensolaris.org/os/licensing.
     10 # See the License for the specific language governing permissions
     11 # and limitations under the License.
     12 #
     13 # When distributing Covered Code, include this CDDL HEADER in each
     14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15 # If applicable, add the following below this CDDL HEADER, with the
     16 # fields enclosed by brackets "[]" replaced with your own identifying
     17 # information: Portions Copyright [yyyy] [name of copyright owner]
     18 #
     19 # CDDL HEADER END
     20 #
     21 
     22 #
     23 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     24 # Use is subject to license terms.
     25 #
     26 # ident	"@(#)README	1.1	08/11/10 SMI"
     27 #
     28 
     29 #
     30 # README file for nc(1) CTI-TET test suite.
     31 #
     32 
     33 1.  Introduction
     34 2.  Test coverage
     35 3.  System requirements
     36 4.  System changes
     37 5.  Installation
     38 6.  Configuring and running the tests
     39 7.  Building, configuring and running the tests from source code
     40 8.  Notes
     41 9.  Future work
     42 10. Information for developers
     43 11. Contact us
     44 
     45 
     46 1. Introduction
     47 ---------------
     48 
     49 The Netcat test suite residing here is set of basic functionality tests
     50 for Netcat implementation shipped with Solaris. It is based on unit 
     51 tests developed for pre-RTI testing of nc(1) integration into ON.
     52 
     53 The test suite uses CTI-TET, Common Test Infrastructure (CTI) for Test
     54 Environment Toolkit (TET). Please see the following link for more 
     55 information about CTI-TET both in OpenSolaris context and in general:
     56 
     57   http://opensolaris.org/os/community/testing/testsuites/ctifortet/
     58 
     59 The test suite is intended to be run by anyone from OpenSolaris community
     60 who wants to contribute a bug fix or RFE to Netcat shipped with Solaris.
     61 
     62 If you want to make a change in this test suite be sure you read "Information
     63 for developers" section before progressing any further.
     64 
     65 2. Test coverage
     66 ----------------
     67 
     68 With every RFE, new test purpose or test case should be added. The same
     69 for serious bugs. Most of the functionality is covered by the tests with the
     70 exception of features which require setup of servers (e.g. SOCKS support).
     71 
     72 All tests should PASS. If not, please report a bug.
     73 
     74 3. System requirements
     75 ----------------------
     76 
     77 3.1 Access to your local machine
     78 --------------------------------
     79 
     80 All tests run on local machine only. Root access is not required
     81 unless the tests are set to use privileged port (see section 8) or test
     82 suite package is installed/removed.
     83 
     84 The test suite can be run both on SPARC and i386. Those two are the only
     85 relevant modes because we use only shell scripts in this test suite.
     86 
     87 3.2 Network interfaces
     88 ----------------------
     89 
     90 All tests need two loopback interface (lo0) instances, configured with
     91 IPv4 (127.0.0.1) and IPv6 address (::1/128).
     92 
     93 4. System changes
     94 -----------------
     95 
     96 This test suite does not currently modify system configuration in any way.
     97 
     98 5. Installation
     99 ---------------
    100 
    101 This section is for those who want to install the test suite package. If you
    102 want to run the tests from source code, see section 7.
    103 
    104 The package will be installed into /opt. It is recommended that you install
    105 the package from scratch, rather than on top of an existing installation.
    106 Thus, if an old version of the tests is installed, remove it and install it
    107 again:
    108 
    109   root# pkgrm SUNWstc-nc
    110   root# pkgadd -d <package-location> SUNWstc-nc
    111 
    112 Note: SUNWstc-tetlite which contains CTI-TET framework tools is prerequisite
    113       for SUNWstc-nc.
    114 
    115 6. Running the tests
    116 ------------------------------------
    117 
    118 Run the tests from the package like this:
    119 
    120   $ cd /opt/SUNWstc-nc && \
    121     export TET_SUITE_ROOT=/opt/SUNWstc-nc; \
    122     export TET_ROOT=/opt/SUNWstc-tetlite; \
    123     export CTI_ROOT=$TET_ROOT/contrib/ctitools; \
    124     export PATH=$PATH:$CTI_ROOT/bin; \
    125     run_test nc
    126 
    127 The results files will be stored in /var/tmp/results.<PID> directory.
    128 The default journal file name will be /var/tmp/results.<PID>/testlog
    129 where PID is pid of run_test process.
    130 
    131 6.1 Running single test case
    132 ----------------------------
    133 
    134 To run single test case (which can contain several test purposes)
    135 use additional argument for run_test, e.g. for Tflag test case:
    136 
    137   $ run_test nc Tflag
    138 
    139 6.2 Running predefined scenarios
    140 ---------------------------------
    141 
    142 nc test suite is based on CTI-TET framework. It supports scenarios
    143 and the test suite has predefined the following scenarios:
    144 
    145   - short
    146   - longer
    147 
    148 Scenario definitions reside in the 'tet_scen' file.
    149 
    150 To run e.g. the short scenario use the following command:
    151 
    152   $ run_test nc short
    153 
    154 6.3  Testing custom nc program
    155 ------------------------------
    156 
    157 To test nc program stored at different location than the default
    158 /usr/bin/nc, set STC2_NC_PATH environment variable to
    159 an alternative location.
    160 
    161 7. Building, configuring and running the tests from source code
    162 ---------------------------------------------------------------
    163 
    164 - checkout the test suite source, if desired:
    165 
    166   $ hg clone ssh://anon@hg.opensolaris.org/hg/test-dev/ostest-stc2
    167 
    168 - set CODEMGR_WS environment variable to the location of the source directory:
    169 
    170   If the previous Mercurial command was performed in directory
    171   /local/userfoo/testing (e.g.) then do the following:
    172 
    173   $ export CODEMGR_WS=/local/userfoo/testing/ostest-stc2
    174 
    175   This variable is needed by the following commands.
    176 
    177   NOTE: Do not use Teamware commands for any build related action
    178         with this test suite otherwise they will not work because
    179 	of collision with internal variable names.
    180 
    181 - set CTI-TET variables and create the scripts:
    182 
    183   $ export TET_ROOT=/opt/SUNWstc-tetlite; \
    184     export CTI_ROOT=$TET_ROOT/contrib/ctitools; \
    185     export TET_SUITE_ROOT=$CODEMGR_WS/src/suites/net; \
    186     export PATH=$PATH:$CTI_ROOT/bin; \
    187     cd $TET_SUITE_ROOT/nc \
    188     && make
    189 
    190 - run the test suite
    191 
    192   $ cd $TET_SUITE_ROOT && run_test nc
    193 
    194 - examine results
    195 
    196   $ less /var/tmp/results.<number>/testlog
    197 
    198   Full path to the journal file is printed by run_test before start
    199   of the tests and at the end of the run.
    200 
    201 - at some later time the journal can be displayed in comprehensive form
    202   via the following command:
    203 
    204   $ report_writer /var/tmp/results.<number>/testlog /tmp/report.$$
    205 
    206 - you can also build the SUNWstc-nc package: 
    207 
    208   $ cd $TET_SUITE_ROOT/nc && make package
    209 
    210   The package will be constructed in 
    211   $CODEMGR_WS/packages/`uname -p`/SUNWstc-nc/ directory.
    212 
    213   After that it can be converted to the cpio package format via:
    214 
    215   $ pkgtrans -s $CODEMGR_WS/packages/`uname -p` \
    216 	/tmp/SUNWstc-nc.pkg SUNWstc-nc
    217 
    218   The result package /tmp/SUNWstc-nc.pkg can be simply copied to
    219   remote sytem and installed:
    220 
    221   $ pkgadd -d SUNWstc-nc.pkg all
    222 
    223 8. Notes
    224 --------
    225 
    226 8.1 Solution for bad latency to the tools
    227 -----------------------------------------
    228 
    229 If you run this test suite far from where the gate is exported from it
    230 might be very slow. In that case it's enough just to recursively copy
    231 tetlite directory from proto area to your local proto/tools directory
    232 and then to set PATH accordingly.
    233 
    234 8.2 Internal variables
    235 ----------------------
    236 
    237 If you need to test nc binary which is not in default location (for
    238 example you want to test it without copying it from a build server)
    239 or need to change port used for testing there is a list of variables
    240 that you can set and export before running the test suite, together
    241 with their default values:
    242 
    243 	variable			default value
    244 	------------------------------+----------------
    245 	STC2_NC_PATH			/usr/bin/nc
    246 	STC2_NC_TEST_PORT 		4444
    247 	STC2_NC_TEST_SOURCE_PORT_FIRST	55555
    248 	STC2_NC_TEST_SOURCE_PORT_LAST	55566
    249 	STC2_NC_WATCHMALLOC 		1
    250 	STC2_NC_DEBUG			0
    251 	STC2_NC_STARTUP_TIMEOUT		10
    252 
    253 8.3 Memory checking
    254 -------------------
    255 
    256 By default every nc command is run with watchmalloc(3MALLOC) checking. 
    257 Setting STC2_NC_WATCHMALLOC environment variable to 0 will cause nc to be run
    258 without the checks.
    259 
    260 8.4 Binding to ports and privileges
    261 -----------------------------------
    262 
    263 All of the tests utilizing TCP/UDP connections are using default port
    264 number STC2_NC_TEST_PORT which is set to unprivileged port.
    265 
    266 This could lead to setup phase (for test purposes which start nc in server
    267 mode first and then perform the test by connecting with nc client process)
    268 failures where bind(3SOCKET) call fails because the port is already
    269 bound by different process. To overcome this limitation,
    270 the default value can be overriden by setting STC2_NC_TEST_PORT
    271 environment variable to privileged port (smaller than 1024) and
    272 running the test suite with net_privaddr privilege (e.g. under root).
    273 
    274 STC2_NC_TEST_SOURCE_PORT_{FIRST,LAST} port range is used (by calling
    275 try_connect_srcport()) in test purposes using -p flag for setting source
    276 TCP port such as those in vflag or pflag test cases. Same rules apply w.r.t.
    277 privileged port number as above.
    278 
    279 9. Future work
    280 --------------
    281 
    282 Aside from better test suite coverage, changes should be done which
    283 would make the test suite more robust:
    284 
    285   - addition of timeouts for test purposes
    286   - detection of bind(3socket) failures and restart or using
    287     net_privaddr privilege for running all tests with privileged port
    288 
    289 As with nc(1), patches and contributions are welcome.
    290 
    291 10. Information for developers
    292 ------------------------------
    293 
    294 If you want or need to debug the test suite, set STC2_NC_DEBUG variable to
    295 positive value before running the tests. It will put some more
    296 information into the journal.
    297 
    298 nc should be executed either using predefined functions such as
    299 listen_wrapper() or start_nc(). In some cases it is needed to execute
    300 it directly. In such cases it should be started like this:
    301 
    302   $ eval $NC arguments
    303 
    304 This is because of watchmalloc(3MALLOC) checking (see NC_PRELOADS
    305 definition in include/vars for details).
    306 
    307 10.1 Start and end of a test purpose
    308 ------------------------------------
    309 
    310 Each test purpose should begin with a call to init_test() and should
    311 end with a call to finish_test().
    312 
    313 init_test() prints test purpose ID and description to journal file
    314 and sets test_port/test_source_port internals variable to
    315 STC2_NC_TEST_PORT/STC2_NC_TEST_SOURCE_PORT values, respectively.
    316 
    317 finish_test() performs cleanup by killing any potentional left-over nc
    318 processes via stop_nc() which uses internal variable NC_PIDFILE.
    319 
    320 Also note that tet_startup,tet_cleanup variables are set to common_startup
    321 and common_cleanup (defined in src/lib/ksh/common_funcs.ksh), respectively.
    322 
    323 10.2 Internal variables
    324 -----------------------
    325 
    326 start_nc() sets two internal variables which accessible from test purposes:
    327 
    328 	Name	     Meaning
    329 	------------+----------------------------------------------
    330 	NC_PIDFILE   file containing pid of nc process
    331 	NC_ERRFILE   file containing stderr produced by nc process
    332 
    333 Both files have to be removed when the program started by start_nc() exits.
    334 Normally, finish_test() takes care of that but in case start_nc()
    335 is executed with custom pid file and error file the caller has to remove
    336 them.
    337 
    338 To remove custom pid files and kill the processes associated with them
    339 finish_test() can be passed the variables.
    340 
    341 10.3 Adding new tests 
    342 ---------------------
    343 
    344 10.3.1 Adding new test purpose
    345 ------------------------------
    346 
    347 The following steps are needed:
    348 
    349   1. create the file for the test purpose in given test case directory
    350      e.g. tests/uflag/tp_uflag_004_neg.ksh
    351 
    352   2. add new test purpose to TARGET_KSH variable in Makefile
    353      for given test case
    354 
    355   3. include the test purpose in test case script
    356      (e.g. tests/uflag/tc_uflag.ksh)
    357 
    358 10.3.2 Adding new test case
    359 ---------------------------
    360 
    361 To add new test case the following steps are needed:
    362 
    363   1. add new subdirectory in tests/ directory with all necessary files
    364      (Makefile, .ksh script for the test case, files for the test purposes)
    365 
    366   2. modify the following files:
    367 
    368      - tests/Makefile
    369        append new test case directory to SUBDIRS variable definition
    370 
    371      - tet_scen
    372        add a new test case name to appropriate scenario and define
    373        the test case with a path to the script
    374 
    375      - Targetdirs
    376        add new directory for the test case to ROOT.TEST variable
    377 
    378 10.4 Code style
    379 ---------------
    380 
    381 When writing new ksh code make sure that the shell style rules are
    382 followed:
    383 
    384   http://www.opensolaris.org/os/project/shell/shellstyle/
    385 
    386 All tests should run with both ksh88 and ksh93.
    387 
    388 10.5 Using internal functions
    389 -----------------------------
    390 
    391 Temporary files or directories should be created using the nc_mktemp()
    392 or nc_mktemp_dir() routines, respectively. These functions use common
    393 prefix from the NC_TMPFILE_PREFIX variable defined in include/vars file.
    394 
    395 Assuming all test cases/purposes use these functions it should be easy to
    396 check for leftover temporary files at the end of test suite run (signaling
    397 there is a problem in test suite code). This command will perform the
    398 check (with current definition of the common prefix used for 
    399 temporary files/directories):
    400 
    401   $ /usr/bin/find /tmp/ -name 'nc_tet-*' 2>/dev/null
    402 
    403 The output of the command should be empty.
    404 
    405 11. Contact us
    406 --------------
    407 
    408 This test suite was developed by Vladimir Kotal, first version was
    409 integrated under RFE 6646967 (netcat needs a test suite).
    410 
    411 Please e-mail the STC_CONTACT listed in the STC.INFO file if you want to
    412 contact us - your feedback is appreciated. If you want to file a bug, use
    413 stc/net/nc category.
    414 
    415