启动和关闭ADB服务(adb start-server和adbkill-server)

经作者测试,模拟器在运行一段时间后,adb服务有可能(在Windows进程中可以找到这个服务,该服务用来为模拟器或通过USB数据线连接的真机服务)会出现异常。这时需要重新对adb服务关闭和重启。当然,重启Eclipse可能会解决问题,但那比较麻烦。如果想手工关闭adb服务,可以使用如下命令:

1. adb kill-server

在关闭adb服务后,要使用如下命令启动adb服务:

1. adb start-server

链接DLNA网络的命令:

ifconfig eth0 down; ifconfig eth0 hw ether 00:00:00:00:fd:87; ifconfig eth0 up; udhcpc

下面的方法是更适合RD 来debug CTS issue的cts运行方式, 这样解决了一个大问题: 如果用android传统方式去运行cts的话,必然已经被cts 运行环境占用了adb端口,用eclipsedebug就无法在另外一台机器上进行(例如RDPC, eclipse debug也需要adb ),  唯一的方式, 就是把android的source code搬到cts 运行的ubuntu机器上,  由于size特别大,非常不便.

下面介绍的运行方式, 直接用adb 去模拟 cts环境的运行方式, 唯一的缺点是, 一个test一个test 的运行.  但是, 对RD来说,这反而是优点! 方便快捷.

这个方法概括一下就是: 在我们的branch 上就有cts 的sourcecode, 我们可以修改其中某个test case所对应的 apk  source, 之后,build 出 apk,  然后安装到板子上去run. 如果我们修改的testcase apk,就是添加了一些message/log之类的, 就立即可以在运行过程中体现出来. 同时,我们可以利用eclipse/ddms相结合 debug android framework部分, 当然, 由于我们也有apk的sourcecode, 也可以debug test case apk本身.

请参考:

剛做完實驗 , 寫下 SOP 給各位參考…

之後若有 RD 需要, 也可以參考這份….

Steps:

1)cmd> cd android/ics-4.x (到 android 目錄)

2)cmd>make cts

的cts 版本 ?

A)cmd> catandroid/ics-4.x/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java|  grepCTS_BUILD_VERSION

Result:public static final String CTS_BUILD_VERSION = "4.0.3_r2";

3)cmd>cd out/host/linux-x86/cts/android-cts/repository/testcases

4)找到需要測試的apk 並copy 到PC端file folder

Ex: CtsTestStubs.apk, CtsOsTestCases.apk, android.core.tests.runner.apk, CtsMyExampleTestCases.apk

5)確定PC 可用adb 連到target

6)

cmd>adbinstall CtsMyExampleTestCases.apk (安裝需要測試的 apk)

cmd>adb install CtsTestStubs.apk (這是google大多原生testapk 需要用到的 stub)

cmd>adbinstall CtsOsTestCases.apk

cmd>adbinstall android.core.tests.runner.apk

7)cmd>adb shell pm list instrumentation   (用來查看已經安裝的instrumentation, 每個 CTS 用測的 apk 都是用instrumentation)

Result:

Instrumentation:com.android.cts.myexample/android.test.InstrumentationTestRunner (target=com.android.cts.myexample)

8)

整個 package 測試

cmd>adbshell am instrument –w –r com.android.cts.myexample/android.test.InstrumentationTest(執行該 test package)

此時可查看 failed (如下:Step8 test result example),也可透過 logcat log來看 fail (如下:[test result from logcat])

單一class測試

cmd> adb shellam instrument –e classandroid.myexample.cts.MySampleCalculatorTest–w –rcom.android.cts.myexample/android.test.InstrumentationTestRunner

cmd> adb shellam instrument –e classandroid.os.cts.MyHelloTest–w –rcom.android.cts.os/android.test.InstrumentationCtsTestRunner

單一function測試

cmd> adbshell am instrument –e classandroid.myexample.cts.MySampleCalculatorTest#testAdd–w –rcom.android.cts.myexample/android.test.InstrumentationTestRunner

9) 移除測試用 apk (cmd: adb uninstall<app_name> à <app_name>可從 target 端查詢: ls /data/app )

cmd> adb uninstall com.android.cts.os

cmd> adb uninstall com.android.cts.stub

cmd> adb uninstall com.android.cts.myexample

=== [Step8: test result example] ===

INSTRUMENTATION_STATUS:id=InstrumentationTestRunner

INSTRUMENTATION_STATUS: current=1

INSTRUMENTATION_STATUS:class=android.myexample.cts.MySampleCalculatorTest

INSTRUMENTATION_STATUS: stream=

android.myexample.cts.MySampleCalculatorTest:

INSTRUMENTATION_STATUS: numtests=2

INSTRUMENTATION_STATUS: test=testAdd

INSTRUMENTATION_STATUS_CODE: 1

INSTRUMENTATION_STATUS:id=InstrumentationTestRunner

INSTRUMENTATION_STATUS: current=1

INSTRUMENTATION_STATUS:class=android.myexample.cts.MySampleCalculatorTest

INSTRUMENTATION_STATUS: stream=.

INSTRUMENTATION_STATUS: numtests=2

