CTS搭建
1. 下载CTS包http://source.android.com/compatibility/cts-intro.html
2. 在手机或者模拟器上安装CtsDelegatingAccessibilityService.apk
(1)$sudo ./adb install -r /home/tester/cts/android-cts/repository/testcases
/CtsDelegatingAccessibil
ityService.apk
(2)手机或模拟器设置Settings > Accessibility > Accessibility > Delegating Accessibility Service
3. 进入android/out/host/linux-x86/cts /android-cts/repository/tools目录下,修改startcts脚本文件。将脚本中的SDK_ROOT该成自己的android SDK路径.
$cd home/tester /cts/android-cts/repository/tools $vim startcts修改脚本中出现的第一个SDK_ROOT,如"SDK_ROOT=/home/tester/cts/android-sdk-linux_86"。
4. 执行startcts脚本。在执行CTS测试计划时(执行一段时间后,大于5分钟)会出现没有足够权限启动devices,使用$sudo ./startcts可解决该问题。
5. 出现如下提示符表示启动cts并连接设备成功。(红色部分未deviceID,视设备号而定)
Android CTS version 2.1_r2
Device(CB511KADGR) connected
cts_host > cts_host >
6. 在“cts_host >”提示符下输入命令,以下为几个常用的命令
help查看所有
exit退出
ls -p列出所有的测试包
ls --plan列出所有的测试方案
start --plan plan_name运行一个测试方案,如:start --plan CTS
start --plan plan_name --package package_name运行一个特定的测试包,如:start --plan CTS --package android.bluetooth
查看测试报告
运行测试时,在CTS运行界面能看到测试报告与运行状况。测试完成后可在android-cts/repository/results/下生成详细的测试报告和一些附加信息,其中用日期和时间命名的文件夹下为所有的测试结果,同时文件夹也会被打成一个对应的.zip包方便提交。用浏览器打开.xml文件(默认就是,直接双击)就可以查看所用的测试报告了
常见问题:
a) 问题描述:在执行paln时,执行一段时间后会抛异常,异常如下:
CTS_INFO >>> Restarting device ...
Device(HC09MPL00037) disconnected
Exception in thread "Thread-17" com.android.ddmlib.AdbCommandRejectedException: insufficient permissions for device
at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.java:736)
at com.android.ddmlib.SyncService.openSync(SyncService.java:164)
at com.android.ddmlib.Device.getSyncService(Device.java:253)
at com.android.cts.DeviceManager$DeviceServiceMonitor.run(DeviceManager.java:217)
解决方案:是因为权限不够,提升至root权限可解决,命令如下$sudo ./startcts
b) 问题描述:输入./adb shell出现如下异常:
error: insufficient permissions for device
解决方案:输入:
$sudo -s
./adb kill-server
./adb devices
c) 问题描述:出现如下异常:Unable to locate android-sdk-linux_86/tools/adb.
解决方案:是因为android-sdk-linux_86的tools目录下没有adb文件,可以从将platfrorm-tools目录下的adb文件拷贝到tools目录下,或者去SVN上取下
d) 问题描述:error: device not found。
解决方法:(1)请确认你的手机是否连接电脑,(2)以连接PC,重新拔下来,在连一次(3)如果2操作后还不行,看下USB连接方式是否为默认(仅充电),选htc或USB连接。
e) 写入测试结果时报Too many open files的错误,这是因为网络请求过多,也就导致了系统打开的文件过多。每一个连接都会当成“文件”看待的。
解决方案:用ulimit –a命令查看每个用户允许打开的最大文件数,看到是的1024,把它改大点,用命令:ulimit -n 4096
补充说明:
为了避免一些没必要的错误,在测试前先更改一下手机设置:
1. You need to download the TTS files via Settings > Speech synthesis > Install
voice data before running CTS tests. (Note that this assumes you have Android
Market installed on the device, if not you will need to install the files manually via
adb)
2. It is advisable to log in to the device with a test Google account, not an account
that you actually use.
3. Make sure the device has a SD card plugged in and the card is empty. Warning:
CTS may modify/erase data on the SD card plugged in to the device.
4. Do a factory data reset on the device (Settings > SD Card & phone storage >
Factory data reset). Warning: This will erase all user data from the phone.
5. Make sure no lock pattern is set on the device (Settings > Security & location >
Require Pattern should be unchecked.
Google Confidential
6. Make sure the "Screen Timeout" is set to "Never Timeout" (Settings > Sound &
Display > Screen Timeout should be set to "Never Timeout".
our board have not this selection, so we can select the longest time 30min
7. Make sure the "Stay Awake" development option is checked (Settings >
Applications > Development > Stay awake).
8. Make sure Settings > Application > Development > Allow mock locations is set
to true.
9. Make sure the device is at the home screen at the start of CTS (Press the home
button).
10. While a device is running tests, it must not be used for any other tasks.
11. Do not press any keys on the device while CTS is running. Pressing keys or
touching the screen of a test device will interfere with the running tests and may
lead to test failures.