KVM test: add VM.verify_alive() and Monitor.verify_responsive()
[autotest-zwu.git] / client / bin / autotest
blobe843b7f9a3f28880456db7f2a88663297543cc50
1 #!/usr/bin/python -u
3 # autotest <control file> - run the autotest control file specified.
5 import os, sys
6 import common
7 from optparse import OptionParser
8 from autotest_lib.client.bin import job
9 from autotest_lib.client.common_lib import global_config
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.
15 autodirbin = os.path.dirname(os.path.realpath(sys.argv[0]))
16 autodir = os.path.dirname(autodirbin)
18 sys.path.insert(0, autodirbin)
20 os.environ['AUTODIR'] = autodir
21 os.environ['AUTODIRBIN'] = autodirbin
22 os.environ['PYTHONPATH'] = autodirbin
24 parser = OptionParser()
26 parser.add_option("-a", "--args", dest='args',
27 help="additional args to pass to control file")
29 parser.add_option("-c", "--continue", dest="cont", action="store_true",
30 default=False, help="continue previously started job")
32 parser.add_option("-t", "--tag", dest="tag", type="string", default="default",
33 help="set the job tag")
35 parser.add_option("-H", "--harness", dest="harness", type="string", default='',
36 help="set the harness type")
38 parser.add_option("-U", "--user", dest="user", type="string",
39 default='', help="set the job username")
41 parser.add_option("-l", "--external_logging", dest="log", action="store_true",
42 default=False, help="enable external logging")
44 parser.add_option('--verbose', dest='verbose', action='store_true',
45 help='Include DEBUG messages in console output')
47 parser.add_option('--quiet', dest='verbose', action='store_false',
48 help='Not include DEBUG messages in console output')
50 parser.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)')
55 parser.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.')
60 parser.add_option('--tap', dest='tap_report', action='store_true',
61 default=None, help='Output TAP (Test anything '
62 'protocol) reports')
64 def usage():
65 parser.print_help()
66 sys.exit(1)
68 options, args = parser.parse_args()
70 # Check for a control file if not in prebuild mode.
71 if len(args) != 1 and options.client_test_setup is None:
72 usage()
74 drop_caches = global_config.global_config.get_config_value('CLIENT',
75 'drop_caches',
76 type=bool,
77 default=True)
79 if 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)
88 # JOB: run the specified job control file.
89 job.runjob(os.path.realpath(args[0]), drop_caches, options)