コード例 #1
0
def _MakeAndroidPlatform():
    """Pulls together all the binary tools / libs we'll be using today."""
    platform = emulated_device.AndroidPlatform()
    runfiles_base = os.environ.get('TEST_SRCDIR') or os.environ.get(
        'DEVICE_RUNFILES')
    if not runfiles_base:
        logging.warning(
            'Cannot find runfiles (via env vars). Defaulting to $CWD.')
        runfiles_base = os.getcwd()
    else:
        runfiles_base = os.path.abspath(runfiles_base)

    if FLAGS.emulator_extra_lib_dir:
        for lib_dir in FLAGS.emulator_extra_lib_dir:
            assert os.path.exists(lib_dir), '%s: does not exist' % lib_dir
        platform.prepended_library_path = ':'.join(
            FLAGS.emulator_extra_lib_dir)

    root_dir = os.path.join(runfiles_base, 'android_test_support')
    # Sometimes we are running from android_test_support, fix root_dir here.
    if not os.path.exists(root_dir):
        root_dir = runfiles_base

    if FLAGS.emulator_x86:
        base_emulator_path = os.path.dirname(
            os.path.join(root_dir, FLAGS.emulator_x86))
    else:
        base_emulator_path = os.path.join(
            root_dir, ('third_party/java/android/android_sdk_linux/tools'))

    if not os.path.exists(base_emulator_path):
        logging.error('emulator tools dir %s does not exist.',
                      base_emulator_path)
        sys.exit(1)
    if FLAGS.android_sdk_path:
        platform.android_sdk = FLAGS.android_sdk_path

    platform.base_emulator_path = base_emulator_path

    if FLAGS.adb_turbo:
        platform.adb = FLAGS.adb_turbo
    else:
        turbo_relative = ('' 'tools/android/emulator/support/adb.turbo')
        turbo_g3_relative = os.path.join('android_test_support',
                                         turbo_relative)
        if os.path.exists(os.path.abspath(turbo_relative)):
            platform.adb = os.path.abspath(turbo_relative)
        elif os.path.exists(os.path.abspath(turbo_g3_relative)):
            platform.adb = os.path.abspath(turbo_g3_relative)
        else:
            platform.adb = resources.GetResourceFilename(turbo_g3_relative)
    assert os.path.exists(platform.adb), ('%s: does not exist. please pass '
                                          '--adb_turbo' % platform.adb)
    platform.real_adb = FLAGS.adb

    if FLAGS.flag_configured_android_tools:
        platform.launcher_tool = FLAGS.android_launcher_tool
        platform.emulator_x86 = FLAGS.emulator_x86
        platform.emulator_arm = FLAGS.emulator_arm
        if FLAGS.kvm_device:
            platform.kvm_device = FLAGS.kvm_device
        platform.empty_snapshot_fs = FLAGS.empty_snapshot_fs
        platform.mksdcard = FLAGS.mksdcard
        platform.bios_files = filter(lambda e: e, FLAGS.bios_files)

    platform.emulator_wrapper_launcher = _ExtractSuffixFile(
        FLAGS.system_images, '/emulator')

    return platform
コード例 #2
0
 def testGetResourceFilenameWithAbsoluteFileName(self):
     temp_file = tempfile.NamedTemporaryFile().name
     resource_file = resources.GetResourceFilename(temp_file)
     self.assertEquals(temp_file, resource_file)