Cts框架解析(4)

Debug

debug的入口在CtsConsole类,所以我们把第一个断点打在249行:

Console console = new CtsConsole();

按F6再按F5进入到Console.startConsole方法中。

按F5进入GlobalConfiguration.createGlobalConfiguration方法中。

该方法内主要是读取全局配置文件并设置IGlobalConfiguration接口对象sInstance。主要方法为95行读取文件的getGlobalConfigPath():

private static String getGlobalConfigPath() throws ConfigurationException {
        String path = System.getenv(GLOBAL_CONFIG_VARIABLE);
        if (path != null) {
            // don't actually check for accessibility here, since the variable
            // might be specifying
            // a java resource rather than a filename. Even so, this can help
            // the user figure out
            // which global config (if any) was picked up by TF.
            System.err
                    .format("Attempting to use global config \"%s\" from variable $%s.\n",
                            path, GLOBAL_CONFIG_VARIABLE);
            return path;
        }

        File file = new File(GLOBAL_CONFIG_FILENAME);
        if (file.exists()) {
            path = file.getPath();
            System.err.format(
                    "Attempting to use auto detected global config \"%s\".\n",
                    path);
            System.err.flush();
            return path;
        }

        // FIXME: search in tradefed.sh launch dir (or classpath?)

        return null;
    }

首先判断是否设置了全局配置文件的系统变量,如果没有设置,那直接在当前文件目录下找tf_global_config.xml文件。很显然,本程序这些都没有,所以该方法返回的结果应该是null。回到了createGlobalConfiguration(String[] args)方法中:

if (globalConfigPath != null) {
				// Found a global config file; attempt to parse and use it
				sInstance = configFactory.createGlobalConfigurationFromArgs(
						ArrayUtil.buildArray(new String[] { globalConfigPath },
								args), nonGlobalArgs);
				System.err.format("Success!  Using global config \"%s\"\n",
						globalConfigPath);
			} else {
				// Use default global config
				sInstance = new GlobalConfiguration();
				nonGlobalArgs = Arrays.asList(args);
			}
			return nonGlobalArgs;

因为返回的路径为null,所以直接跳转到else语句块中,new一个新对象,没有设置任何属性。最后将命令行参数封装在list中返回,然后console设置参数,最终启动线程来执行任务。所以第二个断点要打在Console的run方法里,然后按F8进入run方法。

下一篇继续

时间: 2024-08-12 18:49:35

Cts框架解析(4)的相关文章

Cts框架解析(5)

解析配置文件 Cts框架分为9大部分: cmd_options:命令行接受的参数选项,command包中. device_requirements:设备相关要求,device包中 device_options:设备参数,device包中 builde_provider:版本提供者,build包中 target_preparer:预置条件准备,targetprep包中 test:测试类型,存在testtype包中 device_recovery:任务执行过程中设备异常后的设备恢复,device包中

Cts框架解析(2)-cts调试环境的搭建

上一篇文章中说了怎样在windows搭建cts以及执行cts进行測试.这篇文章来讲讲怎样在eclipse中配置源代码,进行debug调试. 下载 cts源代码地址:https://android.googlesource.com/platform/cts 能够使用git下载到本地. 文件夹结构 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaXRmb290YmFsbA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFC

Cts框架解析(9)-IDeviceRecovery

当设备处于offline状态时,cts框架就要调用IDeviceRecovery接口类去做相应的恢复工作. 接口 /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the Licens

Cts框架解析(13)-任务执行过程

因为测试任务是个很复杂的过程,所以要单独拿出来讲,里面还涉及了result_reporter的内容.所以这是一个大块.首先把断点打在CtsTest的run方法中,删除其他断点,重新启动debug模式: 首先会调用checkFields检查一下命令行参数.然后生成plan里的包名信息.(要理解plan的意思,plan就是cts目录下plan文件下的xml文件,它里面配置的entry代表一个测试项,一个测试项里又包含多个测试的case).本程序执行的是Signature计划,我们就来看看这个xml文

Cts框架解析(7)-任务执行的调度室

TestInvocation /** * {@inheritDoc} */ @Override public void invoke(ITestDevice device, IConfiguration config, IRescheduler rescheduler) throws DeviceNotAvailableException, Throwable { try { mStatus = "fetching build"; config.getLogOutput().init(

Cts框架解析(6)-任务的运行

前两篇讲了任务的加入和9大项配置,这篇讲任务的运行. 任务的运行 任务的运行在CommandScheduler的run方法中,所以删除全部的断点,在run方法中打上断点,重新启动启动debug: 先看while循环以下的第一行代码 ExecutableCommand cmd = dequeueConfigCommand(); private ExecutableCommand dequeueConfigCommand() { try { // poll for a command, rather

Cts框架解析(1)-windows下cts配置

环境搭建 下载 cts工具的下载地址:http://source.android.com/compatibility/downloads.html windows选择Android4.4 R3 Compatibility Test Suite (CTS) - ARM下载. 文件夹结构 解压后的文件夹结构例如以下: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaXRmb290YmFsbA==/font/5a6L5L2T/fontsize/400/fil

Cts框架解析(6)-任务的执行

前两篇讲了任务的添加和9大项配置,这篇讲任务的执行. 任务的执行 任务的执行在CommandScheduler的run方法中,所以删除所有的断点,在run方法中打上断点,重启启动debug: 先看while循环下面的第一行代码 ExecutableCommand cmd = dequeueConfigCommand(); private ExecutableCommand dequeueConfigCommand() { try { // poll for a command, rather t

Cts框架解析(8)-IBuildProvider

IBuildProvider接口中定义了三个方法 /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of th

Cts框架解析(3)

cts是建立在tradefederation项目上的,cts中的tradefed-prebuild.jar就是该项目编译后的jar包.在debug调试的时候少不了这个项目,所以现在开始把这个项目添加到eclipse中. 下载 如果有可以翻墙的话,建议下载最新的版本,我上传的tradefederation应该不是最新的,但是我翻不了墙,所以还是拿这个项目debug. 下载地址:http://download.csdn.net/detail/qhshiniba/8050545 配置 下载后解压后的文