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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM