# HG changeset patch # User Michael Raskey # Date 1490230787 21600 # Node ID aebe38a666fff393ef63829b30c46020a3b4a269 # Parent a7b1224e5a6317ffba532fd6c9eea6f5854edf92 25760427 run.py with an illegal option does not report usage diff -r a7b1224e5a63 -r aebe38a666ff src/tests/README --- a/src/tests/README Wed Mar 22 18:59:47 2017 -0600 +++ b/src/tests/README Wed Mar 22 18:59:47 2017 -0600 @@ -1,5 +1,5 @@ -Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. tests/README @@ -12,27 +12,19 @@ run.py drives the execution of our api and cli test suites, and compares the results to a baseline file stored in baseline.txt. - run.py can also be run standalone with a variety of options: + run.py can also be run standalone with a variety of options. + Use "run.py -h" to see what options are supported. + + To run subsets of tests or individual tests, use the "-o" or the "-s" + options to select what tests to run. - Usage: run.py [-ghptv] [-c format] [-b filename] [-o regexp] - run.py [-hptvx] [-c format] [-b filename] [-s regexp] [-o regexp] - -a Archive failed test cases to /$pid/$testcasename - -b Baseline filename - -c Collect code coverage data in xml or html format - -d Show debug output, including commands run, and outputs - -f Show fail/error information even when test is expected to fail - -g Generate result baseline - -h This help message - -j Parallelism - -o Run only tests that match regexp - -p Parseable output format - -q Quiet output - -s Run tests starting at regexp - -t Generate timing info file - -u Enable IPS GUI tests, disabled by default - -v Verbose output - -x Stop after the first baseline mismatch - -z Lowest port the test suite should use + For example: + - To run the tests in cli/t_pkg_install.py: + $ run.py -o cli.t_pkg_install + - To run just the tests in the TestPkgInstallActions class in that file: + $ run.py -o cli.t_pkg_install.TestPkgInstallActions + - To run just the "test_bad_hardlinks" test: + $ run.py -o cli.t_pkg_install.TestPkgInstallActions.test_bad_hardlinks When adding, removing, or changing the results of test cases, make sure to update baseline.txt and check it in. This can be done with the diff -r a7b1224e5a63 -r aebe38a666ff src/tests/run.py --- a/src/tests/run.py Wed Mar 22 18:59:47 2017 -0600 +++ b/src/tests/run.py Wed Mar 22 18:59:47 2017 -0600 @@ -21,7 +21,7 @@ # # -# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. # from __future__ import print_function @@ -59,11 +59,10 @@ import warnings cov = None -def usage(): - print("Usage: {0} [-ghptv] [-c format] [-b filename] "\ - "[-o regexp]".format(sys.argv[0]), file=sys.stderr) - print(" {0} [-hptvx] [-c format] [-b filename] "\ - "[-s regexp] [-o regexp]".format(sys.argv[0]), file=sys.stderr) +def usage(exitcode=2): + print("Usage: {0} [-dfghlpqtvx] [-a dir] [-b filename] [-c format]\n"\ + " [-j jobs] [-o regexp] [-s regexp]\n"\ + " [-z port] ".format(sys.argv[0]), file=sys.stderr) print("""\ -a Archive failed test cases to /$pid/$testcasename -b Baseline filename @@ -72,7 +71,7 @@ -f Show fail/error information even when test is expected to fail -g Generate result baseline -h This help message - -j Parallelism + -j Parallelism -l Run tests against live system -o Run only tests that match regexp -p Parseable output format @@ -83,7 +82,7 @@ -x Stop after the first baseline mismatch -z Lowest port the test suite should use """, file=sys.stderr) - sys.exit(2) + sys.exit(exitcode) if __name__ == "__main__": # @@ -123,7 +122,7 @@ "verbose", "baseline-file", "only"]) except getopt.GetoptError as e: print("Illegal option -- {0}".format(e.opt), file=sys.stderr) - sys.exit(1) + usage(1) bfile = os.path.join(os.getcwd(), "baseline.txt") generate = False diff -r a7b1224e5a63 -r aebe38a666ff src/util/test-summary.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/util/test-summary.sh Wed Mar 22 18:59:47 2017 -0600 @@ -0,0 +1,62 @@ +#!/usr/bin/bash + +# +# 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) 2017, Oracle and/or its affiliates. All rights reserved. +# + +bindir=${0%/*} +progname=${0##*/} + +function usage +{ + printf "usage: $progname journal\n" >&2 + exit 1 +} + +while getopts ":" OPTION ; do + case $OPTION in + *) usage ;; + esac +done + +if (( $# != 1 )) ; then + usage +fi + +log="$1" + +echo "Test summary:" +echo "" +egrep "^/usr/bin/python.* tests|tests in|FAILED" ${log} +echo "" + +echo "Baseline summary:" +echo "" +# extract text between "^BASELINE MISMATCH" and "Target .* not remade" +nawk ' + /^BASELINE MISMATCH/, /Target .* not remade/ + /Target .* not remade/ {print ""} +' ${log} + +exit 0