virt.virt_test_utils: run_autotest - 'tar' needs relative paths to strip the leading '/'
[autotest-zwu.git] / client / bin / autotest
blob28c6015f06cbb0ff029553a783e2d6f93f11fa88
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("-P", "--harness_args", dest="harness_args", type="string", default='',
39 help="arguments delivered to harness")
41 parser.add_option("-U", "--user", dest="user", type="string",
42 default='', help="set the job username")
44 parser.add_option("-l", "--external_logging", dest="log", action="store_true",
45 default=False, help="enable external logging")
47 parser.add_option('--verbose', dest='verbose', action='store_true',
48 help='Include DEBUG messages in console output')
50 parser.add_option('--quiet', dest='verbose', action='store_false',
51 help='Not include DEBUG messages in console output')
53 parser.add_option('--hostname', dest='hostname', type='string',
54 default=None, action='store',
55 help='Take this as the hostname of this machine '
56 '(given by autoserv)')
58 parser.add_option('--client_test_setup', dest='client_test_setup',
59 type='string', default=None, action='store',
60 help='a comma seperated list of client tests to prebuild on '
61 'the server. Use all to prebuild all of them.')
63 parser.add_option('--tap', dest='tap_report', action='store_true',
64 default=None, help='Output TAP (Test anything '
65 'protocol) reports')
67 def usage():
68 parser.print_help()
69 sys.exit(1)
71 options, args = parser.parse_args()
73 # Check for a control file if not in prebuild mode.
74 if len(args) != 1 and options.client_test_setup is None:
75 usage()
77 drop_caches = global_config.global_config.get_config_value('CLIENT',
78 'drop_caches',
79 type=bool,
80 default=True)
82 if options.client_test_setup:
83 from autotest_lib.client.bin import setup_job
84 exit_code = 0
85 try:
86 setup_job.setup_tests(options)
87 except:
88 exit_code = 1
89 sys.exit(exit_code)
91 # JOB: run the specified job control file.
92 job.runjob(os.path.realpath(args[0]), drop_caches, options)