| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 # | 6 # |
| 7 # A python wrapper to call autotest ebuild. | 7 # A python wrapper to call autotest ebuild. |
| 8 | 8 |
| 9 import commands, logging, optparse, os, subprocess, sys | 9 import commands, logging, optparse, os, subprocess, sys |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 def print_help(self, file=None): | 50 def print_help(self, file=None): |
| 51 optparse.OptionParser.print_help(self, file) | 51 optparse.OptionParser.print_help(self, file) |
| 52 MyOptionParser.help = True | 52 MyOptionParser.help = True |
| 53 | 53 |
| 54 | 54 |
| 55 parser = MyOptionParser() | 55 parser = MyOptionParser() |
| 56 parser.allow_interspersed_args = True | 56 parser.allow_interspersed_args = True |
| 57 | 57 |
| 58 DEFAULT_BOARD = os.environ.get('DEFAULT_BOARD', '') | 58 DEFAULT_BOARD = os.environ.get('DEFAULT_BOARD', '') |
| 59 | 59 |
| 60 parser.add_option('--args', dest='args', action='store', |
| 61 default='', |
| 62 help='The arguments to pass to the test control file.') |
| 60 parser.add_option('--autox', dest='autox', action='store_true', | 63 parser.add_option('--autox', dest='autox', action='store_true', |
| 61 default=True, | 64 default=True, |
| 62 help='Build autox along with autotest [default].') | 65 help='Build autox along with autotest [default].') |
| 63 parser.add_option('--noautox', dest='autox', action='store_false', | 66 parser.add_option('--noautox', dest='autox', action='store_false', |
| 64 help='Don\'t build autox along with autotest.') | 67 help='Don\'t build autox along with autotest.') |
| 65 parser.add_option('--board', dest='board', action='store', | 68 parser.add_option('--board', dest='board', action='store', |
| 66 default=DEFAULT_BOARD, | 69 default=DEFAULT_BOARD, |
| 67 help='The board for which you are building autotest.') | 70 help='The board for which you are building autotest.') |
| 68 parser.add_option('--build', dest='build', action='store', | 71 parser.add_option('--build', dest='build', action='store', |
| 69 help='Only prebuild client tests, do not run tests.') | 72 help='Only prebuild client tests, do not run tests.') |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 environ.get('FEATURES', '')) | 184 environ.get('FEATURES', '')) |
| 182 environ['TEST_LIST'] = test_list | 185 environ['TEST_LIST'] = test_list |
| 183 environ['USE'] = use_flag | 186 environ['USE'] = use_flag |
| 184 emerge_cmd = ['emerge-%s' % options.board, | 187 emerge_cmd = ['emerge-%s' % options.board, |
| 185 'chromeos-base/autotest'] | 188 'chromeos-base/autotest'] |
| 186 if emerge_jobs: | 189 if emerge_jobs: |
| 187 emerge_cmd.append(emerge_jobs) | 190 emerge_cmd.append(emerge_jobs) |
| 188 return run(emerge_cmd) | 191 return run(emerge_cmd) |
| 189 | 192 |
| 190 | 193 |
| 191 def run_autoserv(board, args): | 194 def run_autoserv(options, args): |
| 192 environ = os.environ | 195 environ = os.environ |
| 196 |
| 197 environ['AUTOSERV_TEST_ARGS'] = options.args |
| 193 environ['AUTOSERV_ARGS'] = ' '.join(args) | 198 environ['AUTOSERV_ARGS'] = ' '.join(args) |
| 194 environ['FEATURES'] = ('%s -buildpkg -digest noauto' % | 199 environ['FEATURES'] = ('%s -buildpkg -digest noauto' % |
| 195 environ.get('FEATURES', '')) | 200 environ.get('FEATURES', '')) |
| 196 ebuild_cmd = ['ebuild-%s' % board, | 201 ebuild_cmd = ['ebuild-%s' % options.board, |
| 197 '../third_party/chromiumos-overlay/chromeos-base/' | 202 '../third_party/chromiumos-overlay/chromeos-base/' |
| 198 'autotest/autotest-0.0.1.ebuild', | 203 'autotest/autotest-0.0.1.ebuild', |
| 199 'clean', 'unpack', 'test'] | 204 'clean', 'unpack', 'test'] |
| 200 run(ebuild_cmd) | 205 run(ebuild_cmd) |
| 201 | 206 |
| 202 | 207 |
| 203 def main(): | 208 def main(): |
| 204 me = sys.argv[0] | 209 me = sys.argv[0] |
| 205 common_sh = os.path.join(os.path.dirname(me), 'common.sh') | 210 common_sh = os.path.join(os.path.dirname(me), 'common.sh') |
| 206 | 211 |
| 207 assert_inside_chroot(common_sh) | 212 assert_inside_chroot(common_sh) |
| 208 set_common_env(common_sh, 'GCLIENT_ROOT') | 213 set_common_env(common_sh, 'GCLIENT_ROOT') |
| 209 | 214 |
| 210 options, args = parse_args_and_help() | 215 options, args = parse_args_and_help() |
| 211 if options.build: | 216 if options.build: |
| 212 status = build_autotest(options) | 217 status = build_autotest(options) |
| 213 if status: | 218 if status: |
| 214 die(common_sh, 'build_autotest failed.') | 219 die(common_sh, 'build_autotest failed.') |
| 215 else: | 220 else: |
| 216 ssh_key_file = os.path.join(os.path.dirname(me), | 221 ssh_key_file = os.path.join(os.path.dirname(me), |
| 217 'mod_for_test_scripts/ssh_keys/testing_rsa') | 222 'mod_for_test_scripts/ssh_keys/testing_rsa') |
| 218 os.chmod(ssh_key_file, 0400) | 223 os.chmod(ssh_key_file, 0400) |
| 219 run_autoserv(options.board, args) | 224 run_autoserv(options, args) |
| 220 | 225 |
| 221 | 226 |
| 222 if __name__ == '__main__': | 227 if __name__ == '__main__': |
| 223 main() | 228 main() |
| OLD | NEW |