原文网址:http://www.xuebuyuan.com/1722006.html

Precondition:

1.Get android sdk

2.Set adb to environment variable.

3.Download cts tool from google source

4.Download android-cts-media-1.0 to pc

Phone settings:

1. Open "USB debugging", "Stay awake" and "Allow mock locations"

2.Be sure adb devices connect successfully

3.Terminal execute

"adb install -r <cts_path>/android-cts/repository/testcases/CtsDelegatingAccessibilityService.apk" and

"adb install -r <cts_path>/android-cts/repository/testcases/CtsDeviceAdmin.apk"

4.Open Wi-Fi and connect to a network, make sure you can access us network

5.Open Bluetooth

6.Open NFC(If your device not support NFC, skip this step)

7.Open “Google's location service”, “GPS satellites” and “Location & Google search

8.Settings → Security → Device administrators → Activate all options

9.Set language to English(United States), if your phone is not boot with english, please reboot phone after set language.

10.Set date and time correctly

11.OpenDelegating Accessibility Service in Accessibility

12.Terminal execute "cd <cts_media_path>/android-cts-media-1.0" -> execute ". copy_media.sh all"

Start to run:

1.Terminal execute "cd <cts_path>/android-cts/tools" -> execute "./cts-tradefed"

2.execute "run cts --plan CTS -s <serial_number>", finished

Fail的一些修改:

 

1、直接设置问题

estUnknownSourcesOffByDefault

fail

junit.framework.AssertionFailedError: Device should not ship with 'Unknown Sources' enabled by default. expected:<0> but
was:<1> at android.provider.cts.Settings_SecureTest.testUnknownSourcesOffByDefault(Settings_SecureTest.java:183)

这种fail最好解决,直接按照字面理解就OK,UnKnownSource没有点掉。

2、permission

-- testSensorFeatures

fail

junit.framework.AssertionFailedError: PackageManager#hasSystemFeature(android.hardware.sensor.accelerometer) returns true
but SensorManager#getSensorList(1) shows sensors [] expected:<true> but was:<false> at android.app.cts.SystemFeaturesTest.assertFeatureForSensor(SystemFeaturesTest.java:300)

一般情况修改 - >  frameworks/base/data/etc/*.xml 文件,例如
android.hardware.camera.xml,platform.xml等文件,这边的文件定义了设备具有的一些权限。

3、由测试而引起的非测试项出错

-- testRecordingHint

fail

java.lang.RuntimeException: start failed. at android.media.MediaRecorder.start(Native Method)

这种情况要根据Logcat去查看RuntimeException的具体错误。通常可以先不改,因为很难查错。

4、网络问题

-- test_isReachable

fail

java.net.UnknownHostException: Unable to resolve host "www.google.com": No address associated with hostname at java.net.InetAddress.lookupHostByName(InetAddress.java:426)

这类问题是由于国内的网络无法访问国外网站导致的,最好的办法就在公司搭建一个VPN,链接出去。

5、系统文件权限

-- testAllFilesInSysAreNotWritable

fail

junit.framework.AssertionFailedError: Found writable:

[/sys/devices/platform/malata_ts.0/tsclass/tsclass0/ts_power, /sys/devices/platform/malata_ts.0/tsclass/tsclass0/ts_en_file,
/sys/devices/platform/malata_ts.0/tsclass/tsclass0/ts_Calibrate] at android.permission.cts.FileSystemPermissionTest.

testAllFilesInSysAreNotWritable(FileSystemPermissionTest.java:364)

-- testNoSetuidTcpdump

fail

junit.framework.AssertionFailedError at

android.security.cts.BannedFilesTest.

assertNotSetugid(BannedFilesTest.java:59)

Rootcause: "OTHERS" users does not have "WRITE" permissions on any files under "/dev/" folder

这些问题是系统文件权限的问题,解决方法比较土,就是全局搜索该文件,查看那些对该文件操作的脚本,然后修改即可。

上面两个fail的解决方法是:

a.    修改kernel/drivers/input/touchscreen/malata_ts.c

__ATTR(ts_power, 0777, NULL, ts_set_point),

__ATTR(ts_en_file, 0777, NULL, ts_set_point),

__ATTR(ts_ Calibrate, 0777, NULL, ts_set_point),

b.    修改system/core/include/private/android-filesystem-config.h

{ 06755, ADD_ROOT, ADD_ROOT, “system/xbin/tcpdump”}

6、这种情况最多的。

-- testFocusDistances

fail

junit.framework.ComparisonFailure: expected:<infinity> but was:<auto> at

android.hardware.cts.CameraTest.testFocusDistancesByCamera

(CameraTest.java:1386)

对于这个fail的原因是CTS对摄像头测试时,对摄像头进行参数设置,然后在读取参数后,参数出错。

这种情况要找到CameraTest源码,通常在source/cts/...下面,我们编译时没有编译到这里,仅查看代码,例如找到CameraTest.java,打开后找到1386行,行数一般情况下不会有出入,除非source下面的cts版本和下载的cts版本不一致才会找不到,找到testFocusDistancesByCamera,然后根据代码查看具体的测试,然后在找camera的源代码,使用Log跟踪,当然这个测试一定要结合做该模块的人一起改才行,不然很容易引起其他问题。

其中camera CTS测试代码在:

source/cts/tests/tests/hardware/src/android/hardware/cts/CameraTest.java

摄像头设置的相关代码在:Source/device/Samsung/exynos4/libcamera/下面,有SecCameraHWInterface_zoom.cpp、SecCameraHWInterface_zoom.h、SecCamera_zoom.cpp、SecCamera_zoom.h

找到之后通过修改后测试再修改后再测试直到CTS PASS。

(对于摄像头,应注意是几个摄像头,不然测试可能会对两个一起测试,这样就算一个摄像头调好了,能PASS了,另外一个过不了也是FAIL的。)

7. [CTS]
2 cases failed by android.theme.cts.DeviceDefaultTest

这个cts测试的是Theme_DeviceDefault_dialogWhenLarge这个theme. 这个theme在large/xlarge screen时,显示为dialog; 在normal, small screen时,显示为full screen. 那个它是如何做到的呢?秘诀就是在values-large/xlarge中,把Theme_DeviceDefault_dialogWhenLarge定义为有固定尺寸的dialog
style. 而在values中,它确实普通的theme.holo style.

屏幕的大小是由screen的分辨率决定的:

longsize < 470dp  small screen

longsize >=960 && shortsize >=720   xlarge screen

longsize >=640
&& shortsize >=480   large screen

else normal screen.

那么又如何确定xlarge/large, 或者说指定类型的资源被编译到资源包中呢?

在*.mk中的PRODUCT_AAPT_CONFIG := mdpi【ldpi, hdpi, xhdpi, nodpi, tvdpi】 xlarge【large, normal, small】

ldpi= 120dpi

mdpi=160dpi

hdpi=240dpi

xhdpi=320

tvdpi=213

nodpi=all&noScale

Theme_DeviceDefault_DialogWhenLarge

8. 1 case failed by android.security.cts.ListeningPortsTest#testNoRemotelyAccessibleListeningTcpPorts

这个cts测试的是在user-release时的/proc/net/tcp/监听的端口。在user-release版本下,/proc/net/tcp/下的端口不应该被监听。

cat /proc/net/tcp/显示 监听的端口(16进制) 和inode 数

通过adb shell,  ls -l /proc/*/fd/ | grep -inr inode_number 来找到那个进程的fd在监听这个端口就可以解决了。

