Ubantu下搭建Android CTS 兼容性测试环境及单项测试操作步骤

    CTS 全称(Compatibility Test Suite),兼容性测试工具,其目的就是让各种Android设备厂商能够开发出兼容性更好的Android设备,同时,Google也提供了一份兼容性标准文档(Compatibility Definition Document, CDD)Android设备只有满足CDD的规定并且通过CTS,才能获得Android的商标和享受Android Market的权限。

环境准备:

1、安装ubantu环境

      Windows下搭建Ubantu环境

2、安装openjdk8

    opendjk8的安装按照google官方文档是需要ubuntu version >15.04,在v>15.04时,可以直接使用下述命令进行openjdk8的安装。

    $ sudo apt-get update
    $ sudo apt-get install openjdk-8-jdk

 也可以去oracle官网下载相应的jdk进行安装(需要配置环境变量)

3、Android SDK安装

   android sdk 百度云盘地址:https://pan.baidu.com/s/1G0kvpx81ZAX-XCVydDl0Dw 密码:hmwe 

解压之后,设置环境变量

psp@ubuntu:~$ gedit ~/.bashrc

export ANDROID_SDK_HOME=/home/psp/androidTool/android-sdk-linux
export PATH=$PATH:${ANDROID_SDK_HOME}/tools
export PATH=$PATH:${ANDROID_SDK_HOME}/platform-tools
export PATH=$PATH:${ANDROID_SDK_HOME}/build-tools/24.0.1

4.下载CTS测试套件

百度云盘地址:https://pan.baidu.com/s/1Y0ReCIHvdiuzIP59R83ggA 密码:91la

官方地址 http://source.android.com/compatibility/cts/downloads.html

下载之后解压。解压路径:/home/psp/cts/android-cts  

5、单项测试操作步骤

a、测试之前,确保adb 连接到电脑

psp@ubuntu:~$ adb devices
List of devices attached
18137B451D    device

b、之后执行以下命令:

psp@ubuntu:~$ cd cts/android-cts/
psp@ubuntu:~/cts/android-cts$ ls
logs  results  testcases  tools
psp@ubuntu:~/cts/android-cts$ cd tools/
psp@ubuntu:~/cts/android-cts/tools$ ./cts-tradefed 
Android Compatibility Test Suite 7.1_r18 (4800211)
08-09 00:50:13 I/DeviceManager: Detected new device 18137B451D

cts-tf >   

c、然后在cts-tf > 后执行测试命令:cts-tf > run cts -m CtsAppTestCases -t android.app.cts.SystemFeaturesTest#testNfcFeatures

“-m” :意思就是我们要测试的模块 
“-t”:意思就是我们的测试的类 
“#后面的方法”:我们要测试类中的方法。 
如果要想执行某一个模块的测试项,直接用-m参数,其它参数就不需要了。如果想测试某一个类的话,需要加上-m 和-t的参数了。

输出如下:

