android之CTS兼容性测试

android之CTS兼容性测试

From: http://blog.csdn.net/cnhua57inyu/article/details/12976823
最近在忙碌着CTS测试,头大啊,各种莫名的fail,timeout,今天晚上刚好有时间来写篇文章来记录下;

CTS(Compatibility Test Suite);为什么要做CTS测试:

1. Give your users the best possible experience with the applications they run.When a device is compatible with Android, users can choose from among many high-quality applications. Applications that take full advantage of Android's features are likely to perform best on compatible devices.
2. Make it easy for developers to write top-quality applications for your device. Developers want to streamline their applications for Android, and this is easiest for them when they are writing for a predictable platform.
3. Take advantage of the Android Market. Compatible handsets can give users access to the Android Market.

CTS测试之前的需要的准备项和如何进行测试;

做CTS测试首先得做很多项的配置,现在来仔细说下CTS的配置过程:

1、首先得安装有adb,并且配置adb的环境变量;export PATH=$PATH:/home/myuser/adb;

2、准备一个cts包,可以在源码中通过make cts编译,也可以在android网站上面下载下来(http://source.android.com/compatibility/downloads.html);包里面有三个文件夹,其中tools下面有测试需要的jar包以及cts-tradefed脚本用于执行cts命令;还有一个repository文件夹,里面有一些测试计划,测试结果也会生成在里面;在repository/testcases目录下找到CtsDelegatingAccessibilityService.apk和/CtsDeviceAdmin.apk,并且安装;

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. adb install android-cts/repository/testcases/CtsDelegatingAccessibilityService.apk  
  2. adb install android-cts/repository/testcases/CtsDeviceAdmin.apk  
安装以后在setting中会多出设置项,需要进行设置Settings > Accessibility > Delegating AccessibilityService,Settings > Security > Device Administrators >android.deviceadmin.cts.CtsDeviceAdmin* settings;

3、在setting中需要设置多项设置项,setting-display-sleep设置30min钟,language设置为E文,Security中Screen lock设置NONE;

4、Cts有media stress测试,你需要准备一张sdcard,还需要在http://www.bigbuckbunny.org/index.php/download/下下载各种分辨率的mp4视频文件,在http://source.android.com/compatibility/downloads.html下载android-cts-media-X.Y.zip,执行里面的copy_media.sh脚本,把视频文件拷贝到/sdcard/test目录下;

5、插入一张有钱的SIM卡;

都准备好了接下来就可以跑CTS了,首先

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. ./android-cts/tools/cts-tradefed  

这下就进入了CTS测试的命令行模式了,然后执行

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. run cts --plan CTS  

进行全部项的测试,如果你想测试某一个测试plan,可以

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. run cts --plan <plan_name>  

这个时候等待结果就行了...漫长的等待啊......


如何进行单项测试呢?

如果你想进行单项测试,比如说某个package,class,method之类的,可以这样

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. run cts --package packageName  

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. run cts --class className  

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. run cts --class className --method methodName  

,这下就可以对单个的错误进行调试运行了;这些都是在linux环境下的,如果我想在windows环境下进行CTS单项测试呢(不知道windows下有没有CTS整项测试)?你首先需要将repository\testcases下的所有的apk之类的文件都push到data/app下面去,然后通过

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. adb shell pm list instrumentation  

 显示所有的Runner,这里的Runner作为下面这个命令-w以后的参数,然后通过

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. adb shell am instrument -e class 类名#方法名 -w “Runner”  

进行单项的测试;


举个例子,比如:

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. adb shell am instrument -e   
  2. class android.accessibilityservice.cts.AccessibilityTextTraversalTest#testActionNextAndPreviousAtGranularityPageOverText   
  3. -w com.android.cts.accessibilityservice/android.test.InstrumentationCtsTestRunner  

悲催的result:

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. android.accessibilityservice.cts.AccessibilityTextTraversalTest:  
  2. Error in testActionNextAndPreviousAtGranularityPageOverText:  
  3. java.util.concurrent.TimeoutException: Expected event not received within: 5000 ms.  
  4.         at android.accessibilityservice.cts.AccessibilityActivityTestCase$AccessibilityInteractionBridge.executeCommandA  
  5. ndWaitForAccessibilityEvent(AccessibilityActivityTestCase.java:542)  
  6.         at android.accessibilityservice.cts.AccessibilityTextTraversalTest.testActionNextAndPreviousAtGranularityPageOve  
  7. rText(AccessibilityTextTraversalTest.java:1219)  
  8.         at java.lang.reflect.Method.invokeNative(Native Method)  
  9.         at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)  
  10.         at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)  
  11.         at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)  
  12.         at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)  
  13.         at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)  
  14.         at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)  
  15.         at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1661)  
  16.   
  17. Test results for InstrumentationCtsTestRunner=.E  
  18. Time: 5.796  
  19.   
  20. FAILURES!!!  
  21. Tests run: 1,  Failures: 0,  Errors: 1  