CPDD is gps issue.

cts_host > start --plan CTS -t android.net.cts.ListeningPortsTest#testNoListeningUdpPorts
start test android.net.cts.ListeningPortsTest#testNoListeningUdpPorts
==============================================================
Test package: android.net
android.net.cts.ListeningPortsTest#testNoListeningUdpPorts.............(fail)
android.net.cts.ListeningPortsTest$ListeningPortsAssertionError: Found port listening on 00000000:1C6B in /proc/net/udp at android.net.cts.ListeningPortsTest.assertNoListeningPorts(ListeningPortsTest.java:126)
at android.net.cts.ListeningPortsTest.assertNoListeningPorts(ListeningPortsTest.java:126)
at android.net.cts.ListeningPortsTest.assertNoListeningUdpPorts(ListeningPortsTest.java:78)
at android.net.cts.ListeningPortsTest.testNoListeningUdpPorts(ListeningPortsTest.java:63)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
at android.net.cts.ListeningPortsTest.assertNoListeningPorts(ListeningPortsTest.java:126)
at android.net.cts.ListeningPortsTest.assertNoListeningUdpPorts(ListeningPortsTest.java:78)
at android.net.cts.ListeningPortsTest.testNoListeningUdpPorts(ListeningPortsTest.java:63)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448) ==============================================================
and /proc/net/udp,  adb shell output is :
* daemon started successfully *
/# cat /proc/net/udp
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode ref pointer drops
107: 00000000:1C6B 00000000:0000 07 00000000:00000000 00:00000000 00000000 1000 0 4102 2 e0078000 0
#
and
# cat /proc/net/tcp
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 0100007F:13AD 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 2981 1 dfa58000 300 0 0 2 -1
Converting the hex values to decimal, you get:

0x1C6B = 7275
0x13AD = 5037 The first CTS failure is because there is a remotely accessible UDP port listening on port 7275. This is a security risk. Remotely accessible ports are often used by attackers to gain unauthorized access to computers systems without user knowledge or awareness. Minimizing the number of open ports is considered a security best practice and required by CTS. Per the /proc/net/udp output above, this port is owned by UID=1000 (the "system" user). What do you have running under the system server that opens port 7275? The second /proc/net/tcp output is also problematic. In: # cat /proc/net/tcp
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 0100007F:13AD 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 2981 1 dfa58000 300 0 0 2 -1 There's a process, RUNNING AS ROOT, which is listening on the loopback (127.0.0.1) interface on port 5037. This process is thankfully NOT remotely accessible, but it is accessible to any program installed on the phone. In ICS, this listening port will be considered a CTS failure. Locally accessible ports are often targeted by malicious locally installed programs to gain unauthorized access to program data or cause system corruption. In all cases, a local listening IP port can be replaced by a UNIX domain socket. Unix domain sockets can be protected with unix filesystem permission. Alternatively, you can use getsockopt(SO_PEERCRED) to determine if a program is authorized to connect to your socket. While this isn't a failure today, I'd recommend switching to a UNIX domain socket as soon as practical.