cts-tf > run cts -m CtsAppTestCases -t android.app.cts.SystemFeaturesTest#testNfcFeatures 
08-09 00:54:50 I/TestInvocation: Starting invocation for 'cts' on build '4800211' cts -m CtsAppTestCases -t android.app.cts.SystemFeaturesTest#testNfcFeatures Compatibility Test Suite 4800211 CTS 1533801290986 /home/psp/cts/android-cts/tools/./../.. 7.1_r18 cts https://androidpartner.googleapis.com/v1/dynamicconfig/suites/CTS/modules/{module}/version/{version}?key=AIzaSyAbwX5JRlmsLeygY2WWihpIJPXFLueOQ3U 2018.08.09_00.54.50 on device 18137B451D
08-09 00:54:51 I/ResultReporter: Initializing result directory
08-09 00:54:51 I/ResultReporter: Results Directory: /home/psp/cts/android-cts/tools/./../../android-cts/results/2018.08.09_00.54.50
08-09 00:54:51 I/ResultReporter: Created log dir /home/psp/cts/android-cts/tools/./../../android-cts/logs/2018.08.09_00.54.50
08-09 00:54:51 W/BatteryFetcher: IOException getting battery level for device 18137B451D: Unrecognized response to battery level queries
08-09 00:54:52 W/DynamicConfigPusher: Cannot download and parse json config from URL https://androidpartner.googleapis.com/v1/dynamicconfig/suites/CTS/modules/cts/version/7.1_r18?key=AIzaSyAbwX5JRlmsLeygY2WWihpIJPXFLueOQ3U
08-09 00:54:54 I/SettingsPreparer: Setting verifier_verify_adb_installs to value 0
08-09 00:54:55 I/ApkPreconditionCheck: Instrumenting package com.android.preconditions.cts:
08-09 00:55:05 I/ApkPreconditionCheck: Target preparation successful
08-09 00:55:07 E/WifiCheck: Device has no network connection, no ssid provided, some modules of CTS require an active network connection
08-09 00:55:08 I/DeviceInfoCollector: Instrumenting package com.android.compatibility.common.deviceinfo:
08-09 00:55:33 I/DeviceInfoCollector: Target preparation successful
08-09 00:55:35 W/PropertyCheck: Expected "user" but found "userdebug" for property: ro.build.type
08-09 00:55:35 W/BatteryFetcher: IOException getting battery level for device 18137B451D: Unrecognized response to battery level queries
08-09 00:55:38 I/ModuleRepo: 18137B451D running 2 modules, expected to complete in 13m 16s
08-09 00:55:38 I/CompatibilityTest: Starting 2 modules on 18137B451D
08-09 00:55:39 I/LocationCheck: Verifying location setting
08-09 00:55:41 I/LocationCheck: Verifying location setting
08-09 00:55:59 I/ConsoleReporter: [18137B451D] Starting armeabi-v7a CtsAppTestCases with 1 test
08-09 00:55:59 I/ConsoleReporter: [1/1 armeabi-v7a CtsAppTestCases 18137B451D] android.app.cts.SystemFeaturesTest#testNfcFeatures pass

08-09 00:55:59 I/ConsoleReporter: [18137B451D] armeabi-v7a CtsAppTestCases completed in 185 ms. 1 passed, 0 failed, 0 not executed
08-09 00:56:04 W/CompatibilityTest: Inaccurate runtime hint for armeabi-v7a CtsAppTestCases, expected 6m 38s was 21s
08-09 00:56:05 I/MonitoringUtils: Connectivity check failed, retrying in 5000ms
08-09 00:56:12 I/MonitoringUtils: Connectivity check failed, retrying in 5000ms
08-09 00:56:18 I/MonitoringUtils: Connectivity check failed, retrying in 5000ms
08-09 00:56:24 I/MonitoringUtils: Connectivity check failed, retrying in 5000ms
08-09 00:56:31 I/MonitoringUtils: Connectivity check failed, retrying in 5000ms
08-09 00:56:37 I/MonitoringUtils: Connectivity check failed, retrying in 5000ms

以下输出表示该项测试通过。

08-09 00:55:59 I/ConsoleReporter: [18137B451D] Starting armeabi-v7a CtsAppTestCases with 1 test
08-09 00:55:59 I/ConsoleReporter: [1/1 armeabi-v7a CtsAppTestCases 18137B451D] android.app.cts.SystemFeaturesTest#testNfcFeatures pass

08-09 00:55:59 I/ConsoleReporter: [18137B451D] armeabi-v7a CtsAppTestCases completed in 185 ms. 1 passed, 0 failed, 0

d、相关log和results会保存到以下路径

psp@ubuntu:~/cts/android-cts$ ls
logs  results  testcases  tools

注意:有时候adb devices 会出现no permissions的情况,请参考博文
???????????? no permissions的解决办法 解决网上方法行不通的问题

参考博文:https://blog.csdn.net/huangwei858/article/details/70227463

https://blog.csdn.net/cxq234843654/article/details/52232413

猜你喜欢

转载自blog.csdn.net/pshiping2014/article/details/81537252