相比windows下进行单项测试,Linux下还是简单的多了。。。


如何针对所有的failed的项进行重测呢?

首先你得通过l r命令列出测试记录的sessionId,然后进入respository/result/×××/testResult.xml中,首先把failed总项数改为0,notExecuted总项数改为你之前failed的项数;

然后通过vi的全局替换命令“1,$s/old/new/g”替换所有的result=“failed”为result=“notExecuted”,

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. run cts --continue -session “sessionID”  

接下来就可以通过上面这个命令进行重测了;


CTS bug的记录;

在此记录一下我跟了好几天的一个CTS bug:

1、

android.media.cts.MediaPlayerTest
-- testGapless1
fail
junit.framework.AssertionFailedError: silence detected, please increase volume and rerun test at android.media.cts.MediaPlayerTest.testGapless(MediaPlayerTest.java:397)

出现此问题的原因是EffectVisualizer.cpp中的Context状态一直是VISUALIZER_STATE_INITIALIZED无法VISUALIZER_STATE_ACTIVE,导致无法走进判断;修改system.prop下的两个property为false即可通过测试;PS:不同的android项目可能在不同的prop里面,也有可能在build.prop下;另外此选项是针对qcomm平台的这种解码方式;

Tunnel.decode use for low latency playback, it use Qualcomm HW decoder. But Tunnel decoder don't support Gapless playback, so please disable it when do CTS test.

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. tunnel.decode=false  
  2. tunnel.audiovideo.decode=false  

当然,你也可以

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. getprop tunnel.decode  

然后重测看一下结果;


2、

android.security.cts.PackageSignatureTest
--testPackageSignatures
fail
junit.framework.AssertionFailedError: These packages should not be signed with a well known key: [com.qualcomm.wifip2p.service, com.android.voicedialer, com.qualcomm.timeservice, com.qualcomm.qlogcat, com.qualcomm.atfwd, com.android.launcher, com.android.defcontainer, com.android.quicksearchbox, com.android.contacts, com.android.phone, com.android.calculator2, com.android.htmlviewer, com.android.cellbroadcastreceiver, com.android.MultiplePdpTest, com.android.providers.calendar,.......

[reason]
   using android default key to sign apk;
[Solution]
   sign apk using our own key
[Change File]
  build\target\product\security\*


3、

-- testNoSetuidTcpdump
fail
junit.framework.AssertionFailedError: File "/system/xbin/tcpdump" is setUID at android.security.cts.BannedFilesTest.assertNotSetugid(BannedFilesTest.java:71)

[reason]
   the permission for system/xbin/tcpdump is wrong.
[Solution]
   set the correct permission to 00755 for system/xbin/tcpdump
[Change File]
  system/core/include/private/android_filesystem_config.h;


4、

-- testStartUsingNetworkFeature_enableHipri
fail
junit.framework.AssertionFailedError: Couldn't connect using hipri... at android.net.cts.ConnectivityManagerTest.testStartUsingNetworkFeature_enableHipri(ConnectivityManagerTest.java:293)

[reason]
   don't set the right APN
[Solution]
   set APN and in the APN type field include "hipri"
[Change File]
  N/A

5、

-- testActivateGoodReceiverDisplaysActivationUi
fail
junit.framework.AssertionFailedError at android.admin.cts.DeviceAdminActivationTest.assertDeviceAdminDeactivated(DeviceAdminActivationTest.java:200)

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. junit.framework.AssertionFailedError  
  2.         at android.admin.cts.DeviceAdminActivationTest.assertDeviceAdminDeactivated(DeviceAdminActivationTest.java:200)  
  3.         at android.admin.cts.DeviceAdminActivationTest.testActivateGoodReceiverDisplaysActivationUi(DeviceAdminActivatio  
  4. nTest.java:102)  

在网上找到的一个解决办法:

Install the "CtsDeviceAdmin.apk" and enable only the first two options in the security-->Deviceadministrators".
It will make the Test case "testActivateGoodReceiverDisplaysActivationUi" PASS.
Even all the 18 Test cases in this Package (android.admin) will get PASS on Android 4.3

但是奇怪的是这个fail报错的位置在源码中找不到,DeviceAdminActivationTest,java中根本没有200行的代码,查看4.4的cts源码也是一样的;不知道是不是android-cts-4.3_r2-linux_x86-arm.zip的问题。

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 适合毕业设计、课程设计作业。这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。 所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值