OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Launches Android Virtual Devices with a set configuration for testing Chrome. | 6 """Launches Android Virtual Devices with a set configuration for testing Chrome. |
7 | 7 |
8 The script will launch a specified number of Android Virtual Devices (AVD's). | 8 The script will launch a specified number of Android Virtual Devices (AVD's). |
9 """ | 9 """ |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 # the emulator to find the system images upon launch. | 25 # the emulator to find the system images upon launch. |
26 emulator_sdk = os.path.join(constants.EMULATOR_SDK_ROOT, 'sdk') | 26 emulator_sdk = os.path.join(constants.EMULATOR_SDK_ROOT, 'sdk') |
27 os.environ['ANDROID_SDK_ROOT'] = emulator_sdk | 27 os.environ['ANDROID_SDK_ROOT'] = emulator_sdk |
28 | 28 |
29 opt_parser = optparse.OptionParser(description='AVD script.') | 29 opt_parser = optparse.OptionParser(description='AVD script.') |
30 opt_parser.add_option('-n', '--num', dest='emulator_count', | 30 opt_parser.add_option('-n', '--num', dest='emulator_count', |
31 help='Number of emulators to launch (default is 1).', | 31 help='Number of emulators to launch (default is 1).', |
32 type='int', default='1') | 32 type='int', default='1') |
33 opt_parser.add_option('--abi', default='x86', | 33 opt_parser.add_option('--abi', default='x86', |
34 help='Platform of emulators to launch (x86 default).') | 34 help='Platform of emulators to launch (x86 default).') |
| 35 opt_parser.add_option('--api-level', dest='api_level', |
| 36 help='API level for the image, e.g. 19 for Android 4.4', |
| 37 type='int', default=constants.ANDROID_SDK_VERSION) |
35 | 38 |
36 options, _ = opt_parser.parse_args(argv[1:]) | 39 options, _ = opt_parser.parse_args(argv[1:]) |
37 | 40 |
38 logging.basicConfig(level=logging.INFO, | 41 logging.basicConfig(level=logging.INFO, |
39 format='# %(asctime)-15s: %(message)s') | 42 format='# %(asctime)-15s: %(message)s') |
40 logging.root.setLevel(logging.INFO) | 43 logging.root.setLevel(logging.INFO) |
41 | 44 |
42 # Check if KVM is enabled for x86 AVD's and check for x86 system images. | 45 # Check if KVM is enabled for x86 AVD's and check for x86 system images. |
| 46 # TODO(andrewhayden) Since we can fix all of these with install_emulator_deps |
| 47 # why don't we just run it? |
43 if options.abi =='x86': | 48 if options.abi =='x86': |
44 if not install_emulator_deps.CheckKVM(): | 49 if not install_emulator_deps.CheckKVM(): |
45 logging.critical('ERROR: KVM must be enabled in BIOS, and installed. ' | 50 logging.critical('ERROR: KVM must be enabled in BIOS, and installed. ' |
46 'Enable KVM in BIOS and run install_emulator_deps.py') | 51 'Enable KVM in BIOS and run install_emulator_deps.py') |
47 return 1 | 52 return 1 |
48 elif not install_emulator_deps.CheckX86Image(): | 53 elif not install_emulator_deps.CheckX86Image(options.api_level): |
49 logging.critical('ERROR: System image for x86 AVD not installed. Run ' | 54 logging.critical('ERROR: System image for x86 AVD not installed. Run ' |
50 'install_emulator_deps.py') | 55 'install_emulator_deps.py') |
51 return 1 | 56 return 1 |
52 | 57 |
53 if not install_emulator_deps.CheckSDK(): | 58 if not install_emulator_deps.CheckSDK(): |
54 logging.critical('ERROR: Emulator SDK not installed. Run ' | 59 logging.critical('ERROR: Emulator SDK not installed. Run ' |
55 'install_emulator_deps.py.') | 60 'install_emulator_deps.py.') |
56 return 1 | 61 return 1 |
57 | 62 |
58 emulator.LaunchEmulators(options.emulator_count, options.abi, True) | 63 if not install_emulator_deps.CheckSDKPlatform(options.api_level): |
| 64 logging.critical('ERROR: Emulator SDK missing required target for API %d. ' |
| 65 'Run install_emulator_deps.py.') |
| 66 return 1 |
| 67 |
| 68 emulator.LaunchEmulators(options.emulator_count, options.abi, |
| 69 options.api_level, True) |
59 | 70 |
60 | 71 |
61 if __name__ == '__main__': | 72 if __name__ == '__main__': |
62 sys.exit(main(sys.argv)) | 73 sys.exit(main(sys.argv)) |
OLD | NEW |