autotest revision 861b2d54aec24228cdb3895dbc40062cb40cb2ad
1#!/usr/bin/python -u 2# 3# autotest <control file> - run the autotest control file specified. 4# 5import os, sys 6import common 7from optparse import OptionParser 8from autotest_lib.client.bin import job 9from autotest_lib.client.common_lib import global_config 10 11 12# Use the name of the binary to find the real installation directory 13# aka $AUTODIR. Update our path to include the $AUTODIR/bin/tests 14# directory and ensure we have $AUTODIR in our environment. 15autodirbin = os.path.dirname(os.path.realpath(sys.argv[0])) 16autodir = os.path.dirname(autodirbin) 17 18sys.path.insert(0, autodirbin) 19 20os.environ['AUTODIR'] = autodir 21os.environ['AUTODIRBIN'] = autodirbin 22os.environ['PYTHONPATH'] = autodirbin 23 24parser = OptionParser() 25 26parser.add_option("-a", "--args", dest='args', 27 help="additional args to pass to control file") 28 29parser.add_option("-c", "--continue", dest="cont", action="store_true", 30 default=False, help="continue previously started job") 31 32parser.add_option("-t", "--tag", dest="tag", type="string", default="default", 33 help="set the job tag") 34 35parser.add_option("-H", "--harness", dest="harness", type="string", default='', 36 help="set the harness type") 37 38parser.add_option("-U", "--user", dest="user", type="string", 39 default='', help="set the job username") 40 41parser.add_option("-l", "--external_logging", dest="log", action="store_true", 42 default=False, help="enable external logging") 43 44parser.add_option('--verbose', dest='verbose', action='store_true', 45 help='Include DEBUG messages in console output') 46 47parser.add_option('--quiet', dest='verbose', action='store_false', 48 help='Not include DEBUG messages in console output') 49 50parser.add_option('--hostname', dest='hostname', type='string', 51 default=None, action='store', 52 help='Take this as the hostname of this machine ' 53 '(given by autoserv)') 54 55parser.add_option('--client_test_setup', dest='client_test_setup', 56 type='string', default=None, action='store', 57 help='a comma seperated list of client tests to prebuild on ' 58 'the server. Use all to prebuild all of them.') 59 60parser.add_option('--tap', dest='tap_report', action='store_true', 61 default=None, help='Output TAP (Test anything ' 62 'protocol) reports') 63 64def usage(): 65 parser.print_help() 66 sys.exit(1) 67 68options, args = parser.parse_args() 69 70# Check for a control file if not in prebuild mode. 71if len(args) != 1 and options.client_test_setup is None: 72 usage() 73 74drop_caches = global_config.global_config.get_config_value('CLIENT', 75 'drop_caches', 76 type=bool, 77 default=True) 78 79if options.client_test_setup: 80 from autotest_lib.client.bin import setup_job 81 exit_code = 0 82 try: 83 setup_job.setup_tests(options) 84 except: 85 exit_code = 1 86 sys.exit(exit_code) 87 88# JOB: run the specified job control file. 89job.runjob(os.path.realpath(args[0]), drop_caches, options) 90