INSTRUMENTATION_STATUS: test=testAdd

INSTRUMENTATION_STATUS_CODE: 0

INSTRUMENTATION_STATUS:id=InstrumentationTestRunner

INSTRUMENTATION_STATUS: current=2

INSTRUMENTATION_STATUS: class=android.myexample.cts.MySampleCalculatorTest

INSTRUMENTATION_STATUS: stream=

INSTRUMENTATION_STATUS: numtests=2

INSTRUMENTATION_STATUS:test=testSubtration

INSTRUMENTATION_STATUS_CODE: 1

INSTRUMENTATION_STATUS:id=InstrumentationTestRunner

INSTRUMENTATION_STATUS: current=2

INSTRUMENTATION_STATUS:class=android.myexample.cts.MySampleCalculatorTest

INSTRUMENTATION_STATUS: stream=

Failure in testSubtration:

junit.framework.AssertionFailedError:expected:<20> but was:<30>

atandroid.myexample.cts.MySampleCalculatorTest.testSubtration(MySampleCalculatorTest.java:63)

at java.lang.reflect.Method.invokeNative(Native Method)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)

at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:545)

at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1551)

INSTRUMENTATION_STATUS:numtests=2

INSTRUMENTATION_STATUS:stack=junit.framework.AssertionFailedError: expected:<20> but was:<30>

at android.myexample.cts.MySampleCalculatorTest.testSubtration(MySampleCalculatorTest.java:63)

at java.lang.reflect.Method.invokeNative(Native Method)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)

at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:545)

at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1551)

INSTRUMENTATION_STATUS:test=testSubtration

INSTRUMENTATION_STATUS_CODE: -2

INSTRUMENTATION_RESULT: stream=

Test results forInstrumentationTestRunner=..F

Time: 0.079

FAILURES!!!

Tests run: 2,  Failures: 1, Errors: 0

INSTRUMENTATION_CODE: -1

===[test result from logcat] ====

/ethernet(6210): Loading ethernet jni class

D/AndroidRuntime(6210): Calling main entry com.android.commands.am.Am

I/ActivityManager(1143): Force stopping package com.android.cts.myexample uid=10036

I/ActivityManager(1143): Start proc com.android.cts.myexample for added applicationcom.android.cts.myexample: pid=6220 uid=10036 gids={}

I/TestRunner(6220): started: testAdd(android.myexample.cts.MySampleCalculatorTest)

I/TestRunner(6220): finished: testAdd(android.myexample.cts.MySampleCalculatorTest)

I/TestRunner(6220): passed: testAdd(android.myexample.cts.MySampleCalculatorTest)

I/TestRunner(6220): started: testSubtration(android.myexample.cts.MySampleCalculatorTest)

I/TestRunner(6220): failed: testSubtration(android.myexample.cts.MySampleCalculatorTest)

I/TestRunner(6220): ----- begin exception -----

I/TestRunner(6220):

I/TestRunner(6220): junit.framework.AssertionFailedError: expected:<20> butwas:<30>

I/TestRunner(6220):    at junit.framework.Assert.fail(Assert.java:47)

I/TestRunner(6220):    atjunit.framework.Assert.failNotEquals(Assert.java:282)

I/TestRunner(6220):    at junit.framework.Assert.assertEquals(Assert.java:64)

I/TestRunner(6220):    atjunit.framework.Assert.assertEquals(Assert.java:201)

I/TestRunner(6220):    atjunit.framework.Assert.assertEquals(Assert.java:207)

I/TestRunner(6220):    at android.myexample.cts.MySampleCalculatorTest.testSubtration(MySampleCalculatorTest.java:63)

I/TestRunner(6220):    at java.lang.reflect.Method.invokeNative(NativeMethod)

I/TestRunner(6220):    at java.lang.reflect.Method.invoke(Method.java:511)

I/TestRunner(6220):    at junit.framework.TestCase.runTest(TestCase.java:154)

I/TestRunner(6220):    at junit.framework.TestCase.runBare(TestCase.java:127)

I/TestRunner(6220):    atjunit.framework.TestResult$1.protect(TestResult.java:106)

I/TestRunner(6220):    at junit.framework.TestResult.runProtected(TestResult.java:124)

I/TestRunner(6220):    at junit.framework.TestResult.run(TestResult.java:109)

I/TestRunner(6220):    at junit.framework.TestCase.run(TestCase.java:118)

I/TestRunner(6220):    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)

I/TestRunner(6220):    atandroid.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)

I/TestRunner(6220):    atandroid.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:545)

I/TestRunner(6220):    atandroid.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1551)

I/TestRunner(6220): ----- end exception -----

I/TestRunner(6220): finished: testSubtration(android.myexample.cts.MySampleCalculatorTest)

I/ActivityManager(1143): Force stopping package com.android.cts.myexample uid=10036

I/ActivityManager(1143): Killing proc 6220:com.android.cts.myexample/10036: force stop

D/AndroidRuntime(6210): Shutting down VM

