autotest revision 1f572e5efbaaa8bc0d1246123ab897607c9a011b
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.') 59def usage(): 60 parser.print_help() 61 sys.exit(1) 62 63options, args = parser.parse_args() 64 65# Check for a control file if not in prebuild mode. 66if len(args) != 1 and options.client_test_setup is None: 67 usage() 68 69drop_caches = global_config.global_config.get_config_value('CLIENT', 70 'drop_caches', 71 type=bool, 72 default=True) 73 74if options.client_test_setup: 75 from autotest_lib.client.bin import setup_job 76 exit_code = 0 77 try: 78 setup_job.setup_tests(options) 79 except: 80 exit_code = 1 81 sys.exit(exit_code) 82 83# JOB: run the specified job control file. 84job.runjob(os.path.realpath(args[0]), drop_caches, options) 85