Android CTS keynotes

Android CTS keynotes

1,官方参考设置步骤:
 
  1. Factory data reset the device: Settings > Backup & reset > Factory data reset

    Warning: This will erase all user data from the device.

  2. Set your device’s language to English (United States) from: Settings > Language & input > Language
  3. Turn on the location setting if there is a GPS or Wi-Fi / Cellular network feature on the device: Settings > Location > On
  4. Connect to a Wi-Fi network that supports IPv6, can treat the Device Under Test (DUT) as an isolated client (see the Physical Environment section above), and has an internet connection: Settings > Wi-Fi
  5. Make sure no lock pattern or password is set on the device: Settings > Security > Screen lock > None
  6. Enable USB debugging on your device: Settings > Developer options > USB debugging.

    Note: On Android 4.2 and later, Developer options is hidden by default. To make them available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options. See Enabling On-device Developer Options for additional details.

  7. Select: Settings > Developer options > Stay Awake > On
  8. Select: Settings > Developer options > Allow mock locations > On

    Note: This mock locations setting is applicable only in Android 5.x and 4.4.x.

  9. Select: Settings > Developer options > Verify apps over USB > Off

    Note: This verify apps step became required in Android 4.2.

  10. Launch the browser and dismiss any startup/setup screen.
  11. Connect the desktop machine that will be used to test the device with a USB cable

    Note: When you connect a device running Android 4.2.2 or later to your computer, the system shows a dialog asking whether to accept an RSA key that allows debugging through this computer. Select Allow USB debugging.

  12. Install and configure helper apps on the device.

    Note: For CTS versions 2.1 R2 through 4.2 R4, set up your device (or emulator) to run the accessibility tests with:
    adb install -r android-cts/repository/testcases/CtsDelegatingAccessibilityService.apk
    On the device, enable: Settings > Accessibility > Accessibility > Delegating Accessibility Service

    Note: For CTS 2.3 R4 through CTS 6.0 on devices that declare the android.software.device_admin feature, set up your device to run the device administration tests with:
    adb install -r android-cts/repository/testcases/CtsDeviceAdmin.apk
    On the device, enable only the two android.deviceadmin.cts.CtsDeviceAdminReceiver* device administrators under: Settings > Security > Select device administrators. Make sure theandroid.deviceadmin.cts.CtsDeviceAdminDeactivatedReceiver and any other preloaded device administrators stay disabled in the same menu.

  13. Copy the CTS media files to the device as follows:

    Note: For CTS 2.3 R12 and beyond, if the device supports video codecs, the CTS media files must be copied to the device.

    • Navigate (cd) to the path the media files are downloaded and unzipped to.
    • Change the file permissions: chmod u+x copy_media.sh
    • Run copy_media.sh:
      • To copy clips up to a resolution of 720×480, run: ./copy_media.sh 720x480
      • If you are not sure about the maximum resolution, try ./copy_media.sh all so that all files are copied.
      • If there are multiple devices under adb, add the -s (serial) option to the end. For example, to copy up to 720×480 to the device with serial 1234567, run: ./copy_media.sh 720x480 -s 1234567
2,常用的相关操作
说明 操作
全部开始测试 cts-tf > run cts –plan CTS –disable-reboot
重新测试全部fail/notExecuted/timeout项
cts-tf > l r
cts-tf > add derivedplan –plan xgf0305 –session 0 -r fail (或者[pass/fail/notExecuted/timeout])
cts-tf > run cts –plan xgf0305 –disable-reboot
继续测试
l r
run cts –continue-session session_id (session编号)–disable-reboot
这是一个包的测试: run cts –package/-p :
这个是如果我们电脑同进有连接多台手机测试时,我们指定手机的serial id来跑CTS run cts [options] –serial/-s device_ID
l d
查看当前设备以及他们的状态,显示他们的Serial,电量,等等信息
l packages
查看当前的CTS测试的包
l p:
查看CTS的plan信息,这个plan信息是在android-cts/repository/plans目录下
l r
主要是查看当前CTS的测试结果
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 r/results:
list CTS results currently present in the repository
这个命令有用,是直接跳过前期的检查工作,直接强制运行相关的测试。特别是android 6.0后,CTS测试如果不加这个,会进行前期的wifi,网络,视频,location等等的检查。是否忽略检查和下载视频