7 [cts version]
android-cts_4.2_r4_x86.zip

[cts command]
1. run cts -c android.app.cts.SystemFeaturesTest -m testLocationFeatures

[Failure Details]
junit.framework.AssertionFailedError: PackageManager#hasSystemFeature should NOT return true for android.hardware.location.network at android.app.cts.SystemFeaturesTest.assertNotAvailable(SystemFeaturesTest.java:375)

8 cts
version]
android-cts_4.2_r4_x86.zip

[cts command]
1. run cts -c android.provider.cts.ContactsContract_ContactsTest -m testContentUri

【转】CTS tests 4.2_r4的更多相关文章

  1. Android—— ubuntu下【CTS】測试TV真机

    近期接触到CTS,据传不懂CTS就不算一个合格的android开发者,我之前一直没见周边谁用过.作为一个产品开发的android人员,我还是太年轻- 撰写不易,转载请注明出处:http://blog. ...

  2. android 兼容性测试 CTS 测试过程(实践测试验证通过)

    source: http://blog.csdn.net/jianguo_liao19840726/article/details/7222814 写这个博客的时候是为了记忆,建议大家还是看官方的说明 ...

  3. 【转】android cts failed items

    原文网址:http://blog.csdn.net/linsa0517/article/details/19031479 Fail的一些修改   1.直接设置问题 estUnknownSourcesO ...

  4. 【转】android 兼容性测试 CTS 测试过程(实践测试验证通过)

    原文网址:http://blog.csdn.net/jianguo_liao19840726/article/details/7222814 写这个博客的时候是为了记忆,建议大家还是看官方的说明,官方 ...

  5. 安卓CTS官方文档之兼容性测试套件简介-attach

    官方英文文档原文:https://source.android.com/compatibility/cts-intro.html Compatibility Test Suite  兼容性测试套件 H ...

  6. 安卓CTS官方文档之兼容性测试套件简介

    官方英文文档原文:https://source.android.com/compatibility/cts-intro.html Compatibility Test Suite 兼容性测试套件 Ho ...

  7. Android CTS(frome google)

    Compatibility Test Suite How does the CTS work? The Compatibility Test Suite (CTS) is a free, commer ...

  8. Android CTS

    1.什么是CTS CTS是google制定的兼容性测试包(Compatibility Test Suite),只有通过CTS测试的设备才有可能获得Android的商标和享受Android Market ...

  9. CTS添加新测试用例步骤

    一.CTS添加新测试用例: 前言: google源代码中的cts测试用例集目录为:source_android4.2/cts/tests/tests/ (source_android4.2表示andr ...

随机推荐

  1. 解决比较Oracle中CLOB字段问题

    解决比较Oracle中CLOB字段问题   Oracle中CLOB和BLOB字段虽说在开发中满足了存放超大内容的要求,但是在一些简单使用中确频频带来麻烦.CLOB中存放的是指针,并不能直接取到实际值. ...

  2. Html.DropDownList的用法

    直接上代码 页面代码 <td> <%= Html.DropDownList("selCity") %> </td> controller里面的代 ...

  3. 基于PCA和SVM的人脸识别系统-error修改

    ------------------------------------------------- Undefined function or variable 'W'. Error in class ...

  4. Django之Cookie与Session

    一.cookie 1.cookie使用 def cookie(request): print(request.COOKIES) # 获取所有的COOKIES obj = render(request, ...

  5. 通过BulkLoad的方式快速导入海量数据

    摘要 加载数据到HBase的方式有多种,通过HBase API导入或命令行导入或使用第三方(如sqoop)来导入或使用MR来批量导入(耗费磁盘I/O,容易在导入的过程使节点宕机),但是这些方式不是慢就 ...

  6. Vue + vue-router

    搞了一天的element-ui,vue-router,把侧栏的导航菜单搞了出来后,试着在菜单上加入链接,研究了下官方提供的文档,发现要使用vue-route. 在项目中安装好vue-route, 对照 ...

  7. Could not load the Tomcat server configuration at /Servers/Tomcat v7.0 Server at localhost-config.

    [问题] Eclipse[Ubuntu14.04]中启动Tomcat Server[7.0.55]的时候出现错误例如以下: [解决方法] 1.将下边的Servers中的server[Tomcat v7 ...

  8. Android万能分辨率适应法

    (1)获取屏幕的尺寸 WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); D ...

  9. BGP

    http://network.51cto.com/art/200912/172439.htm http://blog.sina.com.cn/s/blog_b457dde80101cyqr.html ...

  10. [Leetcode] Remove Duplicates From Sorted Array II (C++)

    题目: Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For ex ...