Android CTS 相关记录

 

编译CTS

1、 patch文件

init-cts.patch:该patch用在user版本,修改init.rc文件使adbd能在系统启动时自动运行。修改init.rc文件的ip值为本地局域网可用值。Usb连接测试则不用该patch。

2、 编译用于cts测试的image

host> . build/envsetup.sh

host> lunch xxx-user

host> m –j2 iso_img

 

3、 编译cts工具

host> make cts

 

确认编译cts工具是基于x86的,否则是基于默认的arm。

4、 工具生成位置

编译完成后,生成的CTS工具在~/out/host/linux-x86/cts/android-cts/下。

Before CTS

1、 device设置

1)  通过adb安装/repository/testcases/文件夹下的CtsDelegatingAccessibilityService.apk,并选中Settings-->Accessibility下的四个选项。

2)  选中Settings-->Display-->Animation-->No animations。

3)  选中Settings-->Applications-->Development-->Stay awake。

4)  User版本选中Settings-->Applications-->Development-->allow mock Locations。

5)  设置系统时间为当前测试时间(Settings->Date&time)。

6)  设置并连接上wifi(Settings->Wireless&networks->Wi-Fi settings)。

7)  在sdcard下新建video目录并拷贝testvideo.3gp和testvideo1.3gp到该目录下。这两个文件在源代码的~/cts/tests/res/raw下。

8)  退到launcher界面。

2、 host端的设置

1) 安装android SDK并将添加到环境变量。

2) 在测试前需在终端输入"ulimit -n 8192", 否则会有"open too many files"的error造成cts fail.

3、不加phone的测试修改

    1)去掉repository/plans/CTS.xml中的android.telephony package。

    2)去掉repository/testcases/CtsPermissionTestcase.xml和CtsAppTestCases.xml中的Telephony测项。

4、连接设备

    1)eth方式

host> export ADBHOST=ip

host> adb kill-server

host> adb devices

2) usb debug方式

device通过usb直接连上host。

运行CTS

运行android-cts/tools目录下的startcts。

host> ./startcts

Android CTS version 2.3_r1

Device(emulator-5554) connected

cts_host >

1、  所有包的CTS测试

cts_host> start –-plan CTS

2、  单个package的CTS测试

cts_host> start –-plan CTS –p packagename

3、启动未完成的测试

如果之前的测试没有完成,上述命令运行后可以选择一个session或者重新开启一个测试。

There are 1 existing session(s) for plan CTS.

Create a new session or choose an existing one?

  Create a new session [0]

  Choose a session     [1]

 

选中0开启一个新的测试,选中1则显示未完成测试的列表并可以选择某一个继续测试。

Please choose a session from the existed session(s):

  1  [0]

  3  [1]

after CTS

1、 获取并查看结果

测试结果在/repository/results下,以CTS测试启动时间命名的文件夹和压缩包。通过ie打开testResult.xml能快速查看bug数目及报错信息。Bug的详细信息通过文本等工具打开该文件可以查看。

2、 bug分析步骤

1)  通过testResult.xml确定出错代码的源文件路径和代码。

2)  根据测试源代码确定出错的api。

3)  重复测试验证。

 

0001-Avoid-crash-when-using-CtsVerifier.patch

From 3fa2ebaa480340365ec3f970ce6c83c9156fa61e Mon Sep 17 00:00:00 2001
From: kelly2_zhou <kelly2_zhou@asus.com>
Date: Fri, 10 Jun 2011 11:34:31 +0800
Subject: [PATCH 1/2] Avoid crash when using CtsVerifier

---
 .../verifier/features/FeatureSummaryActivity.java  |    8 ++++++--
 .../sensors/AccelerometerTestActivity.java         |    8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
