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
4 # found in the LICENSE file.
6 """Launches Android Virtual Devices with a set configuration for testing Chrome.
8 The script will launch a specified number of Android Virtual Devices (AVD's).
12 import install_emulator_deps
19 from pylib
import constants
20 from pylib
.utils
import emulator
24 # ANDROID_SDK_ROOT needs to be set to the location of the SDK used to launch
25 # the emulator to find the system images upon launch.
26 emulator_sdk
= os
.path
.join(constants
.EMULATOR_SDK_ROOT
,
27 'android_tools', 'sdk')
28 os
.environ
['ANDROID_SDK_ROOT'] = emulator_sdk
30 opt_parser
= optparse
.OptionParser(description
='AVD script.')
31 opt_parser
.add_option('-n', '--num', dest
='emulator_count',
32 help='Number of emulators to launch (default is 1).',
33 type='int', default
='1')
34 opt_parser
.add_option('--abi', default
='x86',
35 help='Platform of emulators to launch (x86 default).')
37 options
, _
= opt_parser
.parse_args(argv
[1:])
39 logging
.basicConfig(level
=logging
.INFO
,
40 format
='# %(asctime)-15s: %(message)s')
41 logging
.root
.setLevel(logging
.INFO
)
43 # Check if KVM is enabled for x86 AVD's and check for x86 system images.
44 if options
.abi
=='x86':
45 if not install_emulator_deps
.CheckKVM():
46 logging
.critical('ERROR: KVM must be enabled in BIOS, and installed. '
47 'Enable KVM in BIOS and run install_emulator_deps.py')
49 elif not install_emulator_deps
.CheckX86Image():
50 logging
.critical('ERROR: System image for x86 AVD not installed. Run '
51 'install_emulator_deps.py')
54 if not install_emulator_deps
.CheckSDK():
55 logging
.critical('ERROR: Emulator SDK not installed. Run '
56 'install_emulator_deps.py.')
59 emulator
.LaunchEmulators(options
.emulator_count
, options
.abi
, True)
62 if __name__
== '__main__':
63 sys
.exit(main(sys
.argv
))