一什么是CTS
CTS简介:Compatibility Test suite系列兼容测试
google定义了一个兼容性规范(Compatible Definition),而CTS就是为了确保某个测试符合该规范。从而基于Android的应用程序能在基于同一个api版本的设备上面运行。通过CTS测试的device可以获得android的商标,并且享受android market的权限。
例如手机、平板电脑、车载娱乐系统;严格来说需要下载第三方应用的Android系统都要通过CTS测试,才能达到兼容性。
CTS的测试包可以到:http://source.android.com/compatibility/downloads.html去下载,选择对应Android版本的CDD文档(介绍CTS测试),CTS测试包下载(测试包会不断更新),如:android-cts-verifier-4.0.3_r1-linux_x86-arm.zip,android-cts-media-1.0.zip;将下载的CTS测试包解压到相应文件夹里面应包含:android-cts文件夹里面包含Docs、Repository、Tools三个文件夹。需要配置好SDK相关的环境变量,最好是在Ubuntu下进行,搭建好Android的开发环境就可以了。关于环境变量如何配置可以去找下相关的资料。
测试前需要安装apk:adb install android-cts/repository/testcases/CtsDeviceAdmin.apk
会在系统设置-》安全-》设备管理器中生成下图,把这三项选中
二、运行CTS
aaa@aaa-All-Series:~/D/android-cts-4.4_r3-linux_x86-arm/android-cts/tools$ ls
cts-tradefed cts-tradefed.jar ddmlib-prebuilt.jar hosttestlib.jar junit.jar README tradefed-prebuilt.jar
首先在android-cts-4.4_r3-linux_x86-arm/android-cts/tools目录下运行./cts-tradefed
如果没有运行权限需要执行chmod 777 cts-tradefed
aaa@aaa-All-Series:~/D/android-cts-4.4_r3-linux_x86-arm/android-cts/tools$ ./cts-tradefed
此时会出现
cts-tf >
cts-tf > run cts --help
'cts' configuration: Runs a CTS plan from a pre-existing CTS installation
Printing help for only the important options. To see help for all options, use the --help-all flag
cmd_options options:
--[no-]help display the help text for the most important/critical options. Default: false.
--[no-]help-all display the full help text for all options. Default: false.
--[no-]dry-run build but don't actually run the command. Intended as a quick check to ensure that a command is runnable. Default: false.
--[no-]noisy-dry-run build but don't actually run the command. This version prints the command to the console. Intended for cmdfile debugging. Default: false.
--[no-]loop keep running continuously. Default: false.
test options:
--plan the test plan to run.
-p, --package the test packages(s) to run.
-c, --class run a specific test class.
-m, --method run a specific test method, from given --class.
--continue-session continue a previous test session.
'file' logger options:
-l, --log-level-display
the minimum log level to display on stdout. Default: ERROR. Valid values: [VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT]
eg:
执行一个类
cts-tf > run cts --class libcore.javax.net.ssl.SSLSocketTest
测试gts包需要运行在:gts-1.5_r2/android-xts/tools目录下
xts-tf > run xts --class com.go