usr/src/tools/tests/README
author Mary Ding <mary.ding@oracle.com>
Tue, 24 Jul 2012 22:25:25 -0700
changeset 1756 1146a5d31e76
parent 1640 851d069ece17
permissions -rw-r--r--
7185852 Update tools/tests/README to mention removal of old easy-installed nose so updated nose runs.

#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
#

This directory contains configuration files for Nose, the PyUnit test runner
for the slim_source gate. In order to run the tests you should:

1) Install the following additional packages:
		
        pkg install library/python-2/setuptools-26
	pkg install runtime/python-26/tests
	pkg install library/python-2/coverage
	pkg install library/python-2/nose

	Note:	As of March 21, 2012, library/python-2/nose is available in 
		solaris repo in s11u1_b13 and onward.

	  Check /usr/lib/python2.6/site-packages/easy-install.pth and
	  see whether other version of nose had been installed as follows:

          Need to comment out the following line that start with ./nose-x.xx.x:
	  
          e.g:

	  #./nose-0.11.3-py2.6.egg
  

2) Install pylint 0.23.0 and the nosexunit module:
  

	* Make sure that http_proxy is setup in order to use easy_install-2.6

           i.e:  http_proxy=http://www-proxy.us.oracle.com/

	* Running the command:
		easy_install-2.6 -f http://download.logilab.org/pub/pylint pylint-0.23.0
		easy_install-2.6 nosexunit
		(The warning messages during installation may be ignored)

	  Then edit /usr/lib/python2.6/site-packages/easy-install.pth
          as follows:

          Need to comment out the following line:
	  
          /usr/lib/python2.6/vendor-packages

          i.e:

	  #/usr/lib/python2.6/vendor-packages
  
	Note:	For S11, the pylint version is 0.18 and it had bugs.  Thus we
                need to install the latest version of pylint via easy_install
                to run slim_code_cleanliness test.  Unfortunately, the latest 
                pylint 0.25 does not work with nosexunit at all.  As a 
                result, only plint 0.23 will work and this is why the above
                needs to be done.
 
3)  You also need to install the following additional packages from solaris 
    publisher in order for the slim_unit test and slim_code cleaness tests
    to run:

        group/system/solaris-desktop
        install/installadm

4) Build the gate, per the instructions in usr/src/README.
	Note:	The slim_test program will test Python code from
		the proto area, so the associated files must be
		re-built to pick up any changes to tested code.
		The tests themselves are run from the source files,
		so changes to tests do not require a re-build.

5) Use the "bldenv" command to set-up the build and test environment. 

	sudo /opt/onbld/bin/bldenv -d ../../developer.sh

There are two different scripts for execution of tests:
  - slim_test 
  - slim_regression_test.py (see below for an explanation of this script)

The slim_test script:

The "slim_test" command is a thin wrapper around the "nosetests" command,
and accepts the same arguments. To see a full list of available arguments, run:
	sudo ./slim_test -h

Run the following command to execute all the currently known tests:
	sudo ./slim_test -c tests.nose

To run an individual test:
        sudo ./slim_test -c tests.nose TEST_NUM [TEST_NUM]...
        
Where TEST_NUM is the number of the test you'd like to run, and may be
specified multiple times to run more than one test. Test numbers are
indicated during a full run. To query the test numbers without executing the
tests, run:
        sudo ./slim_test -c tests.nose --collect-only

Note: To reset the numbering, delete the "usr/src/.noseids" file

To run all tests within a specific file or package, omit the "-c tests.nose"
portion, and supply the path to the file or package, relative to the usr/src
directory of the workspace. For example, the following command runs only
the liberrsvc_pymod tests:
	sudo ./slim_test lib/liberrsvc_pymod/test 

To run all tests in a specific file:
	sudo ./slim_test lib/liberrsvc_pymod/test/test_liberrsvc.py

To run a specific class of tests in that file:
	sudo ./slim_test lib/liberrsvc_pymod/test/test_liberrsvc.py:error_service

To run a particular test in that class:
	sudo ./slim_test lib/liberrsvc_pymod/test/test_liberrsvc.py:error_service.test_create_error_info

To report code coverage metrics along with test results, add a "--with-cover"
flag:
	sudo ./slim_test -c tests.nose --with-cover

To add a set of tests to the suite, update the tests.nose file. See that
file for more details.

To run the nosexunit test, it should be run with sudo:

sudo source ${WORKSPACE}/developer.sh
sudo ${WORKSPACE}/usr/src/tools/tests/slim_test \
    -c ${WORKSPACE}/usr/src/tools/tests/tests.nose --with-nosexunit \
    --source-folder=${ROOT}/usr/lib/python2.6/vendor-packages --enable-audit \
    --audit-config=${WORKSPACE}/usr/src/tools/env/install.pylintrc

------------------

In addition to the slim_test wrapper, there is also a
slim_regression_test.py script useful for checking your workspace for
regressions.  The slim_regresstion_test.py script requires root permissions
to execute.  The easiest way to set up your system to run these tests as
root is to use sudo.  Before running the regression tests, edit your
/etc/sudoers file (via the visudo command) and set 

Defaults env_keep="PYTHONPATH SRC"

so $SRC and $PYTHONPATH are correctly forwarded to the command being run as
root.

To run all of the tests and check for regressions against the latest Hudson
build:

	sudo ./slim_regression_test.py

To run all of the tests but suppress the printing of the results (useful
for large tests):

	sudo ./slim_regression_test.py --suppress-results

To run a specific subset of tests:

	sudo ./slim_regression_test.py target ai transfer

The list of tests can be found via the --help flag:

	sudo ./slim_regression_test.py --help

              group tests
                      all:  libraries, commands
                libraries:  target, utils, doc, logging_pymod, netif, liberrsvc, libict_pymod, ict, terminalui, liberrsvc_pymod, boot, engine, manifest_input, logging, common, manifest, transfer, libaimdns
                 commands:  distro_const, js2ai, ai-webserver, system-config, system-config/profile, auto-install, auto-install/test, installadm, text-install

         individual tests
             ai-webserver:  cmd/ai-webserver/test
             auto-install:  cmd/auto-install/checkpoints/test
        auto-install/test:  cmd/auto-install/test
 auto-install/test/manual:  cmd/auto-install/test/manual
                     boot:  lib/install_boot/test
                   common:  lib/install_common/test
             distro_const:  cmd/distro_const/checkpoints/test
                      doc:  lib/install_doc/test
                   engine:  lib/install_engine/test
                      ict:  lib/install_ict/test
               installadm:  cmd/installadm/test
        installadm/manual:  cmd/installadm/test/manual
                    js2ai:  cmd/js2ai/modules/test
                libaimdns:  lib/libaimdns/test
                liberrsvc:  lib/liberrsvc/test
          liberrsvc_pymod:  lib/liberrsvc_pymod/test
             libict_pymod:  lib/libict_pymod/test
                  logging:  lib/install_logging/test
            logging_pymod:  lib/install_logging_pymod/test
                 manifest:  lib/install_manifest/test
           manifest_input:  lib/install_manifest_input/test
                    netif:  lib/netif/test
            system-config:  cmd/system-config/test
    system-config/profile:  cmd/system-config/profile/test
                   target:  lib/install_target/test
               terminalui:  lib/terminalui/test
             text-install:  cmd/text-install/test
                 transfer:  lib/install_transfer/test
                    utils:  lib/install_utils/test

To run a regression test against a specific Hudson job number:

	sudo ./slim_regression_test.py --hudson ###

The job numbers can be found here:

        http://indiana-build.us.oracle.com/job/install_unit_tests/

along the left-hand side.