如何debug android cts的更多相关文章

  1. 监听Android CTS测试项解决方案(一)

    前言: 首先这里需要详细叙述一下标题中"监听Android CTS测试项解决方案"的需求.这里的需求是指我们需要精确的监听到当前CTS测试正在测试的测试项. 因为我们知道CTS认证 ...

  2. 监听Android CTS测试项解决方案(二)

    二,监听当前测试项是否是Accelerometer Measurement Test测试项 通过第一种方式介绍的,我们可以得到当前处于活动状态的Activity类似监听CTS测试当前的测试项.但是由于 ...

  3. Android CTS測试Fail项改动总结(四)

    Android5.1上的測试 1.android.security.cts.SELinuxDomainTest# testInitDomain fail 打印的log junit.framework. ...

  4. android CTS测试

    CTS认证是获得Google推出的Android系统中Android Market服务的前提 CTS兼容性测试的主要目的和意义在于使得用户在Android系统的应用过程中,有更好的用户体验,并展现出A ...

  5. Android CTS 测试总结【转】

    Android CTS 测试总结[转] 最近一直在做Android兼容性测试,根据Android官网给出的android-cts-manual 配置好了device后,开始测试. 首先配置软件环境: ...

  6. 如何获取Debug Android Hash Key

    在接入FaceBook第三方登录的时候,需要获取Android Hash Key. Android Hash Key即密钥散列有两种,一种是开发秘钥散列,一种是发布秘钥散列.这里主要介绍如何获取开发秘 ...

  7. Android N和O中使用adb shell dpm set-device-owner 'com.android.cts.verifier/com.android.cts.verifier.managedprovisioning.DeviceAdminTestReceiver' setup Device Owner失败

    PC端出现如下log: D:\workspace\AndroidO\CTS\CTS_Verifier>adb shell dpm set-device-owner 'com.android.ct ...

  8. Android CTS Test

    什么是CTS测试?了解这个问题前,我们先来搜索了解一遍“Google GMS 认证”.GMS全称为GoogleMobile Service,即谷歌移动服务.说白了GMS其实就是一系列谷歌的应用集合.谷 ...

  9. Android CTS Test failed to run to conmpletion 测试超时问题

    引用“Android cts all pass 全攻略”里面的一段话: ❀ testcase timeout 测试某个testcase的时候一直出现 “........”,迟迟没有pass或者fail ...

随机推荐

  1. php测试题整理(0519)

    1.B/S架构和C/S架构: B/S架构是依托于浏览器的网络系统,C/S架构是基于客户端的. B/S架构: 随着Internet和WWW的流行,以往的主机/终端和C/S都无法满足当前的全球网络开放.互 ...

  2. mysql分表方法实现

    一般来说,当我们的数据库的数据超过了100w记录的时候就应该考虑分表或者分区了,这次我来详细说说分表的一些方法.目前我所知道的方法都是MYISAM的,INNODB如何做分表并且保留事务和外键,我还不是 ...

  3. Nexus Root Toolkit教程——刷机

    Nexus Root Toolkit是Nexus系列设备专属解锁.root.刷机.修复工具.本教程以Nexus7二代刷安卓5.0 Lollipop系统为实例演示刷机过程. 标签: 安卓5.0刷机教程 ...

  4. QQ截图时窗口自动识别的原理(WindowFromPoint, ChildWindowFromPoint, ChildWindowFromPointEx,RealChildWindowFromPoint)

    新版的QQ在截图时加入了窗口自动识别的功能,能根据鼠标的位置自动画出下面窗口的轮廓.今天有人在论坛上问起这个问题,下面我们来探讨这个功能的实现原理. 首先我们要明白截图软件的基本原理,截图时实际上是新 ...

  5. python编程之处理GB级的大型文件

    一般我们采取分块处理,一次处理固定大小的块. def read_in_chunks(file_obj,chunk_size): """Lazy function (gen ...

  6. Linux企业级项目实践之网络爬虫(10)——处理HTTP状态码

    HTTP状态码(HTTP Status Code)是用以表示网页服务器HTTP响应状态的3位数字代码.所有状态码的第一个数字代表了响应的五种状态之一.他们分别是:消息(1字头)成功(2字头)这一类型的 ...

  7. win7系统如何恢复administrator用户

    默认情况下,administrator用户是禁用的. 要恢复的话,右键单击我的电脑 管理-->本地用户和组-->用户-->右键属性 把"账户已禁用"前的选择符号去 ...

  8. 我所理解的设计模式(C++实现)——状态模式(State Pattern)

    概述: 看看我们平时用的开关,同样一个开关他有2种状态:开和关,当她处于不同的状态的时候她的行为是不一样的,比如当她是开着的时候,你按她一下,她就变成了关闭状态,她是关着的时候按她一下,她就变成了开着 ...

  9. Android Studio:Unable to add window android.view.ViewRootImpl$W@5e2d85a -- permission denied for this window 第一行代码

    学习<第一行代码>的时候,出现的错误. java.lang.RuntimeException: Unable to start receiver com.example.sevenun.l ...

  10. hibernate分页查询的各种方法

    统计总数: public Integer countAll1() { String hql = "select count(*) from News as news"; List ...