CTS详细命令及结果处理

前言

Android graphics的开发和debug离不开CTS,CTS执行的详细命令可以在官网查到:https://source.android.com/compatibility/cts/run。但是官网的命令格式比较乱看起来不太舒服,不好直接复制粘贴使用。本片文章把常用的命令扒下来方便直接用。

另外CTS的结果是html形式的网页,查看起来很方便,但是批处理的时候需要自己造轮子写,就不那么好用了,我在github上找到一个人写的处理CTS结果的repo,可以把各种case提取出来,用起来还不错,也记录一下。

 

下载CTS及配置环境

在https://source.android.com/docs/compatibility/cts/downloads 下载需要的CTS版本,并且如果测到media的话,需要下CTS media files,否则运行时会在线下载,而由于应该是从美国的googlef服务器下载,所以会下的很慢甚至下载不下来导致运行错误,因此最好提前下好并且push到android系统中去。

$ sudo apt-get install -y aapt adb

 

CTS详细命令

CTS v2 (Android 7.0 and later),
help
Display a summary of the most commonly used commands

help all
Display the complete list of available commands

version
Show the version.

exit
Gracefully exit the CTS console. Console will close when all currently running tests are finished.

run cts --help/--help-all:
get more help on running CTS
查看跑CTS更多的命令

run cts
Run the default CTS plan (that is, the full CTS invocation).

run cts

--plan
Run the specified test plan.

run cts --plan <plan_name>

--module/-m [--module/-m …]
Run the specified test module or modules.

run cts -m Gesture

--subplan
Run the specified subplan.

run cts --subplan <subplan_name>

--module/-m  --test/-t
Run the specified module and test.

run cts -m Gesture --test android.gesture.cts.GestureTest#testGetStrokes

--retry
Retry all tests that failed or were not executed from the previous sessions. Use list results to get the session id.

run retry --retry <session_id>
#session_id can be got by 'l d'

--retry-type NOT_EXECUTED/FAILED

Retry only tests that were not executed/failed from the previous sessions. Use list results to get the session id. Without --retry-type, retry will run both FAIL and NOT_EXECUTED tests

run retry --retry <session_id> --retry-type NOT_EXECUTED

--shards-count <number_of_shards>
Shard a CTS run into given number of independent chunks, to run on multiple devices in parallel.

--serial/-s
Run CTS on the specific device.

--include-filter
[--include-filter …] Run only with the specified modules.

run cts --include-filter "CtsCalendarcommon2TestCases android.calendarcommon2.cts.Calendarcommon2Test#testStaticLinking"
#includes the specified module.

--exclude-filter
[--exclude-filter …] Exclude the specified modules from the run.

run cts --exclude-filter "CtsCalendarcommon2Test android.calendarcommon2.cts.Calendarcommon2Test#testStaticLinking" 
#excludes the specified module.

--abi
Force the test to run on the given ABI, 32 or 64. By default CTS runs a test once for each ABI the device supports.

--skip-device-info
Skips collection of information about the device. Note: do not use this option when running CTS for approval.

run cts --plan CTS -d
--skip-preconditions
Bypasses verification and setup of the device’s configuration, such as pushing media files or checking for Wi-Fi connection.

--disable-reboot

disable the reboot during the cts test

add subplan --name/-n subplan_name --result-type [pass | fail | timeout | notExecuted] [--session session_id]

Create a subplan derived from previous session; this option generates a subplan that can be used to run a subset of tests.
The only required option is --session. Others are optional but, when included, must be followed by a value. The --result-type option is repeatable; for example add subplan --session 0 --result-type passed --result-type failed is valid.

 

最常用命令

run cts --subplan CTS-GFX --skip-preconditions --disable-reboot --skip-all-system-status-check --dynamic-config-url=""

run cts -m <module_name> -t <test_name>

run retry --retry 1

 

Android-CTS-Result-Parser

这是我在github上找到的一个处理CTS result的项目。https://github.com/guei061528/Android-CTS-Result-Parser。

之前我也写过处理CTS result的python脚本,但是由于提取信息的逻辑比较hard code,导致CTS test suit版本小更迭后,会因为result的html某些格式的变化导致提取不成功。而这个项目我看到时2020年的,我当前(2022年)用起来依旧是成功的,尽管只有Parse_Find_Fail.py这个好用,但对我来说够用了,所以以后打算就用这个repo了。

$ git clone https://github.com/guei061528/Android-CTS-Result-Parser
$ cd Android-CTS-Result-Parser
$ python3 Parse_Find_Fail.py <fail_testcase.html> empty
#The failed cases will be ouputed as "Compare_Result_New_Fail.txt"

 

编写CTS Subplan

可以在 android-cts/subplans 中添加一个 SubPlan.xml 文件,如下所示:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<SubPlan version="2.0">
<Entry include="CtsSystemIntentTestCases" />
<Entry include="CtsSystemUiHostTestCases" />
<Entry include="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testAospFileContexts" />
<Entry include="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testAospServiceContexts" />
</SubPlan>

如需运行该Subplan,执行以下操作:

run cts --subplan aSubPlan

Subplan的module/test编写格式如下:

复制代码
Include a module name as follows:
<Entry include="MODULE_NAME" />

Include a package:
<Entry include="MODULE_NAME PACKAGE_NAME" />

Include a class:
<Entry include="MODULE_NAME PACKAGE_NAME.CLASS_NAME" />

Include an individual test:
<Entry include="MODULE_NAME PACKAGE_NAME.CLASS_NAME#TEST_NAME" />
复制代码

参考链接:https://source.android.com/docs/compatibility/cts/development

 

posted @   青山牧云人  阅读(4562)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 如何使用 Uni-app 实现视频聊天(源码,支持安卓、iOS)
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
点击右上角即可分享
微信分享提示