Also, create autotest-local, a tiny wrapper around that library. For now, autotest and autotest-local have the exact same contents, but it's OK to avoid breakage [1] at this stage of the work. We can make autotest to be a symlink to autotest-local when we have a better understanding of the side effects in doing so.
[1] - Specially considering 3rd party users of the client/autotest entry point. Signed-off-by: Lucas Meneghel Rodrigues <[email protected]> --- client/bin/autotest | 102 +------------------------------------------- client/bin/autotest-local | 8 ++++ client/bin/autotest.py | 101 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 99 deletions(-) create mode 100755 client/bin/autotest-local create mode 100644 client/bin/autotest.py diff --git a/client/bin/autotest b/client/bin/autotest index 6431250..f385bf4 100755 --- a/client/bin/autotest +++ b/client/bin/autotest @@ -2,103 +2,7 @@ # # autotest <control file> - run the autotest control file specified. # -import os, sys -import common -from optparse import OptionParser -from autotest_lib.client.bin import job -from autotest_lib.client.common_lib import global_config -from autotest_lib.client.bin import cmdparser +import autotest -# Use the name of the binary to find the real installation directory -# aka $AUTODIR. Update our path to include the $AUTODIR/bin/tests -# directory and ensure we have $AUTODIR in our environment. -autodirbin = os.path.dirname(os.path.realpath(sys.argv[0])) -autodir = os.path.dirname(autodirbin) -autodirtest = os.path.join(autodir, "tests") - -sys.path.insert(0, autodirbin) - -os.environ['AUTODIR'] = autodir -os.environ['AUTODIRBIN'] = autodirbin -os.environ['AUTODIRTEST'] = autodirtest -os.environ['PYTHONPATH'] = autodirbin - -cmd_parser = cmdparser.CommandParser() # Allow access to instance in parser - -parser = OptionParser(usage='Usage: %prog [options] [command] <control-file>', - epilog="[command]\t\tOne of: "+str(cmd_parser.cmdlist)) - -parser.add_option("-a", "--args", dest='args', - help="additional args to pass to control file") - -parser.add_option("-c", "--continue", dest="cont", action="store_true", - default=False, help="continue previously started job") - -parser.add_option("-t", "--tag", dest="tag", type="string", default="default", - help="set the job tag") - -parser.add_option("-H", "--harness", dest="harness", type="string", default='', - help="set the harness type") - -parser.add_option("-P", "--harness_args", dest="harness_args", type="string", default='', - help="arguments delivered to harness") - -parser.add_option("-U", "--user", dest="user", type="string", - default='', help="set the job username") - -parser.add_option("-l", "--external_logging", dest="log", action="store_true", - default=False, help="enable external logging") - -parser.add_option('--verbose', dest='verbose', action='store_true', - help='Include DEBUG messages in console output') - -parser.add_option('--quiet', dest='verbose', action='store_false', - help='Not include DEBUG messages in console output') - -parser.add_option('--hostname', dest='hostname', type='string', - default=None, action='store', - help='Take this as the hostname of this machine ' - '(given by autoserv)') - -parser.add_option('--output_dir', dest='output_dir', - type='string', default="", action='store', - help='Specify an alternate path to store test result logs') - -parser.add_option('--client_test_setup', dest='client_test_setup', - type='string', default=None, action='store', - help='a comma seperated list of client tests to prebuild on ' - 'the server. Use all to prebuild all of them.') - -parser.add_option('--tap', dest='tap_report', action='store_true', - default=None, help='Output TAP (Test anything ' - 'protocol) reports') - -def usage(): - parser.print_help() - sys.exit(1) - -options, args = parser.parse_args() - -args = cmd_parser.parse_args(args) - -# Check for a control file if not in prebuild mode. -if len(args) != 1 and options.client_test_setup is None: - print "Missing control file!" - usage() - -drop_caches = global_config.global_config.get_config_value('CLIENT', - 'drop_caches', - type=bool, - default=True) - -if options.client_test_setup: - from autotest_lib.client.bin import setup_job - exit_code = 0 - try: - setup_job.setup_tests(options) - except Exception: - exit_code = 1 - sys.exit(exit_code) - -# JOB: run the specified job control file. -job.runjob(os.path.realpath(args[0]), drop_caches, options) +if __name__ == '__main__': + autotest.main() diff --git a/client/bin/autotest-local b/client/bin/autotest-local new file mode 100755 index 0000000..f385bf4 --- /dev/null +++ b/client/bin/autotest-local @@ -0,0 +1,8 @@ +#!/usr/bin/python -u +# +# autotest <control file> - run the autotest control file specified. +# +import autotest + +if __name__ == '__main__': + autotest.main() diff --git a/client/bin/autotest.py b/client/bin/autotest.py new file mode 100644 index 0000000..a093af5 --- /dev/null +++ b/client/bin/autotest.py @@ -0,0 +1,101 @@ +import os, sys +import common +from optparse import OptionParser +from autotest_lib.client.bin import job +from autotest_lib.client.common_lib import global_config +from autotest_lib.client.bin import cmdparser + +# Use the name of the binary to find the real installation directory +# aka $AUTODIR. Update our path to include the $AUTODIR/bin/tests +# directory and ensure we have $AUTODIR in our environment. +autodirbin = os.path.dirname(os.path.realpath(sys.argv[0])) +autodir = os.path.dirname(autodirbin) +autodirtest = os.path.join(autodir, "tests") + +sys.path.insert(0, autodirbin) + +os.environ['AUTODIR'] = autodir +os.environ['AUTODIRBIN'] = autodirbin +os.environ['AUTODIRTEST'] = autodirtest +os.environ['PYTHONPATH'] = autodirbin + +cmd_parser = cmdparser.CommandParser() # Allow access to instance in parser + +parser = OptionParser(usage='Usage: %prog [options] [command] <control-file>', + epilog="[command]\t\tOne of: "+str(cmd_parser.cmdlist)) + +parser.add_option("-a", "--args", dest='args', + help="additional args to pass to control file") + +parser.add_option("-c", "--continue", dest="cont", action="store_true", + default=False, help="continue previously started job") + +parser.add_option("-t", "--tag", dest="tag", type="string", default="default", + help="set the job tag") + +parser.add_option("-H", "--harness", dest="harness", type="string", default='', + help="set the harness type") + +parser.add_option("-P", "--harness_args", dest="harness_args", type="string", default='', + help="arguments delivered to harness") + +parser.add_option("-U", "--user", dest="user", type="string", + default='', help="set the job username") + +parser.add_option("-l", "--external_logging", dest="log", action="store_true", + default=False, help="enable external logging") + +parser.add_option('--verbose', dest='verbose', action='store_true', + help='Include DEBUG messages in console output') + +parser.add_option('--quiet', dest='verbose', action='store_false', + help='Not include DEBUG messages in console output') + +parser.add_option('--hostname', dest='hostname', type='string', + default=None, action='store', + help='Take this as the hostname of this machine ' + '(given by autoserv)') + +parser.add_option('--output_dir', dest='output_dir', + type='string', default="", action='store', + help='Specify an alternate path to store test result logs') + +parser.add_option('--client_test_setup', dest='client_test_setup', + type='string', default=None, action='store', + help='a comma seperated list of client tests to prebuild on ' + 'the server. Use all to prebuild all of them.') + +parser.add_option('--tap', dest='tap_report', action='store_true', + default=None, help='Output TAP (Test anything ' + 'protocol) reports') + +def usage(): + parser.print_help() + sys.exit(1) + +def main(): + options, args = parser.parse_args() + + args = cmd_parser.parse_args(args) + + # Check for a control file if not in prebuild mode. + if len(args) != 1 and options.client_test_setup is None: + print "Missing control file!" + usage() + + drop_caches = global_config.global_config.get_config_value('CLIENT', + 'drop_caches', + type=bool, + default=True) + + if options.client_test_setup: + from autotest_lib.client.bin import setup_job + exit_code = 0 + try: + setup_job.setup_tests(options) + except Exception: + exit_code = 1 + sys.exit(exit_code) + + # JOB: run the specified job control file. + job.runjob(os.path.realpath(args[0]), drop_caches, options) -- 1.7.7.5 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
