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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 help='Set sdcard size of the emulators' | 48 help='Set sdcard size of the emulators' |
49 ' e.g. --sdcard-size=512M') | 49 ' e.g. --sdcard-size=512M') |
50 run_parser.add_argument('--partition-size', dest='partition_size', | 50 run_parser.add_argument('--partition-size', dest='partition_size', |
51 default=emulator.DEFAULT_STORAGE_SIZE, | 51 default=emulator.DEFAULT_STORAGE_SIZE, |
52 help='Default internal storage size' | 52 help='Default internal storage size' |
53 ' e.g. --partition-size=1024M') | 53 ' e.g. --partition-size=1024M') |
54 run_parser.add_argument('--launch-without-kill', action='store_false', | 54 run_parser.add_argument('--launch-without-kill', action='store_false', |
55 dest='kill_and_launch', default=True, | 55 dest='kill_and_launch', default=True, |
56 help='Kill all emulators at launch') | 56 help='Kill all emulators at launch') |
57 run_parser.add_argument('--enable-kvm', action='store_true', | 57 run_parser.add_argument('--enable-kvm', action='store_true', |
58 dest='enable_kvm', default=False) | 58 dest='enable_kvm', default=False, |
| 59 help='Enable kvm for faster x86 emulator run') |
59 | 60 |
60 arguments = arg_parser.parse_args(argv[1:]) | 61 arguments = arg_parser.parse_args(argv[1:]) |
61 | 62 |
62 logging.root.setLevel(logging.INFO) | 63 logging.root.setLevel(logging.INFO) |
63 | 64 |
64 if arguments.command == 'kill': | 65 if arguments.command == 'kill': |
65 logging.info('Killing all existing emulator and existing the program') | 66 logging.info('Killing all existing emulator and existing the program') |
66 emulator.KillAllEmulators() | 67 emulator.KillAllEmulators() |
67 return | 68 return |
68 if arguments.command == 'delete': | 69 if arguments.command == 'delete': |
69 emulator.DeleteAllTempAVDs() | 70 emulator.DeleteAllTempAVDs() |
70 return | 71 return |
71 | 72 |
72 # Check if SDK exist in ANDROID_SDK_ROOT | 73 # Check if SDK exist in ANDROID_SDK_ROOT |
73 if not install_emulator_deps.CheckSDK(): | 74 if not install_emulator_deps.CheckSDK(): |
74 raise Exception('Emulator SDK not installed in %s' | 75 raise Exception('Emulator SDK not installed in %s' |
75 % constants.ANDROID_SDK_ROOT) | 76 % constants.ANDROID_SDK_ROOT) |
76 | 77 |
77 # Check if KVM is enabled for x86 AVD's and check for x86 system images. | 78 # Check if KVM is enabled for x86 AVD |
78 # TODO(andrewhayden) Since we can fix all of these with install_emulator_deps | |
79 # why don't we just run it? | |
80 if arguments.abi == 'x86': | 79 if arguments.abi == 'x86': |
81 if not install_emulator_deps.CheckKVM(): | 80 if not install_emulator_deps.CheckKVM(): |
82 logging.warning('KVM is not installed or enabled') | 81 logging.warning('KVM is not installed or enabled') |
83 arguments.enable_kvm = False | 82 arguments.enable_kvm = False |
84 elif not install_emulator_deps.CheckX86Image(arguments.api_level): | 83 |
85 logging.critical('ERROR: System image for x86 AVD not installed. Run ' | 84 # Check if targeted system image exist |
86 'install_emulator_deps.py') | 85 if not install_emulator_deps.CheckSystemImage(arguments.abi, |
87 return 1 | 86 arguments.api_level): |
| 87 logging.critical('ERROR: System image for %s AVD not installed. Run ' |
| 88 'install_emulator_deps.py', arguments.abi) |
| 89 return 1 |
88 | 90 |
89 # If AVD is specified, check that the SDK has the required target. If not, | 91 # If AVD is specified, check that the SDK has the required target. If not, |
90 # check that the SDK has the desired target for the temporary AVD's. | 92 # check that the SDK has the desired target for the temporary AVD's. |
91 api_level = arguments.api_level | 93 api_level = arguments.api_level |
92 if arguments.name: | 94 if arguments.name: |
93 android = os.path.join(constants.ANDROID_SDK_ROOT, 'tools', | 95 android = os.path.join(constants.ANDROID_SDK_ROOT, 'tools', |
94 'android') | 96 'android') |
95 avds_output = cmd_helper.GetCmdOutput([android, 'list', 'avd']) | 97 avds_output = cmd_helper.GetCmdOutput([android, 'list', 'avd']) |
96 names = re.findall(r'Name: (\w+)', avds_output) | 98 names = re.findall(r'Name: (\w+)', avds_output) |
97 api_levels = re.findall(r'API level (\d+)', avds_output) | 99 api_levels = re.findall(r'API level (\d+)', avds_output) |
(...skipping 26 matching lines...) Expand all Loading... |
124 arguments.api_level, | 126 arguments.api_level, |
125 enable_kvm=arguments.enable_kvm, | 127 enable_kvm=arguments.enable_kvm, |
126 kill_and_launch=arguments.kill_and_launch, | 128 kill_and_launch=arguments.kill_and_launch, |
127 sdcard_size=arguments.sdcard_size, | 129 sdcard_size=arguments.sdcard_size, |
128 storage_size=arguments.partition_size, | 130 storage_size=arguments.partition_size, |
129 wait_for_boot=True | 131 wait_for_boot=True |
130 ) | 132 ) |
131 | 133 |
132 if __name__ == '__main__': | 134 if __name__ == '__main__': |
133 sys.exit(main(sys.argv)) | 135 sys.exit(main(sys.argv)) |
OLD | NEW |