CTS研究【转载】
上一篇 / 下一篇 2011-02-12 14:02:04 / 个人分类:CTS
从各种渠道了解到 Android CTS 测试, 是一种类似于 Windows Mobile LTK 的测试。
大体 Google 一下, 发现关于 CTS 的信息非常至少, 只说它有两万多个测试用例。
然后它只对 OHA 成员开发。
本着不抛弃,不放弃的原则,继续 Google...
终于发现了参考1:Cezary Statkiewicz's blog。
搞笑的是该 Blog 的前言部分还写着 CTS 不开放。 后面又纠正了 Google 刚刚开放 CTS 信息(见参考2)。
大喜!
先学习¶
原来 Google 定义了一个兼容性规范(Compatibility Definition), 而 CTS 就是用于确保某个测试符合该规范。
从而基于 Android 的应用程序能够在基于同一 API 版本的各种设备上运行。
由于我们使用Android 2.1 (Eclair), 所以从参考2下载到 Android 2.1 的
Compatibility Definition, 大体阅读一下, 它定义了一些需求:
数据: 必须实现一种无线连接, 速率达到 200Kbit/Sec
Camera: 至少 2M pixels
重力加速: 必须有, 3维, >50Hz
指南针: 必须有, 3纬, >10Hz
GPS: 必须有
内存: 至少 92M (不包括专用内容)
Nand: /data 分区至少 290M
性能: 启动时间: 浏览器 < 1300ms
MMS/SMS < 700ms
AlarmClock < 650ms
第二次启动一个应用的时间不能超过第一次启动时间。
CTS 测试: 必须通过最新的 CTS
升级: 必须有一种办法可以升级全系统。 可以为:
OTA
USB
SD 卡
看来 Android 是在不断往高端方向走。 不过想想也正常,今天的高端就是明天的低端!
Quick Start¶
参考2 的 User Manual 似乎是针对 1.6 的, 其中提到 CTS 是单独下载的一个包。
而参考1 则说从 source code 中编译而来。
先按照参考1简单运行一下。
1) 获取 2.1 代码, 并先做一个基本的编译(不知是否需要)
2) 编译 cts:
cd ~/mydroid
. build/evnsetup.sh
make cts
3) 启动 emulator (或者 device, 不过可能需要按照 User Manual 设置一下)
4) 将 ~/mydroid/out/host/linux-x86/bin 加到路径
5) adb start-server
6) cts
进入 cts 交互环境, 可以敲入 help 看各种命令:cts_host > help
这里是quick start,所以不详解。
7) 在 shell 下直接以非交互模式运行一下:
$ cts start --plan Signature
该测试用例比较少,发现两分钟可以运行通过。 像 Android 测试方案就比较耗时间了。
参考¶
1. 某大牛的 Blog 文章
http://bitbar.com/blog/44/using-androids-compatibility-test-suite
2. Android 官方论坛:
http://source.android.com/compatibility/downloads.html
Android CTS测试研究之二
前言
继续较深入了解CTS的细节
先研究一下具体用法
命令行下敲cts进入命令行,
先看一下帮助
Help一下
cts_host > help
Usage: command options
Avaiable commands and options:
Host:
help: show this message
exit: exit cts command line
Plan:
ls --plan: list available plans
ls --plan plan_name: list contents of the plan with specified name
add --plan plan_name: add a new plan with specified name
add --derivedplan plan_name -s/--session session_id -r/--result result_type: derive a plan from the given session
rm --plan plan_name/all: remove a plan or all plans from repository
start --plan test_plan_name: run a test plan
start --plan test_plan_name -d/--device device_ID: run a test plan using the specified device
start --plan test_plan_name -t/--test test_name: run a specific test
start --plan test_plan_name -p/--package java_package_name: run a specific java package
start --plan test_plan_name -t/--test test_name -d/--device device_ID: run a specific test using the specified device
start --plan test_plan_name -p/--package java_package_name -d/--device device_ID: run a specific java package using the specified device
Package:
ls -p/--package: list available packages
ls -p/--package package_name: list contents of the package with specified name
add -p/--package root: add packages from root to repository
rm -p/--package package_name/all: remove a package or all packages from repository
Result:
ls -r/--result: list all result of sessions
ls -r/--result -s/--session session_id: list detail case result of a specified session
ls -r/--result [pass/fail/notExecuted/timeout] -s/--session session_id: list detail cases of a specified session by the specified result.
History:
history/h: list all commands in command history
history/h count: list the latest count records in command history
history/h -e num: run the command designated by 'num' in command history
Device:
ls -d/--device: list available devices
列出所有的plan
cts_host > ls --plan
List of plans (8 in total):
CTS
Signature
AppSecurity
Performance
RefApp
Java
VM
Android
查看某plan的内容
cts_host > ls --plan Android
Packages of plan Android (29 in total):
=================================
android.apidemos.cts
android.accessibilityservice
android.accounts
android.app
android.bluetooth
android.content
android.database
android.dpi
android.dpi2
android.example
android.gesture
android.graphics
android.hardware
android.jni
android.location
android.media
android.net
android.os
android.permission2
android.permission
android.provider
android.speech
android.telephony
android.text
android.util
android.view
android.webkit
android.widget
android.tests.appsecurity
添加一个新的plan
cts_host > add --plan marvell
[Choose package] SignatureTest: select[Y], reject[n], or choose suite in it[m]? [Y/n/m] Y
Invalid input. Please chose 'y', 'n', or 'm' (default is 'y')
[Choose package] SignatureTest: select[Y], reject[n], or choose suite in it[m]? [Y/n/m] y
[Choose package] android.accessibilityservice: select[Y], reject[n], or choose suite in it[m]? [Y/n/m] y
[Choose package] android.accounts: select[Y], reject[n], or choose suite in it[m]? [Y/n/m] y
[Choose package] android.apidemos.cts: select[Y], reject[n], or choose suite in it[m]? [Y/n/m]
[Choose package] android.app: select[Y], reject[n], or choose suite in it[m]? [Y/n/m] y
。。。。
[Choose package] android.widget: select[Y], reject[n], or choose suite in it[m]? [Y/n/m]
cts_host > ls --plan marvell
The following package(s) contained in plan marvell have been removed:
SignatureTest
Packages of plan marvell (55 in total):
=================================
android.accessibilityservice
android.accounts
android.apidemos.cts
android.app
。。。
android.widget
删除一个plan
cts_host > rm --plan marvell
执行一个plan
cts_host > start --plan Performance
start test plan Performance
==============================================================
Test package: android.performance2
android.performance2.cts.AppStartup#testStartup........................................................................................................................................................(timeout)
==============================================================
CTS_INFO >>> Max ADB operations reached. Restarting ADB...
CTS_INFO >>> Restarting device ...
CTS_INFO >>> Restart complete.
==============================================================
Test package: android.performance3
android.performance3.cts.AppStartup#testStartup..............(pass)
CTS_INFO >>> Max ADB operations reached. Restarting ADB...
CTS_INFO >>> Restarting device ...
CTS_INFO >>> Restart complete.
==============================================================
Test package: android.performance4
android.performance4.cts.AppStartup#testStartup.......(pass)
CTS_INFO >>> Max ADB operations reached. Restarting ADB...
CTS_INFO >>> Restarting device ...
CTS_INFO >>> Restart complete.
==============================================================
Test package: android.performance5
android.performance5.cts.AppStartup#testStartup........(fail)
junit.framework.AssertionFailedError: App Took too long to startup: 715 650 at android.performance5.cts.AppStartup.testStartup(AppStartup.java:67)
at android.performance5.cts.AppStartup.testStartup(AppStartup.java:67)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:205)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:195)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
at android.performance5.cts.AppStartup.testStartup(AppStartup.java:67)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:205)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:195)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
at android.app.ApplicationContext.startActivity(ApplicationContext.java:555)
at android.performance.cts.MultiAppStartupTest.launchActivity(MultiAppStartupTest.java:52)
at android.performance.cts.MultiAppStartupTest.testMultipleApps(MultiAppStartupTest.java:89)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:205)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:195)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
Test summary: pass=2 fail=2 timeOut=1 notExecuted=0 Total=5
Time: 635.927s
查看有多少个包
cts_host > ls -p
Available packages (56 in total):
android.util
android.hardware
。。。
android.core.tests.luni.net
android.jni
android.core.vm-tests
查看某个包
cts_host > ls -p android.net
Test suites (3 in total):
android.net.cts
android.net.wifi.cts
android.net.http.cts
查看测试结果
cts_host > ls -r
List of all results:
Session Test result Start time End time Test plan name
Pass Fail Timeout NotExecuted
1 2 2 1 0 2010.06.01 16:18:03 2010.06.01 16:28:39 Performance
2 1 0 0 0 2010.06.01 16:39:38 2010.06.01 16:41:33 Signature
研究cts生成文件
cts脚本文件位于:~/mydroid/out/host/linux-x86/bin,它是一个100行不到的脚本,最终执行:
java -Xmx512M
-cp ./../framework/ddmlib.jar:./../framework/junit.jar:./../framework/hosttestlib.jar:./../framework/cts.jar:./cts.jar
-DHOST_CONFIG=./../cts/android-cts/repository/host_config.xml
com.android.cts.TestHost
可见,CTS的Java主程序为:com.android.cts.TestHost,同时使用了配置文件:host_config.xml.
两个cts.jar: ./out/host/linux-x86/cts/android-cts/tools/cts.jar ./out/host/linux-x86/framework/cts.jar相同。
cts使用的目录则为:~/mydroid/out/host/linux-x86/cts
文件列表1
songlixin@zjujoe-desktop:~/mydroid/out/host/linux-x86/cts$ tree -L 3
.
├──all_cts_core_files_stamp
├──all_cts_files_stamp
├──android-cts
│ ├──docs
│ ├──repository
│ │ ├──host_config.xml
│ │ ├──log_2010.06.01_16.02.21_.txt
│ │ ├──log_2010.06.01_16.12.22_.txt
│ │ ├──log_2010.06.01_16.38.30_.txt
│ │ ├──log_2010.06.01_16.59.50_.txt
│ │ ├──plans
│ │ ├──results
│ │ └──testcases
│ └──tools
│ ├──cts.jar
│ ├──hosttestlib.jar
│ ├──junit.jar
│ └──startcts
├──android-cts.zip
└──temp
└──description.xml
我们关心的主要是repository目录。
文件列表2
songlixin@zjujoe-desktop:~/mydroid/out/host/linux-x86/cts$ tree android-cts/repository/
android-cts/repository/
├──host_config.xml
├──plans
│ ├──Android.xml
│ ├──AppSecurity.xml
│ ├──CTS.xml
│ ├──Java.xml
│ ├──Performance.xml
│ ├──RefApp.xml
│ ├──Signature.xml
│ └──VM.xml
├──results
│ ├──2010.06.01_16.18.03
│ │ ├──cts_result.css
│ │ ├──cts_result.xsl
│ │ ├──
TAG:
- 引用 删除 hongru321 / 2011-02-23 15:34:43
-
你好,请教个问题,CTS测试中跑performance全部fail了,提示Test package: android.performance2
android.performance2.cts.AppStartup#testStartup...(fail)
Permission Denial: starting instrumentation ComponentInfo{com.android.cts.performance2/android.test.InstrumentationTestRunner} from pid=6824, uid=6824 not allowed because package com.android.cts.performance2 does not have a signature matching the target com.android.music
请问是怎么回事呢
标题搜索
日历
|
|||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
1 | 2 | 3 | 4 | ||||||
5 | 6 | 7 | 8 | 9 | 10 | 11 | |||
12 | 13 | 14 | 15 | 16 | 17 | 18 | |||
19 | 20 | 21 | 22 | 23 | 24 | 25 | |||
26 | 27 | 28 | 29 | 30 | 31 |
我的存档
数据统计
- 访问量: 21754
- 日志数: 35
- 建立时间: 2010-10-09
- 更新时间: 2011-11-25