Android --- An article to help you understand CTS

·What is CTS?
The full name of CTS is Compatibility Test Suite compatibility testing tool. In order to ensure that the developed applications run normally on all Android-compatible devices and ensure a consistent user experience, Google developed CTS to ensure that the Android system running on the device is fully compatible with Android. Specification, Google also provides a compatibility standard document (Compatibility Definition Document, CDD). When electronic products are developed and their own Android system is customized, they must pass the latest CTS test to ensure that standard android applications can run on the platform. After passing the CTS verification, the test report needs to be submitted to Google to obtain android market certification. CTS is a tool operated through the command line. Currently, CTS does not provide a windows version and can only be tested under Linux.

·CTS tool download address

Tool download address for different android versions:
https://source.android.google.cn/docs/compatibility/cts/downloads?hl=zh-cn
If you want to perform media stress testing, after downloading the CTS media file, execute the following in the terminal command to copy media files to the device.

./copy_images.sh
./copy_media.sh

·How to test CTS
①Configure equipment

连接 WiFi(有的测试需要v6网络)
Display->Sleep->30min(设置休眠时间为30分钟)
Security & location->Screen lock->None(设置屏幕锁为无)
System->About phone->Build number(打开开发者模式)
进入开发者模式,打开Stay awake,打开USB调试
开启location
语言设置为English-US(必须是英文,其他语言不行)
设置完成,回到主页,清空后台应用

②Use the test tool
to execute in the terminal under the /android-cts-10_r15-linux_x86-arm/android-cts/tools path (note that the path where the test tool is located cannot have Chinese characters!!!): Whole package test (test time
comparison long, takes about four days):

run cts

Test by module:

run cts -m module名

Single case test:

run cts -m module名 -t case名

·How to view CTS results
① You can view the test results on the test terminal
② Use a browser to open /android-cts-10_r15-linux_x86-arm/android-cts/results/2023.04.26_15.55.26/test_result.html
among which /2023.04.26_15 .55.26/ is the time of each test. You can open a certain test result based on the test time.

·How to view the test log
open /android-cts-10_r15-linux_x86-arm/android-cts/logs/2023.04.26_14.26.07/inv_6131858263139540011/Similarly
, /2023.04.26_15.55.26/ is the time of each test, according to The test results of a certain time can be opened at the test time

 · CTS modification skills
① First use the device to test again. If there are some errors, you may use the latest version to test and pass
② Search the test content of this case in the project code according to the case name.
Example: Test command: run cts -m CtsWindowManagerDeviceTestCases -t android.server.wm.PinnedStackTests#testPinnedStackWithDockedStack
Then search for testPinnedStackWithDockedStack (in the PinnedStackTests class) in the code in the project.
Note: Since Google official tools are used, the CTS code in the local project will be different. Only As a reference, the number of error lines cannot be exactly the same.
③Due to the above problems, what should I do if I want to add some logs to output some information to assist the modification during the modification process?
You can add some logs to the local CTS code, compile the corresponding apk according to LOCAL_PACKAGE_NAME in mk, and use the following command to install the apk into the device:

adb install -r -t .apk

Write the test command: adb shell am instrument -e class test case name -w tested CTS package name/androidx.test.runner.AndroidJUnitRunner

adb shell am instrument -e class android.server.wm.PinnedStackTests#testPinnedStackWithDockedStack -w android.server.wm.cts/androidx.test.runner.AndroidJUnitRunner

Some test modules may be linked or some test modules are compiled into jar packages. Using the above command will not work:
compile the corresponding apk or jar package according to LOCAL_PACKAGE_NAME in mk, and directly replace it to /android -cts-10_r15-linux_x86-arm/android-cts/testcases/ path, which
is equivalent to directly modifying the test case of the Google test tool, and then normalizing it in /android-cts-10_r15-linux_x86-arm/android-cts/tools Testing in the terminal under the path will output the log.

·CTS modification thinking
①CTS tests compatibility, not bugs.
② You cannot modify bugs like normal, directly locate the error code location and modify it based on the error message.
The error thrown by the CTS test is that under the CTS code, you cannot modify the CTS code (this is the difficulty). Instead, you should reflect on whether the problem of your own project is contrary to Google's specifications based on the test content.
③Most of the errors are caused by customized special requirements that violate Google specifications.

Guess you like

Origin blog.csdn.net/m0_50408097/article/details/130554781