原文网址: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. 怎样检查手机是否root成功

    怎样检查手机是否root成功 浏览:154361 | 更新:2011-01-20 13:10 | 标签:root 总有人以为,root后就可以删除自带程序了,这个想法也对也不对,想删除自带的软件,确实 ...

  2. fstream读写UNICODE文件

    今天遇到要处理UNICODE文件的情况,网上找了一圈都是读取出字节,再转的,这个不方便啊!想起了有codecvt这么个东西,顺藤摸瓜,找到了方法. locale utf16(locale(" ...

  3. 九度OJ 1437 To Fill or Not to Fill

    题目大意:小明从杭州去往某目的地,要经过一些加油站,每个加油站的价格不一样.若能顺利到达,求加油费用最少为多少,否则求出能行驶的最远距离. 思路:贪心算法 1>若下一加油站的价格更便宜,则只需走 ...

  4. 符号表实现(Symbol Table Implementations)

    符号表的实现有很多方式,下面介绍其中的几种. 乱序(未排序)数组实现 这种情况,不需要改变数组,操作就在这个数组上执行.在最坏的情况下插入,搜索,删除时间复杂度为O(n). 有序(已排序)数组实现 这 ...

  5. 好多邮箱的SMTP设置

    http://731771490.diandian.com/post/2011-04-20/19576550

  6. SQL 使用经验

    1. 写存储过程,Update数据库表,一定要根据idRow,也就是主键唯一键来更新. 更新操作,如果根据其他条件更新,之后就有的忙活了. 2. Query语句要加NOLOCK

  7. Annotation(一)——注解开发介绍

    <p>在编程中,一直强调的一点就是注释的编写,注释的规范等等.尤其是越是核心,程序越复杂,逻辑越多的清空下,注释的编写对我们以后的阅读代码,维护软件起着至关重要的作用.一款软件有着好的注释 ...

  8. 利用libevent的timer实现定时器interval

    在不怎么了解libevent的情况下,看到timer这个关键字想到可以用来做定时任务,官方资料也不齐全,就从代码里看到了TIMEOUT字样,这么说来应该是支持timeout了,那interval呢,貌 ...

  9. HDU2206 IP的计算 【经典题】

    IP的计算 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  10. SRM 588 D2 L3:GameInDarknessDiv2,DFS

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12710 采用DFS搜索,第一次写的时候忘了加访问标志,结果状态 ...