不收集设备信息,加快测试速度
–[no-]skip-preconditions
Whether to skip precondition checks and automation Default: false.
–[no-]skip-media-download
Whether to skip verifying/downloading media files Default: false.
-d, –[no-]skip-device-info
flag to control whether to collect info from device. Providing this flag will speed up test execution for short test runs but will result in required data being omitted from the test report. Default: false.
3,其实操作
3.1,signature running:  
java -Xmx2048m -jar out/host/linux-x86/framework/signapk.jar -w build/target/product/security/testkey.x509.pem build/target/product/security/testkey.pk8 /tmp/tmpsOokXv out/target/product/k200/k200-ota-20140307.zip

3.2,

+# Just for CTS
+PRODUCT_PROPERTY_OVERRIDES +=
+    ro.config.max_starting_bg=3
system/build.prop
BUILD_SECURE := true

3.2,全能锁屏模块

Amlogic Platform 使能KeyguardService,即锁屏模块
xugangfeng@LETV-U0:~/sc/letv/U4/device/letv/U4/overlay$ git diff
diff –git a/overlay/frameworks/base/packages/SystemUI/res/values/config.xml b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml
index bda91ec..56d9fd5 100644
— a/overlay/frameworks/base/packages/SystemUI/res/values/config.xml
+++ b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml
@@ -1,5 +1,5 @@
 <?xml version=”1.0″ encoding=”utf-8″?>
 <resources>
–    <bool name=”config_enableKeyguardService”>false</bool>
–    <string name=”config_statusBarComponent” translatable=”false”>com.android.systemui.statusbar.tv.TvStatusBar</string>
+    <bool name=”config_enableKeyguardService”>true</bool>
+    <string name=”config_statusBarComponent” translatable=”false”>com.android.systemui.statusbar.phone.PhoneStatusBar</string>
 </resources>

4,CTS调试
4.1,CTS代码下载:
可以用google的网站上提供的方法:
https://android.googlesource.com/platform/cts/
这个是google的CTS code地址,需要翻墙看到。提供了一个方法,克隆得到CTS:
git clone https://android.googlesource.com/platform/cts
如果为6.0 r8版本可以看到tag是:android-cts-6.0_r8
想要得到正确的code, 必须执行:
git checkout android-cts-6.0_r8
 4.2,CTS代码编译:
只是在938上编译成功,其他没有试验过,但是也是应该没有问题的。
把步骤1中下载的整个cts目录替换到当前编译环境下,source、lunch后,直接make cts 就可以在out目录下生成cts的整套测试工具了。
当然也可以到某个apk的目录下,直接mm。

一个fail项的解决示例:

fail项解决方法 
对于最终的测试报告中的fail项,解决方法有以下几种: 
(1)参考报告中的Details 一栏信息。 
(2)可以执行 run cts -c className -m methodName 并通过adb logcat 查看测试某个methodName时,参考具体的log信息,重点看log.e的信息,然后去android源码中跟踪相关代码。 
(3)参考运行run cts -c className -m methodName 之后的打印信息,例如下图 
这里写图片描述

从图中可以发现异常是从AudioTrackTest.Java 中的1959行报出来的,可以进入android的源码中cts目录,执行命令: 
$find -name AudioTrackTest.java 
找到AudioTrackTest.java文件,并vim 打开查看1959行代码,了解具体测试方法测的是什么,以及异常是什么。 
(4)尝试单独测试某个方法,有些测试项单独测试可以通过。 
(5)常见fail信息如:expected:<96000> but was:<95851> at junit.framework.Assert.fail(Assert.java:50) 
原因一般是由于程序运行效率问题导致的偏差,不用解决。 
测试程序设定一个期望值,然后和实际运行结果相对比。 
测试项不过有的是不支持,相关代码就没编译,有的是底层不支持,例如采样率。


 

    

 

 

 例:测试图例中failcase,输入命令:

         run cts -c android.app.cts.SystemFeaturesTest –m testLocationFeatures

TOP