Android兼容性测试(CTS)和连带的兼容性定义文档(CDD),是一个确保终端设备与特定版本Android(比如4.0, 4.1, 4.2, 4.3, 4.4)兼容的自管理程序。CTS测试集包含大约24,000个在Android设备上运行的测试用例,
这些用例分别针对电话、图形、相机、GPS、触摸 屏、无线网等功能。Google针对每个主要Android版本公布了CDD文档,其中指出了对CTS中每类测试的具体要求。
每当我们基于新版本的Android系统适配ROM后,都要对系统进行完整的CTS测试,在我们适配ROM的时候难免会对Android 系统API进行改动,某些改动则会导致输出的结果与预期不一致,最终导致CTS测试不能通过,
于是在发布新机器之前,公司总是将CTS放到最高优先级,但是运行Android CTS的学习代价相对较高,其本身操作实在是令每一个修复CTS bug的工程师疯狂。
为了减少运行CTS 测试case的学习代价,编写的qcts供修复CTS bug的工程师和测试人员使用。
目标:
1.尽量保持运行现有CTS测试case方法的完整性,在这个基础之上,能够帮助使用者更加快速的运行CTS测试case。
2.不需要在终端中疯狂的来回切换Android CTS测试case目录,使切换目录更方便。
3.尽量减少使用者记忆复杂的运行case的命令。
4.我们的共同目标就是:没有蛀牙(^-^)
第一步: 将qcts clone到本机目录下
git clone https://github.com/lmh516/qcts.git
提醒: 如果已经clone过了,下次进入的时候尽量运行:git pull 拉取更新
第二步: 进入qcts工程目录运行命令
. build/envsetup.sh
在clone完整个工程使用命令“. build/envsetup.sh”之后,你就可以快速开始CTS之旅了:
Android CTS 4.4_r1
12-16 16:01:26 I/: Detected new device b1bc8ea9
cts-tf > run cts --plan CTS // 这条命令用于测试整个Android 整个CTS测试计划,同样可以使用命令 cplans 便可以进入到对应的测试计划目,然后录查看到对应的测试计划。
cts-tf > help // 进入到cts-tradefed模式之后使用help命令即可获取更多测试命令。
2). debug模式:主要是调试CTS问题的工程师选用,其使用方法非常简单,可以通过输入mode命令选择debug之后输入对应的测试函数; 或者是直接输入命令:debug $className#$funcName
Example: debug $className#$funcName
注意:$className是待测试类名,$funcName是待测试函数名称,一定不要忘记输入中间的#, 这个一般从测试fail项中直接复制粘贴过来就可以了. ep:debug android.hardware.cts.CameraTest#testFocusDistances
CTS-tradefed is the test harness for running the Android Compatibility Suite, built on top of the tradefed framework.
Available commands and options
Host:
help: show this message
help all: show the complete tradefed help
exit: gracefully exit the cts console, waiting till all invocations are complete
Run:
run cts --plan test_plan_name: run a test plan
run cts --package/-p : run a CTS test package
run cts --class/-c [--method/-m] : run a specific test class and/ormethod
run cts --continue-session session_ID: run all not executed tests from a previous CTS session
run cts [options] --serial/s device_ID: run CTS on specified device
run cts [options] --shards number_of_shards: shard a CTS run into given number of independent chunks, to run on multiple devices inparallel
run cts --help/--help-all: get more help on running CTS
List:
l/list d/devices: list connected devices and their state
l/list packages: list CTS test packages
l/list p/plans: list CTS test plans
l/list i/invocations: list invocations aka CTS test runs currentlyin progress
l/list c/commands: list commands: aka CTS test run commands currently in the queue waiting to be allocated devices
l/list r/results: list CTS results currently present in the repository
Add:
add derivedplan --plan plane_name --session/-s session_id -r [pass/fail/notExecuted/timeout]: derive a plan from the given session
Dump:
d/dump l/logs: dump the tradefed logs for all running invocations
Options:
--disable-reboot : Do not reboot device after running some amount of tests.
Invoke ". build/envsetup.sh" from your shell to add the following commands to your environment:
normal commands:
- help: get the help informations about qcts.
- version: show the current lunch version of android.
- lunch: pick the version of android.
- mode [normal | debug]: pick the mode of cts will be running.
- normal: enter cts-tardefed mode running cts test cases.
- debug [<className#method>]: enter debug mode running cts test cases.
- cts-tradefed: enter cts-tradefed mode, as same as android cts-tradefed script.
- croot: changes directory to the top of the tree.
- ccases: changes directory to the cts testcases of the tree.
- cverifier: changes directory to the cts verifier of the tree.
- ctools: changes directory to the cts tools of the tree.
- clogs: changes directory to the cts logs of the tree.
- cplans: changes directory to the cts plans of the tree.
- cresults: changes directory to the cts results of the tree.
advanced commands:
- install_base: install the base applications of debug mode.
- run <className#method> <runner>: running cts test case in debug mode.
- adb_install_r <apk>: enforce to install an application use adb.