index 8543890..3288cb0 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
@@ -145,8 +145,12 @@ public class FeatureSummaryActivity extends PassFailButtons.ListActivity {
         // get list of all features device thinks it has, & store in a HashMap
         // for fast lookups
         HashMap<String, String> actualFeatures = new HashMap<String, String>();
-        for (FeatureInfo fi : getPackageManager().getSystemAvailableFeatures()) {
-            actualFeatures.put(fi.name, fi.name);
+        try {
+            for (FeatureInfo fi : getPackageManager().getSystemAvailableFeatures()) {
+                actualFeatures.put(fi.name, fi.name);
+            }
+        } catch (NullPointerException e) {
+
         }
 
         // data structure that the SimpleAdapter will use to populate ListView
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerTestActivity.java
index 193f37e..7e9214a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerTestActivity.java
@@ -65,7 +65,11 @@ public class AccelerometerTestActivity extends PassFailButtons.Activity {
     protected void onResume() {
         super.onResume();
         mGLSurfaceView.onResume();
-        mSensorManager.registerListener(mListener, mSensorManager.getSensorList(
-                Sensor.TYPE_ACCELEROMETER).get(0), SensorManager.SENSOR_DELAY_UI);
+        try {
+            mSensorManager.registerListener(mListener, mSensorManager.getSensorList(
+                    Sensor.TYPE_ACCELEROMETER).get(0), SensorManager.SENSOR_DELAY_UI);
+        } catch (IndexOutOfBoundsException e) {
+
+        }
     }
 }
-- 
1.7.1
View Code

 

0002-reboot-and-reconnect-device.patch 

From 90b7325bc602f6dea7e6d0f82b9853df21bae96b Mon Sep 17 00:00:00 2001
Date: Thu, 30 Jun 2011 15:00:27 +0800
Subject: [PATCH 2/2] reboot and reconnect device

---
 tools/host/src/com/android/cts/DeviceManager.java |   54 +++++++++++++++++++--
 tools/host/src/com/android/cts/TestDevice.java    |    8 ++--
 2 files changed, 53 insertions(+), 9 deletions(-)

diff --git a/tools/host/src/com/android/cts/DeviceManager.java b/tools/host/src/com/android/cts/DeviceManager.java
index c794332..db5b314 100644
--- a/tools/host/src/com/android/cts/DeviceManager.java
+++ b/tools/host/src/com/android/cts/DeviceManager.java
@@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit;
 public class DeviceManager implements IDeviceChangeListener {
 
     private static final int SHORT_DELAY = 1000 * 15; // 15 seconds
-    private static final int LONG_DELAY = 1000 * 60 * 10; // 10 minutes
+    private static final int LONG_DELAY = 1000 * 60; // 10 minutes
     /** Time to wait after issuing reboot command  */
     private static final int REBOOT_DELAY = 5 * 1000; // 5 seconds
     /** Time to wait after device reports that boot is complete. */
@@ -182,6 +182,7 @@ public class DeviceManager implements IDeviceChangeListener {
      */
     private TestDevice searchTestDevice(final String deviceSerialNumber) {
         for (TestDevice td : mDevices) {
+            Log.i("getSerialNumber() = " + td.getSerialNumber());
             if (td.getSerialNumber().equals(deviceSerialNumber)) {
                 return td;
             }
@@ -301,6 +302,10 @@ public class DeviceManager implements IDeviceChangeListener {
                 DeviceDisconnectedException {
 
         String deviceSerialNumber = ts.getDeviceId();
+    boolean isemulator = deviceSerialNumber.toLowerCase().startsWith("emulator");
+
+    //====modify 3.0 for epc1015(use tcp/ip connected)======
+    
         if (!deviceSerialNumber.toLowerCase().startsWith("emulator")) {
             // try to reboot the device using the command line adb
             // TODO: do we need logic to retry this
@@ -309,7 +314,7 @@ public class DeviceManager implements IDeviceChangeListener {
 
             // TODO: this is flaky, no guarantee device has actually rebooted, host should wait till
             // device goes offline
-            Thread.sleep(REBOOT_DELAY);
+            Thread.sleep(1000*40/*REBOOT_DELAY*/);
 
             int attempts = 0;
             boolean deviceConnected = false;
@@ -318,6 +323,8 @@ public class DeviceManager implements IDeviceChangeListener {
 
                 // kill the server while the device is rebooting
                 executeCommand("adb kill-server");
+        Log.i("excuteCommand adb kill-server");
+        Thread.sleep(2000);
 
                 // Reset the device counter semaphore. We will wait below until at least one device
                 // has come online. This can happen any time during or after the call to
@@ -326,6 +333,13 @@ public class DeviceManager implements IDeviceChangeListener {
                 mSemaphore.drainPermits();
                 AndroidDebugBridge.createBridge(getAdbLocation(), true);
 
+        if(!isemulator){
+                //if device then connect device's ip address
+            executeCommand("adb connect " + deviceSerialNumber);
+            Log.i("executeCommand adb connect " + deviceSerialNumber);
+                    Thread.sleep(1000);
+        }
+
                 boolean deviceFound = false;
                 while (!deviceFound) {
                     // wait until at least one device has been added
@@ -335,15 +349,30 @@ public class DeviceManager implements IDeviceChangeListener {
                         ts.setTestDevice(device);
                         deviceFound = true;
                         deviceConnected = device.waitForBootComplete();
+             if(!deviceConnected) {
+                                deviceFound=false;
+                       /* if(!isemulator){
+                                //if device then connect device's ip address
+                            executeCommand("adb connect " + deviceSerialNumber);
+                            Log.i("executeCommand adb connect " + deviceSerialNumber);
+                                    Thread.sleep(1000);
+                        }*/
+                         }
+
                         // After boot is complete, the ADB connection sometimes drops
                         // for a short time. Wait for things to stabilize.
-                        try {
+            
+            //==remove 2.22==
+            
+                        /*try {
                             Thread.sleep(POST_BOOT_DELAY);
                         } catch (InterruptedException ignored) {
                             // ignore
-                        }
+                        }*/
+            //====end==========
                         // If the connection dropped during the sleep above, the TestDevice
                         // instance is no longer valid.
+            /*
                         TestDevice newDevice = searchTestDevice(deviceSerialNumber);
                         if (newDevice != null) {
                             ts.setTestDevice(newDevice);
@@ -357,8 +386,23 @@ public class DeviceManager implements IDeviceChangeListener {
                         } else {
                             // connection dropped and has not come back up
                             deviceFound = false; // go wait for next semaphore permit
-                        }
+                        }*/
+                    } else {
+                if(!isemulator){
+                        //if device then connect device's ip address
+                    executeCommand("adb connect " + deviceSerialNumber);
+                    Log.i("Device is null, executeCommand adb connect " + deviceSerialNumber);
+                            Thread.sleep(1000);
+                }
                     }
+
+        
+            //====add====
+            Log.i("device Found = " + deviceFound);
+//            if (!deviceFound){
+//                    break;
+//            }
+            //===end===
                 }
                 attempts += 1;
             }
diff --git a/tools/host/src/com/android/cts/TestDevice.java b/tools/host/src/com/android/cts/TestDevice.java
index 6ac56a1..2f456e0 100644
--- a/tools/host/src/com/android/cts/TestDevice.java
+++ b/tools/host/src/com/android/cts/TestDevice.java
@@ -76,7 +76,7 @@ public class TestDevice implements DeviceObserver {
     /** Interval [ms] for polling a device until boot is completed. */
     private static final int REBOOT_POLL_INTERVAL = 5000;
     /** Number of times a booting device should be polled before we give up. */
-    private static final int REBOOT_POLL_COUNT = 10 * 60 * 1000 / REBOOT_POLL_INTERVAL;
+    private static final int REBOOT_POLL_COUNT = 5;//10 * 60 * 1000 / REBOOT_POLL_INTERVAL;
     /** Max time [ms] to wait for <code>adb shell getprop</code> to return a result. */
     private static final int GETPROP_TIMEOUT = 5000;
 
@@ -248,7 +248,7 @@ public class TestDevice implements DeviceObserver {
      * device does not respond.
      */
     public boolean waitForBootComplete() throws DeviceDisconnectedException {
-        Log.d("probe device status...");
+        Log.i("probe device status...");
 
         mDeviceInfo.set(DeviceParameterCollector.SERIAL_NUMBER, getSerialNumber());
         mObjectSync = new ObjectSync();
@@ -260,7 +260,7 @@ public class TestDevice implements DeviceObserver {
         int retries = 0;
         boolean success = false;
         while (!success && (retries < REBOOT_POLL_COUNT)) {
-            Log.d("Waiting for device to complete boot");
+            Log.i("Waiting for device to complete boot");
             RestartPropReceiver rpr = new RestartPropReceiver();
             this.executeShellCommand("getprop dev.bootcomplete", rpr);
             success = rpr.hasRestarted(GETPROP_TIMEOUT);
@@ -275,7 +275,7 @@ public class TestDevice implements DeviceObserver {
         }
         mDeviceObserver = tmpDeviceObserver;
         if (success) {
-            Log.d("Device boot complete");
+            Log.i("Device boot complete");
         }
         return success;
     }
-- 
1.7.1
View Code

 

posted on 2014-08-11 20:33  mimamo  阅读(418)  评论(0编辑  收藏  举报

导航