remove CTSv1 tradefed harness
Bug: 31788743
Test: $ make ... cts dist
# verify number of modules, API coverage report
$ cts-tradefed run collect-tests-only \
--product-type bullhead --skip-preconditions \
--skip-device-info --skip-connectivity-check \
--primary-abi-only
# verify that test lists are identical before/after
$ make ... checkbuild
Change-Id: Ia5bb36af210f886c8efdc7956b30aed6f74f45d9
diff --git a/development/ide/eclipse/.classpath b/development/ide/eclipse/.classpath
index 98939ba..8e44571 100644
--- a/development/ide/eclipse/.classpath
+++ b/development/ide/eclipse/.classpath
@@ -93,8 +93,6 @@
<classpathentry kind="src" path="cts/tools/dex-tools/src"/>
<classpathentry kind="src" path="cts/tools/signature-tools/src"/>
<classpathentry kind="src" path="cts/tools/signature-tools/test"/>
- <classpathentry kind="src" path="cts/tools/tradefed-host/src"/>
- <classpathentry kind="src" path="cts/tools/tradefed-host/tests/src"/>
<classpathentry kind="src" path="cts/tools/utils"/>
<classpathentry kind="src" path="cts/tools/vm-tests-tf/src"/>
<classpathentry kind="src" path="external/easymock/src"/>
diff --git a/hostsidetests/cpptools/Android.mk b/hostsidetests/cpptools/Android.mk
index 824dd97..2c1f697 100644
--- a/hostsidetests/cpptools/Android.mk
+++ b/hostsidetests/cpptools/Android.mk
@@ -23,7 +23,7 @@
# Must match the package name in CtsTestCaseList.mk
LOCAL_MODULE := CtsCppToolsTestCases
-LOCAL_JAVA_LIBRARIES := old-cts-tradefed ddmlib-prebuilt tradefed-prebuilt
+LOCAL_JAVA_LIBRARIES := ddmlib-prebuilt tradefed-prebuilt
LOCAL_CTS_TEST_PACKAGE := android.tests.cpptools
diff --git a/tools/Android.mk b/tools/Android.mk
index 169accf..0a05aed 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -12,31 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Build the CTS harness
-
-JUNIT_HOST_JAR := $(HOST_OUT_JAVA_LIBRARIES)/junit.jar
-HOSTTESTLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/hosttestlib.jar
-TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
-CTS_TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/old-cts-tradefed.jar
-CTS_TF_EXEC_PATH ?= $(HOST_OUT_EXECUTABLES)/old-cts-tradefed
-
-cts_prebuilt_jar := $(HOST_OUT)/old-cts/old-android-cts/tools/cts-prebuilt.jar
-$(cts_prebuilt_jar): PRIVATE_TESTS_DIR := $(HOST_OUT)/old-cts/old-android-cts/repository/testcases
-$(cts_prebuilt_jar): PRIVATE_PLANS_DIR := $(HOST_OUT)/old-cts/old-android-cts/repository/plans
-$(cts_prebuilt_jar): PRIVATE_TOOLS_DIR := $(HOST_OUT)/old-cts/old-android-cts/tools
-$(cts_prebuilt_jar): $(JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(TF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(ADDITIONAL_TF_JARS) | $(ACP) $(HOST_OUT_EXECUTABLES)/adb
- mkdir -p $(PRIVATE_TESTS_DIR)
- mkdir -p $(PRIVATE_PLANS_DIR)
- mkdir -p $(PRIVATE_TOOLS_DIR)
- $(ACP) -fp $(JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(TF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(ADDITIONAL_TF_JARS) $(PRIVATE_TOOLS_DIR)
-
-.PHONY: cts-harness
-cts-harness : $(cts_prebuilt_jar)
-
-# Put the test coverage report in the dist dir if "old-cts" is among the build goals.
-ifneq ($(filter old-cts, $(MAKECMDGOALS)),)
- $(call dist-for-goals,old-cts,$(CTS_TF_JAR))
- $(call dist-for-goals,old-cts,$(HOSTTESTLIB_JAR))
-endif
-
include $(call all-subdir-makefiles)
diff --git a/tools/tradefed-host/.classpath b/tools/tradefed-host/.classpath
deleted file mode 100644
index e716219..0000000
--- a/tools/tradefed-host/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="res"/>
- <classpathentry kind="src" path="commonutil-src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry exported="true" kind="var" path="CTS_SRC_ROOT/out/host/common/obj/JAVA_LIBRARIES/ctsdeviceinfolib_intermediates/javalib.jar"/>
- <classpathentry kind="var" path="CTS_SRC_ROOT/out/host/common/obj/JAVA_LIBRARIES/hosttestlib_intermediates/javalib.jar"/>
- <classpathentry kind="var" path="CTS_SRC_ROOT/prebuilts/misc/common/tradefed/tradefed-prebuilt.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/tools/tradefed-host/.gitignore b/tools/tradefed-host/.gitignore
deleted file mode 100644
index ba077a4..0000000
--- a/tools/tradefed-host/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/tools/tradefed-host/.project b/tools/tradefed-host/.project
deleted file mode 100644
index ffd16af..0000000
--- a/tools/tradefed-host/.project
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>cts-tradefed-host</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
- <linkedResources>
- <link>
- <name>commonutil-src</name>
- <type>2</type>
- <locationURI>CTS_SRC_ROOT/cts/libs/commonutil/src</locationURI>
- </link>
- </linkedResources>
-</projectDescription>
diff --git a/tools/tradefed-host/Android.mk b/tools/tradefed-host/Android.mk
deleted file mode 100644
index e7954a6..0000000
--- a/tools/tradefed-host/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- $(call all-java-files-under, src) \
- $(call all-java-files-under, ../../libs/commonutil/src)
-
-LOCAL_JAVA_RESOURCE_DIRS := res
-
-LOCAL_MODULE := old-cts-tradefed
-LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := tradefed-prebuilt hosttestlib
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceinfolib compatibility-host-util
-
-LOCAL_JAR_MANIFEST := MANIFEST.mf
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tools/tradefed-host/MANIFEST.mf b/tools/tradefed-host/MANIFEST.mf
deleted file mode 100644
index 5528c06..0000000
--- a/tools/tradefed-host/MANIFEST.mf
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.android.cts.tradefed.testtype
-Implementation-Version: %BUILD_NUMBER%
diff --git a/tools/tradefed-host/README b/tools/tradefed-host/README
deleted file mode 100644
index 545d4b4..0000000
--- a/tools/tradefed-host/README
+++ /dev/null
@@ -1,83 +0,0 @@
-CTS Trade Federation
----------------------
-
-CTS Trade Federation, cts-tradefed for short, is the next
-generation test harness for CTS.
-
-cts-tradefed is built on top of the Android Trade Federation test harness.
-
-It works in a similar manner to the prior CTS harness, but supports some
-advanced features such as:
-
- - modular, flexible extensible design. cts-tradefed can be extended to
-support running CTS in a continuous test environment.
- - supports sharding a CTS test run across multiple devices in parallel
- - automatically continue a CTS test run on another device if connection
-is lost
-
-Configuring cts-tradefed
-------------------------
-
-1. Ensure 'adb' is in your current PATH. adb can be found in the
-Android SDK available from http://developer.android.com
-
-Example:
- PATH=$PATH:/home/myuser/android-sdk-linux_x86/platform-tools
-
-2. Follow the 'Setting up your device' steps documented in the
-CTS User Manual. The CTS User Manual can be downloaded at
-http://source.android.com/compatibility/downloads.html
-
-3. Connect the device to the host machine.
-
-4. Ensure device is visible via 'adb devices'
-
-Using cts-tradefed
--------------------
-
-To run a test plan on a single device:
-
-1. Make sure you have at least one device connected
-2. Launch the cts-tradefed console by running the 'cts-tradefed'. If you've
-downloaded and extracted the CTS zip, the script can be found at
- android-cts/tools/cts-tradefed
-Or else if you are working from the Android source tree and have run make cts,
-the script can be found at
- out/host/linux-x86/cts/android-cts/tools/cts-tradefed
-3. Type:
-'run cts --plan CTS' to run the default CTS plan
-
-Some other useful commands are
-
-To run a test package:
-'run cts --package <packagename>'
-
-To run a test class:
-'run cts --class <full test class name>'
-
-To shard a plan test run on multiple devices
-'run cts --plan CTS --shards <number of shards>
-note: all connected devices must be running the same build
-
-For more options:
-'run cts --help'
-
-CTS Tradefed Development
-------------------------
-See http://source.android.com for instructions on obtaining the Android
-platform source code and setting up a build environment.
-
-The source for the CTS extensions for tradefed can be found at
-<android source root>/cts/tools/tradefed-host
-
-The source for the tradefed framework can be found on the 'tradefed' branch.
-
-Perform these steps to build and run cts-tradefed from the development
-environment:
-cd <path to android source root>
-make cts
-cts-tradefed
-
-More documentation and details on using and extending trade federation will
-be forthcoming in the near future.
-
diff --git a/tools/tradefed-host/etc/Android.mk b/tools/tradefed-host/etc/Android.mk
deleted file mode 100644
index 3c2a3cf..0000000
--- a/tools/tradefed-host/etc/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PREBUILT_EXECUTABLES := old-cts-tradefed
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/tools/tradefed-host/etc/old-cts-tradefed b/tools/tradefed-host/etc/old-cts-tradefed
deleted file mode 100755
index 1dc7638..0000000
--- a/tools/tradefed-host/etc/old-cts-tradefed
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# launcher script for old-cts-tradefed harness
-# can be used from an Android build environment, or a standalone cts zip
-
-checkFile() {
- if [ ! -f "$1" ]; then
- echo "Unable to locate $1"
- exit
- fi;
-}
-
-checkPath() {
- if ! type -P $1 &> /dev/null; then
- echo "Unable to find $1 in path."
- exit
- fi;
-}
-
-checkPath adb
-checkPath java
-
-# check java version
-JAVA_VERSION=$(java -version 2>&1 | head -n 2 | grep '[ "]1\.[678][\. "$$]')
-if [ "${JAVA_VERSION}" == "" ]; then
- echo "Wrong java version. 1.6, 1.7 or 1.8 is required."
- exit
-fi
-
-# check debug flag and set up remote debugging
-if [ -n "${TF_DEBUG}" ]; then
- if [ -z "${TF_DEBUG_PORT}" ]; then
- TF_DEBUG_PORT=10088
- fi
- RDBG_FLAG=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=${TF_DEBUG_PORT}
-fi
-
-# get OS
-HOST=`uname`
-if [ "$HOST" == "Linux" ]; then
- OS="linux-x86"
-elif [ "$HOST" == "Darwin" ]; then
- OS="darwin-x86"
-else
- echo "Unrecognized OS"
- exit
-fi
-
-# check if in Android build env
-if [ ! -z "${ANDROID_BUILD_TOP}" ]; then
- if [ ! -z "${ANDROID_HOST_OUT}" ]; then
- OLD_CTS_ROOT=${ANDROID_HOST_OUT}/old-cts
- else
- OLD_CTS_ROOT=${ANDROID_BUILD_TOP}/${OUT_DIR:-out}/host/${OS}/old-cts
- fi
- if [ ! -d ${OLD_CTS_ROOT} ]; then
- echo "Could not find $OLD_CTS_ROOT in Android build environment. Try 'make old-cts'"
- exit
- fi;
-fi;
-
-if [ -z ${OLD_CTS_ROOT} ]; then
- # assume we're in an extracted cts install
- OLD_CTS_ROOT="$(dirname $0)/../.."
-fi;
-
-JAR_DIR=${OLD_CTS_ROOT}/old-android-cts/tools
-JARS="tradefed-prebuilt.jar hosttestlib.jar old-cts-tradefed.jar"
-
-for JAR in $JARS; do
- checkFile ${JAR_DIR}/${JAR}
- JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}
-done
-
-# load any shared libraries for host-side executables
-LIB_DIR=${OLD_CTS_ROOT}/old-android-cts/lib
-if [ "$HOST" == "Linux" ]; then
- LD_LIBRARY_PATH=${LIB_DIR}:${LIB_DIR}64:${LD_LIBRARY_PATH}
- export LD_LIBRARY_PATH
-elif [ "$HOST" == "Darwin" ]; then
- DYLD_LIBRARY_PATH=${LIB_DIR}:${LIB_DIR}64:${DYLD_LIBRARY_PATH}
- export DYLD_LIBRARY_PATH
-fi
-
-java $RDBG_FLAG \
- -cp ${JAR_PATH} -DCTS_ROOT=${OLD_CTS_ROOT} com.android.cts.tradefed.command.CtsConsole "$@"
-
diff --git a/tools/tradefed-host/res/config/basic-reporters.xml b/tools/tradefed-host/res/config/basic-reporters.xml
deleted file mode 100644
index d52a85b..0000000
--- a/tools/tradefed-host/res/config/basic-reporters.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration description="Configuration with basic cts reporters" >
- <result_reporter class="com.android.cts.tradefed.result.CtsTestLogReporter" />
- <result_reporter class="com.android.cts.tradefed.result.IssueReporter" />
-</configuration>
diff --git a/tools/tradefed-host/res/config/common-config.xml b/tools/tradefed-host/res/config/common-config.xml
deleted file mode 100644
index e1ac66d..0000000
--- a/tools/tradefed-host/res/config/common-config.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration description="Common base configuration for CTS module">
- <!--
- This common base configuration contains some commonly used preparers
- -->
- <target_preparer class="com.android.cts.tradefed.targetprep.CtsFilePusher">
- <option name="cleanup" value="true" />
- </target_preparer>
- <target_preparer class="com.android.cts.tradefed.targetprep.CtsApkInstaller">
- <option name="cleanup-apks" value="true" />
- </target_preparer>
- <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer" />
-</configuration>
diff --git a/tools/tradefed-host/res/config/cts.xml b/tools/tradefed-host/res/config/cts.xml
deleted file mode 100644
index e08ad81..0000000
--- a/tools/tradefed-host/res/config/cts.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration
- description="Runs a CTS plan from a pre-existing CTS installation">
-
- <option name="enable-root" value="false" />
- <build_provider class="com.android.cts.tradefed.build.CtsBuildProvider" />
- <device_recovery class="com.android.tradefed.device.WaitDeviceRecovery" />
- <test class="com.android.cts.tradefed.testtype.CtsTest" />
- <logger class="com.android.tradefed.log.FileLogger">
- <option name="log-level-display" value="WARN" />
- </logger>
- <result_reporter class="com.android.cts.tradefed.result.CtsXmlResultReporter" />
- <template-include name="reporters" default="basic-reporters" />
-</configuration>
diff --git a/tools/tradefed-host/res/report/cts_result.css b/tools/tradefed-host/res/report/cts_result.css
deleted file mode 100644
index f825d7a..0000000
--- a/tools/tradefed-host/res/report/cts_result.css
+++ /dev/null
@@ -1,186 +0,0 @@
-/* Copyright (C) 2008 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-body {
- font-family:arial,sans-serif;
- color:#000;
- font-size:13px;
- color:#333;
- padding:10;
- margin:10;
-}
-
-/* Report logo and device name */
-table.title {
- padding:5px;
- border-width: 0px;
- margin-left:auto;
- margin-right:auto;
- vertical-align:middle;
-}
-
-table.summary {
- background-color: rgb(212, 233, 169);
- border-collapse:collapse;
- border: 0px solid #A5C639;
- margin-left:auto;
- margin-right:auto;
-}
-
-table.summary th {
- background-color: #A5C639;
- font-size: 1.2em;
- padding: 0.5em;
-}
-
-table.summary td {
- border-width: 0px 0px 0px 0px;
- border-color: gray;
- border-style: inset;
- font-size: 1em;
- padding: 0.5em;
- vertical-align: top;
-}
-
-table.testsummary {
- background-color: rgb(212, 233, 169);
- border-collapse:collapse;
- margin-left:auto;
- margin-right:auto;
-}
-
-table.testsummary th {
- background-color: #A5C639;
- border: 1px outset gray;
- padding: 0.5em;
-}
-
-table.testsummary td {
- border: 1px outset #A5C639;
- padding: 0.5em;
- text-align: center;
-}
-
-table.testdetails {
- background-color: rgb(212, 233, 169);
- border-collapse:collapse;
- border-width:1;
- border-color: #A5C639;
- margin-left:auto;
- margin-right:auto;
- margin-bottom: 2em;
- vertical-align: top;
- width: 95%;
-}
-
-table.testdetails th {
- background-color: #A5C639;
- border-width: 1px;
- border-color: gray;
- border-style: outset;
- height: 2em;
- padding: 0.2em;
-}
-
-table.testdetails td {
- border-width: 1px;
- border-color: #A5C639;
- border-style: outset;
- text-align: left;
- vertical-align: top;
- padding: 0.2em;
-}
-
-table.testdetails td.package {
- background-color: white;
- border: 0px;
- font-weight: bold;
-}
-
-/* Test cell details */
-td.failed {
- background-color: #FA5858;
- font-weight:bold;
- vertical-align: top;
- text-align: center;
-}
-
-td.failuredetails {
- text-align: left;
-}
-
-td.pass {
- text-align: center;
- margin-left:auto;
- margin-right:auto;
-}
-
-td.timeout, td.omitted, td.notExecuted {
- background-color: #A5C639;
- vertical-align: top;
- text-align: center;
-}
-
-td.testname {
- border-width: 1px;
- border-color: #A5C639;
- border-style: outset;
- text-align: left;
- vertical-align: top;
- padding:1;
- overflow:hidden;
-}
-
-td.testcase {
- border-width: 1px;
- border-color: #A5C639;
- border-style: outset;
- text-align: left;
- vertical-align: top;
- padding:1;
- overflow:hidden;
- font-weight:bold;
-}
-
-td.testcasespacer {
- border-width: 1px;
- border-color: #A5C639;
- border-style: outset;
- text-align: left;
- vertical-align: top;
- padding:1;
- overflow:hidden;
- font-weight:bold;
-}
-
-td.testsuite {
- border-width: 1px;
- border-color: #A5C639;
- border-style: outset;
- text-align: left;
- vertical-align: top;
- padding:1;
- overflow:hidden;
- font-weight:bold;
-}
-
-div.details {
- white-space: pre-wrap; /* css-3 */
- white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
- white-space: -pre-wrap; /* Opera 4-6 */
- white-space: -o-pre-wrap; /* Opera 7 */
- word-wrap: break-word; /* Internet Explorer 5.5+ */
- overflow:auto;
-}
diff --git a/tools/tradefed-host/res/report/cts_result.xsd b/tools/tradefed-host/res/report/cts_result.xsd
deleted file mode 100644
index ce606e9..0000000
--- a/tools/tradefed-host/res/report/cts_result.xsd
+++ /dev/null
@@ -1,279 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- -->
-
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://compatibility.android.com/cts_result/1.15"
- xmlns="http://compatibility.android.com/cts_result/1.15"
- elementFormDefault="qualified">
-
-<xs:element name="TestResult">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="DeviceInfo" type="deviceInfoType"/>
- <xs:element name="HostInfo" type="hostInfoType"/>
- <xs:element name="Summary" type="summaryType"/>
- <xs:element name="TestPackage" type="testPackageType" maxOccurs="unbounded" minOccurs="1"/>
- </xs:sequence>
- <xs:attribute name="starttime" type="xs:string"/>
- <xs:attribute name="endtime" type="xs:string"/>
- <xs:attribute name="testPlan" type="xs:string"/>
- <xs:attribute name="version" type="xs:string"/>
- <xs:attribute name="suite" type="xs:string"/>
- </xs:complexType>
-</xs:element>
-
-<xs:complexType name="deviceInfoType">
- <xs:sequence>
- <xs:element name="Screen">
- <xs:complexType>
- <xs:attribute name="screen_size" type="xs:string"/>
- <xs:attribute name="resolution" type="xs:string"/>
- <xs:attribute name="screen_density" type="xs:decimal"/>
- <xs:attribute name="screen_density_bucket" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="PhoneSubInfo">
- <xs:complexType>
- <xs:attribute name="subscriberId" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="BuildInfo">
- <xs:complexType>
- <xs:attribute name="Xdpi" type="xs:decimal"/>
- <xs:attribute name="Ydpi" type="xs:decimal"/>
- <xs:attribute name="androidPlatformVersion" type="xs:integer"/>
- <xs:attribute name="buildID" type="xs:string"/>
- <xs:attribute name="buildName" type="xs:string"/>
- <xs:attribute name="buildVersion" type="xs:string"/>
- <xs:attribute name="build_board" type="xs:string"/>
- <xs:attribute name="build_manufacturer" type="xs:string"/>
- <xs:attribute name="build_brand" type="xs:string"/>
- <xs:attribute name="build_device" type="xs:string"/>
- <xs:attribute name="build_fingerprint" type="xs:string"/>
- <xs:attribute name="build_model" type="xs:string"/>
- <xs:attribute name="build_type" type="xs:string"/>
- <xs:attribute name="deviceID" type="xs:string"/>
- <xs:attribute name="imei" type="xs:integer"/>
- <xs:attribute name="imsi" type="xs:integer"/>
- <xs:attribute name="keypad" type="xs:string"/>
- <xs:attribute name="locales" type="xs:string"/>
- <xs:attribute name="navigation" type="xs:string"/>
- <xs:attribute name="network" type="xs:string"/>
- <xs:attribute name="touch" type="xs:string"/>
- <xs:attribute name="openGlEsVersion" type="xs:string"/>
- <xs:attribute name="partitions" type="xs:string"/>
- <xs:attribute name="build_abi" type="xs:string"/>
- <xs:attribute name="build_abi2" type="xs:string"/>
- <xs:attribute name="storage_devices" type="xs:string"/>
- <xs:attribute name="multi_user" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="FeatureInfo" type="featureInfoType"/>
- <xs:element name="ProcessInfo" type="processInfoType"/>
- <xs:element name="SystemLibrariesInfo" type="systemLibrariesInfoType"/>
- <xs:element name="OpenGLCompressedTextureFormatsInfo" type="openGLCompressedTextureFormatsInfoType"/>
- </xs:sequence>
-</xs:complexType>
-
-<xs:complexType name="hostInfoType">
- <xs:sequence>
- <xs:element name="Os">
- <xs:complexType>
- <xs:attribute name="arch" type="xs:string"/>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="version" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="Java">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="version" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="Cts">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="IntValue" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="value" type="xs:integer"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="version" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string"/>
-</xs:complexType>
-
-<xs:complexType name="featureInfoType">
- <xs:sequence>
- <xs:element name="Feature" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" />
- <xs:attribute name="type" type="xs:string" />
- <xs:attribute name="available" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
-</xs:complexType>
-
-<xs:complexType name="processInfoType">
- <xs:sequence>
- <xs:element name="Process" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" />
- <xs:attribute name="uid" type="xs:integer" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
-</xs:complexType>
-
-<xs:complexType name="systemLibrariesInfoType">
- <xs:sequence>
- <xs:element name="Library" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
-</xs:complexType>
-
-<xs:complexType name="openGLCompressedTextureFormatsInfoType">
- <xs:sequence>
- <xs:element name="TextureFormat" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
-</xs:complexType>
-
-<xs:complexType name="summaryType">
- <xs:attribute name="failed" type="xs:integer"/>
- <xs:attribute name="notExecuted" type="xs:integer"/>
- <xs:attribute name="pass" type="xs:integer"/>
- <xs:attribute name="timeout" type="xs:integer"/>
- <xs:attribute name="omitted" type="xs:integer"/>
-</xs:complexType>
-
-<xs:complexType name="testPackageType">
- <xs:sequence>
- <xs:element name="TestSuite" type="testSuiteType" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- <xs:attribute name="appPackageName" type="xs:string"/>
- <xs:attribute name="digest" type="xs:hexBinary"/>
- <xs:attribute name="name" type="xs:string" use="required"/>
- <xs:attribute name="signatureCheck" type="xs:boolean" />
-</xs:complexType>
-
-<xs:complexType name="testSuiteType">
- <xs:sequence>
- <xs:element name="TestCase" type="testCaseType" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element name="TestSuite" type="testSuiteType" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string" use="required"/>
-</xs:complexType>
-
-<xs:complexType name="testCaseType">
- <xs:sequence>
- <xs:element name="Test" type="testType" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string" use="required"/>
- <xs:attribute name="priority" type="xs:string"/>
-</xs:complexType>
-
-<xs:simpleType name="unitType">
- <xs:restriction base="xs:string">
- <xs:enumeration value="none"/>
- <xs:enumeration value="ms"/>
- <xs:enumeration value="fps"/>
- <xs:enumeration value="ops"/>
- <xs:enumeration value="kbps"/>
- <xs:enumeration value="mbps"/>
- <xs:enumeration value="byte"/>
- <xs:enumeration value="count"/>
- <xs:enumeration value="score"/>
- </xs:restriction>
-</xs:simpleType>
-
-<xs:simpleType name="scoreTypeType">
- <xs:restriction base="xs:string">
- <xs:enumeration value="higherBetter"/>
- <xs:enumeration value="lowerBetter"/>
- <xs:enumeration value="neutral"/>
- <xs:enumeration value="warning"/>
- </xs:restriction>
-</xs:simpleType>
-
-<xs:complexType name="testType">
- <xs:sequence>
- <xs:element name="FailedScene" minOccurs="0" maxOccurs="1">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="StackTrace" type="xs:string" minOccurs="0" maxOccurs="1"/>
- </xs:sequence>
- <xs:attribute name="message" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="Summary" minOccurs="0" maxOccurs="1">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="xs:decimal">
- <xs:attribute name="message" type="xs:string" use="required" />
- <xs:attribute name="scoreType" type="scoreTypeType" use="required" />
- <xs:attribute name="unit" type="unitType" use="required" />
- <xs:attribute name="target" type="xs:decimal" />
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="Details" minOccurs="0" maxOccurs="1">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="ValueArray" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="Value" type="xs:decimal" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- <xs:attribute name="source" type="xs:string" use="required" />
- <xs:attribute name="message" type="xs:string" use="required" />
- <xs:attribute name="scoreType" type="scoreTypeType" use="required" />
- <xs:attribute name="unit" type="unitType" use="required" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string" use="required"/>
- <xs:attribute name="result" type="resultType" use="required"/>
- <xs:attribute name="starttime" type="xs:string"/>
- <xs:attribute name="endtime" type="xs:string"/>
-</xs:complexType>
-
-<xs:simpleType name="resultType">
- <xs:restriction base="xs:string">
- <xs:enumeration value="pass"/>
- <xs:enumeration value="fail"/>
- <xs:enumeration value="timeout"/>
- <xs:enumeration value="notExecuted"/>
- <xs:enumeration value="omitted"/>
- </xs:restriction>
-</xs:simpleType>
-</xs:schema>
diff --git a/tools/tradefed-host/res/report/cts_result.xsl b/tools/tradefed-host/res/report/cts_result.xsl
deleted file mode 100644
index 3b92527..0000000
--- a/tools/tradefed-host/res/report/cts_result.xsl
+++ /dev/null
@@ -1,636 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
-<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
-
- <xsl:template match="/">
-
- <html>
- <head>
- <title>Test Report for <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@build_model" /> - <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@deviceID"/></title>
- <script>
- function toggle(id) {
- e = document.getElementById(id)
- e.style.display = e.style.display == "none" ? "block" : "none"
- }
- </script>
- <STYLE type="text/css">
- @import "cts_result.css";
- </STYLE>
- </head>
- <body>
- <DIV>
- <TABLE class="title">
- <TR>
- <TD width="40%" align="left"><img src="logo.gif"></img></TD>
- <TD width="60%" align="left">
- <h1>Test Report for <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@build_model"/> -
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@deviceID"/>
- </h1>
- </TD>
- </TR>
- </TABLE>
- </DIV>
- <img src="newrule-green.png" align="left"></img>
-
- <br></br>
-
- <center>
- <a href="#" onclick="toggle('summary');">Show Device Information</a>
- </center>
-
- <br></br>
-
- <DIV id="summary" style="display: none">
- <TABLE class="summary">
- <TR>
- <TH colspan="2">Device Information</TH>
- </TR>
- <TR>
- <TD width="50%">
- <!-- Device information -->
- <TABLE>
- <TR>
- <TD class="rowtitle">Build Model</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@build_model"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Build Product</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@buildName"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Build Brand</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@build_brand"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Build Manufacturer</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@build_manufacturer"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Device ID</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@deviceID"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Android Version</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@buildVersion"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Build ID</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@buildID"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Build Fingerprint</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@build_fingerprint"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Build ABI</TD>
- <TD>
- <xsl:value-of
- select="TestResult/DeviceInfo/BuildInfo/@build_abi"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Build ABI2</TD>
- <TD>
- <xsl:value-of
- select="TestResult/DeviceInfo/BuildInfo/@build_abi2"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Android API Level</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@androidPlatformVersion"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Supported Locales</TD>
- <TD>
- <xsl:call-template name="formatDelimitedString">
- <xsl:with-param name="string" select="TestResult/DeviceInfo/BuildInfo/@locales"/>
- </xsl:call-template>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Low RAM Device</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/MemoryInfo/@is_low_ram_device"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Memory Class</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/MemoryInfo/@memory_class"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Large Memory Class</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/MemoryInfo/@large_memory_class"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Total Memory</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/MemoryInfo/@total_memory"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Screen Size</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/Screen/@screen_size"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Resolution</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/Screen/@resolution"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Density</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/Screen/@screen_density"/>
- (<xsl:value-of select="TestResult/DeviceInfo/Screen/@screen_density_bucket"/>)
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Phone number</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/PhoneSubInfo/@subscriberId"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">X dpi</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@Xdpi"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Y dpi</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@Ydpi"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Touch</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@touch"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Navigation</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@navigation"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Keypad</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@keypad"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Network</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@network"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">IMEI</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@imei"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">IMSI</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@imsi"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Open GL ES Version</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@openGlEsVersion"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Open GL Compressed Texture Formats</TD>
- <TD>
- <UL>
- <xsl:for-each select="TestResult/DeviceInfo/OpenGLCompressedTextureFormatsInfo/TextureFormat">
- <LI><xsl:value-of select="@name" /></LI>
- </xsl:for-each>
- </UL>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Root Processes</TD>
- <TD>
- <UL>
- <xsl:for-each select="TestResult/DeviceInfo/ProcessInfo/Process[@uid='0']">
- <LI><xsl:value-of select="@name" /></LI>
- </xsl:for-each>
- </UL>
- </TD>
- </TR>
-
- </TABLE>
- </TD>
-
- <TD width="50%">
- <TABLE>
-
- <TR>
- <TD class="rowtitle">Features</TD>
- <TD>
- <xsl:for-each select="TestResult/DeviceInfo/FeatureInfo/Feature[@type='sdk']">
- <xsl:text>[</xsl:text>
- <xsl:choose>
- <xsl:when test="@available = 'true'">
- <xsl:text>X</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>_</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>] </xsl:text>
-
- <xsl:value-of select="@name" />
- <br />
- </xsl:for-each>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Other Features</TD>
- <TD>
- <UL>
- <xsl:for-each select="TestResult/DeviceInfo/FeatureInfo/Feature[@type='other']">
- <LI><xsl:value-of select="@name" /></LI>
- </xsl:for-each>
- </UL>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">System Libraries</TD>
- <TD>
- <UL>
- <xsl:for-each select="TestResult/DeviceInfo/SystemLibrariesInfo/Library">
- <LI><xsl:value-of select="@name" /></LI>
- </xsl:for-each>
- </UL>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Partitions</TD>
- <TD>
- <pre>
- <xsl:call-template name="formatDelimitedString">
- <xsl:with-param name="string" select="TestResult/DeviceInfo/BuildInfo/@partitions" />
- <xsl:with-param name="numTokensPerRow" select="1" />
- </xsl:call-template>
- </pre>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Storage devices</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@storage_devices"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Multi-user support</TD>
- <TD>
- <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@multi_user"/>
- </TD>
- </TR>
- </TABLE>
- </TD>
- </TR>
- </TABLE>
- <br />
- <br />
- </DIV>
-
- <DIV>
- <TABLE class="summary">
- <TR>
- <TH colspan="2">Test Summary</TH>
- </TR>
- <TR>
- <TD class="rowtitle">CTS version</TD>
- <TD>
- <xsl:value-of select="TestResult/HostInfo/Cts/@version"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Test timeout</TD>
- <TD>
- <xsl:value-of select="TestResult/HostInfo/Cts/IntValue[@name='testStatusTimeoutMs']/@value" /> ms
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Host Info</TD>
- <TD>
- <xsl:value-of select="TestResult/HostInfo/@name"/>
- (<xsl:value-of select="TestResult/HostInfo/Os/@name"/> - <xsl:value-of select="TestResult/HostInfo/Os/@version"/>)
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Plan name</TD>
- <TD>
- <xsl:value-of select="TestResult/@testPlan"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Start time</TD>
- <TD>
- <xsl:value-of select="TestResult/@starttime"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">End time</TD>
- <TD>
- <xsl:value-of select="TestResult/@endtime"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Tests Passed</TD>
- <TD>
- <xsl:value-of select="TestResult/Summary/@pass"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Tests Failed</TD>
- <TD>
- <xsl:value-of select="TestResult/Summary/@failed"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Tests Timed out</TD>
- <TD>
- <xsl:value-of select="TestResult/Summary/@timeout"/>
- </TD>
- </TR>
- <TR>
- <TD class="rowtitle">Tests Not Executed</TD>
- <TD>
- <xsl:value-of select="TestResult/Summary/@notExecuted"/>
- </TD>
- </TR>
- </TABLE>
- </DIV>
-
- <!-- High level summary of test execution -->
- <h2 align="center">Test Summary by Package</h2>
- <DIV>
- <TABLE class="testsummary">
- <TR>
- <TH>Test Package</TH>
- <TH>Passed</TH>
- <TH>Failed</TH>
- <TH>Timed Out</TH>
- <TH>Not Executed</TH>
- <TH>Total Tests</TH>
- </TR>
- <xsl:for-each select="TestResult/TestPackage">
- <TR>
- <TD>
- <xsl:variable name="href"><xsl:value-of select="@appPackageName"/></xsl:variable>
- <a href="#{$href}"><xsl:value-of select="@appPackageName"/></a>
- </TD>
- <TD>
- <xsl:value-of select="count(TestSuite//Test[@result = 'pass'])"/>
- </TD>
- <TD>
- <xsl:value-of select="count(TestSuite//Test[@result = 'fail'])"/>
- </TD>
- <TD>
- <xsl:value-of select="count(TestSuite//Test[@result = 'timeout'])"/>
- </TD>
- <TD>
- <xsl:value-of select="count(TestSuite//Test[@result = 'notExecuted'])"/>
- </TD>
- <TD>
- <xsl:value-of select="count(TestSuite//Test)"/>
- </TD>
- </TR>
- </xsl:for-each> <!-- end package -->
- </TABLE>
- </DIV>
-
- <xsl:call-template name="filteredResultTestReport">
- <xsl:with-param name="header" select="'Test Failures'" />
- <xsl:with-param name="resultFilter" select="'fail'" />
- </xsl:call-template>
-
- <xsl:call-template name="filteredResultTestReport">
- <xsl:with-param name="header" select="'Test Timeouts'" />
- <xsl:with-param name="resultFilter" select="'timeout'" />
- </xsl:call-template>
-
- <h2 align="center">Detailed Test Report</h2>
- <xsl:call-template name="detailedTestReport" />
-
- </body>
- </html>
- </xsl:template>
-
- <xsl:template name="filteredResultTestReport">
- <xsl:param name="header" />
- <xsl:param name="resultFilter" />
- <xsl:variable name="numMatching" select="count(TestResult/TestPackage/TestSuite//TestCase/Test[@result=$resultFilter])" />
- <xsl:if test="$numMatching > 0">
- <h2 align="center"><xsl:value-of select="$header" /> (<xsl:value-of select="$numMatching"/>)</h2>
- <xsl:call-template name="detailedTestReport">
- <xsl:with-param name="resultFilter" select="$resultFilter"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
-
- <xsl:template name="detailedTestReport">
- <xsl:param name="resultFilter" />
- <DIV>
- <xsl:for-each select="TestResult/TestPackage">
- <xsl:if test="$resultFilter=''
- or count(TestSuite//TestCase/Test[@result=$resultFilter]) > 0">
-
- <TABLE class="testdetails">
- <TR>
- <TD class="package" colspan="3">
- <xsl:variable name="href"><xsl:value-of select="@appPackageName"/></xsl:variable>
- <a name="{$href}">Compatibility Test Package: <xsl:value-of select="@appPackageName"/>
- <xsl:if test="@abi">
- ABI: <xsl:value-of select="@abi"/>
- </xsl:if>
- </a>
- </TD>
- </TR>
-
- <TR>
- <TH width="30%">Test</TH>
- <TH width="5%">Result</TH>
- <TH>Details</TH>
- </TR>
-
- <!-- test case -->
- <xsl:for-each select="TestSuite//TestCase">
-
- <xsl:if test="$resultFilter='' or count(Test[@result=$resultFilter]) > 0">
- <!-- emit a blank row before every test suite name -->
- <xsl:if test="position()!=1">
- <TR><TD class="testcasespacer" colspan="3"></TD></TR>
- </xsl:if>
-
- <TR>
- <TD class="testcase" colspan="3">
- <xsl:for-each select="ancestor::TestSuite">
- <xsl:if test="position()!=1">.</xsl:if>
- <xsl:value-of select="@name"/>
- </xsl:for-each>
- <xsl:text>.</xsl:text>
- <xsl:value-of select="@name"/>
- </TD>
- </TR>
- </xsl:if>
-
- <!-- test -->
- <xsl:for-each select="Test">
- <xsl:if test="$resultFilter='' or $resultFilter=@result">
- <TR>
- <TD class="testname"> -- <xsl:value-of select="@name"/></TD>
-
- <!-- test results -->
- <xsl:choose>
- <xsl:when test="string(@KnownFailure)">
- <!-- "pass" indicates the that test actually passed (results have been inverted already) -->
- <xsl:if test="@result='pass'">
- <TD class="pass">
- <div style="text-align: center; margin-left:auto; margin-right:auto;">
- Known problem
- </div>
- </TD>
- <TD class="failuredetails"></TD>
- </xsl:if>
-
- <!-- "fail" indicates that a known failure actually passed (results have been inverted already) -->
- <xsl:if test="@result='fail'">
- <TD class="failed">
- <div style="text-align: center; margin-left:auto; margin-right:auto;">
- <xsl:value-of select="@result"/>
- </div>
- </TD>
- <TD class="failuredetails">
- <div class="details">
- A test that was a known failure actually passed. Please check.
- </div>
- </TD>
- </xsl:if>
- </xsl:when>
-
- <xsl:otherwise>
- <xsl:if test="@result='pass'">
- <TD class="pass">
- <div style="text-align: center; margin-left:auto; margin-right:auto;">
- <xsl:value-of select="@result"/>
- </div>
- </TD>
- <TD class="failuredetails"/>
- </xsl:if>
-
- <xsl:if test="@result='fail'">
- <TD class="failed">
- <div style="text-align: center; margin-left:auto; margin-right:auto;">
- <xsl:value-of select="@result"/>
- </div>
- </TD>
- <TD class="failuredetails">
- <div class="details">
- <xsl:value-of select="FailedScene/@message"/>
- </div>
- </TD>
- </xsl:if>
-
- <xsl:if test="@result='timeout'">
- <TD class="timeout">
- <div style="text-align: center; margin-left:auto; margin-right:auto;">
- <xsl:value-of select="@result"/>
- </div>
- <TD class="failuredetails"></TD>
- </TD>
- </xsl:if>
-
- <xsl:if test="@result='notExecuted'">
- <TD class="notExecuted">
- <div style="text-align: center; margin-left:auto; margin-right:auto;">
- <xsl:value-of select="@result"/>
- </div>
- </TD>
- <TD class="failuredetails"></TD>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- </TR> <!-- finished with a row -->
- </xsl:if>
- </xsl:for-each> <!-- end test -->
- </xsl:for-each> <!-- end test case -->
- </TABLE>
- </xsl:if>
- </xsl:for-each> <!-- end test package -->
- </DIV>
- </xsl:template>
-
- <!-- Take a delimited string and insert line breaks after a some number of elements. -->
- <xsl:template name="formatDelimitedString">
- <xsl:param name="string" />
- <xsl:param name="numTokensPerRow" select="10" />
- <xsl:param name="tokenIndex" select="1" />
- <xsl:if test="$string">
- <!-- Requires the last element to also have a delimiter after it. -->
- <xsl:variable name="token" select="substring-before($string, ';')" />
- <xsl:value-of select="$token" />
- <xsl:text> </xsl:text>
-
- <xsl:if test="$tokenIndex mod $numTokensPerRow = 0">
- <br />
- </xsl:if>
-
- <xsl:call-template name="formatDelimitedString">
- <xsl:with-param name="string" select="substring-after($string, ';')" />
- <xsl:with-param name="numTokensPerRow" select="$numTokensPerRow" />
- <xsl:with-param name="tokenIndex" select="$tokenIndex + 1" />
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
-
-</xsl:stylesheet>
diff --git a/tools/tradefed-host/res/report/logo.gif b/tools/tradefed-host/res/report/logo.gif
deleted file mode 100644
index 61970b3..0000000
--- a/tools/tradefed-host/res/report/logo.gif
+++ /dev/null
Binary files differ
diff --git a/tools/tradefed-host/res/report/newrule-green.png b/tools/tradefed-host/res/report/newrule-green.png
deleted file mode 100644
index 10a4194..0000000
--- a/tools/tradefed-host/res/report/newrule-green.png
+++ /dev/null
Binary files differ
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java
deleted file mode 100644
index 1a9f04b..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.build;
-
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.build.IFolderBuildInfo;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-
-/**
- * Helper class for retrieving files from the CTS install.
- * <p/>
- * Encapsulates the filesystem layout of the CTS installation.
- */
-public class CtsBuildHelper {
-
- static final String CTS_DIR_NAME = "old-android-cts";
- private final String mSuiteName = "OLD-CTS";
- /** The root location of the extracted CTS package */
- private final File mRootDir;
- /** the {@link #CTS_DIR_NAME} directory */
- private final File mCtsDir;
-
- /**
- * Creates a {@link CtsBuildHelper}.
- *
- * @param rootDir the parent folder that contains the "android-cts" directory and all its
- * contents.
- */
- public CtsBuildHelper(File rootDir) {
- mRootDir = rootDir;
- mCtsDir = new File(mRootDir, CTS_DIR_NAME);
- }
-
- /**
- * Alternate {@link CtsBuildHelper} constructor that takes the {@link IFolderBuildInfo}
- * representation of a CTS build.
- *
- * @param build the {@link IFolderBuildInfo}
- * @throws FileNotFoundException
- */
- public CtsBuildHelper(IFolderBuildInfo build) throws FileNotFoundException {
- this(build.getRootDir());
- }
-
- /**
- * A helper factory method that creates and validates a {@link CtsBuildHelper} given an
- * {@link IBuildInfo}.
- *
- * @param build the {@link IBuildInfo}
- * @return the {@link CtsBuildHelper}
- * @throws IllegalArgumentException if provided <var>build</var> is not a valid CTS build
- */
- public static CtsBuildHelper createBuildHelper(IBuildInfo build) {
- if (!(build instanceof IFolderBuildInfo)) {
- throw new IllegalArgumentException(String.format(
- "Wrong build type. Expected %s, received %s", IFolderBuildInfo.class.getName(),
- build.getClass().getName()));
- }
- try {
- CtsBuildHelper ctsBuild = new CtsBuildHelper((IFolderBuildInfo)build);
- ctsBuild.validateStructure();
- return ctsBuild;
- } catch (FileNotFoundException e) {
- throw new IllegalArgumentException("Invalid CTS build provided.", e);
- }
- }
-
- public String getSuiteName() {
- return mSuiteName;
- }
-
- /**
- * @return a {@link File} representing the parent folder of the CTS installation
- */
- public File getRootDir() {
- return mRootDir;
- }
-
- /**
- * @return a {@link File} representing the "android-cts" folder of the CTS installation
- */
- public File getCtsDir() {
- return mCtsDir;
- }
-
- /**
- * @return a {@link File} representing the test application file with given name
- * @throws FileNotFoundException if file does not exist
- */
- public File getTestApp(String appFileName) throws FileNotFoundException {
- File apkFile = new File(getTestCasesDir(), appFileName);
- if (!apkFile.exists()) {
- throw new FileNotFoundException(String.format("CTS test app file %s does not exist",
- apkFile.getAbsolutePath()));
- }
- return apkFile;
- }
-
- private File getRepositoryDir() {
- return new File(getCtsDir(), "repository");
- }
-
- /**
- * @return a {@link File} representing the results directory.
- */
- public File getResultsDir() {
- return new File(getRepositoryDir(), "results");
- }
-
- /**
- * @return a {@link File} representing the directory to store result logs.
- */
- public File getLogsDir() {
- return new File(getRepositoryDir(), "logs");
- }
-
- /**
- * @return a {@link File} representing the test cases directory
- */
- public File getTestCasesDir() {
- return new File(getRepositoryDir(), "testcases");
- }
-
- /**
- * @return a {@link File} representing the test plan directory
- */
- public File getTestPlansDir() {
- return new File(getRepositoryDir(), "plans");
- }
-
- /**
- * @return a {@link File} representing the test plan with given name. note: no attempt will be
- * made to ensure the plan actually exists
- * @throws FileNotFoundException if plans directory does not exist
- */
- public File getTestPlanFile(String planName) throws FileNotFoundException {
- String ctsPlanRelativePath = String.format("%s.xml", planName);
- return new File(getTestPlansDir(), ctsPlanRelativePath);
- }
-
- /**
- * Check the validity of the CTS build file system structure.
- * @throws FileNotFoundException if any major directories are missing
- */
- public void validateStructure() throws FileNotFoundException {
- if (!getCtsDir().exists()) {
- throw new FileNotFoundException(String.format(
- "CTS install folder %s does not exist", getCtsDir().getAbsolutePath()));
- }
- if (!getTestCasesDir().exists()) {
- throw new FileNotFoundException(String.format(
- "CTS test cases folder %s does not exist",
- getTestCasesDir().getAbsolutePath()));
- }
- if (!getTestPlansDir().exists()) {
- throw new FileNotFoundException(String.format(
- "CTS test plans folder %s does not exist",
- getTestPlansDir().getAbsolutePath()));
- }
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
deleted file mode 100644
index 7cdbedb..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.build;
-
-import com.android.tradefed.build.BuildRetrievalError;
-import com.android.tradefed.build.DeviceBuildInfo;
-import com.android.tradefed.build.FolderBuildInfo;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.build.IBuildProvider;
-import com.android.tradefed.build.IDeviceBuildProvider;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-
-import java.io.File;
-import java.util.regex.Pattern;
-
-/**
- * A simple {@link IBuildProvider} that uses a pre-existing CTS install.
- */
-public class CtsBuildProvider implements IDeviceBuildProvider {
-
- private static final Pattern RELEASE_BUILD = Pattern.compile("^[A-Z]{3}\\d{2}[A-Z]{0,1}$");
-
- @Option(name="cts-install-path", description="the path to the cts installation to use")
- private String mCtsRootDirPath = System.getProperty("CTS_ROOT");
-
- @Option(name="use-device-build-info", description="Bootstrap build info from device")
- private boolean mUseDeviceBuildInfo = false;
-
- @Option(name="test-tag", description="test tag name to supply.")
- private String mTestTag = "cts";
-
- @Option(name="branch", description="build branch name to supply.")
- private String mBranch = null;
-
- public static final String CTS_BUILD_VERSION = "7.0_r0";
- public static final String CTS_PACKAGE = "com.android.cts.tradefed.testtype";
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IBuildInfo getBuild() {
- if (mCtsRootDirPath == null) {
- throw new IllegalArgumentException("Missing --cts-install-path");
- }
- IFolderBuildInfo ctsBuild = new FolderBuildInfo(
- Package.getPackage(CTS_PACKAGE).getImplementationVersion(),
- mTestTag, mTestTag);
- ctsBuild.setRootDir(new File(mCtsRootDirPath));
- if (mBranch != null) {
- ctsBuild.setBuildBranch(mBranch);
- }
- return ctsBuild;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IBuildInfo getBuild(ITestDevice device)
- throws BuildRetrievalError, DeviceNotAvailableException {
- if (!mUseDeviceBuildInfo) {
- // return a regular build info without extracting device attributes into standard
- // build info fields
- return getBuild();
- } else {
- String buildId = device.getBuildId();
- String buildFlavor = device.getBuildFlavor();
- IBuildInfo info = new DeviceBuildInfo(buildId, mTestTag, buildFlavor);
- if (mBranch == null) {
- // if branch is not specified via param, make a pseudo branch name based on platform
- // version and product info from device
- mBranch = String.format("%s-%s-%s-%s",
- device.getProperty("ro.product.brand"),
- device.getProperty("ro.product.name"),
- device.getProductVariant(),
- device.getProperty("ro.build.version.release"));
- }
- info.setBuildBranch(mBranch);
- info.setBuildFlavor(buildFlavor);
- String buildAlias = device.getBuildAlias();
- if (RELEASE_BUILD.matcher(buildAlias).matches()) {
- info.addBuildAttribute("build_alias", buildAlias);
- }
- return info;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void buildNotTested(IBuildInfo info) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void cleanUp(IBuildInfo info) {
- // ignore
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java b/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
deleted file mode 100644
index 3d59525..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.command;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.tradefed.build.CtsBuildProvider;
-import com.android.cts.tradefed.result.ITestResultRepo;
-import com.android.cts.tradefed.result.ITestSummary;
-import com.android.cts.tradefed.result.PlanCreator;
-import com.android.cts.tradefed.result.TestResultRepo;
-import com.android.cts.tradefed.testtype.ITestPackageRepo;
-import com.android.cts.tradefed.testtype.TestPackageRepo;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.command.Console;
-import com.android.tradefed.config.ArgsOptionParser;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.FileUtil;
-import com.android.tradefed.util.RegexTrie;
-import com.android.tradefed.util.TableFormatter;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Specialization of trade federation console that adds CTS commands to list plans and packages.
- */
-public class CtsConsole extends Console {
-
- protected static final String ADD_PATTERN = "a(?:dd)?";
-
- private IFolderBuildInfo mBuildInfo = null;
- private CtsBuildHelper mBuildHelper = null;
-
- CtsConsole() {
- super();
- }
-
- @Override
- public void run() {
- printLine(String.format("Android CTS %s build:%s",
- CtsBuildProvider.CTS_BUILD_VERSION, getCtsBuildInfo().getBuildId()));
- super.run();
- }
-
- /**
- * Adds the 'list packages' and 'list plans' commands
- */
- @Override
- protected void setCustomCommands(RegexTrie<Runnable> trie, List<String> genericHelp,
- Map<String, String> commandHelp) {
- trie.put(new Runnable() {
- @Override
- public void run() {
- CtsBuildHelper ctsBuild = getCtsBuildHelper();
- if (ctsBuild != null) {
- listPlans(ctsBuild);
- }
- }
- }, LIST_PATTERN, "p(?:lans)?");
- trie.put(new Runnable() {
- @Override
- public void run() {
- CtsBuildHelper ctsBuild = getCtsBuildHelper();
- if (ctsBuild != null) {
- listPackages(ctsBuild);
- }
- }
- }, LIST_PATTERN, "packages");
- trie.put(new Runnable() {
- @Override
- public void run() {
- CtsBuildHelper ctsBuild = getCtsBuildHelper();
- if (ctsBuild != null) {
- listResults(ctsBuild);
- }
- }
- }, LIST_PATTERN, "r(?:esults)?");
-
- // find existing help for 'LIST_PATTERN' commands, and append these commands help
- String listHelp = commandHelp.get(LIST_PATTERN);
- if (listHelp == null) {
- // no help? Unexpected, but soldier on
- listHelp = new String();
- }
- String combinedHelp = listHelp +
- "\tp[lans]\t\tList all CTS test plans" + LINE_SEPARATOR +
- "\tpackages\tList all CTS packages" + LINE_SEPARATOR +
- "\tr[esults]\tList all CTS results" + LINE_SEPARATOR;
- commandHelp.put(LIST_PATTERN, combinedHelp);
-
- ArgRunnable<CaptureList> addDerivedCommand = new ArgRunnable<CaptureList>() {
- @Override
- public void run(CaptureList args) {
- // Skip 2 tokens to get past addPattern and "derivedplan"
- String[] flatArgs = new String[args.size() - 2];
- for (int i = 2; i < args.size(); i++) {
- flatArgs[i - 2] = args.get(i).get(0);
- }
- CtsBuildHelper ctsBuild = getCtsBuildHelper();
- if (ctsBuild != null) {
- // FIXME may want to only add certain ABIs
- addDerivedPlan(ctsBuild, AbiUtils.getAbisSupportedByCompatibility(), flatArgs);
- }
- }
- };
- trie.put(addDerivedCommand, ADD_PATTERN, "d(?:erivedplan?)", null);
- commandHelp.put(ADD_PATTERN, String.format(
- "%s help:" + LINE_SEPARATOR +
- "\tderivedplan Add a derived plan" + LINE_SEPARATOR,
- ADD_PATTERN));
- }
-
- @Override
- protected String getConsolePrompt() {
- return "cts-tf > ";
- }
-
- @Override
- protected String getGenericHelpString(List<String> genericHelp) {
- StringBuilder helpBuilder = new StringBuilder();
- helpBuilder.append("CTS-tradefed host version ");
- helpBuilder.append(CtsBuildProvider.CTS_BUILD_VERSION);
- helpBuilder.append("\n\n");
- helpBuilder.append("CTS-tradefed is the test harness for running the Android ");
- helpBuilder.append("Compatibility Suite, built on top of the tradefed framework.\n\n");
- helpBuilder.append("Available commands and options\n");
- helpBuilder.append("Host:\n");
- helpBuilder.append(" help: show this message\n");
- helpBuilder.append(" help all: show the complete tradefed help\n");
- helpBuilder.append(" exit: gracefully exit the cts console, waiting till all ");
- helpBuilder.append("invocations are complete\n");
- helpBuilder.append("Run:\n");
- helpBuilder.append(" run cts --plan test_plan_name: run a test plan\n");
- helpBuilder.append(" run cts --package/-p : run a CTS test package\n");
- helpBuilder.append(" run cts --class/-c [--method/-m] : run a specific test class and/or");
- helpBuilder.append("method\n");
- helpBuilder.append(" run cts --continue-session session_ID: run all not executed ");
- helpBuilder.append("tests from a previous CTS session\n");
- helpBuilder.append(" run cts [options] --serial/-s device_ID: run CTS on specified ");
- helpBuilder.append("device\n");
- helpBuilder.append(" run cts [options] --shards number_of_shards: shard a CTS run into ");
- helpBuilder.append("given number of independent chunks, to run on multiple devices in");
- helpBuilder.append("parallel\n");
- helpBuilder.append(" run cts --help/--help-all: get more help on running CTS\n");
- helpBuilder.append("List:\n");
- helpBuilder.append(" l/list d/devices: list connected devices and their state\n");
- helpBuilder.append(" l/list packages: list CTS test packages\n");
- helpBuilder.append(" l/list p/plans: list CTS test plans\n");
- helpBuilder.append(" l/list i/invocations: list invocations aka CTS test runs currently");
- helpBuilder.append("in progress\n");
- helpBuilder.append(" l/list c/commands: list commands: aka CTS test run commands ");
- helpBuilder.append("currently in the queue waiting to be allocated devices\n");
- helpBuilder.append(" l/list r/results: list CTS results currently present in the ");
- helpBuilder.append("repository\n");
- helpBuilder.append("Add:\n");
- helpBuilder.append(" add derivedplan --plan plane_name --session/-s session_id -r ");
- helpBuilder.append("[pass/fail/notExecuted/timeout]: derive a plan from the given ");
- helpBuilder.append("session\n");
- helpBuilder.append("Dump:\n");
- helpBuilder.append(" d/dump l/logs: dump the tradefed logs for all running invocations\n");
- helpBuilder.append("Options:\n");
- helpBuilder.append(" --disable-reboot : Do not reboot device after running some amount of tests.\n");
- return helpBuilder.toString();
- }
-
- private void listPlans(CtsBuildHelper ctsBuild) {
- FilenameFilter xmlFilter = new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".xml");
- }
- };
- for (File planFile : ctsBuild.getTestPlansDir().listFiles(xmlFilter)) {
- printLine(FileUtil.getBaseName(planFile.getName()));
- }
- }
-
- private void listPackages(CtsBuildHelper ctsBuild) {
- ITestPackageRepo testCaseRepo = new TestPackageRepo(ctsBuild.getTestCasesDir(), false);
- for (String packageName : testCaseRepo.getPackageNames()) {
- printLine(packageName);
- }
- }
-
- private void listResults(CtsBuildHelper ctsBuild) {
- TableFormatter tableFormatter = new TableFormatter();
- List<List<String>> table = new ArrayList<List<String>>();
- table.add(Arrays.asList("Session","Pass", "Fail","Not Executed","Start time","Plan name",
- "Device serial(s)"));
- ITestResultRepo testResultRepo = new TestResultRepo(ctsBuild.getResultsDir());
- for (ITestSummary result : testResultRepo.getSummaries()) {
- table.add(Arrays.asList(Integer.toString(result.getId()),
- Integer.toString(result.getNumPassed()),
- Integer.toString(result.getNumFailed()),
- Integer.toString(result.getNumIncomplete()),
- result.getTimestamp(),
- result.getTestPlan(),
- result.getDeviceSerials()));
- }
- tableFormatter.displayTable(table, new PrintWriter(System.out, true));
- }
-
- private void addDerivedPlan(CtsBuildHelper ctsBuild, Set<String> abis, String[] flatArgs) {
- PlanCreator creator = new PlanCreator();
- try {
- ArgsOptionParser optionParser = new ArgsOptionParser(creator);
- optionParser.parse(Arrays.asList(flatArgs));
- creator.createAndSerializeDerivedPlan(ctsBuild, abis);
- } catch (ConfigurationException e) {
- printLine("Error: " + e.getMessage());
- printLine(ArgsOptionParser.getOptionHelp(false, creator));
- }
- }
-
- private IFolderBuildInfo getCtsBuildInfo() {
- if (mBuildInfo == null) {
- try {
- mBuildInfo = (IFolderBuildInfo) new CtsBuildProvider().getBuild();
- } catch (IllegalArgumentException e) {
- printLine("Could not find CTS install location: CTS_ROOT env variable not set");
- }
- }
- return mBuildInfo;
- }
-
- private CtsBuildHelper getCtsBuildHelper() {
- if (mBuildHelper == null) {
- try {
- mBuildHelper = new CtsBuildHelper(getCtsBuildInfo());
- mBuildHelper.validateStructure();
- } catch (FileNotFoundException e) {
- printLine(String.format("Invalid cts install: %s", e.getMessage()));
- mBuildHelper = null;
- }
- }
- return mBuildHelper;
- }
-
- public static void main(String[] args) throws InterruptedException, ConfigurationException {
- Console console = new CtsConsole();
- Console.startConsole(console, args);
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java b/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java
deleted file mode 100644
index bdcb029..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.device;
-
-import com.android.cts.tradefed.result.CtsXmlResultReporter;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.InstrumentationTest;
-import com.android.tradefed.util.AbiUtils;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Collects info from device under test.
- * <p/>
- * This class simply serves as a conduit for grabbing info from device using the device info
- * collector apk, and forwarding that data directly to the {@link ITestInvocationListener} as run
- * metrics.
- */
-public class DeviceInfoCollector {
-
- private static final String LOG_TAG = "DeviceInfoCollector";
- private static final String APK_NAME = "TestDeviceSetup";
- public static final String APP_PACKAGE_NAME = "android.tests.devicesetup";
- private static final String INSTRUMENTATION_NAME = "android.tests.getinfo.DeviceInfoInstrument";
-
- private static final String EXTENDED_APK_NAME = "CtsDeviceInfo";
- public static final String EXTENDED_APP_PACKAGE_NAME =
- "com.android.compatibility.common.deviceinfo";
- private static final String EXTENDED_INSTRUMENTATION_NAME =
- "android.support.test.runner.AndroidJUnitRunner";
- private static final String DEVICE_INFO_FILES = "device-info-files";
-
- public static final Set<String> IDS = new HashSet<String>();
- public static final Set<String> EXTENDED_IDS = new HashSet<String>();
-
- static {
- for (String abi : AbiUtils.getAbisSupportedByCompatibility()) {
- IDS.add(AbiUtils.createId(abi, APP_PACKAGE_NAME));
- EXTENDED_IDS.add(AbiUtils.createId(abi, EXTENDED_APP_PACKAGE_NAME));
- }
- }
-
- /**
- * Installs and runs the device info collector instrumentation, and forwards results
- * to the listener.
- *
- * @param device
- * @param listener
- * @throws DeviceNotAvailableException
- */
- public static void collectDeviceInfo(ITestDevice device, String abi, File testApkDir,
- ITestInvocationListener listener) throws DeviceNotAvailableException {
- runInstrumentation(device, abi, testApkDir, listener, APK_NAME, APP_PACKAGE_NAME,
- INSTRUMENTATION_NAME);
- }
-
- /**
- * Installs and runs the extended device info collector instrumentation, and forwards results
- * to the listener.
- *
- * @param device
- * @param listener
- * @throws DeviceNotAvailableException
- */
- public static void collectExtendedDeviceInfo(ITestDevice device, String abi, File testApkDir,
- ITestInvocationListener listener, IBuildInfo buildInfo)
- throws DeviceNotAvailableException {
- // Clear files in device test result directory
- String deviceResultDir = getDeviceResultDir(device);
- device.executeShellCommand(String.format("rm -rf %s", deviceResultDir));
- runInstrumentation(device, abi, testApkDir, listener, EXTENDED_APK_NAME,
- EXTENDED_APP_PACKAGE_NAME, EXTENDED_INSTRUMENTATION_NAME);
- // Copy files in remote result directory to local directory
- pullExtendedDeviceInfoResults(device, buildInfo);
- }
-
- private static void runInstrumentation(ITestDevice device, String abi, File testApkDir,
- ITestInvocationListener listener, String apkName, String packageName,
- String instrumentName) throws DeviceNotAvailableException {
- File apkFile = new File(testApkDir, String.format("%s.apk", apkName));
- if (!apkFile.exists()) {
- Log.e(LOG_TAG, String.format("Could not find %s", apkFile.getAbsolutePath()));
- return;
- }
- // collect the instrumentation bundle results using instrumentation test
- // should work even though no tests will actually be run
- InstrumentationTest instrTest = new InstrumentationTest();
- instrTest.setDevice(device);
- instrTest.setInstallFile(apkFile);
- // no need to collect tests and re-run
- instrTest.setRerunMode(false);
- instrTest.setPackageName(packageName);
- instrTest.setRunName(AbiUtils.createId(abi, packageName));
- instrTest.setRunnerName(instrumentName);
- instrTest.run(listener);
- }
-
- private static void pullExtendedDeviceInfoResults(ITestDevice device, IBuildInfo buildInfo)
- throws DeviceNotAvailableException {
- if (!(buildInfo instanceof IFolderBuildInfo)) {
- Log.e(LOG_TAG, "Invalid instance of buildInfo");
- return;
- }
- File localResultDir = new File(buildInfo.getBuildAttributes().get(
- CtsXmlResultReporter.CTS_RESULT_DIR));
- if (localResultDir == null || !localResultDir.isDirectory()) {
- Log.e(LOG_TAG, "Local result directory is null or is not a directory");
- return;
- }
-
- localResultDir = new File(localResultDir, DEVICE_INFO_FILES);
- localResultDir.mkdirs();
-
-
- String deviceResultDir = getDeviceResultDir(device);
-
- // Pull files from device result directory to local result directory
- String command = String.format("adb -s %s pull %s %s", device.getSerialNumber(),
- deviceResultDir, localResultDir.getAbsolutePath());
- if (!execute(command)) {
- Log.e(LOG_TAG, String.format("Failed to run %s", command));
- }
- }
-
- private static boolean execute(String command) {
- try {
- Process p = Runtime.getRuntime().exec(new String[] {"/bin/bash", "-c", command});
- return (p.waitFor() == 0);
- } catch (Exception e) {
- Log.e(LOG_TAG, e);
- return false;
- }
- }
-
- private static String getDeviceResultDir(ITestDevice device) {
- String externalStorePath = device.getMountPoint(IDevice.MNT_EXTERNAL_STORAGE);
- if (externalStorePath == null) {
- Log.e(LOG_TAG, String.format(
- "Failed to get external storage path on device %s", device.getSerialNumber()));
- return null;
- }
- return String.format("%s/%s", externalStorePath, DEVICE_INFO_FILES);
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/AbstractXmlPullParser.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/AbstractXmlPullParser.java
deleted file mode 100644
index c5f1e2d..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/AbstractXmlPullParser.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.result;
-
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-
-import java.io.IOException;
-import java.io.Reader;
-
-/**
- * Helper abstract class for XmlPullParser
- *
- * TODO: move to com.android.tradefed.util.xml
- */
-public abstract class AbstractXmlPullParser {
-
- /**
- * Parse the summary data from the given input data.
- *
- * @param xmlReader the input XML
- * @throws ParseException if failed to parse the summary data.
- */
- public void parse(Reader xmlReader) throws ParseException {
- try {
- XmlPullParserFactory fact = org.xmlpull.v1.XmlPullParserFactory.newInstance();
- XmlPullParser parser = fact.newPullParser();
- parser.setInput (xmlReader);
- parse(parser);
- } catch (XmlPullParserException e) {
- throw new ParseException(e);
- } catch (IOException e) {
- throw new ParseException(e);
- }
- }
-
- abstract void parse(XmlPullParser parser) throws XmlPullParserException, IOException;
-
- /**
- * Parse an integer value from an XML attribute
- *
- * @param parser the {@link XmlPullParser}
- * @param name the attribute name
- * @return the parsed value or 0 if it could not be parsed
- */
- protected int parseIntAttr(XmlPullParser parser, String name) {
- try {
- String value = parser.getAttributeValue(null, name);
- if (value != null) {
- return Integer.parseInt(value);
- }
- } catch (NumberFormatException e) {
- // ignore
- }
- return 0;
- }
-
- /**
- * Parse a boolean attribute value
- */
- protected boolean parseBooleanAttr(XmlPullParser parser, String name) {
- String stringValue = parser.getAttributeValue(null, name);
- return stringValue != null &&
- Boolean.parseBoolean(stringValue);
- }
-
- /**
- * Helper method for retrieving attribute value with given name
- *
- * @param parser the XmlPullParser
- * @param name the attribute name
- * @return the attribute value
- */
- protected String getAttribute(XmlPullParser parser, String name) {
- return parser.getAttributeValue(null, name);
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestLogReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestLogReporter.java
deleted file mode 100644
index e13c806..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestLogReporter.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.result;
-
-import com.android.cts.tradefed.device.DeviceInfoCollector;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.OptionCopier;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.IShardableListener;
-import com.android.tradefed.result.StubTestInvocationListener;
-import com.android.tradefed.util.AbiUtils;
-
-import java.util.Map;
-
-/**
- * Dumps tests in progress to stdout
- */
-public class CtsTestLogReporter extends StubTestInvocationListener implements IShardableListener {
-
- private static final String DEVICE_INFO_ERROR = "DEVICE_INFO_ERROR_";
-
- @Option(name = "quiet-output", description = "Mute display of test results.")
- private boolean mQuietOutput = false;
-
- protected IBuildInfo mBuildInfo;
- private String mDeviceSerial;
- private TestResults mResults = new TestResults();
- private TestPackageResult mCurrentPkgResult = null;
- private boolean mIsDeviceInfoRun = false;
- private boolean mIsExtendedDeviceInfoRun = false;
-
- @Override
- public void invocationStarted(IBuildInfo buildInfo) {
- mDeviceSerial = buildInfo.getDeviceSerial() == null ? "unknown_device" : buildInfo.getDeviceSerial();
- }
-
- /**
- * Reports the start of a test run.
- *
- * @param id the unique identifier of this test run, generated by
- * {@link AbiUtils#createId(String, String)}.
- * @param numTests total number of tests in test run
- */
- @Override
- public void testRunStarted(String id, int numTests) {
- if (mCurrentPkgResult != null && !id.equals(mCurrentPkgResult.getId())) {
- // display results from previous run
- logCompleteRun(mCurrentPkgResult);
- }
- mIsDeviceInfoRun = DeviceInfoCollector.IDS.contains(id);
- mIsExtendedDeviceInfoRun = DeviceInfoCollector.EXTENDED_IDS.contains(id);
- if (mIsDeviceInfoRun) {
- logResult("Collecting device info");
- } else if (mIsExtendedDeviceInfoRun) {
- logResult("Collecting extended device info");
- } else {
- if (mCurrentPkgResult == null || !id.equals(mCurrentPkgResult.getId())) {
- logResult("-----------------------------------------");
- logResult("Test package %s started", id);
- logResult("-----------------------------------------");
- }
- mCurrentPkgResult = mResults.getOrCreatePackage(id);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testStarted(TestIdentifier test) {
- if (mIsExtendedDeviceInfoRun) {
- return;
- }
- mCurrentPkgResult.insertTest(test);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testFailed(TestIdentifier test, String trace) {
- if (mIsExtendedDeviceInfoRun) {
- return;
- }
- mCurrentPkgResult.reportTestFailure(test, CtsTestStatus.FAIL, trace);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testAssumptionFailure(TestIdentifier test, String trace) {
- if (mIsExtendedDeviceInfoRun) {
- return;
- }
- // TODO: do something different here?
- mCurrentPkgResult.reportTestFailure(test, CtsTestStatus.FAIL, trace);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
- if (mIsExtendedDeviceInfoRun) {
- for (Map.Entry<String, String> metricsEntry : testMetrics.entrySet()) {
- String key = metricsEntry.getKey();
- String value = metricsEntry.getValue();
- if (key.startsWith(DEVICE_INFO_ERROR)) {
- throw new RuntimeException(String.format(
- "Error collecting extended device info: %s=%s", key, value));
- }
- }
- return;
- }
- mCurrentPkgResult.reportTestEnded(test, testMetrics);
- Test result = mCurrentPkgResult.findTest(test);
- String stack = result.getStackTrace() == null ? "" : "\n" + result.getStackTrace();
- logResult("%s#%s %s %s", test.getClassName(), test.getTestName(), result.getResult(),
- stack);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void invocationEnded(long elapsedTime) {
- if (mIsExtendedDeviceInfoRun) {
- return;
- }
- // display the results of the last completed run
- if (mCurrentPkgResult != null) {
- logCompleteRun(mCurrentPkgResult);
- }
- }
-
- private void logResult(String format, Object... args) {
- if (mQuietOutput) {
- CLog.i(format, args);
- } else {
- Log.logAndDisplay(LogLevel.INFO, mDeviceSerial, String.format(format, args));
- }
- }
-
- private void logCompleteRun(TestPackageResult pkgResult) {
- String appPackageName = pkgResult.getAppPackageName();
- if (appPackageName.equals(DeviceInfoCollector.APP_PACKAGE_NAME)) {
- logResult("Device info collection complete");
- return;
- } else if (appPackageName.equals(DeviceInfoCollector.EXTENDED_APP_PACKAGE_NAME)) {
- logResult("Extended device info collection complete");
- return;
- }
- logResult("%s package complete: Passed %d, Failed %d, Not Executed %d",
- pkgResult.getId(), pkgResult.countTests(CtsTestStatus.PASS),
- pkgResult.countTests(CtsTestStatus.FAIL),
- pkgResult.countTests(CtsTestStatus.NOT_EXECUTED));
- }
-
- @Override
- public IShardableListener clone() {
- CtsTestLogReporter clone = new CtsTestLogReporter();
- OptionCopier.copyOptionsNoThrow(this, clone);
- return clone;
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestStatus.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestStatus.java
deleted file mode 100644
index 76c3770..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestStatus.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-/**
- * An enum of possible test statuses.
- */
-public enum CtsTestStatus {
- PASS("pass"),
- FAIL("fail"),
- NOT_EXECUTED("notExecuted");
-
- private String mValue;
-
- CtsTestStatus(String storedValue) {
- mValue = storedValue;
- }
-
- /**
- * Get the String representation of this test status that should be stored in
- * xml
- * @return
- */
- String getValue() {
- return mValue;
- }
-
- /**
- * Find the {@link CtsTestStatus} corresponding to given string value
- * <p/>
- * Performs a case insensitive search
- *
- * @param value
- * @return the CtsTestStatus or <code>null</code> if it could not be found
- */
- static CtsTestStatus getStatus(String value) {
- for (CtsTestStatus status : CtsTestStatus.values()) {
- if (value.compareToIgnoreCase(status.getValue()) == 0) {
- return status;
- }
- }
- return null;
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
deleted file mode 100644
index 07caaef..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
+++ /dev/null
@@ -1,550 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.result;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.tradefed.device.DeviceInfoCollector;
-import com.android.cts.tradefed.testtype.CtsTest;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ILogSaver;
-import com.android.tradefed.result.ILogSaverListener;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.ITestSummaryListener;
-import com.android.tradefed.result.InputStreamSource;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.LogFile;
-import com.android.tradefed.result.LogFileSaver;
-import com.android.tradefed.result.TestSummary;
-import com.android.tradefed.util.FileUtil;
-import com.android.tradefed.util.StreamUtil;
-
-import org.kxml2.io.KXmlSerializer;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Writes results to an XML files in the CTS format.
- * <p/>
- * Collects all test info in memory, then dumps to file when invocation is complete.
- * <p/>
- * Outputs xml in format governed by the cts_result.xsd
- */
-public class CtsXmlResultReporter
- implements ITestInvocationListener, ITestSummaryListener, ILogSaverListener {
-
- private static final String LOG_TAG = "CtsXmlResultReporter";
- private static final String DEVICE_INFO = "DEVICE_INFO_";
- private static final String DEVICE_INFO_EXT = ".deviceinfo.json";
-
- public static final String CTS_RESULT_DIR = "cts-result-dir";
- static final String TEST_RESULT_FILE_NAME = "testResult.xml";
- static final String CTS_RESULT_FILE_VERSION = "4.4";
- private static final String[] CTS_RESULT_RESOURCES = {"cts_result.xsl", "cts_result.css",
- "logo.gif", "newrule-green.png"};
-
- /** the XML namespace */
- static final String ns = null;
-
- static final String RESULT_TAG = "TestResult";
- static final String PLAN_ATTR = "testPlan";
- static final String STARTTIME_ATTR = "starttime";
-
- @Option(name = "quiet-output", description = "Mute display of test results.")
- private boolean mQuietOutput = false;
-
- private static final String REPORT_DIR_NAME = "output-file-path";
- @Option(name=REPORT_DIR_NAME, description="root file system path to directory to store xml " +
- "test results and associated logs. If not specified, results will be stored at " +
- "<cts root>/repository/results")
- protected File mReportDir = null;
-
- // listen in on the plan option provided to CtsTest
- @Option(name = CtsTest.PLAN_OPTION, description = "the test plan to run.")
- private String mPlanName = "NA";
-
- // listen in on the continue-session option provided to CtsTest
- @Option(name = CtsTest.CONTINUE_OPTION, description = "the test result session to continue.")
- private Integer mContinueSessionId = null;
-
- @Option(name = "result-server", description = "Server to publish test results.")
- private String mResultServer;
-
- @Option(name = "include-test-log-tags", description = "Include test log tags in XML report.")
- private boolean mIncludeTestLogTags = false;
-
- @Option(name = "use-log-saver", description = "Also saves generated result XML with log saver")
- private boolean mUseLogSaver = false;
-
- protected IBuildInfo mBuildInfo;
- private String mStartTime;
- private String mDeviceSerial;
- private TestResults mResults = new TestResults();
- private TestPackageResult mCurrentPkgResult = null;
- private Test mCurrentTest = null;
- private boolean mIsDeviceInfoRun = false;
- private boolean mIsExtendedDeviceInfoRun = false;
- private ResultReporter mReporter;
- private File mLogDir;
- private String mSuiteName;
- private String mReferenceUrl;
- private ILogSaver mLogSaver;
-
- public void setReportDir(File reportDir) {
- mReportDir = reportDir;
- }
-
- /** Set whether to include TestLog tags in the XML reports. */
- public void setIncludeTestLogTags(boolean include) {
- mIncludeTestLogTags = include;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void invocationStarted(IBuildInfo buildInfo) {
- mBuildInfo = buildInfo;
- if (!(buildInfo instanceof IFolderBuildInfo)) {
- throw new IllegalArgumentException("build info is not a IFolderBuildInfo");
- }
- IFolderBuildInfo ctsBuild = (IFolderBuildInfo)buildInfo;
- CtsBuildHelper ctsBuildHelper = getBuildHelper(ctsBuild);
- mDeviceSerial = buildInfo.getDeviceSerial() == null ? "unknown_device" :
- buildInfo.getDeviceSerial();
- if (mContinueSessionId != null) {
- CLog.d("Continuing session %d", mContinueSessionId);
- // reuse existing directory
- TestResultRepo resultRepo = new TestResultRepo(ctsBuildHelper.getResultsDir());
- mResults = resultRepo.getResult(mContinueSessionId);
- if (mResults == null) {
- throw new IllegalArgumentException(String.format("Could not find session %d",
- mContinueSessionId));
- }
- mPlanName = resultRepo.getSummaries().get(mContinueSessionId).getTestPlan();
- mStartTime = resultRepo.getSummaries().get(mContinueSessionId).getStartTime();
- mReportDir = resultRepo.getReportDir(mContinueSessionId);
- } else {
- if (mReportDir == null) {
- mReportDir = ctsBuildHelper.getResultsDir();
- }
- mReportDir = createUniqueReportDir(mReportDir);
-
- mStartTime = getTimestamp();
- logResult("Created result dir %s", mReportDir.getName());
- }
- mSuiteName = ctsBuildHelper.getSuiteName();
- mReporter = new ResultReporter(mResultServer, mSuiteName);
-
- ctsBuild.addBuildAttribute(CTS_RESULT_DIR, mReportDir.getAbsolutePath());
-
- // TODO: allow customization of log dir
- // create a unique directory for saving logs, with same name as result dir
- File rootLogDir = getBuildHelper(ctsBuild).getLogsDir();
- mLogDir = new File(rootLogDir, mReportDir.getName());
- mLogDir.mkdirs();
- }
-
- /**
- * Create a unique directory for saving results.
- * <p/>
- * Currently using legacy CTS host convention of timestamp directory names. In case of
- * collisions, will use {@link FileUtil} to generate unique file name.
- * <p/>
- * TODO: in future, consider using LogFileSaver to create build-specific directories
- *
- * @param parentDir the parent folder to create dir in
- * @return the created directory
- */
- private static synchronized File createUniqueReportDir(File parentDir) {
- // TODO: in future, consider using LogFileSaver to create build-specific directories
-
- File reportDir = new File(parentDir, TimeUtil.getResultTimestamp());
- if (reportDir.exists()) {
- // directory with this timestamp exists already! Choose a unique, although uglier, name
- try {
- reportDir = FileUtil.createTempDir(TimeUtil.getResultTimestamp() + "_", parentDir);
- } catch (IOException e) {
- CLog.e(e);
- CLog.e("Failed to create result directory %s", reportDir.getAbsolutePath());
- }
- } else {
- if (!reportDir.mkdirs()) {
- // TODO: consider throwing an exception
- CLog.e("mkdirs failed when attempting to create result directory %s",
- reportDir.getAbsolutePath());
- }
- }
- return reportDir;
- }
-
- /**
- * Helper method to retrieve the {@link CtsBuildHelper}.
- * @param ctsBuild
- */
- CtsBuildHelper getBuildHelper(IFolderBuildInfo ctsBuild) {
- CtsBuildHelper buildHelper = new CtsBuildHelper(ctsBuild.getRootDir());
- try {
- buildHelper.validateStructure();
- } catch (FileNotFoundException e) {
- // just log an error - it might be expected if we failed to retrieve a build
- CLog.e("Invalid CTS build %s", ctsBuild.getRootDir());
- }
- return buildHelper;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testLog(String dataName, LogDataType dataType, InputStreamSource dataStream) {
- try {
- File logFile = getLogFileSaver().saveAndZipLogData(dataName, dataType,
- dataStream.createInputStream());
- logResult(String.format("Saved log %s", logFile.getName()));
- } catch (IOException e) {
- CLog.e("Failed to write log for %s", dataName);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream,
- LogFile logFile) {
- CLog.i("Got log for %s %s %s", dataName, dataType, logFile.getUrl());
- if (mIncludeTestLogTags && mCurrentTest != null) {
- TestLog log = TestLog.fromDataName(dataName, logFile.getUrl());
- if (log != null) {
- mCurrentTest.addTestLog(log);
- }
- }
- }
-
- /**
- * Return the {@link LogFileSaver} to use.
- * <p/>
- * Exposed for unit testing.
- */
- LogFileSaver getLogFileSaver() {
- return new LogFileSaver(mLogDir);
- }
-
- @Override
- public void setLogSaver(ILogSaver logSaver) {
- mLogSaver = logSaver;
- }
-
- @Override
- public void testRunStarted(String id, int numTests) {
- mIsDeviceInfoRun = DeviceInfoCollector.IDS.contains(id);
- mIsExtendedDeviceInfoRun = DeviceInfoCollector.EXTENDED_IDS.contains(id);
- if (!mIsDeviceInfoRun && !mIsExtendedDeviceInfoRun) {
- mCurrentPkgResult = mResults.getOrCreatePackage(id);
- mCurrentPkgResult.setDeviceSerial(mDeviceSerial);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testStarted(TestIdentifier test) {
- if (!mIsDeviceInfoRun && !mIsExtendedDeviceInfoRun) {
- mCurrentTest = mCurrentPkgResult.insertTest(test);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testFailed(TestIdentifier test, String trace) {
- if (!mIsDeviceInfoRun && !mIsExtendedDeviceInfoRun) {
- mCurrentPkgResult.reportTestFailure(test, CtsTestStatus.FAIL, trace);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testAssumptionFailure(TestIdentifier test, String trace) {
- // TODO: do something different here?
- if (!mIsDeviceInfoRun && !mIsExtendedDeviceInfoRun) {
- mCurrentPkgResult.reportTestFailure(test, CtsTestStatus.FAIL, trace);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testIgnored(TestIdentifier test) {
- // TODO: ??
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
- if (!mIsDeviceInfoRun && !mIsExtendedDeviceInfoRun) {
- mCurrentPkgResult.reportTestEnded(test, testMetrics);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunEnded(long elapsedTime, Map<String, String> runMetrics) {
- if (mIsDeviceInfoRun) {
- mResults.populateDeviceInfoMetrics(runMetrics);
- } else if (mIsExtendedDeviceInfoRun) {
- checkExtendedDeviceInfoMetrics(runMetrics);
- } else {
- mCurrentPkgResult.populateMetrics(runMetrics);
- }
- }
-
- private void checkExtendedDeviceInfoMetrics(Map<String, String> runMetrics) {
- for (Map.Entry<String, String> metricEntry : runMetrics.entrySet()) {
- String key = metricEntry.getKey();
- String value = metricEntry.getValue();
- if (!key.startsWith(DEVICE_INFO) && !value.endsWith(DEVICE_INFO_EXT)) {
- CLog.e(String.format("%s failed: %s", key, value));
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void invocationEnded(long elapsedTime) {
- if (mReportDir == null || mStartTime == null) {
- // invocationStarted must have failed, abort
- CLog.w("Unable to create XML report");
- return;
- }
-
- File reportFile = getResultFile(mReportDir);
- createXmlResult(reportFile, mStartTime, elapsedTime);
- if (mUseLogSaver) {
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(reportFile);
- mLogSaver.saveLogData("cts-result", LogDataType.XML, fis);
- } catch (IOException ioe) {
- CLog.e("error saving XML with log saver");
- CLog.e(ioe);
- } finally {
- StreamUtil.close(fis);
- }
- }
- copyFormattingFiles(mReportDir);
- zipResults(mReportDir);
-
- try {
- mReporter.reportResult(reportFile, mReferenceUrl);
- } catch (IOException e) {
- CLog.e(e);
- }
- }
-
- private void logResult(String format, Object... args) {
- if (mQuietOutput) {
- CLog.i(format, args);
- } else {
- Log.logAndDisplay(LogLevel.INFO, mDeviceSerial, String.format(format, args));
- }
- }
-
- /**
- * Creates a report file and populates it with the report data from the completed tests.
- */
- private void createXmlResult(File reportFile, String startTimestamp, long elapsedTime) {
- String endTime = getTimestamp();
- OutputStream stream = null;
- try {
- stream = createOutputResultStream(reportFile);
- KXmlSerializer serializer = new KXmlSerializer();
- serializer.setOutput(stream, "UTF-8");
- serializer.startDocument("UTF-8", false);
- serializer.setFeature(
- "http://xmlpull.org/v1/doc/features.html#indent-output", true);
- serializer.processingInstruction("xml-stylesheet type=\"text/xsl\" " +
- "href=\"cts_result.xsl\"");
- serializeResultsDoc(serializer, startTimestamp, endTime);
- serializer.endDocument();
- String msg = String.format("XML test result file generated at %s. Passed %d, " +
- "Failed %d, Not Executed %d", mReportDir.getName(),
- mResults.countTests(CtsTestStatus.PASS),
- mResults.countTests(CtsTestStatus.FAIL),
- mResults.countTests(CtsTestStatus.NOT_EXECUTED));
- logResult(msg);
- logResult("Time: %s", TimeUtil.formatElapsedTime(elapsedTime));
- } catch (IOException e) {
- Log.e(LOG_TAG, "Failed to generate report data");
- } finally {
- StreamUtil.close(stream);
- }
- }
-
- /**
- * Output the results XML.
- *
- * @param serializer the {@link KXmlSerializer} to use
- * @param startTime the user-friendly starting time of the test invocation
- * @param endTime the user-friendly ending time of the test invocation
- * @throws IOException
- */
- private void serializeResultsDoc(KXmlSerializer serializer, String startTime, String endTime)
- throws IOException {
- serializer.startTag(ns, RESULT_TAG);
- serializer.attribute(ns, PLAN_ATTR, mPlanName);
- serializer.attribute(ns, STARTTIME_ATTR, startTime);
- serializer.attribute(ns, "endtime", endTime);
- serializer.attribute(ns, "version", CTS_RESULT_FILE_VERSION);
- serializer.attribute(ns, "suite", mSuiteName);
- if (mReferenceUrl != null) {
- serializer.attribute(ns, "referenceUrl", mReferenceUrl);
- }
- mResults.serialize(serializer, mBuildInfo.getBuildId());
- // TODO: not sure why, but the serializer doesn't like this statement
- //serializer.endTag(ns, RESULT_TAG);
- }
-
- private File getResultFile(File reportDir) {
- return new File(reportDir, TEST_RESULT_FILE_NAME);
- }
-
- /**
- * Creates the output stream to use for test results. Exposed for mocking.
- */
- OutputStream createOutputResultStream(File reportFile) throws IOException {
- logResult("Created xml report file at file://%s", reportFile.getAbsolutePath());
- return new FileOutputStream(reportFile);
- }
-
- /**
- * Copy the xml formatting files stored in this jar to the results directory
- *
- * @param resultsDir
- */
- private void copyFormattingFiles(File resultsDir) {
- for (String resultFileName : CTS_RESULT_RESOURCES) {
- InputStream configStream = getClass().getResourceAsStream(String.format("/report/%s",
- resultFileName));
- if (configStream != null) {
- File resultFile = new File(resultsDir, resultFileName);
- try {
- FileUtil.writeToFile(configStream, resultFile);
- } catch (IOException e) {
- Log.w(LOG_TAG, String.format("Failed to write %s to file", resultFileName));
- }
- } else {
- Log.w(LOG_TAG, String.format("Failed to load %s from jar", resultFileName));
- }
- }
- }
-
- /**
- * Zip the contents of the given results directory.
- *
- * @param resultsDir
- */
- private void zipResults(File resultsDir) {
- try {
- // create a file in parent directory, with same name as resultsDir
- File zipResultFile = new File(resultsDir.getParent(), String.format("%s.zip",
- resultsDir.getName()));
- FileUtil.createZip(resultsDir, zipResultFile);
- } catch (IOException e) {
- Log.w(LOG_TAG, String.format("Failed to create zip for %s", resultsDir.getName()));
- }
- }
-
- /**
- * Get a String version of the current time.
- * <p/>
- * Exposed so unit tests can mock.
- */
- String getTimestamp() {
- return TimeUtil.getTimestamp();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunFailed(String errorMessage) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunStopped(long elapsedTime) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void invocationFailed(Throwable cause) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TestSummary getSummary() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void putSummary(List<TestSummary> summaries) {
- // By convention, only store the first summary that we see as the summary URL.
- if (summaries.isEmpty()) {
- return;
- }
-
- mReferenceUrl = summaries.get(0).getSummary().getString();
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/DeviceInfoResult.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/DeviceInfoResult.java
deleted file mode 100644
index fb253e6..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/DeviceInfoResult.java
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import android.tests.getinfo.DeviceInfoConstants;
-
-import com.android.tradefed.log.LogUtil.CLog;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Data structure for the device info collected by CTS.
- * <p/>
- * Provides methods to serialize and deserialize from XML, as well as checks for consistency
- * when multiple devices are used to generate the report.
- */
-class DeviceInfoResult extends AbstractXmlPullParser {
- static final String TAG = "DeviceInfo";
- private static final String ns = CtsXmlResultReporter.ns;
- static final String BUILD_TAG = "BuildInfo";
- private static final String PHONE_TAG = "PhoneSubInfo";
- private static final String SCREEN_TAG = "Screen";
- private static final String MEMORY_TAG = "MemoryInfo";
-
- private static final String FEATURE_INFO_TAG = "FeatureInfo";
- private static final String FEATURE_TAG = "Feature";
- private static final String FEATURE_ATTR_DELIM = ":";
- private static final String FEATURE_DELIM = ";";
-
- private static final String OPENGL_TEXTURE_FORMATS_INFO_TAG =
- "OpenGLCompressedTextureFormatsInfo";
- private static final String OPENGL_TEXTURE_FORMAT_TAG = "TextureFormat";
- private static final String OPENGL_TEXTURE_FORMAT_DELIM = ";";
-
- private static final String OPENGL_EXTENSIONS_TAG = "OpenGlExtensions";
- private static final String OPENGL_EXTENSION_TAG = "OpenGlExtension";
- private static final String OPENGL_EXTENSION_DELIM = ";";
-
- private static final String SYSLIB_INFO_TAG = "SystemLibrariesInfo";
- private static final String SYSLIB_TAG = "Library";
- private static final String SYSLIB_DELIM = ";";
-
- private static final String PROCESS_INFO_TAG = "ProcessInfo";
- private static final String PROCESS_TAG = "Process";
- private static final String PROCESS_DELIM = ";";
- private static final String PROCESS_ATTR_DELIM = ":";
-
- private Map<String, String> mMetrics = new HashMap<String, String>();
-
- /**
- * Serialize this object and all its contents to XML.
- *
- * @param serializer
- * @throws IOException
- */
- public void serialize(KXmlSerializer serializer) throws IOException {
- serializer.startTag(ns, TAG);
-
- if (mMetrics.isEmpty()) {
- // this might be expected, if device info collection was turned off
- CLog.d("Could not find device info");
- serializer.endTag(ns, TAG);
- return;
- }
-
- // Extract metrics that need extra handling, and then dump the remainder into BuildInfo
- Map<String, String> metricsCopy = new HashMap<String, String>(mMetrics);
- serializer.startTag(ns, SCREEN_TAG);
- serializer.attribute(ns, DeviceInfoConstants.RESOLUTION,
- getMetric(metricsCopy, DeviceInfoConstants.RESOLUTION));
- serializer.attribute(ns, DeviceInfoConstants.SCREEN_DENSITY,
- getMetric(metricsCopy, DeviceInfoConstants.SCREEN_DENSITY));
- serializer.attribute(ns, DeviceInfoConstants.SCREEN_DENSITY_BUCKET,
- getMetric(metricsCopy, DeviceInfoConstants.SCREEN_DENSITY_BUCKET));
- serializer.attribute(ns, DeviceInfoConstants.SCREEN_SIZE,
- getMetric(metricsCopy, DeviceInfoConstants.SCREEN_SIZE));
- serializer.attribute(ns, DeviceInfoConstants.SMALLEST_SCREEN_WIDTH_DP,
- getMetric(metricsCopy, DeviceInfoConstants.SMALLEST_SCREEN_WIDTH_DP));
- serializer.endTag(ns, SCREEN_TAG);
-
- serializer.startTag(ns, PHONE_TAG);
- serializer.attribute(ns, DeviceInfoConstants.PHONE_NUMBER,
- getMetric(metricsCopy, DeviceInfoConstants.PHONE_NUMBER));
- serializer.endTag(ns, PHONE_TAG);
-
- serializer.startTag(ns, MEMORY_TAG);
- serializer.attribute(ns, DeviceInfoConstants.IS_LOW_RAM_DEVICE,
- getMetric(metricsCopy, DeviceInfoConstants.IS_LOW_RAM_DEVICE));
- serializer.attribute(ns, DeviceInfoConstants.MEMORY_CLASS,
- getMetric(metricsCopy, DeviceInfoConstants.MEMORY_CLASS));
- serializer.attribute(ns, DeviceInfoConstants.LARGE_MEMORY_CLASS,
- getMetric(metricsCopy, DeviceInfoConstants.LARGE_MEMORY_CLASS));
- serializer.attribute(ns, DeviceInfoConstants.TOTAL_MEMORY,
- getMetric(metricsCopy, DeviceInfoConstants.TOTAL_MEMORY));
- serializer.endTag(ns, MEMORY_TAG);
-
- String featureData = getMetric(metricsCopy, DeviceInfoConstants.FEATURES);
- String processData = getMetric(metricsCopy, DeviceInfoConstants.PROCESSES);
- String sysLibData = getMetric(metricsCopy, DeviceInfoConstants.SYS_LIBRARIES);
- String textureData = getMetric(metricsCopy,
- DeviceInfoConstants.OPEN_GL_COMPRESSED_TEXTURE_FORMATS);
- String openGlExtensionData = getMetric(metricsCopy,
- DeviceInfoConstants.OPEN_GL_EXTENSIONS);
-
- // dump the remaining metrics without translation
- serializer.startTag(ns, BUILD_TAG);
- for (Map.Entry<String, String> metricEntry : metricsCopy.entrySet()) {
- serializer.attribute(ns, metricEntry.getKey(), metricEntry.getValue());
- }
- serializer.endTag(ns, BUILD_TAG);
-
- serializeFeatureInfo(serializer, featureData);
- serializeProcessInfo(serializer, processData);
- serializeSystemLibrariesInfo(serializer, sysLibData);
- serializeOpenGLCompressedTextureFormatsInfo(serializer, textureData);
- serializeOpenGLExtensions(serializer, openGlExtensionData);
- // End
- serializer.endTag(ns, TAG);
- }
-
- /**
- * Fetch and remove given metric from hashmap.
- *
- * @return the metric value or empty string if it was not present in map.
- */
- private String getMetric(Map<String, String> metrics, String metricName ) {
- String value = metrics.remove(metricName);
- if (value == null) {
- value = "";
- }
- return value;
- }
-
- private void serializeFeatureInfo(KXmlSerializer serializer, String featureData)
- throws IOException {
- serialize(serializer, FEATURE_INFO_TAG, FEATURE_TAG, FEATURE_DELIM, FEATURE_ATTR_DELIM,
- featureData, "name", "type", "available");
- }
-
- private void serializeProcessInfo(KXmlSerializer serializer, String rootProcesses)
- throws IOException {
- serialize(serializer, PROCESS_INFO_TAG, PROCESS_TAG, PROCESS_DELIM, PROCESS_ATTR_DELIM,
- rootProcesses, "name", "uid");
- }
-
- private void serializeOpenGLCompressedTextureFormatsInfo(KXmlSerializer serializer,
- String formats) throws IOException {
- serialize(serializer, OPENGL_TEXTURE_FORMATS_INFO_TAG, OPENGL_TEXTURE_FORMAT_TAG,
- OPENGL_TEXTURE_FORMAT_DELIM, null, formats, "name");
- }
-
- private void serializeOpenGLExtensions(KXmlSerializer serializer, String extensions)
- throws IOException {
- serialize(serializer, OPENGL_EXTENSIONS_TAG, OPENGL_EXTENSION_TAG,
- OPENGL_EXTENSION_DELIM, null, extensions, "name");
- }
-
- private void serializeSystemLibrariesInfo(KXmlSerializer serializer, String libs)
- throws IOException {
- serialize(serializer, SYSLIB_INFO_TAG, SYSLIB_TAG, SYSLIB_DELIM, null, libs, "name");
- }
-
- /**
- * Serializes a XML structure where there is an outer tag with tags inside it.
- *
- * <pre>
- * Input: value1:value2;value3:value4
- *
- * Output:
- * <OuterTag>
- * <SubTag attr1="value1" attr2="value2" />
- * <SubTag attr1="value3" attr2="value4" />
- * </OuterTag>
- * </pre>
- *
- * @param serializer to do it
- * @param tag would be "OuterTag"
- * @param subTag would be "SubTag"
- * @param delim would be ";"
- * @param attrDelim would be ":" in the example but can be null if only one attrName given
- * @param data would be "value1:value2;value3:value4"
- * @param attrNames would be an array with "attr1", "attr2"
- * @throws IOException if there is a problem
- */
- private void serialize(KXmlSerializer serializer, String tag, String subTag,
- String delim, String attrDelim, String data, String... attrNames) throws IOException {
- serializer.startTag(ns, tag);
-
- if (data == null) {
- data = "";
- }
-
- String[] values = data.split(delim);
- for (String value : values) {
- if (!value.isEmpty()) {
- String[] attrValues = attrDelim != null ? value.split(attrDelim) : new String[] {value};
- if (attrValues.length == attrNames.length) {
- serializer.startTag(ns, subTag);
- for (int i = 0; i < attrNames.length; i++) {
- serializer.attribute(ns, attrNames[i], attrValues[i]);
- }
- serializer.endTag(ns, subTag);
- }
- }
- }
-
- serializer.endTag(ns, tag);
- }
-
- /**
- * Populates this class with package result data parsed from XML.
- *
- * @param parser the {@link XmlPullParser}. Expected to be pointing at start
- * of a {@link #TAG}
- */
- @Override
- void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
- if (!parser.getName().equals(TAG)) {
- throw new XmlPullParserException(String.format(
- "invalid XML: Expected %s tag but received %s", TAG, parser.getName()));
- }
- int eventType = parser.getEventType();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG) {
- if (parser.getName().equals(SCREEN_TAG) ||
- parser.getName().equals(PHONE_TAG) ||
- parser.getName().equals(BUILD_TAG)) {
- addMetricsFromAttributes(parser);
- } else if (parser.getName().equals(FEATURE_INFO_TAG)) {
- mMetrics.put(DeviceInfoConstants.FEATURES, parseFeatures(parser));
- } else if (parser.getName().equals(PROCESS_INFO_TAG)) {
- mMetrics.put(DeviceInfoConstants.PROCESSES, parseProcess(parser));
- } else if (parser.getName().equals(SYSLIB_INFO_TAG)) {
- mMetrics.put(DeviceInfoConstants.SYS_LIBRARIES, parseSystemLibraries(parser));
- } else if (parser.getName().equals(OPENGL_TEXTURE_FORMATS_INFO_TAG)) {
- mMetrics.put(DeviceInfoConstants.OPEN_GL_COMPRESSED_TEXTURE_FORMATS,
- parseOpenGLCompressedTextureFormats(parser));
- }
- } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(TAG)) {
- return;
- }
- eventType = parser.next();
- }
- }
-
- private String parseFeatures(XmlPullParser parser) throws XmlPullParserException, IOException {
- return parseTag(parser, FEATURE_INFO_TAG, FEATURE_TAG, FEATURE_DELIM, FEATURE_ATTR_DELIM,
- "name", "type", "available");
- }
-
- private String parseProcess(XmlPullParser parser) throws XmlPullParserException, IOException {
- return parseTag(parser, PROCESS_INFO_TAG, PROCESS_TAG, PROCESS_DELIM,
- PROCESS_ATTR_DELIM, "name", "uid");
- }
-
- private String parseOpenGLCompressedTextureFormats(XmlPullParser parser)
- throws XmlPullParserException, IOException {
- return parseTag(parser, OPENGL_TEXTURE_FORMATS_INFO_TAG, OPENGL_TEXTURE_FORMAT_TAG,
- OPENGL_TEXTURE_FORMAT_DELIM, null, "name");
- }
-
- private String parseSystemLibraries(XmlPullParser parser)
- throws XmlPullParserException, IOException {
- return parseTag(parser, SYSLIB_INFO_TAG, SYSLIB_TAG, SYSLIB_DELIM, null, "name");
- }
-
- /**
- * Converts XML into a flattened string.
- *
- * <pre>
- * Input:
- * <OuterTag>
- * <SubTag attr1="value1" attr2="value2" />
- * <SubTag attr1="value3" attr2="value4" />
- * </OuterTag>
- *
- * Output: value1:value2;value3:value4
- * </pre>
- *
- * @param parser that parses the xml
- * @param tag like "OuterTag"
- * @param subTag like "SubTag"
- * @param delim like ";"
- * @param attrDelim like ":" or null if tehre is only one attribute
- * @param attrNames like "attr1", "attr2"
- * @return flattened string like "value1:value2;value3:value4"
- * @throws XmlPullParserException
- * @throws IOException
- */
- private String parseTag(XmlPullParser parser, String tag, String subTag, String delim,
- String attrDelim, String... attrNames) throws XmlPullParserException, IOException {
- if (!parser.getName().equals(tag)) {
- throw new XmlPullParserException(String.format(
- "invalid XML: Expected %s tag but received %s", tag,
- parser.getName()));
- }
- StringBuilder flattened = new StringBuilder();
-
- for (int eventType = parser.getEventType();
- eventType != XmlPullParser.END_DOCUMENT;
- eventType = parser.next()) {
-
- if (eventType == XmlPullParser.START_TAG && parser.getName().equals(subTag)) {
- for (int i = 0; i < attrNames.length; i++) {
- flattened.append(getAttribute(parser, attrNames[i]));
- if (i + 1 < attrNames.length) {
- flattened.append(attrDelim);
- }
- }
- flattened.append(delim);
- } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(tag)) {
- break;
- }
- }
-
- return flattened.toString();
- }
-
- /**
- * Adds all attributes from the current XML tag to metrics as name-value pairs
- */
- private void addMetricsFromAttributes(XmlPullParser parser) {
- int attrCount = parser.getAttributeCount();
- for (int i = 0; i < attrCount; i++) {
- mMetrics.put(parser.getAttributeName(i), parser.getAttributeValue(i));
- }
- }
-
- /**
- * Populate the device info metrics with values collected from device.
- * <p/>
- * Check that the provided device info metrics are consistent with the currently stored metrics.
- * If any inconsistencies occur, logs errors and stores error messages in the metrics map
- */
- public void populateMetrics(Map<String, String> metrics) {
- if (mMetrics.isEmpty()) {
- // no special processing needed, no existing metrics
- mMetrics.putAll(metrics);
- return;
- }
- Map<String, String> metricsCopy = new HashMap<String, String>(
- metrics);
- // add values for metrics that might be different across runs
- combineMetrics(metricsCopy, DeviceInfoConstants.PHONE_NUMBER, DeviceInfoConstants.IMSI,
- DeviceInfoConstants.IMSI, DeviceInfoConstants.SERIAL_NUMBER);
-
- // ensure all the metrics we expect to be identical actually are
- checkMetrics(metricsCopy, DeviceInfoConstants.BUILD_FINGERPRINT,
- DeviceInfoConstants.BUILD_MODEL, DeviceInfoConstants.BUILD_BRAND,
- DeviceInfoConstants.BUILD_MANUFACTURER, DeviceInfoConstants.BUILD_BOARD,
- DeviceInfoConstants.BUILD_DEVICE, DeviceInfoConstants.PRODUCT_NAME,
- DeviceInfoConstants.BUILD_ABI, DeviceInfoConstants.BUILD_ABI2,
- DeviceInfoConstants.BUILD_ABIS, DeviceInfoConstants.BUILD_ABIS_32,
- DeviceInfoConstants.BUILD_ABIS_64, DeviceInfoConstants.SCREEN_SIZE);
- }
-
- private void combineMetrics(Map<String, String> metrics, String... keysToCombine) {
- for (String combineKey : keysToCombine) {
- String currentKeyValue = mMetrics.get(combineKey);
- String valueToAdd = metrics.remove(combineKey);
- if (valueToAdd != null) {
- if (currentKeyValue == null) {
- // strange - no existing value. Can occur during unit testing
- mMetrics.put(combineKey, valueToAdd);
- } else if (!currentKeyValue.equals(valueToAdd)) {
- // new value! store a comma separated list
- valueToAdd = String.format("%s,%s", currentKeyValue, valueToAdd);
- mMetrics.put(combineKey, valueToAdd);
- } else {
- // ignore, current value is same as existing
- }
-
- } else {
- CLog.d("Missing metric %s", combineKey);
- }
- }
- }
-
- private void checkMetrics(Map<String, String> metrics, String... keysToCheck) {
- Set<String> keyCheckSet = new HashSet<String>();
- Collections.addAll(keyCheckSet, keysToCheck);
- for (Map.Entry<String, String> metricEntry : metrics.entrySet()) {
- String currentValue = mMetrics.get(metricEntry.getKey());
- if (keyCheckSet.contains(metricEntry.getKey()) && currentValue != null
- && !metricEntry.getValue().equals(currentValue)) {
- CLog.e("Inconsistent info collected from devices. "
- + "Current result has %s='%s', Received '%s'. Are you sharding or " +
- "resuming a test run across different devices and/or builds?",
- metricEntry.getKey(), currentValue, metricEntry.getValue());
- mMetrics.put(metricEntry.getKey(),
- String.format("ERROR: Inconsistent results: %s, %s",
- metricEntry.getValue(), currentValue));
- } else {
- mMetrics.put(metricEntry.getKey(), metricEntry.getValue());
- }
- }
- }
-
- /**
- * Return the currently stored metrics.
- * <p/>
- * Exposed for unit testing.
- */
- Map<String, String> getMetrics() {
- return mMetrics;
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestResultRepo.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestResultRepo.java
deleted file mode 100644
index 19b0540..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestResultRepo.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import java.io.File;
-import java.util.List;
-
-/**
- * Repository for CTS results.
- */
-public interface ITestResultRepo {
-
- /**
- * @return the list of {@link ITestSummary}s. The index of the {@link ITestSummary} in the
- * list is its session id
- */
- public List<ITestSummary> getSummaries();
-
- /**
- * Get the {@link TestResults} for given session id.
- *
- * @param sessionId the session id
- * @return the {@link TestResults} or <code>null</null> if the result with that session id
- * cannot be retrieved
- */
- public TestResults getResult(int sessionId);
-
- /**
- * Get the report directory for given result
- * @param sessionId
- * @return A {@link File} representing the report directory for the given sessionId
- */
- public File getReportDir(int sessionId);
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestSummary.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestSummary.java
deleted file mode 100644
index e7041ec..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestSummary.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-/**
- * Interface for a single CTS result summary.
- */
-public interface ITestSummary {
-
- /**
- * @return the session id
- */
- public int getId();
-
- /**
- * @return the starting timestamp, also known as result directory name
- */
- public String getTimestamp();
-
- /**
- * @return the num of not executed tests
- */
- public int getNumIncomplete();
-
- /**
- * @return the number of failed tests
- */
- public int getNumFailed();
-
- /**
- * @return the number of passed tests
- */
- public int getNumPassed();
-
- /**
- * @return the test plan associated with result
- */
- public String getTestPlan();
-
- /**
- * Return the user-friendly displayed start time stored in result XML.
- * <p/>
- * Expected format: {@link TimeUtil#getTimestamp()}
- */
- public String getStartTime();
-
- /**
- * @return a comma separated list of device serials associated with result
- */
- public String getDeviceSerials();
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/IssueReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/IssueReporter.java
deleted file mode 100644
index ed5f238..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/IssueReporter.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.result;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.InputStreamSource;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.TestSummary;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.zip.GZIPOutputStream;
-
-/**
- * Class that sends a HTTP POST multipart/form-data request containing details
- * about a test failure.
- */
-public class IssueReporter implements ITestInvocationListener {
-
- private static final int BUGREPORT_SIZE = 500 * 1024;
-
- private static final String PRODUCT_NAME_KEY = "buildName";
- private static final String BUILD_TYPE_KEY = "build_type";
- private static final String BUILD_ID_KEY = "buildID";
-
- @Option(name = "issue-server", description = "Server url to post test failures to.")
- private String mServerUrl;
-
- private final ExecutorService mReporterService = Executors.newCachedThreadPool();
-
- private Issue mCurrentIssue;
- private String mBuildId;
- private String mBuildType;
- private String mProductName;
-
- @Override
- public void testFailed(TestIdentifier test, String trace) {
- mCurrentIssue = new Issue();
- mCurrentIssue.mTestName = test.toString();
- mCurrentIssue.mStackTrace = trace;
- }
-
- @Override
- public void testAssumptionFailure(TestIdentifier test, String trace) {
- mCurrentIssue = new Issue();
- mCurrentIssue.mTestName = test.toString();
- mCurrentIssue.mStackTrace = trace;
- }
-
- @Override
- public void testIgnored(TestIdentifier test) {
- // TODO: ??
- }
-
- @Override
- public void testLog(String dataName, LogDataType dataType, InputStreamSource dataStream) {
- if (dataName.startsWith("bug-")) {
- try {
- setBugReport(dataStream);
- } catch (IOException e) {
- CLog.e(e);
- }
- }
- }
-
- /**
- * Set the bug report for the current test failure. GZip it to save space.
- * This is only called when the --bugreport option is enabled.
- */
- private void setBugReport(InputStreamSource dataStream) throws IOException {
- if (mCurrentIssue != null) {
- // Only one bug report can be stored at a time and they are gzipped to
- // about 0.5 MB so there shoudn't be any memory leak bringing down CTS.
- InputStream input = null;
- try {
- input = dataStream.createInputStream();
- mCurrentIssue.mBugReport = getBytes(input, BUGREPORT_SIZE);
- } finally {
- if (input != null) {
- input.close();
- }
- }
- } else {
- CLog.e("setBugReport is getting called on an empty issue...");
- }
- }
-
- /**
- * @param input that will be gzipped and returne as a byte array
- * @param size of the output expected
- * @return the byte array with the input's data
- * @throws IOException
- */
- static byte[] getBytes(InputStream input, int size) throws IOException {
- ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(size);
- GZIPOutputStream gzipOutput = new GZIPOutputStream(byteOutput);
- for (byte[] buffer = new byte[1024]; ; ) {
- int numRead = input.read(buffer);
- if (numRead < 0) {
- break;
- }
- gzipOutput.write(buffer, 0, numRead);
- }
- gzipOutput.close();
- return byteOutput.toByteArray();
- }
-
- @Override
- public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
- if (mCurrentIssue != null) {
- mReporterService.submit(mCurrentIssue);
- mCurrentIssue = null;
- }
- }
-
- @Override
- public void testRunEnded(long elapsedTime, Map<String, String> runMetrics) {
- setDeviceMetrics(runMetrics);
- }
-
- /** Set device information. Populated once when the device info app runs. */
- private void setDeviceMetrics(Map<String, String> metrics) {
- if (metrics.containsKey(BUILD_ID_KEY)) {
- mBuildId = metrics.get(BUILD_ID_KEY);
- }
- if (metrics.containsKey(BUILD_TYPE_KEY)) {
- mBuildType = metrics.get(BUILD_TYPE_KEY);
- }
- if (metrics.containsKey(PRODUCT_NAME_KEY)) {
- mProductName = metrics.get(PRODUCT_NAME_KEY);
- }
- }
-
- @Override
- public void invocationEnded(long elapsedTime) {
- try {
- mReporterService.shutdown();
- if (!mReporterService.awaitTermination(1, TimeUnit.MINUTES)) {
- CLog.i("Some issues could not be reported...");
- }
- } catch (InterruptedException e) {
- CLog.e(e);
- }
- }
-
- class Issue implements Callable<Void> {
-
- private String mTestName;
- private String mStackTrace;
- private byte[] mBugReport;
-
- @Override
- public Void call() throws Exception {
- if (isEmpty(mServerUrl)
- || isEmpty(mBuildId)
- || isEmpty(mBuildType)
- || isEmpty(mProductName)
- || isEmpty(mTestName)
- || isEmpty(mStackTrace)) {
- return null;
- }
-
- new MultipartForm(mServerUrl)
- .addFormValue("productName", mProductName)
- .addFormValue("buildType", mBuildType)
- .addFormValue("buildId", mBuildId)
- .addFormValue("testName", mTestName)
- .addFormValue("stackTrace", mStackTrace)
- .addFormFile("bugReport", "bugreport.txt.gz", mBugReport)
- .submit();
-
- return null;
- }
-
- private boolean isEmpty(String value) {
- return value == null || value.trim().isEmpty();
- }
- }
-
- @Override
- public void invocationStarted(IBuildInfo buildInfo) {
- }
-
- @Override
- public void testRunStarted(String id, int numTests) {
- }
-
- @Override
- public void testStarted(TestIdentifier test) {
- }
-
- @Override
- public void testRunFailed(String arg0) {
- }
-
- @Override
- public void testRunStopped(long elapsedTime) {
- }
-
- @Override
- public void invocationFailed(Throwable cause) {
- }
-
- @Override
- public TestSummary getSummary() {
- return null;
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/MultipartForm.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/MultipartForm.java
deleted file mode 100644
index f3ef0bb..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/MultipartForm.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.result;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-/** MultipartForm builds a multipart form and submits it. */
-class MultipartForm {
-
- private static final String FORM_DATA_BOUNDARY = "C75I55u3R3p0r73r";
-
- private final String mServerUrl;
-
- private final Map<String, String> mFormValues = new HashMap<String, String>();
-
- private String mName;
- private String mFileName;
- private byte[] mData;
-
- public MultipartForm(String serverUrl) {
- mServerUrl = serverUrl;
- }
-
- public MultipartForm addFormValue(String name, String value) {
- mFormValues.put(name, value);
- return this;
- }
-
- public MultipartForm addFormFile(String name, String fileName, byte[] data) {
- mName = name;
- mFileName = fileName;
- mData = data;
- return this;
- }
-
- public void submit() throws IOException {
- String redirectUrl = submitForm(mServerUrl);
- if (redirectUrl != null) {
- submitForm(redirectUrl);
- }
- }
-
- /**
- * @param serverUrl to post the data to
- * @return a url if the server redirected to another url
- * @throws IOException
- */
- private String submitForm(String serverUrl) throws IOException {
- HttpURLConnection connection = null;
- try {
- URL url = new URL(serverUrl);
- connection = (HttpURLConnection) url.openConnection();
- connection.setInstanceFollowRedirects(false);
- connection.setRequestMethod("POST");
- connection.setDoOutput(true);
- connection.setRequestProperty("Content-Type",
- "multipart/form-data; boundary=" + FORM_DATA_BOUNDARY);
-
- byte[] body = getContentBody();
- connection.setRequestProperty("Content-Length", Integer.toString(body.length));
-
- OutputStream output = connection.getOutputStream();
- try {
- output.write(body);
- } finally {
- output.close();
- }
-
- // Open the stream to get a response. Otherwise request will be cancelled.
- InputStream input = connection.getInputStream();
- input.close();
-
- if (connection.getResponseCode() == 302) {
- return connection.getHeaderField("Location");
- }
- } finally {
- if (connection != null) {
- connection.disconnect();
- }
- }
-
- return null;
- }
-
- private byte[] getContentBody() throws IOException {
- ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
- PrintWriter writer = new PrintWriter(new OutputStreamWriter(byteOutput));
- writer.println();
-
- for (Map.Entry<String, String> formValue : mFormValues.entrySet()) {
- writeFormField(writer, formValue.getKey(), formValue.getValue());
- }
-
- if (mData != null) {
- writeFormFileHeader(writer, mName, mFileName);
- writer.flush(); // Must flush here before writing to the byte stream!
- byteOutput.write(mData);
- writer.println();
- }
- writer.append("--").append(FORM_DATA_BOUNDARY).println("--");
- writer.flush();
- writer.close();
- return byteOutput.toByteArray();
- }
-
- private void writeFormField(PrintWriter writer, String name, String value) {
- writer.append("--").println(FORM_DATA_BOUNDARY);
- writer.append("Content-Disposition: form-data; name=\"").append(name).println("\"");
- writer.println();
- writer.println(value);
- }
-
- private void writeFormFileHeader(PrintWriter writer, String name, String fileName) {
- writer.append("--").println(FORM_DATA_BOUNDARY);
- writer.append("Content-Disposition: form-data; name=\"").append(name);
- writer.append("\"; filename=\"").append(fileName).println("\"");
- writer.println("Content-Type: application/x-gzip");
- writer.println("Content-Transfer-Encoding: binary");
- writer.println();
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/PlanCreator.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/PlanCreator.java
deleted file mode 100644
index 0926635..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/PlanCreator.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.tradefed.testtype.CtsTest;
-import com.android.cts.tradefed.testtype.ITestPackageDef;
-import com.android.cts.tradefed.testtype.ITestPackageRepo;
-import com.android.cts.tradefed.testtype.ITestPlan;
-import com.android.cts.tradefed.testtype.TestPackageRepo;
-import com.android.cts.tradefed.testtype.TestPlan;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.Option.Importance;
-import com.android.tradefed.log.LogUtil.CLog;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * Class for creating test plans from CTS result XML.
- */
-public class PlanCreator {
-
- @Option (name = "plan", shortName = 'p', description = "the name of the plan to create",
- importance=Importance.IF_UNSET)
- private String mPlanName = null;
-
- @Option (name = "session", shortName = 's', description = "the session id to derive from",
- importance=Importance.IF_UNSET)
- private Integer mSessionId = null;
-
- @Option (name = "result", shortName = 'r',
- description = "the result type to filter. One of pass, fail, notExecuted.",
- importance=Importance.IF_UNSET)
- private String mResultFilterString = null;
-
- @Option(name = CtsTest.RUN_KNOWN_FAILURES_OPTION)
- private boolean mIncludeKnownFailures = false;
-
- private CtsTestStatus mResultFilter = null;
- private TestResults mResult = null;
-
- private File mPlanFile;
-
- /**
- * Create an empty {@link PlanCreator}.
- * <p/>
- * All {@link Option} fields must be populated via
- * {@link com.android.tradefed.config.ArgsOptionParser}
- */
- public PlanCreator() {
- }
-
- /**
- * Create a {@link PlanCreator} using the specified option values.
- */
- public PlanCreator(String planName, int session, CtsTestStatus result) {
- mPlanName = planName;
- mSessionId = session;
- mResultFilterString = result.getValue();
- }
-
- /**
- * Create and serialize a test plan derived from a result.
- * <p/>
- * {@link Option} values must all be set before this is called.
- * @throws ConfigurationException
- */
- public void createAndSerializeDerivedPlan(CtsBuildHelper build, Set<String> abis)
- throws ConfigurationException {
- ITestPlan derivedPlan = createDerivedPlan(build, abis);
- if (derivedPlan != null) {
- try {
- derivedPlan.serialize(new BufferedOutputStream(new FileOutputStream(mPlanFile)));
- } catch (IOException e) {
- Log.logAndDisplay(LogLevel.ERROR, "", String.format("Failed to create plan file %s",
- mPlanName));
- CLog.e(e);
- }
- }
- }
-
- /**
- * Create a test plan derived from a result.
- * <p/>
- * {@link Option} values must all be set before this is called.
- *
- * @param build
- * @return test plan
- * @throws ConfigurationException
- */
- public ITestPlan createDerivedPlan(CtsBuildHelper build, Set<String> abis)
- throws ConfigurationException {
- checkFields(build);
- ITestPackageRepo pkgDefRepo =
- new TestPackageRepo(build.getTestCasesDir(), mIncludeKnownFailures);
- ITestPlan derivedPlan = new TestPlan(mPlanName, abis);
- for (TestPackageResult pkg : mResult.getPackages()) {
- Collection<TestIdentifier> filteredTests = pkg.getTestsWithStatus(mResultFilter);
- String pkgId = pkg.getId();
- ITestPackageDef pkgDef = pkgDefRepo.getTestPackage(pkgId);
- if (pkgDef != null) {
- Collection<TestIdentifier> excludedTests =
- new LinkedHashSet<TestIdentifier>(pkgDef.getTests());
- excludedTests.removeAll(filteredTests);
- derivedPlan.addPackage(pkgId);
- derivedPlan.addExcludedTests(pkgId, excludedTests);
- } else {
- CLog.e("Could not find package %s in repository", pkgId);
- }
- }
- return derivedPlan;
- }
-
- /**
- * Check that all {@Option}s have been populated with valid values.
- * @param build
- * @throws ConfigurationException if any option has an invalid value
- */
- private void checkFields(CtsBuildHelper build) throws ConfigurationException {
- if (mSessionId == null) {
- throw new ConfigurationException("Missing --session argument");
- }
- ITestResultRepo repo = new TestResultRepo(build.getResultsDir());
- mResult = repo.getResult(mSessionId);
- if (mResult == null) {
- throw new ConfigurationException(String.format("Could not find session with id %d",
- mSessionId));
- }
- if (mResultFilterString == null) {
- throw new ConfigurationException("Missing --result argument");
- }
- mResultFilter = CtsTestStatus.getStatus(mResultFilterString);
- if (mResultFilter == null) {
- throw new ConfigurationException(
- "Invalid result argument. Expected one of pass,fail,notExecuted");
- }
- if (mPlanName == null) {
- throw new ConfigurationException("Missing --plan argument");
- }
- try {
- mPlanFile = build.getTestPlanFile(mPlanName);
- if (mPlanFile.exists()) {
- throw new ConfigurationException(String.format("Test plan %s already exists",
- mPlanName));
- }
- } catch (FileNotFoundException e) {
- throw new ConfigurationException("Could not find plans directory");
- }
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/ResultReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/ResultReporter.java
deleted file mode 100644
index 39969d3..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/ResultReporter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.result;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.annotation.Nullable;
-
-/**
- * Class that sends a HTTP POST multipart/form-data request containing
- * the test result XML.
- */
-class ResultReporter {
-
- private static final int RESULT_XML_BYTES = 500 * 1024;
-
- private final String mServerUrl;
- private final String mSuiteName;
-
- ResultReporter(String serverUrl, String suiteName) {
- mServerUrl = serverUrl;
- mSuiteName = suiteName;
- }
-
- public void reportResult(File reportFile, @Nullable String referenceUrl) throws IOException {
- if (isEmpty(mServerUrl)) {
- return;
- }
-
- InputStream input = new FileInputStream(reportFile);
- try {
- byte[] data = IssueReporter.getBytes(input, RESULT_XML_BYTES);
- MultipartForm multipartForm = new MultipartForm(mServerUrl)
- .addFormValue("suite", mSuiteName)
- .addFormFile("resultXml", "testResult.xml.gz", data);
- if (!isEmpty(referenceUrl)) {
- multipartForm.addFormValue("referenceUrl", referenceUrl);
- }
- multipartForm.submit();
- } finally {
- input.close();
- }
- }
-
- private static boolean isEmpty(String value) {
- return value == null || value.trim().isEmpty();
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/Test.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/Test.java
deleted file mode 100644
index e25ea5a..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/Test.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.compatibility.common.util.MetricsXmlSerializer;
-import com.android.compatibility.common.util.ReportLog;
-import com.android.cts.tradefed.result.TestLog.TestLogType;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Data structure that represents a "Test" result XML element.
- */
-class Test extends AbstractXmlPullParser {
- static final String TAG = "Test";
- private static final String NAME_ATTR = "name";
- private static final String MESSAGE_ATTR = "message";
- private static final String ENDTIME_ATTR = "endtime";
- private static final String STARTTIME_ATTR = "starttime";
- private static final String RESULT_ATTR = "result";
- private static final String SCENE_TAG = "FailedScene";
- private static final String STACK_TAG = "StackTrace";
- private String mName;
- private CtsTestStatus mResult;
- private String mStartTime;
- private String mEndTime;
- private String mMessage;
- private String mStackTrace;
- private ReportLog mReport;
-
- /**
- * Log info for this test like a logcat dump or bugreport.
- * Use *Locked methods instead of mutating this directly.
- */
- private List<TestLog> mTestLogs;
-
- /**
- * Create an empty {@link Test}
- */
- public Test() {
- }
-
- /**
- * Create a {@link Test}.
- *
- * @param name
- */
- public Test(String name) {
- mName = name;
- mResult = CtsTestStatus.NOT_EXECUTED;
- mStartTime = TimeUtil.getTimestamp();
- updateEndTime();
- }
-
- /**
- * Add a test log to this Test.
- */
- public void addTestLog(TestLog testLog) {
- addTestLogLocked(testLog);
- }
-
- /**
- * Set the name of this {@link Test}
- */
- public void setName(String name) {
- mName = name;
- }
-
- /**
- * Get the name of this {@link Test}
- */
- public String getName() {
- return mName;
- }
-
- public CtsTestStatus getResult() {
- return mResult;
- }
-
- public String getMessage() {
- return mMessage;
- }
-
- public void setMessage(String message) {
- mMessage = message;
- }
-
- public String getStartTime() {
- return mStartTime;
- }
-
- public String getEndTime() {
- return mEndTime;
- }
-
- public String getStackTrace() {
- return mStackTrace;
- }
-
- public void setStackTrace(String stackTrace) {
-
- mStackTrace = sanitizeStackTrace(stackTrace);
- mMessage = getFailureMessageFromStackTrace(mStackTrace);
- }
-
- public ReportLog getReportLog() {
- return mReport;
- }
-
- public void setReportLog(ReportLog report) {
- mReport = report;
- }
-
- public void updateEndTime() {
- mEndTime = TimeUtil.getTimestamp();
- }
-
- public void setResultStatus(CtsTestStatus status) {
- mResult = status;
- }
-
- /**
- * Serialize this object and all its contents to XML.
- *
- * @param serializer
- * @throws IOException
- */
- public void serialize(KXmlSerializer serializer)
- throws IOException {
- serializer.startTag(CtsXmlResultReporter.ns, TAG);
- serializer.attribute(CtsXmlResultReporter.ns, NAME_ATTR, getName());
- serializer.attribute(CtsXmlResultReporter.ns, RESULT_ATTR, mResult.getValue());
- serializer.attribute(CtsXmlResultReporter.ns, STARTTIME_ATTR, mStartTime);
- serializer.attribute(CtsXmlResultReporter.ns, ENDTIME_ATTR, mEndTime);
-
- serializeTestLogsLocked(serializer);
-
- if (mMessage != null) {
- serializer.startTag(CtsXmlResultReporter.ns, SCENE_TAG);
- serializer.attribute(CtsXmlResultReporter.ns, MESSAGE_ATTR, mMessage);
- if (mStackTrace != null) {
- serializer.startTag(CtsXmlResultReporter.ns, STACK_TAG);
- serializer.text(mStackTrace);
- serializer.endTag(CtsXmlResultReporter.ns, STACK_TAG);
- }
- serializer.endTag(CtsXmlResultReporter.ns, SCENE_TAG);
- }
- MetricsXmlSerializer metricsXmlSerializer = new MetricsXmlSerializer(serializer);
- metricsXmlSerializer.serialize(mReport);
- serializer.endTag(CtsXmlResultReporter.ns, TAG);
- }
-
- /**
- * Strip out any invalid XML characters that might cause the report to be unviewable.
- * http://www.w3.org/TR/REC-xml/#dt-character
- */
- private static String sanitizeStackTrace(String trace) {
- if (trace != null) {
- return trace.replaceAll("[^\\u0009\\u000A\\u000D\\u0020-\\uD7FF\\uE000-\\uFFFD]", "");
- } else {
- return null;
- }
- }
-
- /**
- * Gets the failure message to show from the stack trace.
- * <p/>
- * Exposed for unit testing
- *
- * @param stack the full stack trace
- * @return the failure message
- */
- static String getFailureMessageFromStackTrace(String stack) {
- // return the first two lines of stack as failure message
- int endPoint = stack.indexOf('\n');
- if (endPoint != -1) {
- int nextLine = stack.indexOf('\n', endPoint + 1);
- if (nextLine != -1) {
- return stack.substring(0, nextLine);
- }
- }
- return stack;
- }
-
- /**
- * Populates this class with test result data parsed from XML.
- *
- * @param parser the {@link XmlPullParser}. Expected to be pointing at start
- * of a Test tag
- */
- @Override
- void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
- if (!parser.getName().equals(TAG)) {
- throw new XmlPullParserException(String.format(
- "invalid XML: Expected %s tag but received %s", TAG, parser.getName()));
- }
- setName(getAttribute(parser, NAME_ATTR));
- mResult = CtsTestStatus.getStatus(getAttribute(parser, RESULT_ATTR));
- mStartTime = getAttribute(parser, STARTTIME_ATTR);
- mEndTime = getAttribute(parser, ENDTIME_ATTR);
-
- int eventType = parser.next();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG && parser.getName().equals(SCENE_TAG)) {
- mMessage = getAttribute(parser, MESSAGE_ATTR);
- } else if (eventType == XmlPullParser.START_TAG && parser.getName().equals(STACK_TAG)) {
- mStackTrace = parser.nextText();
- } else if (eventType == XmlPullParser.START_TAG && TestLog.isTag(parser.getName())) {
- parseTestLog(parser);
- } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(TAG)) {
- return;
- }
- eventType = parser.next();
- }
- }
-
- /** Parse a TestLog entry from the parser positioned at a TestLog tag. */
- private void parseTestLog(XmlPullParser parser) throws XmlPullParserException{
- TestLog log = TestLog.fromXml(parser);
- if (log == null) {
- throw new XmlPullParserException("invalid XML: bad test log tag");
- }
- addTestLog(log);
- }
-
- /** Add a TestLog to the test in a thread safe manner. */
- private synchronized void addTestLogLocked(TestLog testLog) {
- if (mTestLogs == null) {
- mTestLogs = new ArrayList<>(TestLogType.values().length);
- }
- mTestLogs.add(testLog);
- }
-
- /** Serialize the TestLogs of this test in a thread safe manner. */
- private synchronized void serializeTestLogsLocked(KXmlSerializer serializer) throws IOException {
- if (mTestLogs != null) {
- for (TestLog log : mTestLogs) {
- log.serialize(serializer);
- }
- }
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestCase.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestCase.java
deleted file mode 100644
index fdb8b3b..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestCase.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.util.ArrayUtil;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Deque;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Data structure that represents a "TestCase" XML element and its children.
- */
-class TestCase extends AbstractXmlPullParser {
-
- static final String TAG = "TestCase";
-
- private String mName;
-
- Map<String, Test> mChildTestMap = new LinkedHashMap<String, Test>();
-
- /**
- * Create a {@link TestCase}
- * @param testCaseName
- */
- public TestCase(String testCaseName) {
- setName(testCaseName);
- }
-
- public TestCase() {
- }
-
- public void setName(String name) {
- mName = name;
- }
-
- public String getName() {
- return mName;
- }
-
- /**
- * Gets the child tests
- */
- public Collection<Test> getTests() {
- return mChildTestMap.values();
- }
-
- /**
- * @param testName
- * @param insertIfMissing
- * @return
- */
- public Test findTest(String testName, boolean insertIfMissing) {
- Test t = mChildTestMap.get(testName);
- if (t == null && insertIfMissing) {
- t = new Test(testName);
- mChildTestMap.put(t.getName(), t);
- }
- return t;
- }
-
- /**
- * Serialize this object and all its contents to XML.
- *
- * @param serializer
- * @throws IOException
- */
- public void serialize(KXmlSerializer serializer) throws IOException {
- serializer.startTag(CtsXmlResultReporter.ns, TAG);
- serializer.attribute(CtsXmlResultReporter.ns, "name", getName());
- // unused
- serializer.attribute(CtsXmlResultReporter.ns, "priority", "");
- for (Test t : mChildTestMap.values()) {
- t.serialize(serializer);
- }
- serializer.endTag(CtsXmlResultReporter.ns, TAG);
- }
-
- /**
- * Populates this class with test case result data parsed from XML.
- *
- * @param parser the {@link XmlPullParser}. Expected to be pointing at start
- * of a TestCase tag
- */
- @Override
- void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
- if (!parser.getName().equals(TAG)) {
- throw new XmlPullParserException(String.format(
- "invalid XML: Expected %s tag but received %s", TAG, parser.getName()));
- }
- setName(getAttribute(parser, "name"));
- int eventType = parser.next();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG && parser.getName().equals(Test.TAG)) {
- Test test = new Test();
- test.parse(parser);
- mChildTestMap.put(test.getName(), test);
- } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(TAG)) {
- return;
- }
- eventType = parser.next();
- }
- }
-
- /**
- * Adds tests contained in this result that have the given <var>resultFilter</var>.
- *
- * @param tests the {@link Collection} of {@link TestIdentifier}s to add to
- * @param parentSuiteNames a {@link Deque} of parent suite names. Used to
- * construct the full class name of the test
- * @param resultFilter the {@link CtsTestStatus} to filter by
- */
- void addTestsWithStatus(Collection<TestIdentifier> tests, Deque<String> parentSuiteNames,
- CtsTestStatus resultFilter) {
- if (getName() != null) {
- parentSuiteNames.addLast(getName());
- }
- String fullClassName = ArrayUtil.join(".", parentSuiteNames);
- for (Test test : mChildTestMap.values()) {
- if (resultFilter.equals(test.getResult())) {
- tests.add(new TestIdentifier(fullClassName, test.getName()));
- }
- }
- if (getName() != null) {
- parentSuiteNames.removeLast();
- }
- }
-
- /**
- * Count the number of tests in this {@link TestCase} with given status.
- *
- * @param status
- * @return the test count
- */
- public int countTests(CtsTestStatus status) {
- int total = 0;
- for (Test test : mChildTestMap.values()) {
- if (test.getResult().equals(status)) {
- total++;
- }
- }
- return total;
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestLog.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestLog.java
deleted file mode 100644
index 1210432..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestLog.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.IOException;
-
-import javax.annotation.Nullable;
-
-/**
- * TestLog describes a log for a test. It corresponds to the "TestLog" XML element.
- */
-class TestLog {
-
- private static final String TAG = "TestLog";
- private static final String TYPE_ATTR = "type";
- private static final String URL_ATTR = "url";
-
- /** Type of log. */
- public enum TestLogType {
- LOGCAT("logcat-"),
- BUGREPORT("bug-"),
-
- ;
-
- // This enum restricts the type of logs reported back to the server,
- // because we do not intend to support them all. Using an enum somewhat
- // assures that we will only see these expected types on the server side.
-
- /**
- * Returns the TestLogType from an ILogSaver data name or null
- * if the data name is not supported.
- */
- @Nullable
- static TestLogType fromDataName(String dataName) {
- if (dataName == null) {
- return null;
- }
-
- for (TestLogType type : values()) {
- if (dataName.startsWith(type.dataNamePrefix)) {
- return type;
- }
- }
- return null;
- }
-
- private final String dataNamePrefix;
-
- private TestLogType(String dataNamePrefix) {
- this.dataNamePrefix = dataNamePrefix;
- }
-
- String getAttrValue() {
- return name().toLowerCase();
- }
- }
-
- /** Type of the log like LOGCAT or BUGREPORT. */
- private final TestLogType mLogType;
-
- /** Url pointing to the log file. */
- private final String mUrl;
-
- /** Create a TestLog from an ILogSaver callback. */
- @Nullable
- static TestLog fromDataName(String dataName, String url) {
- TestLogType logType = TestLogType.fromDataName(dataName);
- if (logType == null) {
- return null;
- }
-
- if (url == null) {
- return null;
- }
-
- return new TestLog(logType, url);
- }
-
- /** Create a TestLog from XML given a XmlPullParser positioned at the TestLog tag. */
- @Nullable
- static TestLog fromXml(XmlPullParser parser) {
- String type = parser.getAttributeValue(null, TYPE_ATTR);
- if (type == null) {
- return null;
- }
-
- String url = parser.getAttributeValue(null, URL_ATTR);
- if (url == null) {
- return null;
- }
-
- try {
- TestLogType logType = TestLogType.valueOf(type.toUpperCase());
- return new TestLog(logType, url);
- } catch (IllegalArgumentException e) {
- return null;
- }
- }
-
- /** Create a TestLog directly given a log type and url. */
- public static TestLog of(TestLogType logType, String url) {
- return new TestLog(logType, url);
- }
-
- private TestLog(TestLogType logType, String url) {
- this.mLogType = logType;
- this.mUrl = url;
- }
-
- /** Returns this TestLog's log type. */
- TestLogType getLogType() {
- return mLogType;
- }
-
- /** Returns this TestLog's URL. */
- String getUrl() {
- return mUrl;
- }
-
- /** Serialize the TestLog to XML. */
- public void serialize(KXmlSerializer serializer) throws IOException {
- serializer.startTag(CtsXmlResultReporter.ns, TAG);
- serializer.attribute(CtsXmlResultReporter.ns, TYPE_ATTR, mLogType.getAttrValue());
- serializer.attribute(CtsXmlResultReporter.ns, URL_ATTR, mUrl);
- serializer.endTag(CtsXmlResultReporter.ns, TAG);
- }
-
- /** Returns true if the tag is a TestLog tag. */
- public static boolean isTag(String tagName) {
- return TAG.equals(tagName);
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestPackageResult.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestPackageResult.java
deleted file mode 100644
index f323503..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestPackageResult.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.compatibility.common.util.MetricsStore;
-import com.android.compatibility.common.util.ReportLog;
-import com.android.cts.tradefed.testtype.CtsTest;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.util.AbiUtils;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Data structure for a CTS test package result.
- * <p/>
- * Provides methods to serialize to XML.
- */
-class TestPackageResult extends AbstractXmlPullParser {
-
- static final String TAG = "TestPackage";
-
- public static final String RESULT_KEY = "COMPATIBILITY_TEST_RESULT";
-
- private static final String DIGEST_ATTR = "digest";
- private static final String APP_PACKAGE_NAME_ATTR = "appPackageName";
- private static final String NAME_ATTR = "name";
- private static final String ABI_ATTR = "abi";
- private static final String ns = CtsXmlResultReporter.ns;
- private static final String SIGNATURE_TEST_PKG = "android.tests.sigtest";
-
- private String mDeviceSerial;
- private String mAppPackageName;
- private String mName;
- private String mAbi;
- private String mDigest;
-
- private Map<String, String> mMetrics = new HashMap<String, String>();
- private Map<TestIdentifier, Map<String, String>> mTestMetrics = new HashMap<TestIdentifier, Map<String, String>>();
-
- private TestSuite mSuiteRoot = new TestSuite(null);
-
- public void setDeviceSerial(String deviceSerial) {
- mDeviceSerial = deviceSerial;
- }
-
- public String getDeviceSerial() {
- return mDeviceSerial;
- }
-
- public String getId() {
- return AbiUtils.createId(getAbi(), getAppPackageName());
- }
-
- public void setAppPackageName(String appPackageName) {
- mAppPackageName = appPackageName;
- }
-
- public String getAppPackageName() {
- return mAppPackageName;
- }
-
- public void setName(String name) {
- mName = name;
- }
-
- public String getName() {
- return mName;
- }
-
- public void setAbi(String abi) {
- mAbi = abi;
- }
-
- public String getAbi() {
- return mAbi;
- }
-
- public void setDigest(String digest) {
- mDigest = digest;
- }
-
- public String getDigest() {
- return mDigest;
- }
-
- /**
- * Return the {@link TestSuite}s
- */
- public Collection<TestSuite> getTestSuites() {
- return mSuiteRoot.getTestSuites();
- }
-
- /**
- * Adds a test result to this test package
- *
- * @param testId
- */
- public Test insertTest(TestIdentifier testId) {
- return findTest(testId, true);
- }
-
- private Test findTest(TestIdentifier testId, boolean insertIfMissing) {
- List<String> classNameSegments = new LinkedList<String>();
- Collections.addAll(classNameSegments, testId.getClassName().split("\\."));
- if (classNameSegments.size() <= 0) {
- CLog.e("Unrecognized package name format for test class '%s'",
- testId.getClassName());
- // should never happen
- classNameSegments.add("UnknownTestClass");
- }
- String testCaseName = classNameSegments.remove(classNameSegments.size() - 1);
- return mSuiteRoot.findTest(classNameSegments, testCaseName, testId.getTestName(), insertIfMissing);
- }
-
-
- /**
- * Find the test result for given {@link TestIdentifier}.
- * @param testId
- * @return the {@link Test} or <code>null</code>
- */
- public Test findTest(TestIdentifier testId) {
- return findTest(testId, false);
- }
-
- /**
- * Serialize this object and all its contents to XML.
- *
- * @param serializer
- * @throws IOException
- */
- public void serialize(KXmlSerializer serializer) throws IOException {
- serializer.startTag(ns, TAG);
- serializeAttribute(serializer, NAME_ATTR, mName);
- serializeAttribute(serializer, APP_PACKAGE_NAME_ATTR, mAppPackageName);
- serializeAttribute(serializer, ABI_ATTR, mAbi);
- serializeAttribute(serializer, DIGEST_ATTR, getDigest());
- if (SIGNATURE_TEST_PKG.equals(mName)) {
- serializer.attribute(ns, "signatureCheck", "true");
- }
- mSuiteRoot.serialize(serializer);
- serializer.endTag(ns, TAG);
- }
-
- /**
- * Helper method to serialize attributes.
- * Can handle null values. Useful for cases where test package has not been fully populated
- * such as when unit testing.
- *
- * @param attrName
- * @param attrValue
- * @throws IOException
- */
- private void serializeAttribute(KXmlSerializer serializer, String attrName, String attrValue)
- throws IOException {
- attrValue = attrValue == null ? "" : attrValue;
- serializer.attribute(ns, attrName, attrValue);
- }
-
- /**
- * Populates this class with package result data parsed from XML.
- *
- * @param parser the {@link XmlPullParser}. Expected to be pointing at start
- * of TestPackage tag
- */
- @Override
- void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
- if (!parser.getName().equals(TAG)) {
- throw new XmlPullParserException(String.format(
- "invalid XML: Expected %s tag but received %s", TAG, parser.getName()));
- }
- setAppPackageName(getAttribute(parser, APP_PACKAGE_NAME_ATTR));
- setName(getAttribute(parser, NAME_ATTR));
- setAbi(getAttribute(parser, ABI_ATTR));
- setDigest(getAttribute(parser, DIGEST_ATTR));
- int eventType = parser.getEventType();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG && parser.getName().equals(TestSuite.TAG)) {
- TestSuite suite = new TestSuite();
- suite.parse(parser);
- mSuiteRoot.insertSuite(suite);
- }
- if (eventType == XmlPullParser.END_TAG && parser.getName().equals(TAG)) {
- return;
- }
- eventType = parser.next();
- }
- }
-
- /**
- * Return a list of {@link TestIdentifier}s contained in this result with the given status
- *
- * @param resultFilter the {@link CtsTestStatus} to filter by
- * @return a collection of {@link TestIdentifier}s
- */
- public Collection<TestIdentifier> getTestsWithStatus(CtsTestStatus resultFilter) {
- Collection<TestIdentifier> tests = new LinkedList<TestIdentifier>();
- Deque<String> suiteNames = new LinkedList<String>();
- mSuiteRoot.addTestsWithStatus(tests, suiteNames, resultFilter);
- return tests;
- }
-
- /**
- * Populate values in this package result from run metrics
- * @param metrics A map of metrics from the completed test run.
- */
- public void populateMetrics(Map<String, String> metrics) {
- String name = metrics.get(CtsTest.PACKAGE_NAME_METRIC);
- if (name != null) {
- setName(name);
- }
- String abi = metrics.get(CtsTest.PACKAGE_ABI_METRIC);
- if (abi != null) {
- setAbi(abi);
- }
- String digest = metrics.get(CtsTest.PACKAGE_DIGEST_METRIC);
- if (digest != null) {
- setDigest(digest);
- }
- mMetrics.putAll(metrics);
-
- // Collect performance results
- for (TestIdentifier test : mTestMetrics.keySet()) {
- // device test can have performance results in test metrics
- String perfResult = mTestMetrics.get(test).get(RESULT_KEY);
- ReportLog report = null;
- if (perfResult != null) {
- try {
- report = ReportLog.parse(perfResult);
- } catch (XmlPullParserException | IOException e) {
- e.printStackTrace();
- }
- }
- Test result = findTest(test);
- if (report != null && !result.getResult().equals(CtsTestStatus.FAIL)) {
- result.setResultStatus(CtsTestStatus.PASS);
- result.setReportLog(report);
- }
- }
- }
-
- /**
- * Report the given test as a failure.
- *
- * @param test
- * @param status
- * @param trace
- */
- public void reportTestFailure(TestIdentifier test, CtsTestStatus status, String trace) {
- Test result = findTest(test);
- result.setResultStatus(status);
- result.setStackTrace(trace);
- }
-
- /**
- * Report that the given test has completed.
- *
- * @param test The {@link TestIdentifier} of the completed test.
- * @param testMetrics A map holding metrics about the completed test, if any.
- */
- public void reportTestEnded(TestIdentifier test, Map<String, String> testMetrics) {
- Test result = findTest(test);
- if (!result.getResult().equals(CtsTestStatus.FAIL)) {
- result.setResultStatus(CtsTestStatus.PASS);
- }
- result.updateEndTime();
- if (mTestMetrics.containsKey(test)) {
- CLog.e("Test metrics already contains key: " + test);
- }
- mTestMetrics.put(test, testMetrics);
- CLog.i("Test metrics:" + testMetrics);
- }
-
- /**
- * Return the number of tests with given status
- *
- * @param status
- * @return the total number of tests with given status
- */
- public int countTests(CtsTestStatus status) {
- return mSuiteRoot.countTests(status);
- }
-
- /**
- * @return A map holding the metrics from the test run.
- */
- public Map<String, String> getMetrics() {
- return mMetrics;
- }
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResultRepo.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResultRepo.java
deleted file mode 100644
index fd42892..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResultRepo.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * An implementation of {@link ITestResultsRepo}.
- */
-public class TestResultRepo implements ITestResultRepo {
-
- /**
- * ordered list of result directories. the index of each file is its session id.
- */
- private List<File> mResultDirs;
-
- /**
- * Create a {@link TestResultRepo} from a directory of results
- *
- * @param testResultsDir the parent directory of results
- */
- public TestResultRepo(File testResultsDir) {
- mResultDirs = new ArrayList<File>();
- File[] resultArray = testResultsDir.listFiles(new ResultDirFilter());
- if (resultArray != null) {
- List<File> resultList = new ArrayList<File>();
- Collections.addAll(resultList, resultArray);
- Collections.sort(resultList, new FileComparator());
- for (int i=0; i < resultList.size(); i++) {
- File resultFile = new File(resultList.get(i),
- CtsXmlResultReporter.TEST_RESULT_FILE_NAME);
- if (resultFile.exists()) {
- mResultDirs.add(resultList.get(i));
- }
- }
- }
- }
-
- @Override
- public File getReportDir(int sessionId) {
- return mResultDirs.get(sessionId);
- }
-
- private ITestSummary parseSummary(int id, File resultDir) {
- TestSummaryXml result = new TestSummaryXml(id, resultDir.getName());
- try {
- result.parse(new BufferedReader(new FileReader(new File(resultDir,
- CtsXmlResultReporter.TEST_RESULT_FILE_NAME))));
- return result;
- } catch (ParseException e) {
- CLog.e(e);
- } catch (FileNotFoundException e) {
- // should never happen, since we check for file existence above. Barf the stack trace
- CLog.e(e);
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<ITestSummary> getSummaries() {
- // parsing the summary data should be relatively quick, so just parse it every time
- // rather than caching it
- List<ITestSummary> summaries = new ArrayList<ITestSummary>(mResultDirs.size());
- for (int i = 0; i < mResultDirs.size(); i++) {
- summaries.add(parseSummary(i, mResultDirs.get(i)));
- }
- return summaries;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TestResults getResult(int sessionId) {
- // TODO: consider caching the results in future
- if (mResultDirs.size() <= sessionId) {
- CLog.e("Session id %d does not exist", sessionId);
- return null;
- }
- try {
- TestResults results = new TestResults();
- File resultFile = new File(mResultDirs.get(sessionId),
- CtsXmlResultReporter.TEST_RESULT_FILE_NAME);
- results.parse(new BufferedReader(new FileReader(resultFile)));
- return results;
- } catch (FileNotFoundException e) {
- CLog.e("Could not find result file for session %d", sessionId);
- } catch (ParseException e) {
- CLog.e("Failed to parse result file for session %d", sessionId);
- }
- return null;
- }
-
- private class ResultDirFilter implements FileFilter {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean accept(File file) {
- return file.isDirectory();
- }
- }
-
- /**
- * A {@link Comparator} that compares {@link File}s by name.
- */
- private class FileComparator implements Comparator<File> {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int compare(File file0, File file1) {
- return file0.getName().compareTo(file1.getName());
- }
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResults.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResults.java
deleted file mode 100644
index d289b82..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResults.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.cts.tradefed.build.CtsBuildProvider;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.util.AbiUtils;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Data structure for the detailed CTS test results.
- * <p/>
- * Can deserialize results for test packages from XML
- */
-class TestResults extends AbstractXmlPullParser {
-
- private static final String ns = CtsXmlResultReporter.ns;
-
- // XML constants
- static final String SUMMARY_TAG = "Summary";
- static final String PASS_ATTR = "pass";
- static final String TIMEOUT_ATTR = "timeout";
- static final String NOT_EXECUTED_ATTR = "notExecuted";
- static final String FAILED_ATTR = "failed";
-
- private Map<String, TestPackageResult> mPackageResults =
- new LinkedHashMap<String, TestPackageResult>();
- private DeviceInfoResult mDeviceInfo = new DeviceInfoResult();
-
- /**
- * {@inheritDoc}
- */
- @Override
- void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
- int eventType = parser.getEventType();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
- DeviceInfoResult.TAG)) {
- mDeviceInfo.parse(parser);
- }
- if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
- TestPackageResult.TAG)) {
- TestPackageResult pkg = new TestPackageResult();
- pkg.parse(parser);
- if (pkg.getId() != null) {
- mPackageResults.put(pkg.getId(), pkg);
- } else {
- CLog.w("Found package with no id");
- }
- }
- eventType = parser.next();
- }
- }
-
- /**
- * @return the list of {@link TestPackageResult}.
- */
- public Collection<TestPackageResult> getPackages() {
- return mPackageResults.values();
- }
-
- /**
- * Count the number of tests with given status
- * @param status
- */
- public int countTests(CtsTestStatus status) {
- int total = 0;
- for (TestPackageResult result : mPackageResults.values()) {
- total += result.countTests(status);
- }
- return total;
- }
-
- /**
- * Serialize the test results to XML.
- *
- * @param serializer
- * @throws IOException
- */
- public void serialize(KXmlSerializer serializer, String buildId) throws IOException {
- mDeviceInfo.serialize(serializer);
- serializeHostInfo(serializer, buildId);
- serializeTestSummary(serializer);
- // sort before serializing
- List<TestPackageResult> pkgs = new ArrayList<TestPackageResult>(mPackageResults.values());
- Collections.sort(pkgs, new PkgComparator());
- for (TestPackageResult r : pkgs) {
- r.serialize(serializer);
- }
- }
-
- /**
- * Output the host info XML.
- *
- * @param serializer
- */
- private void serializeHostInfo(KXmlSerializer serializer, String buildId) throws IOException {
- serializer.startTag(ns, "HostInfo");
-
- String hostName = "";
- try {
- hostName = InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException ignored) {}
- serializer.attribute(ns, "name", hostName);
-
- serializer.startTag(ns, "Os");
- serializer.attribute(ns, "name", System.getProperty("os.name"));
- serializer.attribute(ns, "version", System.getProperty("os.version"));
- serializer.attribute(ns, "arch", System.getProperty("os.arch"));
- serializer.endTag(ns, "Os");
-
- serializer.startTag(ns, "Java");
- serializer.attribute(ns, "name", System.getProperty("java.vendor"));
- serializer.attribute(ns, "version", System.getProperty("java.version"));
- serializer.endTag(ns, "Java");
-
- serializer.startTag(ns, "Cts");
- serializer.attribute(ns, "version", CtsBuildProvider.CTS_BUILD_VERSION);
- serializer.attribute(ns, "build", buildId);
- // TODO: consider outputting other tradefed options here
- serializer.startTag(ns, "IntValue");
- serializer.attribute(ns, "name", "testStatusTimeoutMs");
- // TODO: create a constant variable for testStatusTimeoutMs value. Currently it cannot be
- // changed
- serializer.attribute(ns, "value", "600000");
- serializer.endTag(ns, "IntValue");
- serializer.endTag(ns, "Cts");
-
- serializer.endTag(ns, "HostInfo");
- }
-
- /**
- * Output the test summary XML containing summary totals for all tests.
- *
- * @param serializer
- * @throws IOException
- */
- private void serializeTestSummary(KXmlSerializer serializer) throws IOException {
- serializer.startTag(ns, SUMMARY_TAG);
- serializer.attribute(ns, FAILED_ATTR, Integer.toString(countTests(CtsTestStatus.FAIL)));
- serializer.attribute(ns, NOT_EXECUTED_ATTR,
- Integer.toString(countTests(CtsTestStatus.NOT_EXECUTED)));
- // ignore timeouts - these are reported as errors
- serializer.attribute(ns, TIMEOUT_ATTR, "0");
- serializer.attribute(ns, PASS_ATTR, Integer.toString(countTests(CtsTestStatus.PASS)));
- serializer.endTag(ns, SUMMARY_TAG);
- }
-
- private static class PkgComparator implements Comparator<TestPackageResult> {
-
- @Override
- public int compare(TestPackageResult lhs, TestPackageResult rhs) {
- return lhs.getId().compareTo(rhs.getId());
- }
- }
-
- /**
- * Return existing package with given id. If not found, create a new one.
- * @param id
- * @return
- */
- public TestPackageResult getOrCreatePackage(String id) {
- TestPackageResult pkgResult = mPackageResults.get(id);
- if (pkgResult == null) {
- pkgResult = new TestPackageResult();
- String[] abiAndName = AbiUtils.parseId(id);
- pkgResult.setAbi(abiAndName[0]);
- pkgResult.setAppPackageName(abiAndName[1]);
- mPackageResults.put(id, pkgResult);
- }
- return pkgResult;
- }
-
- /**
- * Populate the results with collected device info metrics.
- * @param runMetrics
- */
- public void populateDeviceInfoMetrics(Map<String, String> runMetrics) {
- mDeviceInfo.populateMetrics(runMetrics);
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSuite.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSuite.java
deleted file mode 100644
index ca287ca..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSuite.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Deque;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Data structure that represents a "TestSuite" XML element and its children.
- */
-class TestSuite extends AbstractXmlPullParser {
-
- static final String TAG = "TestSuite";
-
- private String mName;
-
- // use linked hash map for predictable iteration order
- Map<String, TestSuite> mChildSuiteMap = new LinkedHashMap<String, TestSuite>();
- Map<String, TestCase> mChildTestCaseMap = new LinkedHashMap<String, TestCase>();
-
- /**
- * @param testSuite
- */
- public TestSuite(String suiteName) {
- mName = suiteName;
- }
-
- public TestSuite() {
- }
-
- /**
- * @return the name of this suite
- */
- public String getName() {
- return mName;
- }
-
- /**
- * Set the name of this suite
- */
- public void setName(String name) {
- mName = name;
- }
-
- /**
- * Insert the given test result into this suite.
- *
- * @param suiteNames list of remaining suite names for this test
- * @param testClassName the test class name
- * @param testName the test method name
- * @param testResult the {@link TestResult}
- */
- public Test findTest(List<String> suiteNames, String testClassName, String testName,
- boolean insertIfMissing) {
- if (suiteNames.size() <= 0) {
- // no more package segments
- TestCase testCase = getTestCase(testClassName);
- return testCase.findTest(testName, insertIfMissing);
- } else {
- String rootName = suiteNames.remove(0);
- TestSuite suite = getTestSuite(rootName);
- return suite.findTest(suiteNames, testClassName, testName, insertIfMissing);
- }
- }
-
- /**
- * Gets all the child {@link TestSuite}s
- */
- public Collection<TestSuite> getTestSuites() {
- return mChildSuiteMap.values();
- }
-
- /**
- * Gets all the child {@link TestCase}s
- */
- public Collection<TestCase> getTestCases() {
- return mChildTestCaseMap.values();
- }
-
- /**
- * Get the child {@link TestSuite} with given name, creating if necessary.
- *
- * @param suiteName
- * @return the {@link TestSuite}
- */
- private TestSuite getTestSuite(String suiteName) {
- TestSuite testSuite = mChildSuiteMap.get(suiteName);
- if (testSuite == null) {
- testSuite = new TestSuite(suiteName);
- mChildSuiteMap.put(suiteName, testSuite);
- }
- return testSuite;
- }
-
- /**
- * Get the child {@link TestCase} with given name, creating if necessary.
- * @param testCaseName
- * @return
- */
- private TestCase getTestCase(String testCaseName) {
- TestCase testCase = mChildTestCaseMap.get(testCaseName);
- if (testCase == null) {
- testCase = new TestCase(testCaseName);
- mChildTestCaseMap.put(testCaseName, testCase);
- }
- return testCase;
- }
-
- /**
- * Serialize this object and all its contents to XML.
- *
- * @param serializer
- * @throws IOException
- */
- public void serialize(KXmlSerializer serializer) throws IOException {
- if (mName != null) {
- serializer.startTag(CtsXmlResultReporter.ns, TAG);
- serializer.attribute(CtsXmlResultReporter.ns, "name", mName);
- }
- for (TestSuite childSuite : mChildSuiteMap.values()) {
- childSuite.serialize(serializer);
- }
- for (TestCase childCase : mChildTestCaseMap.values()) {
- childCase.serialize(serializer);
- }
- if (mName != null) {
- serializer.endTag(CtsXmlResultReporter.ns, TAG);
- }
- }
-
- /**
- * Populates this class with suite result data parsed from XML.
- *
- * @param parser the {@link XmlPullParser}. Expected to be pointing at start
- * of a TestSuite tag
- */
- @Override
- void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
- if (!parser.getName().equals(TAG)) {
- throw new XmlPullParserException(String.format(
- "invalid XML: Expected %s tag but received %s", TAG, parser.getName()));
- }
- setName(getAttribute(parser, "name"));
- int eventType = parser.next();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG && parser.getName().equals(TestSuite.TAG)) {
- TestSuite suite = new TestSuite();
- suite.parse(parser);
- insertSuite(suite);
- } else if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
- TestCase.TAG)) {
- TestCase testCase = new TestCase();
- testCase.parse(parser);
- insertTestCase(testCase);
- } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(TAG)) {
- return;
- }
- eventType = parser.next();
- }
- }
-
- /**
- * Adds a child {@link TestCase}.
- */
- public void insertTestCase(TestCase testCase) {
- mChildTestCaseMap.put(testCase.getName(), testCase);
- }
-
- /**
- * Adds a child {@link TestSuite}.
- */
- public void insertSuite(TestSuite suite) {
- mChildSuiteMap.put(suite.getName(), suite);
- }
-
-
- /**
- * Adds tests contained in this result that have the given <var>resultFilter</var>
- *
- * @param tests the {@link Collection} of {@link TestIdentifier}s to add to
- * @param parentSuiteNames a {@link Deque} of parent suite names. Used to construct the full
- * class name of the test
- * @param resultFilter the {@link CtsTestStatus} to filter by
- */
- void addTestsWithStatus(Collection<TestIdentifier> tests, Deque<String> parentSuiteNames,
- CtsTestStatus resultFilter) {
- if (getName() != null) {
- parentSuiteNames.addLast(getName());
- }
- for (TestSuite suite : mChildSuiteMap.values()) {
- suite.addTestsWithStatus(tests, parentSuiteNames, resultFilter);
- }
- for (TestCase testCase : mChildTestCaseMap.values()) {
- testCase.addTestsWithStatus(tests, parentSuiteNames, resultFilter);
- }
- if (getName() != null) {
- parentSuiteNames.removeLast();
- }
- }
-
- /**
- * Count the number of tests in this {@link TestSuite} with given status.
- *
- * @param status
- * @return the test count
- */
- public int countTests(CtsTestStatus status) {
- int total = 0;
- for (TestSuite suite : mChildSuiteMap.values()) {
- total += suite.countTests(status);
- }
- for (TestCase testCase : mChildTestCaseMap.values()) {
- total += testCase.countTests(status);
- }
- return total;
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSummaryXml.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSummaryXml.java
deleted file mode 100644
index 36f3297..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSummaryXml.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import android.tests.getinfo.DeviceInfoConstants;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-/**
- * A {@link ITestSummary} that parses summary data from the CTS result XML.
- */
-public class TestSummaryXml extends AbstractXmlPullParser implements ITestSummary {
-
- private final int mId;
- private final String mTimestamp;
- private int mNumFailed = 0;
- private int mNumNotExecuted = 0;
- private int mNumPassed = 0;
- private String mPlan = "NA";
- private String mStartTime = "unknown";
- private String mDeviceSerials = "unknown";
-
- /**
- * @param id
- * @param resultFile
- * @throws ParseException
- * @throws FileNotFoundException
- */
- public TestSummaryXml(int id, String timestamp) {
- mId = id;
- mTimestamp = timestamp;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getId() {
- return mId;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getTimestamp() {
- return mTimestamp;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getNumIncomplete() {
- return mNumNotExecuted;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getNumFailed() {
- return mNumFailed;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getNumPassed() {
- return mNumPassed;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getTestPlan() {
- return mPlan ;
- }
-
-
- @Override
- void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
- int eventType = parser.getEventType();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
- CtsXmlResultReporter.RESULT_TAG)) {
- mPlan = getAttribute(parser, CtsXmlResultReporter.PLAN_ATTR);
- mStartTime = getAttribute(parser, CtsXmlResultReporter.STARTTIME_ATTR);
- } else if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
- DeviceInfoResult.BUILD_TAG)) {
- mDeviceSerials = getAttribute(parser, DeviceInfoConstants.SERIAL_NUMBER);
- } else if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
- TestResults.SUMMARY_TAG)) {
- mNumFailed = parseIntAttr(parser, TestResults.FAILED_ATTR) +
- parseIntAttr(parser, TestResults.TIMEOUT_ATTR);
- mNumNotExecuted = parseIntAttr(parser, TestResults.NOT_EXECUTED_ATTR);
- mNumPassed = parseIntAttr(parser, TestResults.PASS_ATTR);
- // abort after parsing Summary, which should be the last tag
- return;
- }
- eventType = parser.next();
- }
- throw new XmlPullParserException("Could not find Summary tag");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getStartTime() {
- return mStartTime;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getDeviceSerials() {
- return mDeviceSerials;
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TimeUtil.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TimeUtil.java
deleted file mode 100644
index fb737f9..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TimeUtil.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Utility class for formatting times as strings.
- */
-class TimeUtil {
-
- /**
- * Return a prettified version of the given elapsed time
- * @return
- */
- static String formatElapsedTime(long elapsedTimeMs) {
- long seconds = TimeUnit.MILLISECONDS.toSeconds(elapsedTimeMs) % 60;
- long minutes = TimeUnit.MILLISECONDS.toMinutes(elapsedTimeMs) % 60;
- long hours = TimeUnit.MILLISECONDS.toHours(elapsedTimeMs);
- StringBuilder time = new StringBuilder();
- if (hours > 0) {
- time.append(hours);
- time.append("h ");
- }
- if (minutes > 0) {
- time.append(minutes);
- time.append("m ");
- }
- time.append(seconds);
- time.append("s");
-
- return time.toString();
- }
-
- /**
- * Return the current timestamp as a {@link String} suitable for displaying.
- * <p/>
- * Example: Fri Aug 20 15:13:03 PDT 2010
- */
- static String getTimestamp() {
- return getTimestamp(System.currentTimeMillis());
- }
-
- /**
- * Return the given time as a {@link String} suitable for displaying.
- * <p/>
- * Example: Fri Aug 20 15:13:03 PDT 2010
- *
- * @param time the epoch time in ms since midnight Jan 1, 1970
- */
- static String getTimestamp(long time) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
- return dateFormat.format(new Date(time));
- }
-
- /**
- * Return the current timestamp in a compressed format, used to uniquely identify results.
- * <p/>
- * Example: 2010.08.16_11.42.12
- */
- static String getResultTimestamp() {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd_HH.mm.ss");
- return dateFormat.format(new Date());
- }
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsApkInstaller.java b/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsApkInstaller.java
deleted file mode 100644
index 0ad93b9..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsApkInstaller.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.targetprep;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.OptionClass;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.targetprep.TargetSetupError;
-import com.android.tradefed.targetprep.TestAppInstallSetup;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-
-/**
- * Installs specified apks from CTS test case repository
- */
-@OptionClass(alias="cts-apk-installer")
-public class CtsApkInstaller extends TestAppInstallSetup {
-
- private CtsBuildHelper mBuildHelper = null;
-
- protected CtsBuildHelper getCtsBuildHelper(IBuildInfo buildInfo) {
- if (mBuildHelper == null) {
- mBuildHelper = CtsBuildHelper.createBuildHelper(buildInfo);
- }
- return mBuildHelper;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected File getLocalPathForFilename(IBuildInfo buildInfo, String apkFileName,
- ITestDevice device) throws TargetSetupError {
- try {
- return getCtsBuildHelper(buildInfo).getTestApp(apkFileName);
- } catch (FileNotFoundException e) {
- throw new TargetSetupError(String.format("apk not found: %s", apkFileName), e,
- device.getDeviceDescriptor());
- }
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsFilePusher.java b/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsFilePusher.java
deleted file mode 100644
index c6ae2e1..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsFilePusher.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.targetprep;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.OptionClass;
-import com.android.tradefed.targetprep.PushFilePreparer;
-
-import java.io.File;
-
-/**
- * Pushes specified testing artifacts from CTS test case repository
- */
-@OptionClass(alias="cts-file-pusher")
-public class CtsFilePusher extends PushFilePreparer {
-
- private CtsBuildHelper mBuildHelper;
-
- protected CtsBuildHelper getCtsBuildHelper(IBuildInfo buildInfo) {
- if (mBuildHelper == null) {
- mBuildHelper = CtsBuildHelper.createBuildHelper(buildInfo);
- }
- return mBuildHelper;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public File resolveRelativeFilePath(IBuildInfo buildInfo, String fileName) {
- return new File(getCtsBuildHelper(buildInfo).getTestCasesDir(), fileName);
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsRootDeviceSetup.java b/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsRootDeviceSetup.java
deleted file mode 100644
index f75a99e..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsRootDeviceSetup.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.targetprep;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.targetprep.DeviceSetup;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.targetprep.TargetSetupError;
-
-import java.io.FileNotFoundException;
-
-/**
- * A {@link ITargetPreparer} that attempts to automatically perform the CTS-specific manual steps
- * for setting up a device for CTS testing.
- * <p/>
- * This class is NOT intended for 'official' CTS runs against a production device as the steps
- * performed by this class require a debug build (aka 'adb root' must succeed).
- * <p/>
- * This class currently performs the 'Allow mock locations' and 'accessibililty setup' steps
- * documented in the CTS user manual. It is intended to be used in conjunction with
- * a {@link DeviceSetup} which will enable the 'Stay Awake' setting and verify that external
- * storage is present.
- */
-public class CtsRootDeviceSetup implements ITargetPreparer {
-
- private static final String DEVICE_ADMIN_APK_FILE_NAME = "CtsAdminApp.apk";
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setUp(ITestDevice device, IBuildInfo buildInfo) throws TargetSetupError,
- DeviceNotAvailableException {
- if (!(buildInfo instanceof IFolderBuildInfo)) {
- throw new IllegalArgumentException("Provided buildInfo is not a IFolderBuildInfo");
- }
- CLog.i("Setting up %s to run CTS tests", device.getSerialNumber());
-
- IFolderBuildInfo ctsBuild = (IFolderBuildInfo)buildInfo;
- try {
- CtsBuildHelper buildHelper = new CtsBuildHelper(ctsBuild.getRootDir());
-
- if (!device.enableAdbRoot()) {
- throw new TargetSetupError(String.format(
- "Failed to set root on device %s.", device.getSerialNumber()));
- }
-
- // perform CTS setup steps that only work if adb is root
- SettingsToggler.setSecureInt(device, "mock_location", 1);
- enableDeviceAdmin(device, buildHelper);
- // This is chrome specific setting to disable the first screen.
- // For other browser, it will not do anything.
- device.executeShellCommand(
- "echo \"chrome --disable-fre\" > /data/local/chrome-command-line");
- // end root setup steps
- } catch (FileNotFoundException e) {
- throw new TargetSetupError("Invalid CTS installation", e);
- }
- }
-
- private void enableDeviceAdmin(ITestDevice device, CtsBuildHelper ctsBuild)
- throws DeviceNotAvailableException, TargetSetupError, FileNotFoundException {
- String errorCode = device.installPackage(ctsBuild.getTestApp(DEVICE_ADMIN_APK_FILE_NAME),
- true);
- if (errorCode != null) {
- // TODO: retry ?
- throw new TargetSetupError(String.format(
- "Failed to install %s on device %s. Reason: %s",
- DEVICE_ADMIN_APK_FILE_NAME, device.getSerialNumber(), errorCode));
- }
- // TODO: enable device admin Settings
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/SettingsToggler.java b/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/SettingsToggler.java
deleted file mode 100644
index ff6c4f4..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/SettingsToggler.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.targetprep;
-
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-
-/**
- * {@link SettingsToggler} sets settings by using the "adb shell content" command.
- */
-public class SettingsToggler {
- private static final String GROUP_SECURE = "secure";
- private static final String GROUP_GLOBAL = "global";
-
- /** Sets a setting by deleting and then inserting the string value. */
- public static void setString(ITestDevice device, String group, String name, String value)
- throws DeviceNotAvailableException {
- deleteSetting(device, group, name);
- device.executeShellCommand(
- "content insert"
- + " --uri content://settings/" + group
- + " --bind name:s:" + name
- + " --bind value:s:" + value);
- }
-
- /** Sets a secure setting by deleting and then inserting the string value. */
- public static void setSecureString(ITestDevice device, String name, String value)
- throws DeviceNotAvailableException {
- setString(device, GROUP_SECURE, name, value);
- }
-
- /** Sets a global setting by deleting and then inserting the string value. */
- public static void setGlobalString(ITestDevice device, String name, String value)
- throws DeviceNotAvailableException {
- setString(device, GROUP_GLOBAL, name, value);
- }
-
- /** Sets a setting by deleting and then inserting the int value. */
- public static void setInt(ITestDevice device, String group, String name, int value)
- throws DeviceNotAvailableException {
- deleteSetting(device, group, name);
- device.executeShellCommand(
- "content insert"
- + " --uri content://settings/" + group
- + " --bind name:s:" + name
- + " --bind value:i:" + value);
- }
-
- /** Sets a secure setting by deleting and then inserting the int value. */
- public static void setSecureInt(ITestDevice device, String name, int value)
- throws DeviceNotAvailableException {
- setInt(device, GROUP_SECURE, name, value);
- }
-
- /** Sets a global setting by deleting and then inserting the int value. */
- public static void setGlobalInt(ITestDevice device, String name, int value)
- throws DeviceNotAvailableException {
- setInt(device, GROUP_GLOBAL, name, value);
- }
-
- public static void updateString(ITestDevice device, String group, String name, String value)
- throws DeviceNotAvailableException {
- device.executeShellCommand(
- "content update"
- + " --uri content://settings/" + group
- + " --bind value:s:" + value
- + " --where \"name='" + name + "'\"");
- }
-
- public static void updateSecureString(ITestDevice device, String name, String value)
- throws DeviceNotAvailableException {
- updateString(device, GROUP_SECURE, name, value);
- }
-
- public static void updateGlobalString(ITestDevice device, String name, String value)
- throws DeviceNotAvailableException {
- updateString(device, GROUP_GLOBAL, name, value);
- }
-
- public static void updateInt(ITestDevice device, String group, String name, int value)
- throws DeviceNotAvailableException {
- device.executeShellCommand(
- "content update"
- + " --uri content://settings/" + group
- + " --bind value:i:" + value
- + " --where \"name='" + name + "'\"");
- }
-
- public static void updateSecureInt(ITestDevice device, String name, int value)
- throws DeviceNotAvailableException {
- updateInt(device, GROUP_SECURE, name, value);
- }
-
- public static void updateGlobalInt(ITestDevice device, String name, int value)
- throws DeviceNotAvailableException {
- updateInt(device, GROUP_GLOBAL, name, value);
- }
-
- private static void deleteSetting(ITestDevice device, String group, String name)
- throws DeviceNotAvailableException {
- device.executeShellCommand(
- "content delete"
- + " --uri content://settings/" + group
- + " --where \"name='" + name + "'\"");
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java
deleted file mode 100644
index e903e9a..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.Log;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.InstrumentationTest;
-import com.android.tradefed.util.AbiUtils;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * An {@link InstrumentationTest} that will install CTS apks
- * before test execution, and uninstall on execution completion.
- */
-public class CtsInstrumentationApkTest extends InstrumentationTest implements IBuildReceiver {
-
- private static final String LOG_TAG = "CtsInstrumentationApkTest";
-
- /** the file names of the CTS apks to install */
- private Collection<String> mInstallFileNames = new ArrayList<String>();
- private Collection<String> mUninstallPackages = new ArrayList<String>();
- protected CtsBuildHelper mCtsBuild = null;
- protected IAbi mAbi = null;
-
- /**
- * @param abi the ABI to run the test on
- */
- public void setAbi(IAbi abi) {
- mAbi = abi;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setBuild(IBuildInfo build) {
- mCtsBuild = CtsBuildHelper.createBuildHelper(build);
- }
-
- /**
- * Add an apk to install.
- *
- * @param apkFileName the apk file name
- * @param packageName the apk's Android package name
- */
- public void addInstallApk(String apkFileName, String packageName) {
- mInstallFileNames.add(apkFileName);
- mUninstallPackages.add(packageName);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run(final ITestInvocationListener listener)
- throws DeviceNotAvailableException {
- ITestDevice testDevice = getDevice();
-
- if (testDevice == null) {
- Log.e(LOG_TAG, "Missing device.");
- return;
- }
- if (mCtsBuild == null) {
- Log.e(LOG_TAG, "Missing build");
- return;
- }
- boolean success = true;
- for (String apkFileName : mInstallFileNames) {
- Log.d(LOG_TAG, String.format("Installing %s on %s", apkFileName,
- testDevice.getSerialNumber()));
- try {
- File apkFile = mCtsBuild.getTestApp(apkFileName);
- String errorCode = null;
- String[] options = {AbiUtils.createAbiFlag(mAbi.getName())};
- errorCode = testDevice.installPackage(apkFile, true, options);
- if (errorCode != null) {
- Log.e(LOG_TAG, String.format("Failed to install %s on %s. Reason: %s",
- apkFileName, testDevice.getSerialNumber(), errorCode));
- success = false;
- }
- } catch (FileNotFoundException e) {
- Log.e(LOG_TAG, String.format("Could not find file %s", apkFileName));
- success = false;
- }
- }
- if (success) {
- super.run(listener);
- }
- for (String packageName : mUninstallPackages) {
- Log.d(LOG_TAG, String.format("Uninstalling %s on %s", packageName,
- testDevice.getSerialNumber()));
- testDevice.uninstallPackage(packageName);
- }
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
deleted file mode 100644
index c25eb4d..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
+++ /dev/null
@@ -1,1228 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.MonitoringUtils;
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.tradefed.device.DeviceInfoCollector;
-import com.android.cts.tradefed.result.CtsTestStatus;
-import com.android.cts.tradefed.result.PlanCreator;
-import com.android.cts.tradefed.util.ReportLogUtil;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.Option.Importance;
-import com.android.tradefed.config.OptionCopier;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.DeviceUnresponsiveException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.device.TestDeviceOptions;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.InputStreamSource;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.ResultForwarder;
-import com.android.tradefed.targetprep.BuildError;
-import com.android.tradefed.targetprep.ITargetCleaner;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.targetprep.TargetSetupError;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IAbiReceiver;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.IResumableTest;
-import com.android.tradefed.testtype.IShardableTest;
-import com.android.tradefed.testtype.InstrumentationTest;
-import com.android.tradefed.util.AbiFormatter;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.RunUtil;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import junit.framework.Test;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-
-
-/**
- * A {@link Test} for running CTS tests.
- * <p/>
- * Supports running all the tests contained in a CTS plan, or individual test packages.
- */
-public class CtsTest implements IDeviceTest, IResumableTest, IShardableTest, IBuildReceiver {
- private static final String LOG_TAG = "CtsTest";
-
- public static final String PLAN_OPTION = "plan";
- private static final String PACKAGE_OPTION = "package";
- private static final String CLASS_OPTION = "class";
- private static final String METHOD_OPTION = "method";
- private static final String TEST_OPTION = "test";
- public static final String CONTINUE_OPTION = "continue-session";
- public static final String RUN_KNOWN_FAILURES_OPTION = "run-known-failures";
- private static final String INCLUDE_FILTERS_OPTION = "include";
- private static final String EXCLUDE_FILTERS_OPTION = "exclude";
-
- public static final String PACKAGE_NAME_METRIC = "packageName";
- public static final String PACKAGE_ABI_METRIC = "packageAbi";
- public static final String PACKAGE_DIGEST_METRIC = "packageDigest";
-
- @Option(name = PLAN_OPTION, description = "the test plan to run.",
- importance = Importance.IF_UNSET)
- private String mPlanName = null;
-
- @Option(name = PACKAGE_OPTION, shortName = 'p', description = "the test packages(s) to run.",
- importance = Importance.IF_UNSET)
- private Collection<String> mPackageNames = new ArrayList<String>();
-
- @Option(name = "exclude-package", description = "the test packages(s) to exclude from the run.")
- private Collection<String> mExcludedPackageNames = new ArrayList<String>();
-
- @Option(name = CLASS_OPTION, shortName = 'c', description = "run a specific test class.",
- importance = Importance.IF_UNSET)
- private String mClassName = null;
-
- @Option(name = METHOD_OPTION, shortName = 'm',
- description = "run a specific test method, from given --class.",
- importance = Importance.IF_UNSET)
- private String mMethodName = null;
-
- @Option(name = TEST_OPTION, shortName = 't', description = "run a specific test",
- importance = Importance.IF_UNSET)
- private String mTestName = null;
-
- @Option(name = CONTINUE_OPTION,
- description = "continue a previous test session.",
- importance = Importance.IF_UNSET)
- private Integer mContinueSessionId = null;
-
- @Option(name = "skip-device-info", shortName = 'd', description =
- "flag to control whether to collect info from device. Providing this flag will speed up " +
- "test execution for short test runs but will result in required data being omitted from " +
- "the test report.")
- private boolean mSkipDeviceInfo = false;
-
- @Option(name = "resume", description =
- "flag to attempt to automatically resume aborted test run on another connected device. ")
- private boolean mResume = false;
-
- @Option(name = "shards", description =
- "shard the tests to run into separately runnable chunks to execute on multiple devices " +
- "concurrently.")
- private int mShards = 1;
-
- @Option(name = "screenshot", description =
- "flag for taking a screenshot of the device when test execution is complete.")
- private boolean mScreenshot = false;
-
- @Option(name = "bugreport", shortName = 'b', description =
- "take a bugreport after each failed test. " +
- "Warning: can potentially use a lot of disk space.")
- private boolean mBugreport = false;
-
- @Option(name = RUN_KNOWN_FAILURES_OPTION, shortName = 'k', description =
- "run tests including known failures")
- private boolean mIncludeKnownFailures;
-
- @Option(name = "disable-reboot", description =
- "Do not reboot device after running some amount of tests. Default behavior is to reboot.")
- private boolean mDisableReboot = false;
-
- @Option(name = "reboot-wait-time", description =
- "Additional wait time in ms after boot complete.")
- private int mRebootWaitTimeMSec = 2 * 60 * 1000;
-
- @Option(name = "reboot-interval", description =
- "Interval between each reboot in min.")
- private int mRebootIntervalMin = 30;
-
- @Option(name = "screenshot-on-failure", description =
- "take a screenshot on every test failure.")
- private boolean mScreenshotOnFailures = false;
-
- @Option(name = "logcat-on-failure", description =
- "take a logcat snapshot on every test failure. Unlike --bugreport, this can capture" +
- "logs even if connection with device has been lost, as well as being much more " +
- "performant.")
- private boolean mLogcatOnFailures = false;
-
- @Option(name = AbiFormatter.FORCE_ABI_STRING,
- description = AbiFormatter.FORCE_ABI_DESCRIPTION,
- importance = Importance.IF_UNSET)
- private String mForceAbi = null;
-
- @Option(name = "logcat-on-failure-size", description =
- "The max number of logcat data in bytes to capture when --logcat-on-failure is on. " +
- "Should be an amount that can comfortably fit in memory.")
- private int mMaxLogcatBytes = 500 * 1024; // 500K
-
- @Option(name = "collect-deqp-logs", description =
- "Collect dEQP logs from the device.")
- private boolean mCollectDeqpLogs = false;
-
- @Option(name = INCLUDE_FILTERS_OPTION, description = "Positive filters to pass to tests.")
- private List<String> mPositiveFilters = new ArrayList<> ();
-
- @Option(name = EXCLUDE_FILTERS_OPTION, description = "Negative filters to pass to tests.")
- private List<String> mNegativeFilters = new ArrayList<> ();
-
- @Option(name = "min-pre-reboot-package-count", description =
- "The minimum number of packages to require a pre test reboot")
- private int mMinPreRebootPackageCount = 2;
-
- @Option(name = "skip-connectivity-check",
- description = "Don't verify device connectivity between module execution.")
- private boolean mSkipConnectivityCheck = false;
-
- private final int mShardAssignment;
- private final int mTotalShards;
- private ITestDevice mDevice = null;
- private CtsBuildHelper mCtsBuild = null;
- private IBuildInfo mBuildInfo = null;
- // last reboot time
- private long mPrevRebootTime;
- // The list of packages to run. populated in {@code setupTestPackageList}
- // This is a member variable so that run can be called more than once
- // and the test run is resumed.
- private List<TestPackage> mTestPackageList = new ArrayList<>();
- // The index in the pacakge list of the last test to complete
- private int mLastTestPackageIndex = 0;
-
- /** data structure for a {@link IRemoteTest} and its known tests */
- static class TestPackage {
- private final IRemoteTest mTestForPackage;
- private final ITestPackageDef mPackageDef;
- private final Collection<TestIdentifier> mKnownTests;
-
- TestPackage(ITestPackageDef packageDef, IRemoteTest testForPackage) {
- mPackageDef = packageDef;
- mTestForPackage = testForPackage;
- mKnownTests = packageDef.getTests();
- }
-
- IRemoteTest getTestForPackage() {
- return mTestForPackage;
- }
-
- Collection<TestIdentifier> getKnownTests() {
- return mKnownTests;
- }
-
- ITestPackageDef getPackageDef() {
- return mPackageDef;
- }
-
- /**
- * @return the test run name that should be used for the TestPackage.
- */
- String getTestRunName() {
- return mPackageDef.getId();
- }
-
- /**
- * @return the ABI on which the test will run.
- */
- IAbi getAbi() {
- return mPackageDef.getAbi();
- }
- }
-
- /**
- * A {@link ResultForwarder} that will forward a bugreport on each failed test.
- */
- private static class FailedTestBugreportGenerator extends ResultForwarder {
- private ITestDevice mDevice;
-
- public FailedTestBugreportGenerator(ITestInvocationListener listener, ITestDevice device) {
- super(listener);
- mDevice = device;
- }
-
- @Override
- public void testFailed(TestIdentifier test, String trace) {
- super.testFailed(test, trace);
- InputStreamSource bugSource = mDevice.getBugreport();
- super.testLog(String.format("bug-%s_%s", test.getClassName(), test.getTestName()),
- LogDataType.TEXT, bugSource);
- bugSource.cancel();
- }
- }
-
- /**
- * A {@link ResultForwarder} that will forward a logcat snapshot on each failed test.
- */
- private static class FailedTestLogcatGenerator extends ResultForwarder {
- private ITestDevice mDevice;
- private int mNumLogcatBytes;
-
- public FailedTestLogcatGenerator(ITestInvocationListener listener, ITestDevice device,
- int maxLogcatBytes) {
- super(listener);
- mDevice = device;
- mNumLogcatBytes = maxLogcatBytes;
- }
-
- @Override
- public void testFailed(TestIdentifier test, String trace) {
- super.testFailed(test, trace);
- // sleep 2s to ensure test failure stack trace makes it into logcat capture
- RunUtil.getDefault().sleep(2 * 1000);
- InputStreamSource logSource = mDevice.getLogcat(mNumLogcatBytes);
- super.testLog(String.format("logcat-%s_%s", test.getClassName(), test.getTestName()),
- LogDataType.TEXT, logSource);
- logSource.cancel();
- }
- }
-
- /**
- * A {@link ResultForwarder} that will forward a screenshot on test failures.
- */
- private static class FailedTestScreenshotGenerator extends ResultForwarder {
- private ITestDevice mDevice;
-
- public FailedTestScreenshotGenerator(ITestInvocationListener listener,
- ITestDevice device) {
- super(listener);
- mDevice = device;
- }
-
- @Override
- public void testFailed(TestIdentifier test, String trace) {
- super.testFailed(test, trace);
-
- try {
- InputStreamSource screenSource = mDevice.getScreenshot();
- super.testLog(String.format("screenshot-%s_%s", test.getClassName(),
- test.getTestName()), LogDataType.PNG, screenSource);
- screenSource.cancel();
- } catch (DeviceNotAvailableException e) {
- // TODO: rethrow this somehow
- CLog.e("Device %s became unavailable while capturing screenshot, %s",
- mDevice.getSerialNumber(), e.toString());
- }
- }
- }
-
- /**
- * Create a new {@link CtsTest} that will run the default list of {@link TestPackage}s.
- */
- public CtsTest() {
- this(0 /*shardAssignment*/, 1 /*totalShards*/);
- }
-
- /**
- * Create a new {@link CtsTest} that will run the given {@link List} of {@link TestPackage}s.
- */
- public CtsTest(int shardAssignment, int totalShards) {
- if (shardAssignment < 0) {
- throw new IllegalArgumentException(
- "shardAssignment cannot be negative. found:" + shardAssignment);
- }
- if (totalShards < 1) {
- throw new IllegalArgumentException(
- "shardAssignment must be at least 1. found:" + totalShards);
- }
- this.mShardAssignment = shardAssignment;
- this.mTotalShards = totalShards;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ITestDevice getDevice() {
- return mDevice;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setDevice(ITestDevice device) {
- mDevice = device;
- }
-
- /**
- * Set the plan name to run.
- * <p/>
- * Exposed for unit testing
- */
- void setPlanName(String planName) {
- mPlanName = planName;
- }
-
- /**
- * Set the skip collect device info flag.
- * <p/>
- * Exposed for unit testing
- */
- void setSkipDeviceInfo(boolean skipDeviceInfo) {
- mSkipDeviceInfo = skipDeviceInfo;
- }
-
- /**
- * Adds a package name to the list of test packages to run.
- * <p/>
- * Exposed for unit testing
- */
- void addPackageName(String packageName) {
- mPackageNames.add(packageName);
- }
-
- /**
- * Adds a package name to the list of test packages to exclude.
- * <p/>
- * Exposed for unit testing
- */
- void addExcludedPackageName(String packageName) {
- mExcludedPackageNames.add(packageName);
- }
-
- /**
- * Set the test class name to run.
- * <p/>
- * Exposed for unit testing
- */
- void setClassName(String className) {
- mClassName = className;
- }
-
- /**
- * Set the test method name to run.
- * <p/>
- * Exposed for unit testing
- */
- void setMethodName(String methodName) {
- mMethodName = methodName;
- }
-
- /**
- * Set the test name to run e.g. android.test.cts.SampleTest#testSample
- * <p/>
- * Exposed for unit testing
- */
- void setTestName(String testName) {
- mTestName = testName;
- }
-
- /**
- * Sets the test session id to continue.
- * <p/>
- * Exposed for unit testing
- */
- void setContinueSessionId(int sessionId) {
- mContinueSessionId = sessionId;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isResumable() {
- return mResume;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setBuild(IBuildInfo build) {
- mCtsBuild = CtsBuildHelper.createBuildHelper(build);
- mBuildInfo = build;
- }
-
- /**
- * Set the CTS build container.
- * <p/>
- * Exposed so unit tests can mock the provided build.
- */
- void setBuildHelper(CtsBuildHelper buildHelper) {
- mCtsBuild = buildHelper;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- if (getDevice() == null) {
- throw new IllegalArgumentException("missing device");
- }
-
- Set<String> abiSet = getAbis();
- if (abiSet == null || abiSet.isEmpty()) {
- throw new IllegalArgumentException("could not get device's ABIs");
- }
- Log.logAndDisplay(LogLevel.INFO, LOG_TAG, "ABIs: " + abiSet);
-
- checkFields();
- setupTestPackageList(abiSet);
- if (mBugreport) {
- listener = new FailedTestBugreportGenerator(listener, getDevice());
- }
- if (mScreenshotOnFailures) {
- listener = new FailedTestScreenshotGenerator(listener, getDevice());
- }
- if (mLogcatOnFailures) {
- listener = new FailedTestLogcatGenerator(listener, getDevice(), mMaxLogcatBytes);
- }
-
- // Setup the a map of Test id to ResultFilter
- Map<String, ResultFilter> filterMap = new HashMap<>();
- int totalTestCount = 0;
- for (TestPackage testPackage : mTestPackageList) {
- ResultFilter resultFilter = new ResultFilter(listener, testPackage);
- totalTestCount += resultFilter.getKnownTestCount();
- filterMap.put(testPackage.getPackageDef().getId(), resultFilter);
- }
-
- // collect and install the prerequisiteApks first, to save time when multiple test
- // packages are using the same prerequisite apk
- Map<String, Set<String>> prerequisiteApks = getPrerequisiteApks(mTestPackageList, abiSet);
- Collection<String> uninstallPackages = getPrerequisitePackageNames(mTestPackageList);
-
- try {
- // always collect the device info, even for resumed runs, since test will likely be
- // running on a different device
- collectDeviceInfo(getDevice(), mCtsBuild, listener);
- // prepare containers to hold test metric report logs.
- prepareReportLogContainers(getDevice(), mBuildInfo);
- preRebootIfNecessary(mTestPackageList);
-
- mPrevRebootTime = System.currentTimeMillis();
- int remainingPackageCount = mTestPackageList.size();
- Log.logAndDisplay(LogLevel.INFO, LOG_TAG,
- String.format("Start test run of %,d packages, containing %,d tests",
- remainingPackageCount, totalTestCount));
- IAbi currentAbi = null;
-
- // check connectivity upfront
- if (!mSkipConnectivityCheck) {
- MonitoringUtils.checkDeviceConnectivity(getDevice(), listener, "start");
- }
- for (int i = mLastTestPackageIndex; i < mTestPackageList.size(); i++) {
- TestPackage testPackage = mTestPackageList.get(i);
-
- if (currentAbi == null ||
- !currentAbi.getName().equals(testPackage.getAbi().getName())) {
- currentAbi = testPackage.getAbi();
- installPrerequisiteApks(
- prerequisiteApks.get(currentAbi.getName()), currentAbi);
- }
-
- IRemoteTest test = testPackage.getTestForPackage();
- if (test instanceof IBuildReceiver) {
- ((IBuildReceiver) test).setBuild(mBuildInfo);
- }
- if (test instanceof IDeviceTest) {
- ((IDeviceTest) test).setDevice(getDevice());
- }
- if (test instanceof DeqpTestRunner) {
- ((DeqpTestRunner)test).setCollectLogs(mCollectDeqpLogs);
- }
- if (test instanceof GeeTest) {
- if (!mPositiveFilters.isEmpty()) {
- String positivePatterns = join(mPositiveFilters, ":");
- ((GeeTest)test).setPositiveFilters(positivePatterns);
- }
- if (!mNegativeFilters.isEmpty()) {
- String negativePatterns = join(mNegativeFilters, ":");
- ((GeeTest)test).setPositiveFilters(negativePatterns);
- }
- }
- if (test instanceof InstrumentationTest) {
- if (!mPositiveFilters.isEmpty()) {
- String annotation = join(mPositiveFilters, ",");
- ((InstrumentationTest)test).addInstrumentationArg(
- "annotation", annotation);
- }
- if (!mNegativeFilters.isEmpty()) {
- String notAnnotation = join(mNegativeFilters, ",");
- ((InstrumentationTest)test).addInstrumentationArg(
- "notAnnotation", notAnnotation);
- }
- }
-
- forwardPackageDetails(testPackage.getPackageDef(), listener);
- try {
- performPackagePrepareSetup(testPackage.getPackageDef());
- test.run(filterMap.get(testPackage.getPackageDef().getId()));
- performPackagePreparerTearDown(testPackage.getPackageDef());
- } catch (DeviceUnresponsiveException due) {
- // being able to catch a DeviceUnresponsiveException here implies that recovery
- // was successful, and test execution should proceed to next module
- ByteArrayOutputStream stack = new ByteArrayOutputStream();
- due.printStackTrace(new PrintWriter(stack, true));
- try {
- stack.close();
- } catch (IOException ioe) {
- // won't happen on BAOS
- }
- CLog.w("Ignored DeviceUnresponsiveException because recovery was successful, "
- + "proceeding with next test package. Stack trace: %s",
- stack.toString());
- CLog.w("This may be due to incorrect timeout setting on test package %s",
- testPackage.getPackageDef().getName());
- }
- if (!mSkipConnectivityCheck) {
- MonitoringUtils.checkDeviceConnectivity(getDevice(), listener,
- String.format("%s-%s", testPackage.getPackageDef().getName(),
- testPackage.getPackageDef().getAbi().getName()));
- }
- if (i < mTestPackageList.size() - 1) {
- TestPackage nextPackage = mTestPackageList.get(i + 1);
- rebootIfNecessary(testPackage, nextPackage);
- changeToHomeScreen();
- }
- // Track of the last complete test package index for resume
- mLastTestPackageIndex = i;
- }
-
- if (mScreenshot) {
- InputStreamSource screenshotSource = getDevice().getScreenshot();
- try {
- listener.testLog("screenshot", LogDataType.PNG, screenshotSource);
- } finally {
- screenshotSource.cancel();
- }
- }
-
- uninstallPrequisiteApks(uninstallPackages);
- // Collect test metric report logs.
- collectReportLogs(getDevice(), mBuildInfo);
- } catch (RuntimeException e) {
- CLog.e(e);
- throw e;
- } catch (Error e) {
- CLog.e(e);
- throw e;
- } finally {
- for (ResultFilter filter : filterMap.values()) {
- filter.reportUnexecutedTests();
- }
- }
- }
-
- /**
- * Invokes {@link ITargetPreparer}s configured for the test package. {@link TargetSetupError}s
- * thrown by any preparer will be rethrown as {@link RuntimeException} so that the entire test
- * package will be skipped for execution. Note that preparers will be invoked in the same order
- * as they are defined in the module test config.
- * @param packageDef definition for the test package
- * @throws DeviceNotAvailableException
- */
- private void performPackagePrepareSetup(ITestPackageDef packageDef)
- throws DeviceNotAvailableException {
- List<ITargetPreparer> preparers = packageDef.getPackagePreparers();
- if (preparers != null) {
- for (ITargetPreparer preparer : preparers) {
- if (preparer instanceof IAbiReceiver) {
- ((IAbiReceiver) preparer).setAbi(packageDef.getAbi());
- }
- try {
- preparer.setUp(getDevice(), mBuildInfo);
- } catch (BuildError e) {
- // This should only happen for flashing new build
- CLog.e("Unexpected BuildError from preparer: %s",
- preparer.getClass().getCanonicalName());
- } catch (TargetSetupError e) {
- // log preparer class then rethrow & let caller handle
- CLog.e("TargetSetupError in preparer: %s",
- preparer.getClass().getCanonicalName());
- throw new RuntimeException(e);
- }
- }
- }
- }
-
- /**
- * Invokes clean up step for {@link ITargetCleaner}s configured for the test package. Note that
- * the cleaners will be invoked in the reverse order as they are defined in module test config.
- * @param packageDef definition for the test package
- * @throws DeviceNotAvailableException
- */
- private void performPackagePreparerTearDown(ITestPackageDef packageDef)
- throws DeviceNotAvailableException {
- List<ITargetPreparer> preparers = packageDef.getPackagePreparers();
- if (preparers != null) {
- ListIterator<ITargetPreparer> itr = preparers.listIterator(preparers.size());
- // do teardown in reverse order
- while (itr.hasPrevious()) {
- ITargetPreparer preparer = itr.previous();
- if (preparer instanceof ITargetCleaner) {
- ((ITargetCleaner) preparer).tearDown(getDevice(), mBuildInfo, null);
- }
- }
- }
- }
-
- /**
- * Helper method to join strings. Exposed for unit tests
- * @param input
- * @param conjunction
- * @return string with elements of the input list with interleaved conjunction.
- */
- protected static String join(List<String> input, String conjunction) {
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (String item : input) {
- if (first) {
- first = false;
- } else {
- sb.append(conjunction);
- }
- sb.append(item);
- }
- return sb.toString();
- }
-
- /**
- * @param allTestPackageDefList The package list to filter
- * @param deviceAbiSet The ABIs supported by the device being tested
- * @return A {@link List} of {@link ITestPackageDef}s that should be tested
- */
- private static List<ITestPackageDef> filterByAbi(
- List<ITestPackageDef> allTestPackageDefList, Set<String> deviceAbiSet) {
- List<ITestPackageDef> filteredTestPackageDefList = new LinkedList<>();
- for (ITestPackageDef testPackageDef : allTestPackageDefList) {
- if (deviceAbiSet.contains(testPackageDef.getAbi().getName())) {
- // We only need test packages that are not empty and of matching ABIs
- filteredTestPackageDefList.add(testPackageDef);
- }
- }
- return filteredTestPackageDefList;
- }
-
- /** Reboot then the device iff the list of packages exceeds the minimum */
- private void preRebootIfNecessary(List<TestPackage> testPackageList)
- throws DeviceNotAvailableException {
- if (mDisableReboot) {
- return;
- }
-
- Set<String> packageNameSet = new HashSet<>();
- for (TestPackage testPackage : testPackageList) {
- // Parse the package name
- packageNameSet.add(AbiUtils.parseTestName(testPackage.getPackageDef().getId()));
- }
- if (packageNameSet.size() < mMinPreRebootPackageCount) {
- // There is actually only one unique package name. No need to reboot.
- return;
- }
-
- // Reboot is needed
- Log.logAndDisplay(LogLevel.INFO, LOG_TAG,
- String.format("Pre-test reboot (%,d packages). Use --disable-reboot to skip",
- packageNameSet.size()));
-
- rebootDevice();
- }
-
- private void rebootIfNecessary(TestPackage testFinished, TestPackage testToRun)
- throws DeviceNotAvailableException {
- // If there comes spurious failure like INJECT_EVENTS for a package,
- // reboot it before running it.
- // Also reboot after package which is know to leave pop-up behind
- final List<String> rebootAfterList = Arrays.asList(
- "CtsMediaTestCases",
- "CtsAccessibilityTestCases",
- "CtsAccountManagerTestCases");
- final List<String> rebootBeforeList = Arrays.asList(
- "CtsAnimationTestCases",
- "CtsGraphicsTestCases",
- "CtsViewTestCases",
- "CtsWidgetTestCases" );
- long intervalInMSec = mRebootIntervalMin * 60 * 1000;
- if (mDisableReboot || mDevice.getSerialNumber().startsWith("emulator-")) {
- return;
- }
- long currentTime = System.currentTimeMillis();
- if (((currentTime - mPrevRebootTime) > intervalInMSec) ||
- rebootAfterList.contains(testFinished.getPackageDef().getName()) ||
- rebootBeforeList.contains(testToRun.getPackageDef().getName()) ) {
- Log.i(LOG_TAG,
- String.format("Rebooting after running package %s, before package %s",
- testFinished.getPackageDef().getName(),
- testToRun.getPackageDef().getName()));
- rebootDevice();
- mPrevRebootTime = System.currentTimeMillis();
- }
- }
-
- private void rebootDevice() throws DeviceNotAvailableException {
- final int TIMEOUT_MS = 10 * 60 * 1000;
- TestDeviceOptions options = mDevice.getOptions();
- // store default value and increase time-out for reboot
- int rebootTimeout = options.getRebootTimeout();
- long onlineTimeout = options.getOnlineTimeout();
- options.setRebootTimeout(TIMEOUT_MS);
- options.setOnlineTimeout(TIMEOUT_MS);
- mDevice.setOptions(options);
-
- mDevice.reboot();
-
- // restore default values
- options.setRebootTimeout(rebootTimeout);
- options.setOnlineTimeout(onlineTimeout);
- mDevice.setOptions(options);
- Log.i(LOG_TAG, "Rebooting done");
- try {
- Thread.sleep(mRebootWaitTimeMSec);
- } catch (InterruptedException e) {
- Log.i(LOG_TAG, "Boot wait interrupted");
- }
- }
-
- /**
- * Remove artifacts like status bar from the previous test.
- * But this cannot dismiss dialog popped-up.
- */
- private void changeToHomeScreen() throws DeviceNotAvailableException {
- final String homeCmd = "input keyevent 3";
-
- mDevice.executeShellCommand(homeCmd);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- //ignore
- }
- }
-
- /**
- * Set {@code mTestPackageList} to the list of test packages to run filtered by ABI.
- */
- private void setupTestPackageList(Set<String> abis) throws DeviceNotAvailableException {
- if (!mTestPackageList.isEmpty()) {
- Log.logAndDisplay(LogLevel.INFO, LOG_TAG, "Resume tests using existing package list");
- return;
- }
- try {
- // Collect ALL tests
- ITestPackageRepo testRepo = createTestCaseRepo();
- List<ITestPackageDef> testPkgDefs = new ArrayList<>(getAvailableTestPackages(testRepo));
- testPkgDefs = filterByAbi(testPkgDefs, abis);
- // Note: run() relies on the fact that the list is reliably sorted for sharding purposes
- Collections.sort(testPkgDefs);
- // Create test package list.
- List<TestPackage> testPackageList = new ArrayList<>();
- for (ITestPackageDef testPackageDef : testPkgDefs) {
- // Note: createTest filters the test list inside of testPackageDef by exclusion list
- IRemoteTest testForPackage = testPackageDef.createTest(mCtsBuild.getTestCasesDir());
- if (testPackageDef.getTests().size() > 0) {
- testPackageList.add(new TestPackage(testPackageDef, testForPackage));
- }
- }
-
- // Filter by shard
- int numTestPackages = testPackageList.size();
- int totalShards = Math.min(mTotalShards, numTestPackages);
-
- List<TestPackage> shardTestPackageList = new ArrayList<>();
- for (int i = mShardAssignment; i < numTestPackages; i += totalShards) {
- shardTestPackageList.add(testPackageList.get(i));
- }
- mTestPackageList.addAll(shardTestPackageList);
- } catch (FileNotFoundException e) {
- throw new IllegalArgumentException("failed to find test plan file", e);
- } catch (ParseException e) {
- throw new IllegalArgumentException("failed to parse test plan file", e);
- } catch (ConfigurationException e) {
- throw new IllegalArgumentException("failed to process arguments", e);
- }
- }
-
- /**
- * Return the {@link Set} of {@link ITestPackageDef}s to run unfiltered by ABI
- *
- * @return the {@link Set} of {@link ITestPackageDef}s to run
- * @throws ParseException
- * @throws FileNotFoundException
- * @throws ConfigurationException
- */
- private Set<ITestPackageDef> getAvailableTestPackages(ITestPackageRepo testRepo)
- throws ParseException, FileNotFoundException, ConfigurationException {
- // use LinkedHashSet to have predictable iteration order
- Set<ITestPackageDef> testPkgDefs = new LinkedHashSet<>();
- if (mPlanName != null) {
- Log.i(LOG_TAG, String.format("Executing CTS test plan %s", mPlanName));
- File ctsPlanFile = mCtsBuild.getTestPlanFile(mPlanName);
- ITestPlan plan = createPlan(mPlanName);
- plan.parse(createXmlStream(ctsPlanFile));
-
- for (String testId : plan.getTestIds()) {
- if (mExcludedPackageNames.contains(AbiUtils.parseTestName(testId))) {
- continue;
- }
- ITestPackageDef testPackageDef = testRepo.getTestPackage(testId);
- if (testPackageDef == null) {
- CLog.e("Could not find test id %s referenced in plan %s", testId, mPlanName);
- continue;
- }
-
- testPackageDef.setTestFilter(plan.getTestFilter(testId));
- testPkgDefs.add(testPackageDef);
- }
- } else if (mPackageNames.size() > 0){
- Log.i(LOG_TAG, String.format("Executing test packages %s", mPackageNames));
-
- Map<String, List<ITestPackageDef>> testPackageDefMap =
- testRepo.getTestPackageDefsByName();
-
- for (String name : mPackageNames) {
- if (!testPackageDefMap.containsKey(name)) {
- throw new IllegalArgumentException(String.format(
- "Could not find test package %s. " +
- "Use 'list packages' to see available packages.", name));
- }
- testPkgDefs.addAll(testPackageDefMap.get(name));
- }
- } else if (mClassName != null) {
- Log.i(LOG_TAG, String.format("Executing CTS test class %s", mClassName));
- testPkgDefs.addAll(buildTestPackageDefSet(testRepo, mClassName, mMethodName));
- } else if (mTestName != null) {
- Log.i(LOG_TAG, String.format("Executing CTS test %s", mTestName));
- String [] split = mTestName.split("#");
- if (split.length != 2) {
- Log.logAndDisplay(LogLevel.WARN, LOG_TAG, String.format(
- "Could not parse class and method from test %s", mTestName));
- } else {
- String className = split[0];
- String methodName = split[1];
- testPkgDefs.addAll(buildTestPackageDefSet(testRepo, className, methodName));
- }
- } else if (mContinueSessionId != null) {
- // create an in-memory derived plan that contains the notExecuted tests from previous
- // session use timestamp as plan name so it will hopefully be unique
- String uniquePlanName = Long.toString(System.currentTimeMillis());
- PlanCreator planCreator = new PlanCreator(uniquePlanName, mContinueSessionId,
- CtsTestStatus.NOT_EXECUTED);
- ITestPlan plan = createPlan(planCreator);
- for (String testId : plan.getTestIds()) {
- if (mExcludedPackageNames.contains(AbiUtils.parseTestName(testId))) {
- continue;
- }
- ITestPackageDef testPackageDef = testRepo.getTestPackage(testId);
- if (testPackageDef == null) {
- CLog.e("Could not find test id %s referenced in plan %s", testId, mPlanName);
- continue;
- }
-
- testPackageDef.setTestFilter(plan.getTestFilter(testId));
- testPkgDefs.add(testPackageDef);
- }
- } else {
- // should never get here - was checkFields() not called?
- throw new IllegalStateException("nothing to run?");
- }
- return testPkgDefs;
- }
-
- /**
- * Return the list of unique prerequisite Android package names
- *
- * @param testPackages The {@link TestPackage}s that contain prerequisites
- */
- private Collection<String> getPrerequisitePackageNames(List<TestPackage> testPackages) {
- Set<String> pkgNames = new HashSet<>();
- for (TestPackage testPkg : testPackages) {
- String pkgName = testPkg.mPackageDef.getTargetPackageName();
- if (pkgName != null) {
- pkgNames.add(pkgName);
- }
- }
- return pkgNames;
- }
-
- /**
- * @return a {@link Set} containing {@link ITestPackageDef}s pertaining to the given
- * {@code className} and {@code methodName}.
- */
- private static Set<ITestPackageDef> buildTestPackageDefSet(
- ITestPackageRepo testRepo, String className, String methodName) {
- Set<ITestPackageDef> testPkgDefs = new LinkedHashSet<>();
- // try to find packages to run from class name
- List<String> packageIds = testRepo.findPackageIdsForTest(className);
- if (packageIds.isEmpty()) {
- Log.logAndDisplay(LogLevel.WARN, LOG_TAG, String.format(
- "Could not find package for test class %s", className));
- }
- for (String packageId: packageIds) {
- ITestPackageDef testPackageDef = testRepo.getTestPackage(packageId);
- if (testPackageDef != null) {
- testPackageDef.setClassName(className, methodName);
- testPkgDefs.add(testPackageDef);
- }
- }
- return testPkgDefs;
- }
-
- /**
- * Return the list (by abi) of unique prerequisite apks to install
- *
- * @param testPackages The {@link List} of {@link TestPackage} that contain prerequisite APKs
- */
- private Map<String, Set<String>> getPrerequisiteApks(
- List<TestPackage> testPackages, Set<String> abiSet) {
- Map<String, Set<String>> abiToApkMap = new HashMap<>();
- for (TestPackage testPkg : testPackages) {
- if (testPkg.getKnownTests().size() == 0) {
- // No tests, no point in installing pre-reqs
- continue;
- }
- String apkName = testPkg.mPackageDef.getTargetApkName();
- if (apkName == null) {
- continue;
- }
- String abiName = testPkg.getAbi().getName();
- if (!abiSet.contains(abiName)) {
- continue;
- }
-
- if (!abiToApkMap.containsKey(abiName)) {
- abiToApkMap.put(abiName, new HashSet<String>());
- }
- abiToApkMap.get(abiName).add(apkName);
- }
- return abiToApkMap;
- }
-
- /**
- * FIXME eventually this should be removed once we get rid of CtsTestStubs, any other
- * prerequisite apks should be installed by the test runner
- *
- * Install the collection of test apk file names
- *
- * @param prerequisiteApks The APKs that must be installed
- * @throws DeviceNotAvailableException
- */
- private void installPrerequisiteApks(Collection<String> prerequisiteApks, IAbi abi)
- throws DeviceNotAvailableException {
- if (prerequisiteApks == null) {
- return;
- }
- Log.logAndDisplay(LogLevel.INFO, LOG_TAG, "Installing prerequisites");
- for (String apkName : prerequisiteApks) {
- try {
- File apkFile = mCtsBuild.getTestApp(apkName);
- String[] options = {AbiUtils.createAbiFlag(abi.getName())};
- String errorCode = getDevice().installPackage(apkFile, true, options);
- if (errorCode != null) {
- CLog.e("Failed to install %s. Reason: %s", apkName, errorCode);
- }
- } catch (FileNotFoundException e) {
- CLog.e("Could not find test apk %s", apkName);
- }
- }
- }
-
- /**
- * Uninstalls the collection of android package names from device.
- *
- * @param uninstallPackages The packages that must be uninstalled
- */
- private void uninstallPrequisiteApks(Collection<String> uninstallPackages)
- throws DeviceNotAvailableException {
- for (String pkgName : uninstallPackages) {
- getDevice().uninstallPackage(pkgName);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<IRemoteTest> split() {
- if (mShards <= 1) {
- return null;
- }
- checkFields();
-
- List<IRemoteTest> shardQueue = new LinkedList<>();
- for (int shardAssignment = 0; shardAssignment < mShards; shardAssignment++) {
- CtsTest ctsTest = new CtsTest(shardAssignment, mShards /* totalShards */);
- OptionCopier.copyOptionsNoThrow(this, ctsTest);
- // Set the shard count because the copy option on the previous line copies
- // over the mShard value
- ctsTest.mShards = 0;
- shardQueue.add(ctsTest);
- }
-
- return shardQueue;
- }
-
- /**
- * Runs the device info collector instrumentation on device, and forwards it to test listeners
- * as run metrics.
- * <p/>
- * Exposed so unit tests can mock.
- *
- * @throws DeviceNotAvailableException
- */
- void collectDeviceInfo(ITestDevice device, CtsBuildHelper ctsBuild,
- ITestInvocationListener listener) throws DeviceNotAvailableException {
- if (!mSkipDeviceInfo) {
- String abi = AbiFormatter.getDefaultAbi(device, "");
- DeviceInfoCollector.collectDeviceInfo(device, abi, ctsBuild.getTestCasesDir(), listener);
- DeviceInfoCollector.collectExtendedDeviceInfo(
- device, abi, ctsBuild.getTestCasesDir(), listener, mBuildInfo);
- }
- }
-
- /**
- * Prepares the report log directory on host to store test metric report logs.
- */
- void prepareReportLogContainers(ITestDevice device, IBuildInfo buildInfo) {
- ReportLogUtil.prepareReportLogContainers(device, buildInfo);
- }
-
- /**
- * Collects the test metric report logs written out by device-side and host-side tests.
- */
- void collectReportLogs(ITestDevice device, IBuildInfo buildInfo) {
- ReportLogUtil.collectReportLogs(device, buildInfo);
- }
-
- /**
- * Factory method for creating a {@link ITestPackageRepo}.
- * <p/>
- * Exposed for unit testing
- */
- ITestPackageRepo createTestCaseRepo() {
- return new TestPackageRepo(mCtsBuild.getTestCasesDir(), mIncludeKnownFailures);
- }
-
- /**
- * Factory method for creating a {@link TestPlan}.
- * <p/>
- * Exposed for unit testing
- */
- ITestPlan createPlan(String planName) {
- return new TestPlan(planName, AbiUtils.getAbisSupportedByCompatibility());
- }
-
- /**
- * Gets the set of ABIs supported by both CTS and the device under test
- * <p/>
- * Exposed for unit testing
- * @return The set of ABIs to run the tests on
- * @throws DeviceNotAvailableException
- */
- Set<String> getAbis() throws DeviceNotAvailableException {
- String bitness = (mForceAbi == null) ? "" : mForceAbi;
- Set<String> abis = new HashSet<>();
- for (String abi : AbiFormatter.getSupportedAbis(mDevice, bitness)) {
- if (AbiUtils.isAbiSupportedByCompatibility(abi)) {
- abis.add(abi);
- }
- }
- return abis;
- }
-
- /**
- * Factory method for creating a {@link TestPlan} from a {@link PlanCreator}.
- * <p/>
- * Exposed for unit testing
- * @throws ConfigurationException
- */
- ITestPlan createPlan(PlanCreator planCreator)
- throws ConfigurationException {
- return planCreator.createDerivedPlan(mCtsBuild, AbiUtils.getAbisSupportedByCompatibility());
- }
-
- /**
- * Factory method for creating a {@link InputStream} from a plan xml file.
- * <p/>
- * Exposed for unit testing
- */
- InputStream createXmlStream(File xmlFile) throws FileNotFoundException {
- return new BufferedInputStream(new FileInputStream(xmlFile));
- }
-
- private void checkFields() {
- // for simplicity of command line usage, make --plan, --package, --test and --class mutually
- // exclusive
- boolean mutualExclusiveArgs = xor(mPlanName != null, mPackageNames.size() > 0,
- mClassName != null, mContinueSessionId != null, mTestName != null);
-
- if (!mutualExclusiveArgs) {
- throw new IllegalArgumentException(String.format(
- "Ambiguous or missing arguments. " +
- "One and only one of --%s --%s(s), --%s or --%s to run can be specified",
- PLAN_OPTION, PACKAGE_OPTION, CLASS_OPTION, CONTINUE_OPTION));
- }
- if (mMethodName != null && mClassName == null) {
- throw new IllegalArgumentException(String.format(
- "Must specify --%s when --%s is used", CLASS_OPTION, METHOD_OPTION));
- }
- if (mCtsBuild == null) {
- throw new IllegalArgumentException("missing CTS build");
- }
- }
-
- /**
- * Helper method to perform exclusive or on list of boolean arguments
- *
- * @param args set of booleans on which to perform exclusive or
- * @return <code>true</code> if one and only one of <var>args</code> is <code>true</code>.
- * Otherwise return <code>false</code>.
- */
- private static boolean xor(boolean... args) {
- boolean currentVal = args[0];
- for (int i=1; i < args.length; i++) {
- if (currentVal && args[i]) {
- return false;
- }
- currentVal |= args[i];
- }
- return currentVal;
- }
-
- /**
- * Forward the digest and package name to the listener as a metric
- *
- * @param listener Handles test results
- */
- private static void forwardPackageDetails(ITestPackageDef def, ITestInvocationListener listener) {
- Map<String, String> metrics = new HashMap<>(3);
- metrics.put(PACKAGE_NAME_METRIC, def.getName());
- metrics.put(PACKAGE_ABI_METRIC, def.getAbi().getName());
- metrics.put(PACKAGE_DIGEST_METRIC, def.getDigest());
- listener.testRunStarted(def.getId(), 0);
- listener.testRunEnded(0, metrics);
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java
deleted file mode 100644
index 881b963..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java
+++ /dev/null
@@ -1,1916 +0,0 @@
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.TimeoutException;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ByteArrayInputStreamSource;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.IRunUtil;
-import com.android.tradefed.util.RunInterruptedException;
-import com.android.tradefed.util.RunUtil;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Test runner for dEQP tests
- *
- * Supports running drawElements Quality Program tests found under external/deqp.
- */
-public class DeqpTestRunner implements IBuildReceiver, IDeviceTest, IRemoteTest {
-
- private static final String DEQP_ONDEVICE_APK = "com.drawelements.deqp.apk";
- private static final String DEQP_ONDEVICE_PKG = "com.drawelements.deqp";
- private static final String INCOMPLETE_LOG_MESSAGE = "Crash: Incomplete test log";
- private static final String SKIPPED_INSTANCE_LOG_MESSAGE = "Configuration skipped";
- private static final String NOT_EXECUTABLE_LOG_MESSAGE = "Abort: Test cannot be executed";
- private static final String CASE_LIST_FILE_NAME = "/sdcard/dEQP-TestCaseList.txt";
- private static final String LOG_FILE_NAME = "/sdcard/TestLog.qpa";
- public static final String FEATURE_LANDSCAPE = "android.hardware.screen.landscape";
- public static final String FEATURE_PORTRAIT = "android.hardware.screen.portrait";
-
- private static final int TESTCASE_BATCH_LIMIT = 1000;
- private static final BatchRunConfiguration DEFAULT_CONFIG =
- new BatchRunConfiguration("rgba8888d24s8", "unspecified", "window");
-
- private static final int UNRESPOSIVE_CMD_TIMEOUT_MS = 10*60*1000; // ten minutes
-
- private final String mPackageName;
- private final String mName;
- private final Collection<TestIdentifier> mRemainingTests;
- private final Map<TestIdentifier, Set<BatchRunConfiguration>> mTestInstances;
- private final TestInstanceResultListener mInstanceListerner = new TestInstanceResultListener();
- private final Map<TestIdentifier, Integer> mTestInstabilityRatings;
- private IAbi mAbi;
- private CtsBuildHelper mCtsBuild;
- private boolean mLogData = false;
- private ITestDevice mDevice;
- private Set<String> mDeviceFeatures;
- private Map<String, Boolean> mConfigQuerySupportCache = new HashMap<>();
- private IRunUtil mRunUtil = RunUtil.getDefault();
-
- private IRecovery mDeviceRecovery = new Recovery();
- {
- mDeviceRecovery.setSleepProvider(new SleepProvider());
- }
-
- public DeqpTestRunner(String packageName, String name, Collection<TestIdentifier> tests,
- Map<TestIdentifier, List<Map<String,String>>> testInstances) {
- mPackageName = packageName;
- mName = name;
- mRemainingTests = new LinkedList<>(tests); // avoid modifying arguments
- mTestInstances = parseTestInstances(tests, testInstances);
- mTestInstabilityRatings = new HashMap<>();
- }
-
- /**
- * @param abi the ABI to run the test on
- */
- public void setAbi(IAbi abi) {
- mAbi = abi;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setBuild(IBuildInfo buildInfo) {
- mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
- }
-
- /**
- * Set the CTS build container.
- * <p/>
- * Exposed so unit tests can mock the provided build.
- *
- * @param buildHelper
- */
- public void setBuildHelper(CtsBuildHelper buildHelper) {
- mCtsBuild = buildHelper;
- }
-
- /**
- * Enable or disable raw dEQP test log collection.
- */
- public void setCollectLogs(boolean logData) {
- mLogData = logData;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setDevice(ITestDevice device) {
- mDevice = device;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ITestDevice getDevice() {
- return mDevice;
- }
-
- /**
- * Set recovery handler.
- *
- * Exposed for unit testing.
- */
- public void setRecovery(IRecovery deviceRecovery) {
- mDeviceRecovery = deviceRecovery;
- }
-
- /**
- * Set IRunUtil.
- *
- * Exposed for unit testing.
- */
- public void setRunUtil(IRunUtil runUtil) {
- mRunUtil = runUtil;
- }
-
- private static final class CapabilityQueryFailureException extends Exception {
- }
-
- /**
- * Test configuration of dEPQ test instance execution.
- * Exposed for unit testing
- */
- public static final class BatchRunConfiguration {
- public static final String ROTATION_UNSPECIFIED = "unspecified";
- public static final String ROTATION_PORTRAIT = "0";
- public static final String ROTATION_LANDSCAPE = "90";
- public static final String ROTATION_REVERSE_PORTRAIT = "180";
- public static final String ROTATION_REVERSE_LANDSCAPE = "270";
-
- private final String mGlConfig;
- private final String mRotation;
- private final String mSurfaceType;
-
- public BatchRunConfiguration(String glConfig, String rotation, String surfaceType) {
- mGlConfig = glConfig;
- mRotation = rotation;
- mSurfaceType = surfaceType;
- }
-
- /**
- * Get string that uniquely identifies this config
- */
- public String getId() {
- return String.format("{glformat=%s,rotation=%s,surfacetype=%s}",
- mGlConfig, mRotation, mSurfaceType);
- }
-
- /**
- * Get the GL config used in this configuration.
- */
- public String getGlConfig() {
- return mGlConfig;
- }
-
- /**
- * Get the screen rotation used in this configuration.
- */
- public String getRotation() {
- return mRotation;
- }
-
- /**
- * Get the surface type used in this configuration.
- */
- public String getSurfaceType() {
- return mSurfaceType;
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == null) {
- return false;
- } else if (!(other instanceof BatchRunConfiguration)) {
- return false;
- } else {
- return getId().equals(((BatchRunConfiguration)other).getId());
- }
- }
-
- @Override
- public int hashCode() {
- return getId().hashCode();
- }
- }
-
- /**
- * dEQP test instance listerer and invocation result forwarded
- */
- private class TestInstanceResultListener {
- private ITestInvocationListener mSink;
- private BatchRunConfiguration mRunConfig;
-
- private TestIdentifier mCurrentTestId;
- private boolean mGotTestResult;
- private String mCurrentTestLog;
-
- private class PendingResult {
- boolean allInstancesPassed;
- Map<BatchRunConfiguration, String> testLogs;
- Map<BatchRunConfiguration, String> errorMessages;
- Set<BatchRunConfiguration> remainingConfigs;
- }
-
- private final Map<TestIdentifier, PendingResult> mPendingResults = new HashMap<>();
-
- public void setSink(ITestInvocationListener sink) {
- mSink = sink;
- }
-
- public void setCurrentConfig(BatchRunConfiguration runConfig) {
- mRunConfig = runConfig;
- }
-
- /**
- * Get currently processed test id, or null if not currently processing a test case
- */
- public TestIdentifier getCurrentTestId() {
- return mCurrentTestId;
- }
-
- /**
- * Forward result to sink
- */
- private void forwardFinalizedPendingResult(TestIdentifier testId) {
- if (mRemainingTests.contains(testId)) {
- final PendingResult result = mPendingResults.get(testId);
-
- mPendingResults.remove(testId);
- mRemainingTests.remove(testId);
-
- // Forward results to the sink
- mSink.testStarted(testId);
-
- // Test Log
- if (mLogData) {
- for (Map.Entry<BatchRunConfiguration, String> entry :
- result.testLogs.entrySet()) {
- final ByteArrayInputStreamSource source
- = new ByteArrayInputStreamSource(entry.getValue().getBytes());
-
- mSink.testLog(testId.getClassName() + "." + testId.getTestName() + "@"
- + entry.getKey().getId(), LogDataType.XML, source);
-
- source.cancel();
- }
- }
-
- // Error message
- if (!result.allInstancesPassed) {
- final StringBuilder errorLog = new StringBuilder();
-
- for (Map.Entry<BatchRunConfiguration, String> entry :
- result.errorMessages.entrySet()) {
- if (errorLog.length() > 0) {
- errorLog.append('\n');
- }
- errorLog.append(String.format("=== with config %s ===\n",
- entry.getKey().getId()));
- errorLog.append(entry.getValue());
- }
-
- mSink.testFailed(testId, errorLog.toString());
- }
-
- final Map<String, String> emptyMap = Collections.emptyMap();
- mSink.testEnded(testId, emptyMap);
- } else {
- CLog.w("Finalization for non-pending case %s", testId);
- }
- }
-
- /**
- * Declare existence of a test and instances
- */
- public void setTestInstances(TestIdentifier testId, Set<BatchRunConfiguration> configs) {
- // Test instances cannot change at runtime, ignore if we have already set this
- if (!mPendingResults.containsKey(testId)) {
- final PendingResult pendingResult = new PendingResult();
- pendingResult.allInstancesPassed = true;
- pendingResult.testLogs = new LinkedHashMap<>();
- pendingResult.errorMessages = new LinkedHashMap<>();
- pendingResult.remainingConfigs = new HashSet<>(configs); // avoid mutating argument
- mPendingResults.put(testId, pendingResult);
- }
- }
-
- /**
- * Query if test instance has not yet been executed
- */
- public boolean isPendingTestInstance(TestIdentifier testId,
- BatchRunConfiguration config) {
- final PendingResult result = mPendingResults.get(testId);
- if (result == null) {
- // test is not in the current working batch of the runner, i.e. it cannot be
- // "partially" completed.
- if (!mRemainingTests.contains(testId)) {
- // The test has been fully executed. Not pending.
- return false;
- } else {
- // Test has not yet been executed. Check if such instance exists
- return mTestInstances.get(testId).contains(config);
- }
- } else {
- // could be partially completed, check this particular config
- return result.remainingConfigs.contains(config);
- }
- }
-
- /**
- * Fake execution of an instance with current config
- */
- public void skipTest(TestIdentifier testId) {
- final PendingResult result = mPendingResults.get(testId);
-
- result.errorMessages.put(mRunConfig, SKIPPED_INSTANCE_LOG_MESSAGE);
- result.remainingConfigs.remove(mRunConfig);
-
- // Pending result finished, report result
- if (result.remainingConfigs.isEmpty()) {
- forwardFinalizedPendingResult(testId);
- }
- }
-
- /**
- * Fake failure of an instance with current config
- */
- public void abortTest(TestIdentifier testId, String errorMessage) {
- final PendingResult result = mPendingResults.get(testId);
-
- CLog.i("Test %s aborted with message %s", testId, errorMessage);
-
- // Mark as executed
- result.allInstancesPassed = false;
- result.errorMessages.put(mRunConfig, errorMessage);
- result.remainingConfigs.remove(mRunConfig);
-
- // Pending result finished, report result
- if (result.remainingConfigs.isEmpty()) {
- forwardFinalizedPendingResult(testId);
- }
-
- if (testId.equals(mCurrentTestId)) {
- mCurrentTestId = null;
- }
- }
-
- /**
- * Handles beginning of dEQP session.
- */
- private boolean handleBeginSession(Map<String, String> values) {
- // ignore
- return true;
- }
-
- /**
- * Handle session info
- */
- private boolean handleSessionInfo(Map<String, String> values) {
- // ignore
- return true;
- }
-
- /**
- * Handles end of dEQP session.
- */
- private boolean handleEndSession(Map<String, String> values) {
- // ignore
- return true;
- }
-
- /**
- * Handles beginning of dEQP testcase.
- */
- private boolean handleBeginTestCase(Map<String, String> values) {
- String casePath = values.get("dEQP-BeginTestCase-TestCasePath");
-
- if (mCurrentTestId != null) {
- CLog.w("Got unexpected start of %s, so aborting", mCurrentTestId);
- abortTest(mCurrentTestId, INCOMPLETE_LOG_MESSAGE);
- mCurrentTestId = null;
- }
-
- mCurrentTestLog = "";
- mGotTestResult = false;
-
- if (casePath == null) {
- CLog.w("Got null case path for test case begin event. Current test ID: %s", mCurrentTestId);
- mCurrentTestId = null;
- return false;
- }
-
- mCurrentTestId = pathToIdentifier(casePath);
-
- if (mPendingResults.get(mCurrentTestId) == null) {
- CLog.w("Got unexpected start of %s", mCurrentTestId);
- }
- return true;
- }
-
- /**
- * Handles end of dEQP testcase.
- */
- private boolean handleEndTestCase(Map<String, String> values) {
- final PendingResult result = mPendingResults.get(mCurrentTestId);
-
- if (result != null) {
- if (!mGotTestResult) {
- result.allInstancesPassed = false;
- result.errorMessages.put(mRunConfig, INCOMPLETE_LOG_MESSAGE);
- CLog.i("Test %s failed as it ended before receiving result.", mCurrentTestId);
- }
- result.remainingConfigs.remove(mRunConfig);
-
- if (mLogData && mCurrentTestLog != null && mCurrentTestLog.length() > 0) {
- result.testLogs.put(mRunConfig, mCurrentTestLog);
- }
-
- // Pending result finished, report result
- if (result.remainingConfigs.isEmpty()) {
- forwardFinalizedPendingResult(mCurrentTestId);
- }
- } else {
- CLog.w("Got unexpected end of %s", mCurrentTestId);
- }
- mCurrentTestId = null;
- return true;
- }
-
- /**
- * Handles dEQP testcase result.
- */
- private boolean handleTestCaseResult(Map<String, String> values) {
- String code = values.get("dEQP-TestCaseResult-Code");
- if (code == null) {
- return false;
- }
-
- String details = values.get("dEQP-TestCaseResult-Details");
-
- if (mPendingResults.get(mCurrentTestId) == null) {
- CLog.w("Got unexpected result for %s", mCurrentTestId);
- mGotTestResult = true;
- return true;
- }
-
- if (code.compareTo("Pass") == 0) {
- mGotTestResult = true;
- } else if (code.compareTo("NotSupported") == 0) {
- mGotTestResult = true;
- } else if (code.compareTo("QualityWarning") == 0) {
- mGotTestResult = true;
- } else if (code.compareTo("CompatibilityWarning") == 0) {
- mGotTestResult = true;
- } else if (code.compareTo("Fail") == 0 || code.compareTo("ResourceError") == 0
- || code.compareTo("InternalError") == 0 || code.compareTo("Crash") == 0
- || code.compareTo("Timeout") == 0) {
- mPendingResults.get(mCurrentTestId).allInstancesPassed = false;
- mPendingResults.get(mCurrentTestId)
- .errorMessages.put(mRunConfig, code + ": " + details);
- mGotTestResult = true;
- } else {
- String codeError = "Unknown result code: " + code;
- mPendingResults.get(mCurrentTestId).allInstancesPassed = false;
- mPendingResults.get(mCurrentTestId)
- .errorMessages.put(mRunConfig, codeError + ": " + details);
- mGotTestResult = true;
- CLog.e("Got invalid result code '%s' for test %s", code, mCurrentTestId);
- }
- return true;
- }
-
- /**
- * Handles terminated dEQP testcase.
- */
- private boolean handleTestCaseTerminate(Map<String, String> values) {
- final PendingResult result = mPendingResults.get(mCurrentTestId);
-
- if (result != null) {
- String reason = values.get("dEQP-TerminateTestCase-Reason");
- mPendingResults.get(mCurrentTestId).allInstancesPassed = false;
- mPendingResults.get(mCurrentTestId)
- .errorMessages.put(mRunConfig, "Terminated: " + reason);
- result.remainingConfigs.remove(mRunConfig);
-
- // Pending result finished, report result
- if (result.remainingConfigs.isEmpty()) {
- forwardFinalizedPendingResult(mCurrentTestId);
- }
- } else {
- CLog.w("Got unexpected termination of %s", mCurrentTestId);
- }
-
- mCurrentTestId = null;
- mGotTestResult = true;
- return true;
- }
-
- /**
- * Handles dEQP testlog data.
- */
- private boolean handleTestLogData(Map<String, String> values) {
- String newLog = values.get("dEQP-TestLogData-Log");
- if (newLog == null) {
- return false;
- }
- mCurrentTestLog = mCurrentTestLog + newLog;
- return true;
- }
-
- /**
- * Handles new instrumentation status message.
- * @return true if handled correctly, false if missing values.
- */
- public boolean handleStatus(Map<String, String> values) {
- String eventType = values.get("dEQP-EventType");
-
- if (eventType == null) {
- // Not an event, but some other line
- return true;
- }
-
- if (eventType.compareTo("BeginSession") == 0) {
- return handleBeginSession(values);
- } else if (eventType.compareTo("SessionInfo") == 0) {
- return handleSessionInfo(values);
- } else if (eventType.compareTo("EndSession") == 0) {
- return handleEndSession(values);
- } else if (eventType.compareTo("BeginTestCase") == 0) {
- return handleBeginTestCase(values);
- } else if (eventType.compareTo("EndTestCase") == 0) {
- return handleEndTestCase(values);
- } else if (eventType.compareTo("TestCaseResult") == 0) {
- return handleTestCaseResult(values);
- } else if (eventType.compareTo("TerminateTestCase") == 0) {
- return handleTestCaseTerminate(values);
- } else if (eventType.compareTo("TestLogData") == 0) {
- return handleTestLogData(values);
- }
- CLog.e("Unknown event type (%s)", eventType);
- return false;
- }
-
- /**
- * Signal listener that batch ended and forget incomplete results.
- */
- public void endBatch() {
- // end open test if when stream ends
- if (mCurrentTestId != null) {
- // Current instance was removed from remainingConfigs when case
- // started. Mark current instance as pending.
- CLog.i("Batch ended with test '%s' current", mCurrentTestId);
- if (mPendingResults.get(mCurrentTestId) != null) {
- mPendingResults.get(mCurrentTestId).remainingConfigs.add(mRunConfig);
- } else {
- CLog.w("Got unexpected internal state of %s", mCurrentTestId);
- }
- }
- mCurrentTestId = null;
- }
- }
-
- /**
- * dEQP instrumentation parser
- */
- private static class InstrumentationParser extends MultiLineReceiver {
- private TestInstanceResultListener mListener;
-
- private Map<String, String> mValues;
- private String mCurrentName;
- private String mCurrentValue;
- private int mResultCode;
- private boolean mGotExitValue = false;
- private boolean mParseSuccessful = true;
-
-
- public InstrumentationParser(TestInstanceResultListener listener) {
- mListener = listener;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void processNewLines(String[] lines) {
- for (String line : lines) {
- if (mValues == null) mValues = new HashMap<String, String>();
-
- if (line.startsWith("INSTRUMENTATION_STATUS_CODE: ")) {
- if (mCurrentName != null) {
- mValues.put(mCurrentName, mCurrentValue);
-
- mCurrentName = null;
- mCurrentValue = null;
- }
-
- mParseSuccessful &= mListener.handleStatus(mValues);
- mValues = null;
- } else if (line.startsWith("INSTRUMENTATION_STATUS: dEQP-")) {
- if (mCurrentName != null) {
- mValues.put(mCurrentName, mCurrentValue);
-
- mCurrentValue = null;
- mCurrentName = null;
- }
-
- String prefix = "INSTRUMENTATION_STATUS: ";
- int nameBegin = prefix.length();
- int nameEnd = line.indexOf('=');
- if (nameEnd < 0) {
- CLog.e("Line does not contain value. Logcat interrupted? (%s)", line);
- mCurrentValue = null;
- mCurrentName = null;
- mParseSuccessful = false;
- return;
- } else {
- int valueBegin = nameEnd + 1;
- mCurrentName = line.substring(nameBegin, nameEnd);
- mCurrentValue = line.substring(valueBegin);
- }
- } else if (line.startsWith("INSTRUMENTATION_CODE: ")) {
- try {
- mResultCode = Integer.parseInt(line.substring(22));
- mGotExitValue = true;
- } catch (NumberFormatException ex) {
- CLog.e("Instrumentation code format unexpected");
- mParseSuccessful = false;
- return;
- }
- } else if (mCurrentValue != null) {
- mCurrentValue = mCurrentValue + line;
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void done() {
- if (mCurrentName != null) {
- mValues.put(mCurrentName, mCurrentValue);
-
- mCurrentName = null;
- mCurrentValue = null;
- }
-
- if (mValues != null) {
- mParseSuccessful &= mListener.handleStatus(mValues);
- mValues = null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isCancelled() {
- return false;
- }
-
- /**
- * Returns whether target instrumentation exited normally.
- */
- public boolean wasSuccessful() {
- return mGotExitValue && mParseSuccessful;
- }
-
- /**
- * Returns Instrumentation return code
- */
- public int getResultCode() {
- return mResultCode;
- }
- }
-
- /**
- * dEQP platfom query instrumentation parser
- */
- private static class PlatformQueryInstrumentationParser extends MultiLineReceiver {
- private Map<String,String> mResultMap = new LinkedHashMap<>();
- private int mResultCode;
- private boolean mGotExitValue = false;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void processNewLines(String[] lines) {
- for (String line : lines) {
- if (line.startsWith("INSTRUMENTATION_RESULT: ")) {
- final String parts[] = line.substring(24).split("=",2);
- if (parts.length == 2) {
- mResultMap.put(parts[0], parts[1]);
- } else {
- CLog.w("Instrumentation status format unexpected");
- }
- } else if (line.startsWith("INSTRUMENTATION_CODE: ")) {
- try {
- mResultCode = Integer.parseInt(line.substring(22));
- mGotExitValue = true;
- } catch (NumberFormatException ex) {
- CLog.w("Instrumentation code format unexpected");
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isCancelled() {
- return false;
- }
-
- /**
- * Returns whether target instrumentation exited normally.
- */
- public boolean wasSuccessful() {
- return mGotExitValue;
- }
-
- /**
- * Returns Instrumentation return code
- */
- public int getResultCode() {
- return mResultCode;
- }
-
- public Map<String,String> getResultMap() {
- return mResultMap;
- }
- }
-
- /**
- * Interface for sleeping.
- *
- * Exposed for unit testing
- */
- public static interface ISleepProvider {
- public void sleep(int milliseconds);
- }
-
- private static class SleepProvider implements ISleepProvider {
- public void sleep(int milliseconds) {
- try {
- Thread.sleep(milliseconds);
- } catch (InterruptedException ex) {
- }
- }
- }
-
- /**
- * Interface for failure recovery.
- *
- * Exposed for unit testing
- */
- public static interface IRecovery {
- /**
- * Sets the sleep provider IRecovery works on
- */
- public void setSleepProvider(ISleepProvider sleepProvider);
-
- /**
- * Sets the device IRecovery works on
- */
- public void setDevice(ITestDevice device);
-
- /**
- * Informs Recovery that test execution has progressed since the last recovery
- */
- public void onExecutionProgressed();
-
- /**
- * Tries to recover device after failed refused connection.
- *
- * @throws DeviceNotAvailableException if recovery did not succeed
- */
- public void recoverConnectionRefused() throws DeviceNotAvailableException;
-
- /**
- * Tries to recover device after abnormal execution termination or link failure.
- *
- * @param progressedSinceLastCall true if test execution has progressed since last call
- * @throws DeviceNotAvailableException if recovery did not succeed
- */
- public void recoverComLinkKilled() throws DeviceNotAvailableException;
- };
-
- /**
- * State machine for execution failure recovery.
- *
- * Exposed for unit testing
- */
- public static class Recovery implements IRecovery {
- private int RETRY_COOLDOWN_MS = 6000; // 6 seconds
- private int PROCESS_KILL_WAIT_MS = 1000; // 1 second
-
- private static enum MachineState {
- WAIT, // recover by waiting
- RECOVER, // recover by calling recover()
- REBOOT, // recover by rebooting
- FAIL, // cannot recover
- };
-
- private MachineState mState = MachineState.WAIT;
- private ITestDevice mDevice;
- private ISleepProvider mSleepProvider;
-
- private static class ProcessKillFailureException extends Exception {
- }
-
- /**
- * {@inheritDoc}
- */
- public void setSleepProvider(ISleepProvider sleepProvider) {
- mSleepProvider = sleepProvider;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setDevice(ITestDevice device) {
- mDevice = device;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onExecutionProgressed() {
- mState = MachineState.WAIT;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void recoverConnectionRefused() throws DeviceNotAvailableException {
- switch (mState) {
- case WAIT: // not a valid stratedy for connection refusal, fallthrough
- case RECOVER:
- // First failure, just try to recover
- CLog.w("ADB connection failed, trying to recover");
- mState = MachineState.REBOOT; // the next step is to reboot
-
- try {
- recoverDevice();
- } catch (DeviceNotAvailableException ex) {
- // chain forward
- recoverConnectionRefused();
- }
- break;
-
- case REBOOT:
- // Second failure in a row, try to reboot
- CLog.w("ADB connection failed after recovery, rebooting device");
- mState = MachineState.FAIL; // the next step is to fail
-
- try {
- rebootDevice();
- } catch (DeviceNotAvailableException ex) {
- // chain forward
- recoverConnectionRefused();
- }
- break;
-
- case FAIL:
- // Third failure in a row, just fail
- CLog.w("Cannot recover ADB connection");
- throw new DeviceNotAvailableException("failed to connect after reboot");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void recoverComLinkKilled() throws DeviceNotAvailableException {
- switch (mState) {
- case WAIT:
- // First failure, just try to wait and try again
- CLog.w("ADB link failed, retrying after a cooldown period");
- mState = MachineState.RECOVER; // the next step is to recover the device
-
- waitCooldown();
-
- // even if the link to deqp on-device process was killed, the process might
- // still be alive. Locate and terminate such unwanted processes.
- try {
- killDeqpProcess();
- } catch (DeviceNotAvailableException ex) {
- // chain forward
- recoverComLinkKilled();
- } catch (ProcessKillFailureException ex) {
- // chain forward
- recoverComLinkKilled();
- }
- break;
-
- case RECOVER:
- // Second failure, just try to recover
- CLog.w("ADB link failed, trying to recover");
- mState = MachineState.REBOOT; // the next step is to reboot
-
- try {
- recoverDevice();
- killDeqpProcess();
- } catch (DeviceNotAvailableException ex) {
- // chain forward
- recoverComLinkKilled();
- } catch (ProcessKillFailureException ex) {
- // chain forward
- recoverComLinkKilled();
- }
- break;
-
- case REBOOT:
- // Third failure in a row, try to reboot
- CLog.w("ADB link failed after recovery, rebooting device");
- mState = MachineState.FAIL; // the next step is to fail
-
- try {
- rebootDevice();
- } catch (DeviceNotAvailableException ex) {
- // chain forward
- recoverComLinkKilled();
- }
- break;
-
- case FAIL:
- // Fourth failure in a row, just fail
- CLog.w("Cannot recover ADB connection");
- throw new DeviceNotAvailableException("link killed after reboot");
- }
- }
-
- private void waitCooldown() {
- mSleepProvider.sleep(RETRY_COOLDOWN_MS);
- }
-
- private Iterable<Integer> getDeqpProcessPids() throws DeviceNotAvailableException {
- final List<Integer> pids = new ArrayList<Integer>(2);
- final String processes = mDevice.executeShellCommand("ps | grep com.drawelements");
- final String[] lines = processes.split("(\\r|\\n)+");
- for (String line : lines) {
- final String[] fields = line.split("\\s+");
- if (fields.length < 2) {
- continue;
- }
-
- try {
- final int processId = Integer.parseInt(fields[1], 10);
- pids.add(processId);
- } catch (NumberFormatException ex) {
- continue;
- }
- }
- return pids;
- }
-
- private void killDeqpProcess() throws DeviceNotAvailableException,
- ProcessKillFailureException {
- for (Integer processId : getDeqpProcessPids()) {
- CLog.i("Killing deqp device process with ID %d", processId);
- mDevice.executeShellCommand(String.format("kill -9 %d", processId));
- }
-
- mSleepProvider.sleep(PROCESS_KILL_WAIT_MS);
-
- // check that processes actually died
- if (getDeqpProcessPids().iterator().hasNext()) {
- // a process is still alive, killing failed
- CLog.w("Failed to kill all deqp processes on device");
- throw new ProcessKillFailureException();
- }
- }
-
- public void recoverDevice() throws DeviceNotAvailableException {
- // Work around the API. We need to call recoverDevice() on the test device and
- // we know that mDevice is a TestDevice. However even though the recoverDevice()
- // method is public suggesting it should be publicly accessible, the class itself
- // and its super-interface (IManagedTestDevice) are package-private.
- final Method recoverDeviceMethod;
- try {
- recoverDeviceMethod = mDevice.getClass().getMethod("recoverDevice");
- recoverDeviceMethod.setAccessible(true);
- } catch (NoSuchMethodException ex) {
- throw new AssertionError("Test device must have recoverDevice()");
- }
-
- try {
- recoverDeviceMethod.invoke(mDevice);
- } catch (InvocationTargetException ex) {
- if (ex.getCause() instanceof DeviceNotAvailableException) {
- throw (DeviceNotAvailableException)ex.getCause();
- } else if (ex.getCause() instanceof RuntimeException) {
- throw (RuntimeException)ex.getCause();
- } else {
- throw new AssertionError("unexpected throw", ex);
- }
- } catch (IllegalAccessException ex) {
- throw new AssertionError("unexpected throw", ex);
- }
- }
-
- private void rebootDevice() throws DeviceNotAvailableException {
- mDevice.reboot();
- }
- }
-
- /**
- * Parse map of instance arguments to map of BatchRunConfigurations
- */
- private static Map<TestIdentifier, Set<BatchRunConfiguration>> parseTestInstances(
- Collection<TestIdentifier> tests,
- Map<TestIdentifier, List<Map<String,String>>> testInstances) {
- final Map<TestIdentifier, Set<BatchRunConfiguration>> instances = new HashMap<>();
- for (final TestIdentifier test : tests) {
- final Set<BatchRunConfiguration> testInstanceSet = new LinkedHashSet<>();
- if (testInstances.get(test).isEmpty()) {
- // no instances defined, use default
- testInstanceSet.add(DEFAULT_CONFIG);
- } else {
- for (Map<String, String> instanceArgs : testInstances.get(test)) {
- testInstanceSet.add(parseRunConfig(instanceArgs));
- }
- }
- instances.put(test, testInstanceSet);
- }
- return instances;
- }
-
- private static BatchRunConfiguration parseRunConfig(Map<String,String> instanceArguments) {
- final String glConfig;
- final String rotation;
- final String surfaceType;
-
- if (instanceArguments.containsKey("glconfig")) {
- glConfig = instanceArguments.get("glconfig");
- } else {
- glConfig = DEFAULT_CONFIG.getGlConfig();
- }
- if (instanceArguments.containsKey("rotation")) {
- rotation = instanceArguments.get("rotation");
- } else {
- rotation = DEFAULT_CONFIG.getRotation();
- }
- if (instanceArguments.containsKey("surfaceType")) {
- surfaceType = instanceArguments.get("surfaceType");
- } else {
- surfaceType = DEFAULT_CONFIG.getSurfaceType();
- }
-
- return new BatchRunConfiguration(glConfig, rotation, surfaceType);
- }
-
- private Set<BatchRunConfiguration> getTestRunConfigs (TestIdentifier testId) {
- return mTestInstances.get(testId);
- }
-
- /**
- * Converts dEQP testcase path to TestIdentifier.
- */
- private static TestIdentifier pathToIdentifier(String testPath) {
- String[] components = testPath.split("\\.");
- String name = components[components.length - 1];
- String className = null;
-
- for (int i = 0; i < components.length - 1; i++) {
- if (className == null) {
- className = components[i];
- } else {
- className = className + "." + components[i];
- }
- }
-
- return new TestIdentifier(className, name);
- }
-
- private String getId() {
- return AbiUtils.createId(mAbi.getName(), mPackageName);
- }
-
- /**
- * Generates tescase trie from dEQP testcase paths. Used to define which testcases to execute.
- */
- private static String generateTestCaseTrieFromPaths(Collection<String> tests) {
- String result = "{";
- boolean first = true;
-
- // Add testcases to results
- for (Iterator<String> iter = tests.iterator(); iter.hasNext();) {
- String test = iter.next();
- String[] components = test.split("\\.");
-
- if (components.length == 1) {
- if (!first) {
- result = result + ",";
- }
- first = false;
-
- result += components[0];
- iter.remove();
- }
- }
-
- if (!tests.isEmpty()) {
- HashMap<String, ArrayList<String> > testGroups = new HashMap<>();
-
- // Collect all sub testgroups
- for (String test : tests) {
- String[] components = test.split("\\.");
- ArrayList<String> testGroup = testGroups.get(components[0]);
-
- if (testGroup == null) {
- testGroup = new ArrayList<String>();
- testGroups.put(components[0], testGroup);
- }
-
- testGroup.add(test.substring(components[0].length()+1));
- }
-
- for (String testGroup : testGroups.keySet()) {
- if (!first) {
- result = result + ",";
- }
-
- first = false;
- result = result + testGroup
- + generateTestCaseTrieFromPaths(testGroups.get(testGroup));
- }
- }
-
- return result + "}";
- }
-
- /**
- * Generates testcase trie from TestIdentifiers.
- */
- private static String generateTestCaseTrie(Collection<TestIdentifier> tests) {
- ArrayList<String> testPaths = new ArrayList<String>();
-
- for (TestIdentifier test : tests) {
- testPaths.add(test.getClassName() + "." + test.getTestName());
- }
-
- return generateTestCaseTrieFromPaths(testPaths);
- }
-
- private static class TestBatch {
- public BatchRunConfiguration config;
- public List<TestIdentifier> tests;
- }
-
- private TestBatch selectRunBatch() {
- return selectRunBatch(mRemainingTests, null);
- }
-
- /**
- * Creates a TestBatch from the given tests or null if not tests remaining.
- *
- * @param pool List of tests to select from
- * @param requiredConfig Select only instances with pending requiredConfig, or null to select
- * any run configuration.
- */
- private TestBatch selectRunBatch(Collection<TestIdentifier> pool,
- BatchRunConfiguration requiredConfig) {
- // select one test (leading test) that is going to be executed and then pack along as many
- // other compatible instances as possible.
-
- TestIdentifier leadingTest = null;
- for (TestIdentifier test : pool) {
- if (!mRemainingTests.contains(test)) {
- continue;
- }
- if (requiredConfig != null &&
- !mInstanceListerner.isPendingTestInstance(test, requiredConfig)) {
- continue;
- }
- leadingTest = test;
- break;
- }
-
- // no remaining tests?
- if (leadingTest == null) {
- return null;
- }
-
- BatchRunConfiguration leadingTestConfig = null;
- if (requiredConfig != null) {
- leadingTestConfig = requiredConfig;
- } else {
- for (BatchRunConfiguration runConfig : getTestRunConfigs(leadingTest)) {
- if (mInstanceListerner.isPendingTestInstance(leadingTest, runConfig)) {
- leadingTestConfig = runConfig;
- break;
- }
- }
- }
-
- // test pending <=> test has a pending config
- if (leadingTestConfig == null) {
- throw new AssertionError("search postcondition failed");
- }
-
- final int leadingInstability = getTestInstabilityRating(leadingTest);
-
- final TestBatch runBatch = new TestBatch();
- runBatch.config = leadingTestConfig;
- runBatch.tests = new ArrayList<>();
- runBatch.tests.add(leadingTest);
-
- for (TestIdentifier test : pool) {
- if (test == leadingTest) {
- // do not re-select the leading tests
- continue;
- }
- if (!mInstanceListerner.isPendingTestInstance(test, leadingTestConfig)) {
- // select only compatible
- continue;
- }
- if (getTestInstabilityRating(test) != leadingInstability) {
- // pack along only cases in the same stability category. Packing more dangerous
- // tests along jeopardizes the stability of this run. Packing more stable tests
- // along jeopardizes their stability rating.
- continue;
- }
- if (runBatch.tests.size() >= getBatchSizeLimitForInstability(leadingInstability)) {
- // batch size is limited.
- break;
- }
- runBatch.tests.add(test);
- }
-
- return runBatch;
- }
-
- private int getBatchNumPendingCases(TestBatch batch) {
- int numPending = 0;
- for (TestIdentifier test : batch.tests) {
- if (mInstanceListerner.isPendingTestInstance(test, batch.config)) {
- ++numPending;
- }
- }
- return numPending;
- }
-
- private int getBatchSizeLimitForInstability(int batchInstabilityRating) {
- // reduce group size exponentially down to one
- return Math.max(1, TESTCASE_BATCH_LIMIT / (1 << batchInstabilityRating));
- }
-
- private int getTestInstabilityRating(TestIdentifier testId) {
- if (mTestInstabilityRatings.containsKey(testId)) {
- return mTestInstabilityRatings.get(testId);
- } else {
- return 0;
- }
- }
-
- private void recordTestInstability(TestIdentifier testId) {
- mTestInstabilityRatings.put(testId, getTestInstabilityRating(testId) + 1);
- }
-
- private void clearTestInstability(TestIdentifier testId) {
- mTestInstabilityRatings.put(testId, 0);
- }
-
- /**
- * Executes all tests on the device.
- */
- private void runTests() throws DeviceNotAvailableException, CapabilityQueryFailureException {
- for (;;) {
- TestBatch batch = selectRunBatch();
-
- if (batch == null) {
- break;
- }
-
- runTestRunBatch(batch);
- }
- }
-
- /**
- * Runs a TestBatch by either faking it or executing it on a device.
- */
- private void runTestRunBatch(TestBatch batch) throws DeviceNotAvailableException,
- CapabilityQueryFailureException {
- // prepare instance listener
- mInstanceListerner.setCurrentConfig(batch.config);
- for (TestIdentifier test : batch.tests) {
- mInstanceListerner.setTestInstances(test, getTestRunConfigs(test));
- }
-
- // execute only if config is executable, else fake results
- if (isSupportedRunConfiguration(batch.config)) {
- executeTestRunBatch(batch);
- } else {
- fakePassTestRunBatch(batch);
- }
- }
-
- private boolean isSupportedRunConfiguration(BatchRunConfiguration runConfig)
- throws DeviceNotAvailableException, CapabilityQueryFailureException {
- // orientation support
- if (!BatchRunConfiguration.ROTATION_UNSPECIFIED.equals(runConfig.getRotation())) {
- final Set<String> features = getDeviceFeatures(mDevice);
-
- if (isPortraitClassRotation(runConfig.getRotation()) &&
- !features.contains(FEATURE_PORTRAIT)) {
- return false;
- }
- if (isLandscapeClassRotation(runConfig.getRotation()) &&
- !features.contains(FEATURE_LANDSCAPE)) {
- return false;
- }
- }
-
- if (isOpenGlEsPackage()) {
- // renderability support for OpenGL ES tests
- return isSupportedGlesRenderConfig(runConfig);
- } else {
- return true;
- }
- }
-
- private static final class AdbComLinkOpenError extends Exception {
- public AdbComLinkOpenError(String description, Throwable inner) {
- super(description, inner);
- }
- }
-
- private static final class AdbComLinkKilledError extends Exception {
- public AdbComLinkKilledError(String description, Throwable inner) {
- super(description, inner);
- }
- }
-
- /**
- * Executes a given command in adb shell
- *
- * @throws AdbComLinkOpenError if connection cannot be established.
- * @throws AdbComLinkKilledError if established connection is killed prematurely.
- */
- private void executeShellCommandAndReadOutput(final String command,
- final IShellOutputReceiver receiver)
- throws AdbComLinkOpenError, AdbComLinkKilledError {
- try {
- mDevice.getIDevice().executeShellCommand(command, receiver,
- UNRESPOSIVE_CMD_TIMEOUT_MS, TimeUnit.MILLISECONDS);
- } catch (TimeoutException ex) {
- // Opening connection timed out
- CLog.e("Opening connection timed out for command: '%s'", command);
- throw new AdbComLinkOpenError("opening connection timed out", ex);
- } catch (AdbCommandRejectedException ex) {
- // Command rejected
- CLog.e("Device rejected command: '%s'", command);
- throw new AdbComLinkOpenError("command rejected", ex);
- } catch (IOException ex) {
- // shell command channel killed
- CLog.e("Channel died for command: '%s'", command);
- throw new AdbComLinkKilledError("command link killed", ex);
- } catch (ShellCommandUnresponsiveException ex) {
- // shell command halted
- CLog.e("No output from command in %d ms: '%s'", UNRESPOSIVE_CMD_TIMEOUT_MS, command);
- throw new AdbComLinkKilledError("command link hung", ex);
- }
- }
-
- /**
- * Executes given test batch on a device
- */
- private void executeTestRunBatch(TestBatch batch) throws DeviceNotAvailableException {
- // attempt full run once
- executeTestRunBatchRun(batch);
-
- // split remaining tests to two sub batches and execute both. This will terminate
- // since executeTestRunBatchRun will always progress for a batch of size 1.
- final ArrayList<TestIdentifier> pendingTests = new ArrayList<>();
-
- for (TestIdentifier test : batch.tests) {
- if (mInstanceListerner.isPendingTestInstance(test, batch.config)) {
- pendingTests.add(test);
- }
- }
-
- final int divisorNdx = pendingTests.size() / 2;
- final List<TestIdentifier> headList = pendingTests.subList(0, divisorNdx);
- final List<TestIdentifier> tailList = pendingTests.subList(divisorNdx, pendingTests.size());
-
- // head
- for (;;) {
- TestBatch subBatch = selectRunBatch(headList, batch.config);
-
- if (subBatch == null) {
- break;
- }
-
- executeTestRunBatch(subBatch);
- }
-
- // tail
- for (;;) {
- TestBatch subBatch = selectRunBatch(tailList, batch.config);
-
- if (subBatch == null) {
- break;
- }
-
- executeTestRunBatch(subBatch);
- }
-
- if (getBatchNumPendingCases(batch) != 0) {
- throw new AssertionError("executeTestRunBatch postcondition failed");
- }
- }
-
- /**
- * Runs one execution pass over the given batch.
- *
- * Tries to run the batch. Always makes progress (executes instances or modifies stability
- * scores).
- */
- private void executeTestRunBatchRun(TestBatch batch) throws DeviceNotAvailableException {
- if (getBatchNumPendingCases(batch) != batch.tests.size()) {
- throw new AssertionError("executeTestRunBatchRun precondition failed");
- }
-
- checkInterrupted(); // throws if interrupted
-
- final String testCases = generateTestCaseTrie(batch.tests);
-
- mDevice.executeShellCommand("rm " + CASE_LIST_FILE_NAME);
- mDevice.executeShellCommand("rm " + LOG_FILE_NAME);
- mDevice.pushString(testCases + "\n", CASE_LIST_FILE_NAME);
-
- final String instrumentationName =
- "com.drawelements.deqp/com.drawelements.deqp.testercore.DeqpInstrumentation";
-
- final StringBuilder deqpCmdLine = new StringBuilder();
- deqpCmdLine.append("--deqp-caselist-file=");
- deqpCmdLine.append(CASE_LIST_FILE_NAME);
- deqpCmdLine.append(" ");
- deqpCmdLine.append(getRunConfigDisplayCmdLine(batch.config));
-
- // If we are not logging data, do not bother outputting the images from the test exe.
- if (!mLogData) {
- deqpCmdLine.append(" --deqp-log-images=disable");
- }
-
- deqpCmdLine.append(" --deqp-watchdog=enable");
-
- final String command = String.format(
- "am instrument %s -w -e deqpLogFileName \"%s\" -e deqpCmdLine \"%s\""
- + " -e deqpLogData \"%s\" %s",
- AbiUtils.createAbiFlag(mAbi.getName()), LOG_FILE_NAME, deqpCmdLine.toString(),
- mLogData, instrumentationName);
-
- final int numRemainingInstancesBefore = getNumRemainingInstances();
- final InstrumentationParser parser = new InstrumentationParser(mInstanceListerner);
- Throwable interruptingError = null;
-
- try {
- CLog.d("Running command '%s'", command);
- executeShellCommandAndReadOutput(command, parser);
- parser.flush();
- } catch (Throwable ex) {
- CLog.w("Instrumented call threw '%s'", ex.getMessage());
- interruptingError = ex;
- }
-
- final boolean progressedSinceLastCall = mInstanceListerner.getCurrentTestId() != null ||
- getNumRemainingInstances() < numRemainingInstancesBefore;
-
- if (progressedSinceLastCall) {
- mDeviceRecovery.onExecutionProgressed();
- }
-
- // interrupted, try to recover
- if (interruptingError != null) {
- if (interruptingError instanceof AdbComLinkOpenError) {
- CLog.i("Recovering from comm link error");
- mDeviceRecovery.recoverConnectionRefused();
- } else if (interruptingError instanceof AdbComLinkKilledError) {
- CLog.i("Recovering from comm link killed");
- mDeviceRecovery.recoverComLinkKilled();
- } else if (interruptingError instanceof RunInterruptedException) {
- // external run interruption request. Terminate immediately.
- CLog.i("Run termination requested. Throwing forward.");
- throw (RunInterruptedException)interruptingError;
- } else {
- CLog.e(interruptingError);
- throw new RuntimeException(interruptingError);
- }
-
- // recoverXXX did not throw => recovery succeeded
- } else if (!parser.wasSuccessful()) {
- CLog.i("Parse not successful. Will attempt comm link recovery.");
- mDeviceRecovery.recoverComLinkKilled();
- // recoverXXX did not throw => recovery succeeded
- }
-
- // Progress guarantees.
- if (batch.tests.size() == 1) {
- final TestIdentifier onlyTest = batch.tests.iterator().next();
- final boolean wasTestExecuted =
- !mInstanceListerner.isPendingTestInstance(onlyTest, batch.config) &&
- mInstanceListerner.getCurrentTestId() == null;
- final boolean wasLinkFailure = !parser.wasSuccessful() || interruptingError != null;
-
- // Link failures can be caused by external events, require at least two observations
- // until bailing.
- if (!wasTestExecuted && (!wasLinkFailure || getTestInstabilityRating(onlyTest) > 0)) {
- recordTestInstability(onlyTest);
- // If we cannot finish the test, mark the case as a crash.
- //
- // If we couldn't even start the test, fail the test instance as non-executable.
- // This is required so that a consistently crashing or non-existent tests will
- // not cause futile (non-terminating) re-execution attempts.
- if (mInstanceListerner.getCurrentTestId() != null) {
- CLog.w("Test '%s' started, but not completed", onlyTest);
- mInstanceListerner.abortTest(onlyTest, INCOMPLETE_LOG_MESSAGE);
- } else {
- CLog.w("Test '%s' could not start", onlyTest);
- mInstanceListerner.abortTest(onlyTest, NOT_EXECUTABLE_LOG_MESSAGE);
- }
- } else if (wasTestExecuted) {
- clearTestInstability(onlyTest);
- }
- }
- else
- {
- // Analyze results to update test stability ratings. If there is no interrupting test
- // logged, increase instability rating of all remaining tests. If there is a
- // interrupting test logged, increase only its instability rating.
- //
- // A successful run of tests clears instability rating.
- if (mInstanceListerner.getCurrentTestId() == null) {
- for (TestIdentifier test : batch.tests) {
- if (mInstanceListerner.isPendingTestInstance(test, batch.config)) {
- recordTestInstability(test);
- } else {
- clearTestInstability(test);
- }
- }
- } else {
- recordTestInstability(mInstanceListerner.getCurrentTestId());
- for (TestIdentifier test : batch.tests) {
- // \note: isPendingTestInstance is false for getCurrentTestId. Current ID is
- // considered 'running' and will be restored to 'pending' in endBatch().
- if (!test.equals(mInstanceListerner.getCurrentTestId()) &&
- !mInstanceListerner.isPendingTestInstance(test, batch.config)) {
- clearTestInstability(test);
- }
- }
- }
- }
-
- mInstanceListerner.endBatch();
- }
-
- private static String getRunConfigDisplayCmdLine(BatchRunConfiguration runConfig) {
- final StringBuilder deqpCmdLine = new StringBuilder();
- if (!runConfig.getGlConfig().isEmpty()) {
- deqpCmdLine.append("--deqp-gl-config-name=");
- deqpCmdLine.append(runConfig.getGlConfig());
- }
- if (!runConfig.getRotation().isEmpty()) {
- if (deqpCmdLine.length() != 0) {
- deqpCmdLine.append(" ");
- }
- deqpCmdLine.append("--deqp-screen-rotation=");
- deqpCmdLine.append(runConfig.getRotation());
- }
- if (!runConfig.getSurfaceType().isEmpty()) {
- if (deqpCmdLine.length() != 0) {
- deqpCmdLine.append(" ");
- }
- deqpCmdLine.append("--deqp-surface-type=");
- deqpCmdLine.append(runConfig.getSurfaceType());
- }
- return deqpCmdLine.toString();
- }
-
- private int getNumRemainingInstances() {
- int retVal = 0;
- for (TestIdentifier testId : mRemainingTests) {
- // If case is in current working set, sum only not yet executed instances.
- // If case is not in current working set, sum all instances (since they are not yet
- // executed).
- if (mInstanceListerner.mPendingResults.containsKey(testId)) {
- retVal += mInstanceListerner.mPendingResults.get(testId).remainingConfigs.size();
- } else {
- retVal += mTestInstances.get(testId).size();
- }
- }
- return retVal;
- }
-
- /**
- * Checks if this execution has been marked as interrupted and throws if it has.
- */
- private void checkInterrupted() throws RunInterruptedException {
- // Work around the API. RunUtil::checkInterrupted is private but we can call it indirectly
- // by sleeping a value <= 0.
- mRunUtil.sleep(0);
- }
-
- /**
- * Pass given batch tests without running it
- */
- private void fakePassTestRunBatch(TestBatch batch) {
- for (TestIdentifier test : batch.tests) {
- CLog.d("Skipping test '%s' invocation in config '%s'", test.toString(),
- batch.config.getId());
- mInstanceListerner.skipTest(test);
- }
- }
-
- /**
- * Pass all remaining tests without running them
- */
- private void fakePassTests(ITestInvocationListener listener) {
- Map <String, String> emptyMap = Collections.emptyMap();
- for (TestIdentifier test : mRemainingTests) {
- CLog.d("Skipping test '%s', Opengl ES version not supported", test.toString());
- listener.testStarted(test);
- listener.testEnded(test, emptyMap);
- }
- mRemainingTests.clear();
- }
-
- /**
- * Check if device supports OpenGL ES version.
- */
- private static boolean isSupportedGles(ITestDevice device, int requiredMajorVersion,
- int requiredMinorVersion) throws DeviceNotAvailableException {
- String roOpenglesVersion = device.getProperty("ro.opengles.version");
-
- if (roOpenglesVersion == null)
- return false;
-
- int intValue = Integer.parseInt(roOpenglesVersion);
-
- int majorVersion = ((intValue & 0xffff0000) >> 16);
- int minorVersion = (intValue & 0xffff);
-
- return (majorVersion > requiredMajorVersion)
- || (majorVersion == requiredMajorVersion && minorVersion >= requiredMinorVersion);
- }
-
- /**
- * Query if rendertarget is supported
- */
- private boolean isSupportedGlesRenderConfig(BatchRunConfiguration runConfig)
- throws DeviceNotAvailableException, CapabilityQueryFailureException {
- // query if configuration is supported
- final StringBuilder configCommandLine =
- new StringBuilder(getRunConfigDisplayCmdLine(runConfig));
- if (configCommandLine.length() != 0) {
- configCommandLine.append(" ");
- }
- configCommandLine.append("--deqp-gl-major-version=");
- configCommandLine.append(getGlesMajorVersion());
- configCommandLine.append(" --deqp-gl-minor-version=");
- configCommandLine.append(getGlesMinorVersion());
-
- final String commandLine = configCommandLine.toString();
-
- // check for cached result first
- if (mConfigQuerySupportCache.containsKey(commandLine)) {
- return mConfigQuerySupportCache.get(commandLine);
- }
-
- final boolean supported = queryIsSupportedConfigCommandLine(commandLine);
- mConfigQuerySupportCache.put(commandLine, supported);
- return supported;
- }
-
- private boolean queryIsSupportedConfigCommandLine(String deqpCommandLine)
- throws DeviceNotAvailableException, CapabilityQueryFailureException {
- final String instrumentationName =
- "com.drawelements.deqp/com.drawelements.deqp.platformutil.DeqpPlatformCapabilityQueryInstrumentation";
- final String command = String.format(
- "am instrument %s -w -e deqpQueryType renderConfigSupported -e deqpCmdLine \"%s\""
- + " %s",
- AbiUtils.createAbiFlag(mAbi.getName()), deqpCommandLine, instrumentationName);
-
- final PlatformQueryInstrumentationParser parser = new PlatformQueryInstrumentationParser();
- mDevice.executeShellCommand(command, parser);
- parser.flush();
-
- if (parser.wasSuccessful() && parser.getResultCode() == 0 &&
- parser.getResultMap().containsKey("Supported")) {
- if ("Yes".equals(parser.getResultMap().get("Supported"))) {
- return true;
- } else if ("No".equals(parser.getResultMap().get("Supported"))) {
- return false;
- } else {
- CLog.e("Capability query did not return a result");
- throw new CapabilityQueryFailureException();
- }
- } else if (parser.wasSuccessful()) {
- CLog.e("Failed to run capability query. Code: %d, Result: %s",
- parser.getResultCode(), parser.getResultMap().toString());
- throw new CapabilityQueryFailureException();
- } else {
- CLog.e("Failed to run capability query");
- throw new CapabilityQueryFailureException();
- }
- }
-
- /**
- * Return feature set supported by the device
- */
- private Set<String> getDeviceFeatures(ITestDevice device)
- throws DeviceNotAvailableException, CapabilityQueryFailureException {
- if (mDeviceFeatures == null) {
- mDeviceFeatures = queryDeviceFeatures(device);
- }
- return mDeviceFeatures;
- }
-
- /**
- * Query feature set supported by the device
- */
- private static Set<String> queryDeviceFeatures(ITestDevice device)
- throws DeviceNotAvailableException, CapabilityQueryFailureException {
- // NOTE: Almost identical code in BaseDevicePolicyTest#hasDeviceFeatures
- // TODO: Move this logic to ITestDevice.
- String command = "pm list features";
- String commandOutput = device.executeShellCommand(command);
-
- // Extract the id of the new user.
- HashSet<String> availableFeatures = new HashSet<>();
- for (String feature: commandOutput.split("\\s+")) {
- // Each line in the output of the command has the format "feature:{FEATURE_VALUE}".
- String[] tokens = feature.split(":");
- if (tokens.length < 2 || !"feature".equals(tokens[0])) {
- CLog.e("Failed parse features. Unexpect format on line \"%s\"", tokens[0]);
- throw new CapabilityQueryFailureException();
- }
- availableFeatures.add(tokens[1]);
- }
- return availableFeatures;
- }
-
- private boolean isPortraitClassRotation(String rotation) {
- return BatchRunConfiguration.ROTATION_PORTRAIT.equals(rotation) ||
- BatchRunConfiguration.ROTATION_REVERSE_PORTRAIT.equals(rotation);
- }
-
- private boolean isLandscapeClassRotation(String rotation) {
- return BatchRunConfiguration.ROTATION_LANDSCAPE.equals(rotation) ||
- BatchRunConfiguration.ROTATION_REVERSE_LANDSCAPE.equals(rotation);
- }
-
- /**
- * Install dEQP OnDevice Package
- */
- private void installTestApk() throws DeviceNotAvailableException {
- try {
- File apkFile = mCtsBuild.getTestApp(DEQP_ONDEVICE_APK);
- String[] options = {AbiUtils.createAbiFlag(mAbi.getName())};
- String errorCode = getDevice().installPackage(apkFile, true, options);
- if (errorCode != null) {
- CLog.e("Failed to install %s. Reason: %s", DEQP_ONDEVICE_APK, errorCode);
- }
- } catch (FileNotFoundException e) {
- CLog.e("Could not find test apk %s", DEQP_ONDEVICE_APK);
- }
- }
-
- /**
- * Uninstall dEQP OnDevice Package
- */
- private void uninstallTestApk() throws DeviceNotAvailableException {
- getDevice().uninstallPackage(DEQP_ONDEVICE_PKG);
- }
-
- /**
- * Parse gl nature from package name
- */
- private boolean isOpenGlEsPackage() {
- if ("dEQP-GLES2".equals(mName) || "dEQP-GLES3".equals(mName) ||
- "dEQP-GLES31".equals(mName)) {
- return true;
- } else if ("dEQP-EGL".equals(mName)) {
- return false;
- } else {
- throw new IllegalStateException("dEQP runner was created with illegal name");
- }
- }
-
- /**
- * Check GL support (based on package name)
- */
- private boolean isSupportedGles() throws DeviceNotAvailableException {
- return isSupportedGles(mDevice, getGlesMajorVersion(), getGlesMinorVersion());
- }
-
- /**
- * Get GL major version (based on package name)
- */
- private int getGlesMajorVersion() throws DeviceNotAvailableException {
- if ("dEQP-GLES2".equals(mName)) {
- return 2;
- } else if ("dEQP-GLES3".equals(mName)) {
- return 3;
- } else if ("dEQP-GLES31".equals(mName)) {
- return 3;
- } else {
- throw new IllegalStateException("getGlesMajorVersion called for non gles pkg");
- }
- }
-
- /**
- * Get GL minor version (based on package name)
- */
- private int getGlesMinorVersion() throws DeviceNotAvailableException {
- if ("dEQP-GLES2".equals(mName)) {
- return 0;
- } else if ("dEQP-GLES3".equals(mName)) {
- return 0;
- } else if ("dEQP-GLES31".equals(mName)) {
- return 1;
- } else {
- throw new IllegalStateException("getGlesMinorVersion called for non gles pkg");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- final Map<String, String> emptyMap = Collections.emptyMap();
- final boolean isSupportedApi = !isOpenGlEsPackage() || isSupportedGles();
-
- listener.testRunStarted(getId(), mRemainingTests.size());
-
- try {
- if (isSupportedApi) {
- // Make sure there is no pre-existing package form earlier interrupted test run.
- uninstallTestApk();
- installTestApk();
-
- mInstanceListerner.setSink(listener);
- mDeviceRecovery.setDevice(mDevice);
- runTests();
-
- uninstallTestApk();
- } else {
- // Pass all tests if OpenGL ES version is not supported
- CLog.i("Package %s not supported by the device. Tests trivially pass.", mPackageName);
- fakePassTests(listener);
- }
- } catch (CapabilityQueryFailureException ex) {
- // Platform is not behaving correctly, for example crashing when trying to create
- // a window. Instead of silenty failing, signal failure by leaving the rest of the
- // test cases in "NotExecuted" state
- uninstallTestApk();
- }
-
- listener.testRunEnded(0, emptyMap);
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTest.java
deleted file mode 100644
index a2f4016..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTest.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.testrunner.ITestRunListener;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.util.AbiUtils;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Test runner for native gTests.
- *
- * TODO: This is similar to Tradefed's existing GTest, but it doesn't confirm
- * each directory segment exists using ddmlib's file service. This was
- * a problem since /data is not visible on a user build, but it is
- * executable. It's also a lot more verbose when it comes to errors.
- */
-public class GeeTest implements IBuildReceiver, IDeviceTest, IRemoteTest {
-
- private static final String NATIVE_TESTS_DIRECTORY = "/data/local/tmp/cts-native-tests";
- private static final String NATIVE_TESTS_DIRECTORY_TMP = "/data/local/tmp";
- private static final String ANDROID_PATH_SEPARATOR = "/";
- private static final String GTEST_FLAG_FILTER = "--gtest_filter=";
-
- private int mMaxTestTimeMs = 1 * 90 * 1000;
-
- private CtsBuildHelper mCtsBuild;
- private ITestDevice mDevice;
- private IAbi mAbi;
- private String mExeName;
-
- private final String mPackageName;
-
- private String mPositiveFilters = "";
- private String mNegativeFilters = "";
-
- public GeeTest(String packageName, String exeName) {
- mPackageName = packageName;
- mExeName = exeName;
- }
-
- public void setPositiveFilters(String positiveFilters) {
- mPositiveFilters = positiveFilters;
- }
-
- public void setNegativeFilters(String negativeFilters) {
- mNegativeFilters = negativeFilters;
- }
-
- protected String getGTestFilters() {
- // If both filters are empty or null return empty string.
- if (mPositiveFilters == null && mNegativeFilters == null) {
- return "";
- }
- if (mPositiveFilters.isEmpty() && mNegativeFilters.isEmpty()) {
- return "";
- }
- // Build filter string.
- StringBuilder sb = new StringBuilder();
- sb.append(GTEST_FLAG_FILTER);
- boolean hasPositiveFilters = false;
- if (mPositiveFilters != null && !mPositiveFilters.isEmpty()) {
- sb.append(mPositiveFilters);
- hasPositiveFilters = true;
- }
- if (mNegativeFilters != null && ! mNegativeFilters.isEmpty()) {
- if (hasPositiveFilters) {
- sb.append(":");
- }
- sb.append("-");
- sb.append(mNegativeFilters);
- }
- return sb.toString();
- }
-
- /**
- * @param abi The ABI to run the test on
- */
- public void setAbi(IAbi abi) {
- mAbi = abi;
- mExeName += mAbi.getBitness();
- }
-
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- if (installTest()) {
- runTest(listener);
- } else {
- CLog.e("Failed to install native tests");
- }
- }
-
- private boolean installTest() throws DeviceNotAvailableException {
- if (!createRemoteDir(NATIVE_TESTS_DIRECTORY)) {
- CLog.e("Could not create directory for native tests: " + NATIVE_TESTS_DIRECTORY);
- return false;
- }
-
- File nativeExe = new File(mCtsBuild.getTestCasesDir(), mExeName);
- if (!nativeExe.exists()) {
- CLog.e("Native test not found: " + nativeExe);
- return false;
- }
-
- String devicePath = NATIVE_TESTS_DIRECTORY + ANDROID_PATH_SEPARATOR + mExeName;
- if (!mDevice.pushFile(nativeExe, devicePath)) {
- CLog.e("Failed to push native test to device");
- return false;
- }
- return true;
- }
-
- private boolean createRemoteDir(String remoteFilePath) throws DeviceNotAvailableException {
- if (mDevice.doesFileExist(remoteFilePath)) {
- return true;
- }
- if (!(mDevice.doesFileExist(NATIVE_TESTS_DIRECTORY_TMP))) {
- CLog.e("Could not find the /data/local/tmp directory");
- return false;
- }
-
- mDevice.executeShellCommand(String.format("mkdir %s", remoteFilePath));
- return mDevice.doesFileExist(remoteFilePath);
- }
-
- void runTest(ITestRunListener listener) throws DeviceNotAvailableException {
- String id = AbiUtils.createId(mAbi.getName(), mPackageName);
- GeeTestResultParser resultParser = new GeeTestResultParser(id, listener);
- resultParser.setFakePackagePrefix(mPackageName + ".");
-
- String fullPath = NATIVE_TESTS_DIRECTORY + ANDROID_PATH_SEPARATOR + mExeName;
- String flags = getGTestFilters();
- CLog.v("Running gtest %s %s on %s", fullPath, flags, mDevice.getSerialNumber());
- // force file to be executable
- CLog.v("%s", mDevice.executeShellCommand(String.format("chmod 755 %s", fullPath)));
-
- try {
- mDevice.executeShellCommand(String.format("%s %s", fullPath, flags), resultParser,
- mMaxTestTimeMs /* maxTimeToShellOutputResponse */, TimeUnit.MILLISECONDS,
- 0 /* retryAttempts */);
- } catch (DeviceNotAvailableException e) {
- resultParser.flush();
- throw e;
- } catch (RuntimeException e) {
- resultParser.flush();
- throw e;
- }
- }
-
-
- @Override
- public void setBuild(IBuildInfo buildInfo) {
- mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
- }
-
- @Override
- public void setDevice(ITestDevice device) {
- mDevice = device;
- }
-
- @Override
- public ITestDevice getDevice() {
- return mDevice;
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTestResultParser.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTestResultParser.java
deleted file mode 100644
index d0ea0cf..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTestResultParser.java
+++ /dev/null
@@ -1,668 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.testrunner.ITestRunListener;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.testtype.testdefs.XmlDefsTest;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * TODO: Merge change to add package prefix to tradefed's GTestResultParser.
- * Otherwise this file should be the same as TradeFed's version.
- *
- * Parses the 'raw output mode' results of native tests using GTest that run from shell, and informs
- * a ITestRunListener of the results.
- * <p>Sample format of output expected:
- *
- * <pre>
- * [==========] Running 15 tests from 1 test case.
- * [----------] Global test environment set-up.
- * [----------] 15 tests from MessageTest
- * [ RUN ] MessageTest.DefaultConstructor
- * [ OK ] MessageTest.DefaultConstructor (1 ms)
- * [ RUN ] MessageTest.CopyConstructor
- * external/gtest/test/gtest-message_test.cc:67: Failure
- * Value of: 5
- * Expected: 2
- * external/gtest/test/gtest-message_test.cc:68: Failure
- * Value of: 1 == 1
- * Actual: true
- * Expected: false
- * [ FAILED ] MessageTest.CopyConstructor (2 ms)
- * ...
- * [ RUN ] MessageTest.DoesNotTakeUpMuchStackSpace
- * [ OK ] MessageTest.DoesNotTakeUpMuchStackSpace (0 ms)
- * [----------] 15 tests from MessageTest (26 ms total)
- *
- * [----------] Global test environment tear-down
- * [==========] 15 tests from 1 test case ran. (26 ms total)
- * [ PASSED ] 6 tests.
- * [ FAILED ] 9 tests, listed below:
- * [ FAILED ] MessageTest.CopyConstructor
- * [ FAILED ] MessageTest.ConstructsFromCString
- * [ FAILED ] MessageTest.StreamsCString
- * [ FAILED ] MessageTest.StreamsNullCString
- * [ FAILED ] MessageTest.StreamsString
- * [ FAILED ] MessageTest.StreamsStringWithEmbeddedNUL
- * [ FAILED ] MessageTest.StreamsNULChar
- * [ FAILED ] MessageTest.StreamsInt
- * [ FAILED ] MessageTest.StreamsBasicIoManip
- * 9 FAILED TESTS
- * </pre>
- *
- * <p>where the following tags are used to signal certain events:
- * <pre>
- * [==========]: the first occurrence indicates a new run started, including the number of tests
- * to be expected in this run
- * [ RUN ]: indicates a new test has started to run; a series of zero or more lines may
- * follow a test start, and will be captured in case of a test failure or error
- * [ OK ]: the preceding test has completed successfully, optionally including the time it
- * took to run (in ms)
- * [ FAILED ]: the preceding test has failed, optionally including the time it took to run (in ms)
- * [==========]: the preceding test run has completed, optionally including the time it took to run
- * (in ms)
- * </pre>
- *
- * All other lines are ignored.
- */
-public class GeeTestResultParser extends MultiLineReceiver {
- private static final String LOG_TAG = "GTestResultParser";
-
- // Variables to keep track of state
- private TestResult mCurrentTestResult = null;
- private int mNumTestsRun = 0;
- private int mNumTestsExpected = 0;
- private long mTotalRunTime = 0;
- private boolean mTestInProgress = false;
- private boolean mTestRunInProgress = false;
- private final String mTestRunId;
- private final Collection<ITestRunListener> mTestListeners;
-
- /** Fake adding a package prefix if the test listener needs it. */
- private String mFakePackagePrefix = "";
-
- /** True if start of test has already been reported to listener. */
- private boolean mTestRunStartReported = false;
-
- /** True if current test run has been canceled by user. */
- private boolean mIsCancelled = false;
-
- private String mCoverageTarget = null;
-
- /**
- * Test result data
- */
- private static class TestResult {
- private String mTestName = null;
- private String mTestClass = null;
- private StringBuilder mStackTrace = null;
- @SuppressWarnings("unused")
- private Long mRunTime = null;
-
- /** Returns whether expected values have been parsed
- *
- * @return true if all expected values have been parsed
- */
- boolean isComplete() {
- return mTestName != null && mTestClass != null;
- }
-
- /** Returns whether there is currently a stack trace
- *
- * @return true if there is currently a stack trace, false otherwise
- */
- boolean hasStackTrace() {
- return mStackTrace != null;
- }
-
- /**
- * Returns the stack trace of the current test.
- *
- * @return a String representation of the current test's stack trace; if there is not
- * a current stack trace, it returns an error string. Use {@link TestResult#hasStackTrace}
- * if you need to know whether there is a stack trace.
- */
- String getTrace() {
- if (hasStackTrace()) {
- return mStackTrace.toString();
- } else {
- Log.e(LOG_TAG, "Could not find stack trace for failed test");
- return new Throwable("Unknown failure").toString();
- }
- }
-
- /** Provides a more user readable string for TestResult, if possible */
- @Override
- public String toString() {
- StringBuilder output = new StringBuilder();
- if (mTestClass != null ) {
- output.append(mTestClass);
- output.append('#');
- }
- if (mTestName != null) {
- output.append(mTestName);
- }
- if (output.length() > 0) {
- return output.toString();
- }
- return "unknown result";
- }
- }
-
- /** Internal helper struct to store parsed test info. */
- private static class ParsedTestInfo {
- String mTestName = null;
- String mTestClassName = null;
- String mTestRunTime = null;
-
- public ParsedTestInfo(String testName, String testClassName, String testRunTime) {
- mTestName = testName;
- mTestClassName = testClassName;
- mTestRunTime = testRunTime;
- }
- }
-
- /** Prefixes used to demarcate and identify output. */
- private static class Prefixes {
- @SuppressWarnings("unused")
- private static final String INFORMATIONAL_MARKER = "[----------]";
- private static final String START_TEST_RUN_MARKER = "[==========] Running";
- private static final String TEST_RUN_MARKER = "[==========]";
- private static final String START_TEST_MARKER = "[ RUN ]";
- private static final String OK_TEST_MARKER = "[ OK ]";
- private static final String FAILED_TEST_MARKER = "[ FAILED ]";
- }
-
- /**
- * Creates the GTestResultParser.
- *
- * @param testRunId the test run id to provide to
- * {@link ITestRunListener#testRunStarted(String, int)}
- * @param listeners informed of test results as the tests are executing
- */
- public GeeTestResultParser(String testRunId, Collection<ITestRunListener> listeners) {
- mTestRunId = testRunId;
- mTestListeners = new ArrayList<ITestRunListener>(listeners);
- }
-
- /**
- * Creates the GTestResultParser for a single listener.
- *
- * @param testRunId the test run id to provide to
- * {@link ITestRunListener#testRunStarted(String, int)}
- * @param listener informed of test results as the tests are executing
- */
- public GeeTestResultParser(String testRunId, ITestRunListener listener) {
- mTestRunId = testRunId;
- mTestListeners = new ArrayList<ITestRunListener>(1);
- mTestListeners.add(listener);
- }
-
- /**
- * Package prefix to be added to test names when they are reported like
- * "android.nativemedia." You may need to add the dot if you need it.
- */
- public void setFakePackagePrefix(String prefix) {
- mFakePackagePrefix = prefix;
- }
-
- /**
- * Returns the current TestResult for test in progress, or a new default one.
- *
- * @return The TestResult for the current test run
- */
- private TestResult getCurrentTestResult() {
- if (mCurrentTestResult == null) {
- mCurrentTestResult = new TestResult();
- }
- return mCurrentTestResult;
- }
-
-
- /**
- * Clears out the current TestResult.
- */
- private void clearCurrentTestResult() {
- mCurrentTestResult = null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void processNewLines(String[] lines) {
- for (String line : lines) {
- parse(line);
- }
- }
-
- /**
- * Parse an individual output line.
- *
- * @param line Text output line
- */
- private void parse(String line) {
- String message = null;
-
- if (mTestRunInProgress || line.startsWith(Prefixes.TEST_RUN_MARKER)) {
- if (line.startsWith(Prefixes.START_TEST_MARKER)) {
- // Individual test started
- message = line.substring(Prefixes.START_TEST_MARKER.length()).trim();
- processTestStartedTag(message);
- }
- else if (line.startsWith(Prefixes.OK_TEST_MARKER)) {
- // Individual test completed successfully
- message = line.substring(Prefixes.OK_TEST_MARKER.length()).trim();
- processOKTag(message);
- clearCurrentTestResult();
- }
- else if (line.startsWith(Prefixes.FAILED_TEST_MARKER)) {
- // Individual test completed with failure
- message = line.substring(Prefixes.FAILED_TEST_MARKER.length()).trim();
- processFailedTag(message);
- clearCurrentTestResult();
- }
- else if (line.startsWith(Prefixes.START_TEST_RUN_MARKER)) {
- // Test run started
- // Make sure to leave the "Running" in the string
- message = line.substring(Prefixes.TEST_RUN_MARKER.length()).trim();
- processRunStartedTag(message);
- }
- else if (line.startsWith(Prefixes.TEST_RUN_MARKER)) {
- // Test run ended
- // This is for the end of the test suite run, so make sure this else-if is after the
- // check for START_TEST_SUITE_MARKER
- message = line.substring(Prefixes.TEST_RUN_MARKER.length()).trim();
- processRunCompletedTag(message);
- }
- else if (testInProgress()) {
- // Note this does not handle the case of an error outside an actual test run
- appendTestOutputLine(line);
- }
- }
- }
-
- /**
- * Returns true if test run canceled.
- *
- * @see IShellOutputReceiver#isCancelled()
- */
- @Override
- public boolean isCancelled() {
- return mIsCancelled;
- }
-
- /**
- * Requests cancellation of test run.
- */
- public void cancel() {
- mIsCancelled = true;
- }
-
- /**
- * Returns whether we're in the middle of running a test.
- *
- * @return True if a test was started, false otherwise
- */
- private boolean testInProgress() {
- return mTestInProgress;
- }
-
- /**
- * Set state to indicate we've started running a test.
- *
- */
- private void setTestStarted() {
- mTestInProgress = true;
- }
-
- /**
- * Set state to indicate we've started running a test.
- *
- */
- private void setTestEnded() {
- mTestInProgress = false;
- }
-
- /**
- * Reports the start of a test run, and the total test count, if it has not been previously
- * reported.
- */
- private void reportTestRunStarted() {
- // if start test run not reported yet
- if (!mTestRunStartReported) {
- for (ITestRunListener listener : mTestListeners) {
- listener.testRunStarted(mTestRunId, mNumTestsExpected);
- }
- mTestRunStartReported = true;
- }
- }
-
- /**
- * Reports the end of a test run, and resets that test
- */
- private void reportTestRunEnded() {
- for (ITestRunListener listener : mTestListeners) {
- listener.testRunEnded(mTotalRunTime, getRunMetrics());
- }
- mTestRunStartReported = false;
- }
-
- /**
- * Create the run metrics {@link Map} to report.
- *
- * @return a {@link Map} of run metrics data
- */
- private Map<String, String> getRunMetrics() {
- Map<String, String> metricsMap = new HashMap<String, String>();
- if (mCoverageTarget != null) {
- metricsMap.put(XmlDefsTest.COVERAGE_TARGET_KEY, mCoverageTarget);
- }
- return metricsMap;
- }
-
- /**
- * Parse the test identifier (class and test name), and optional time info.
- *
- * @param identifier Raw identifier of the form classname.testname, with an optional time
- * element in the format of (XX ms) at the end
- * @return A ParsedTestInfo representing the parsed info from the identifier string.
- *
- * If no time tag was detected, then the third element in the array (time_in_ms) will
- * be null. If the line failed to parse properly (eg: could not determine name of
- * test/class) then an "UNKNOWN" string value will be returned for the classname and
- * testname. This method guarantees a string will always be returned for the class and
- * test names (but not for the time value).
- */
- private ParsedTestInfo parseTestIdentifier(String identifier) {
- ParsedTestInfo returnInfo = new ParsedTestInfo("UNKNOWN_CLASS", "UNKNOWN_TEST", null);
-
- Pattern timePattern = Pattern.compile(".*(\\((\\d+) ms\\))"); // eg: (XX ms)
- Matcher time = timePattern.matcher(identifier);
-
- // Try to find a time
- if (time.find()) {
- String timeString = time.group(2); // the "XX" in "(XX ms)"
- String discardPortion = time.group(1); // everything after the test class/name
- identifier = identifier.substring(0, identifier.lastIndexOf(discardPortion)).trim();
- returnInfo.mTestRunTime = timeString;
- }
-
- String[] testId = identifier.split("\\.");
- if (testId.length < 2) {
- Log.e(LOG_TAG, "Could not detect the test class and test name, received: " +
- identifier);
- }
- else {
- returnInfo.mTestClassName = testId[0];
- returnInfo.mTestName = testId[1];
- }
- return returnInfo;
- }
-
- /**
- * Parses and stores the test identifier (class and test name).
- *
- * @param identifier Raw identifier
- */
- private void processRunStartedTag(String identifier) {
- // eg: (Running XX tests from 1 test case.)
- Pattern numTestsPattern = Pattern.compile("Running (\\d+) test[s]? from .*");
- Matcher numTests = numTestsPattern.matcher(identifier);
-
- // Try to find number of tests
- if (numTests.find()) {
- try {
- mNumTestsExpected = Integer.parseInt(numTests.group(1));
- }
- catch (NumberFormatException e) {
- Log.e(LOG_TAG, "Unable to determine number of tests expected, received: " +
- numTests.group(1));
- }
- }
- if (mNumTestsExpected > 0) {
- reportTestRunStarted();
- mNumTestsRun = 0;
- mTestRunInProgress = true;
- }
- }
-
- /**
- * Processes and informs listener when we encounter a tag indicating that a test suite is done.
- *
- * @param identifier Raw log output from the suite ended tag
- */
- private void processRunCompletedTag(String identifier) {
- Pattern timePattern = Pattern.compile(".*\\((\\d+) ms total\\)"); // eg: (XX ms total)
- Matcher time = timePattern.matcher(identifier);
-
- // Try to find the total run time
- if (time.find()) {
- try {
- mTotalRunTime = Long.parseLong(time.group(1));
- }
- catch (NumberFormatException e) {
- Log.e(LOG_TAG, "Unable to determine the total running time, received: " +
- time.group(1));
- }
- }
- reportTestRunEnded();
- mTestRunInProgress = false;
- }
-
- /**
- * Processes and informs listener when we encounter a tag indicating that a test has started.
- *
- * @param identifier Raw log output of the form classname.testname, with an optional time (x ms)
- */
- private void processTestStartedTag(String identifier) {
- ParsedTestInfo parsedResults = parseTestIdentifier(identifier);
- TestResult testResult = getCurrentTestResult();
- testResult.mTestClass = parsedResults.mTestClassName;
- testResult.mTestName = parsedResults.mTestName;
-
- TestIdentifier testId = new TestIdentifier(mFakePackagePrefix + testResult.mTestClass,
- testResult.mTestName);
-
- for (ITestRunListener listener : mTestListeners) {
- listener.testStarted(testId);
- }
- setTestStarted();
- }
-
- /**
- * Helper method to do the work necessary when a test has ended.
- *
- * @param identifier Raw log output of the form "classname.testname" with an optional (XX ms)
- * at the end indicating the running time.
- * @param testPassed Indicates whether the test passed or failed (set to true if passed, false
- * if failed)
- */
- private void doTestEnded(String identifier, boolean testPassed) {
- ParsedTestInfo parsedResults = parseTestIdentifier(identifier);
- TestResult testResult = getCurrentTestResult();
- TestIdentifier testId = new TestIdentifier(mFakePackagePrefix + testResult.mTestClass,
- testResult.mTestName);
-
- // Error - trying to end a test when one isn't in progress
- if (!testInProgress()) {
- Log.e(LOG_TAG, "Test currently not in progress when trying to end test: " + identifier);
- return;
- }
-
- // Save the run time for this test if one exists
- if (parsedResults.mTestRunTime != null) {
- try {
- testResult.mRunTime = new Long(parsedResults.mTestRunTime);
- }
- catch (NumberFormatException e) {
- Log.e(LOG_TAG, "Test run time value is invalid, received: " +
- parsedResults.mTestRunTime);
- }
- }
-
- // Check that the test result is for the same test/class we're expecting it to be for
- boolean encounteredUnexpectedTest = false;
- if (!testResult.isComplete()) {
- Log.e(LOG_TAG, "No test/class name is currently recorded as running!");
- }
- else {
- if (testResult.mTestClass.compareTo(parsedResults.mTestClassName) != 0) {
- Log.e(LOG_TAG, "Name for current test class does not match class we started " +
- "with, expected: " + testResult.mTestClass + " but got: " +
- parsedResults.mTestClassName);
- encounteredUnexpectedTest = true;
- }
- if (testResult.mTestName.compareTo(parsedResults.mTestName) != 0) {
- Log.e(LOG_TAG, "Name for current test does not match test we started with," +
- "expected: " + testResult.mTestName + " bug got: " +
- parsedResults.mTestName);
- encounteredUnexpectedTest = true;
- }
- }
-
- if (encounteredUnexpectedTest) {
- // If the test name of the result changed from what we started with, report that
- // the last known test failed, regardless of whether we received a pass or fail tag.
- for (ITestRunListener listener : mTestListeners) {
- listener.testFailed(testId, mCurrentTestResult.getTrace());
- }
- }
- else if (!testPassed) { // test failed
- for (ITestRunListener listener : mTestListeners) {
- listener.testFailed(testId, mCurrentTestResult.getTrace());
- }
- }
- // For all cases (pass or fail), we ultimately need to report test has ended
- Map <String, String> emptyMap = Collections.emptyMap();
- for (ITestRunListener listener : mTestListeners) {
- // @TODO: Add reporting of test run time to ITestRunListener
- listener.testEnded(testId, emptyMap);
- }
-
- setTestEnded();
- ++mNumTestsRun;
- }
-
- /**
- * Processes and informs listener when we encounter the OK tag.
- *
- * @param identifier Raw log output of the form "classname.testname" with an optional (XX ms)
- * at the end indicating the running time.
- */
- private void processOKTag(String identifier) {
- doTestEnded(identifier, true);
- }
-
- /**
- * Processes and informs listener when we encounter the FAILED tag.
- *
- * @param identifier Raw log output of the form "classname.testname" with an optional (XX ms)
- * at the end indicating the running time.
- */
- private void processFailedTag(String identifier) {
- doTestEnded(identifier, false);
- }
-
- /**
- * Appends the test output to the current TestResult.
- *
- * @param line Raw test result line of output.
- */
- private void appendTestOutputLine(String line) {
- TestResult testResult = getCurrentTestResult();
- if (testResult.mStackTrace == null) {
- testResult.mStackTrace = new StringBuilder();
- }
- else {
- testResult.mStackTrace.append("\r\n");
- }
- testResult.mStackTrace.append(line);
- }
-
- /**
- * Process an instrumentation run failure
- *
- * @param errorMsg The message to output about the nature of the error
- */
- private void handleTestRunFailed(String errorMsg) {
- errorMsg = (errorMsg == null ? "Unknown error" : errorMsg);
- Log.i(LOG_TAG, String.format("Test run failed: %s", errorMsg));
- String testRunStackTrace = "";
-
- // Report that the last known test failed
- if ((mCurrentTestResult != null) && (mCurrentTestResult.isComplete())) {
- // current test results are cleared out after every complete test run,
- // if it's not null, assume the last test caused this and report as a test failure
- TestIdentifier testId = new TestIdentifier(mCurrentTestResult.mTestClass,
- mCurrentTestResult.mTestName);
-
- // If there was any stack trace during the test run, append it to the "test failed"
- // error message so we have an idea of what caused the crash/failure.
- Map<String, String> emptyMap = Collections.emptyMap();
- if (mCurrentTestResult.hasStackTrace()) {
- testRunStackTrace = mCurrentTestResult.getTrace();
- }
- for (ITestRunListener listener : mTestListeners) {
- listener.testFailed(testId, "No test results.\r\n" + testRunStackTrace);
- listener.testEnded(testId, emptyMap);
- }
- clearCurrentTestResult();
- }
- // Report the test run failed
- for (ITestRunListener listener : mTestListeners) {
- listener.testRunFailed(errorMsg);
- listener.testRunEnded(mTotalRunTime, getRunMetrics());
- }
- }
-
- /**
- * Called by parent when adb session is complete.
- */
- @Override
- public void done() {
- super.done();
- if (mNumTestsExpected > mNumTestsRun) {
- handleTestRunFailed(String.format("Test run incomplete. Expected %d tests, received %d",
- mNumTestsExpected, mNumTestsRun));
- }
- else if (mTestRunInProgress) {
- handleTestRunFailed("No test results");
- }
- }
-
- /**
- * Sets the coverage target for this test.
- * <p/>
- * Will be sent as a metric to test listeners.
- *
- * @param coverageTarget the coverage target
- */
- public void setCoverageTarget(String coverageTarget) {
- mCoverageTarget = coverageTarget;
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageDef.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageDef.java
deleted file mode 100644
index 13f3572..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageDef.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IRemoteTest;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Container for CTS test info.
- * <p/>
- * Knows how to translate this info into a runnable {@link IRemoteTest}.
- */
-public interface ITestPackageDef extends Comparable<ITestPackageDef> {
-
- /**
- * Get the id of the test package.
- * @return the {@link String} id
- */
- public String getId();
-
- /**
- * Creates a runnable {@link IRemoteTest} from info stored in this definition.
- *
- * @param testCaseDir {@link File} representing directory of test case data
- * @return a {@link IRemoteTest} with all necessary data populated to run the test or
- * <code>null</code> if test could not be created
- */
- public IRemoteTest createTest(File testCaseDir);
-
- /**
- * Get the collection of tests in this test package.
- */
- public Collection<TestIdentifier> getTests();
-
- /**
- * Return the sha1sum of the binary file for this test package.
- * <p/>
- * Will only return a valid value after {@link #createTest(File)} has been called.
- *
- * @return the sha1sum in {@link String} form
- */
- public String getDigest();
-
- /**
- * @return the name of this test package.
- */
- public String getName();
-
- /**
- * @return the ABI of this test package.
- */
- public IAbi getAbi();
-
- /**
- * Set the filter to use for tests
- *
- * @param testFilter
- */
- public void setTestFilter(TestFilter testFilter);
-
- /**
- * Restrict this test package to run a specific class and method name
- *
- * @param className the test class to restrict this run to
- * @param methodName the optional test method to restrict this run to, or <code>null</code> to
- * run all tests in class
- */
- public void setClassName(String className, String methodName);
-
- /**
- * Return the file name of this package's instrumentation target apk.
- *
- * @return the file name or <code>null</code> if not applicable.
- */
- public String getTargetApkName();
-
- /**
- * Return the Android package name of this package's instrumentation target, or
- * <code>null</code> if not applicable.
- */
- public String getTargetPackageName();
-
- /**
- * Return a list of preparers used for setup or teardown of test cases in this package
- * @return
- */
- public List<ITargetPreparer> getPackagePreparers();
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageRepo.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageRepo.java
deleted file mode 100644
index 3de95ee..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageRepo.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.tradefed.util.AbiUtils;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Interface for accessing tests from the CTS repository.
- */
-public interface ITestPackageRepo {
-
- /**
- * Get a {@link TestPackageDef} given an id.
- *
- * @param id the unique identifier of this test package, generated by
- * {@link AbiUtils#createId(String, String)}.
- * @return a {@link TestPackageDef}
- */
- public ITestPackageDef getTestPackage(String id);
-
- /**
- * @return a sorted {@link List} of all package ids found in repo.
- */
- public List<String> getPackageIds();
-
- /**
- * @return a sorted {@link List} of test package names
- */
- public List<String> getPackageNames();
-
- /**
- * @return A {@link Map} of test package name to a {@link List} of {@link ITestPackageDef}s.
- */
- public Map<String, List<ITestPackageDef>> getTestPackageDefsByName();
-
- /**
- * Attempt to find the package ids for a given test class name
- *
- * @param testClassName the test class name
- * @return a {@link List} of package ids.
- */
- public List<String> findPackageIdsForTest(String testClassName);
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPlan.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPlan.java
deleted file mode 100644
index 2d5f4a7..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPlan.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Interface for accessing test plan data.
- */
-public interface ITestPlan {
-
- /**
- * Populates the test plan data from given XML stream.
- *
- * @param xmlStream the {@link InputStream} that contains the test plan xml.
- */
- public void parse(InputStream xmlStream) throws ParseException;
-
- /**
- * Gets a sorted list of test ids contained in this plan.
- */
- public Collection<String> getTestIds();
-
- /**
- * Gets a sorted {@link List} of test names contained in this plan.
- */
- public List<String> getTestNames();
-
- /**
- * Gets the {@link TestFilter} that should be used to filter tests from given package.
- */
- public TestFilter getTestFilter(String id);
-
- /**
- * Add a package to this test plan
- * @param id
- */
- public void addPackage(String id);
-
- /**
- * Add a excluded test to this test plan
- *
- * @param id the package id
- * @param testToExclude the test to exclude for given package
- */
- public void addExcludedTest(String id, TestIdentifier testToExclude);
-
- /**
- * Adds the list of excluded tests for given package
- *
- * @param id
- * @param excludedTests
- */
- public void addExcludedTests(String id, Collection<TestIdentifier> excludedTests);
-
- /**
- * Serialize the contents of this test plan.
- *
- * @param xmlOutStream the {@link OutputStream} to serialize test plan contents to
- * @throws IOException
- */
- public void serialize(OutputStream xmlOutStream) throws IOException;
-
- /**
- * @return the test plan name
- */
- public String getName();
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/JUnitDeviceTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/JUnitDeviceTest.java
deleted file mode 100644
index 5efa7cd..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/JUnitDeviceTest.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.Option.Importance;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.util.AbiFormatter;
-import com.android.tradefed.util.ArrayUtil;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-/**
- * {@link Test} for running CTS JUnit tests on the device.
- */
-public class JUnitDeviceTest implements IDeviceTest, IRemoteTest, IBuildReceiver {
-
- private static final String TMP_DIR = "/data/local/tmp/";
-
- @Option(name = "junit-device-runtime",
- description = "The name of the runtime to use on the device",
- importance = Importance.ALWAYS)
- private String mRuntimePath = "dalvikvm|#ABI#|";
-
- @Option(name = "junit-device-tmpdir", description = "Device path where to store the test jars."
- , importance = Importance.IF_UNSET)
- private String mDeviceTestTmpPath = TMP_DIR;
-
-
-
- // default to no timeout
- private long mMaxTimeToOutputResponse = 0;
-
- private ITestDevice mDevice;
- private String mRunName;
- private Collection<TestIdentifier> mTests;
- private CtsBuildHelper mCtsBuild = null;
-
- private List<String> mJarPaths = new ArrayList<String>();
-
- private String mRuntimeArgs;
-
- private IAbi mAbi;
-
- private static final String JUNIT_JAR = "cts-junit.jar";
-
- private Set<String> mTestJars = new HashSet<String>(Arrays.asList(JUNIT_JAR));
-
- /**
- * @param abi The ABI to run the test on
- */
- public void setAbi(IAbi abi) {
- mAbi = abi;
- }
-
- @Override
- public ITestDevice getDevice() {
- return mDevice;
- }
-
- @Override
- public void setDevice(ITestDevice device) {
- mDevice = device;
- }
-
- public void addTestJarFileName(String jarFileName) {
- mTestJars.add(jarFileName);
- }
-
- public void setRunName(String runName) {
- mRunName = runName;
- }
-
- public void setTests(Collection<TestIdentifier> tests) {
- mTests = tests;
- }
-
- public Collection<TestIdentifier> getTests() {
- return mTests;
- }
-
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- addTestJarFileName(JUNIT_JAR);
- checkFields();
- long startTime = System.currentTimeMillis();
- listener.testRunStarted(mRunName, mTests.size());
- try {
- installJars();
- String jarPath = ArrayUtil.join(":", mJarPaths);
- for (TestIdentifier testId : mTests) {
- SingleJUnitTestResultParser resultParser = new SingleJUnitTestResultParser(
- testId, listener);
- String cmdLine = String.format("ANDROID_DATA=%s %s -cp %s %s " +
- "com.android.cts.junit.SingleJUnitTestRunner %s#%s",
- mDeviceTestTmpPath, mRuntimePath, jarPath, mRuntimeArgs,
- testId.getClassName(), testId.getTestName());
- String cmd = AbiFormatter.formatCmdForAbi(cmdLine, mAbi.getBitness());
- CLog.d("Running %s", cmd);
- listener.testStarted(testId);
- mDevice.executeShellCommand(cmd, resultParser, mMaxTimeToOutputResponse,
- TimeUnit.MILLISECONDS, 0);
- }
- } finally {
- listener.testRunEnded(System.currentTimeMillis() - startTime,
- Collections.<String, String> emptyMap());
- // Remove jar files from device
- removeJars();
- }
- }
-
- /**
- * Installs the jar files on the device under test.
- *
- * @throws DeviceNotAvailableException
- */
- protected void installJars() throws DeviceNotAvailableException {
- for (String f : mTestJars) {
- CLog.d("Installing %s on %s", f, getDevice().getSerialNumber());
- File jarFile;
- try {
- String fullJarPath = String.format("%s%s", mDeviceTestTmpPath, f);
- jarFile = mCtsBuild.getTestApp(f);
- boolean result = getDevice().pushFile(jarFile, fullJarPath);
- Assert.assertTrue(String.format("Failed to push file to %s", fullJarPath), result);
- mJarPaths.add(fullJarPath);
- } catch (FileNotFoundException e) {
- Assert.fail(String.format("Could not find file %s", f));
- }
- }
- }
-
- /**
- * Cleans up the jar files from the device under test.
- *
- * @throws DeviceNotAvailableException
- */
- protected void removeJars() throws DeviceNotAvailableException {
- for (String f : mTestJars) {
- String fullJarPath = String.format("%s%s", mDeviceTestTmpPath, f);
- CLog.d("Uninstalling %s on %s", fullJarPath, getDevice().getSerialNumber());
- getDevice().executeShellCommand(String.format("rm %s", fullJarPath));
- }
- }
-
- @Override
- public void setBuild(IBuildInfo buildInfo) {
- mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
- }
-
- /**
- * Checks that all mandatory member fields has been set.
- */
- protected void checkFields() {
- if (mRunName == null) {
- throw new IllegalArgumentException("run name has not been set");
- }
- if (mDevice == null) {
- throw new IllegalArgumentException("Device has not been set");
- }
- if (mTestJars.isEmpty()) {
- throw new IllegalArgumentException("No test jar has been set");
- }
- if (mTests == null) {
- throw new IllegalArgumentException("tests has not been set");
- }
- if (mCtsBuild == null) {
- throw new IllegalArgumentException("build has not been set");
- }
- for (String f : mTestJars) {
- try {
-
- mCtsBuild.getTestApp(f);
- } catch (FileNotFoundException e) {
- throw new IllegalArgumentException(String.format(
- "Could not find jar %s in CTS build %s", f,
- mCtsBuild.getRootDir().getAbsolutePath()));
- }
- }
- }
-
- /**
- * Add runtime arguments to run the tests with.
- *
- * @param mRunTimeArgs
- */
- public void addRunTimeArgs(String mRunTimeArgs) {
- mRuntimeArgs = mRunTimeArgs;
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/JarHostTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/JarHostTest.java
deleted file mode 100644
index 9d9596e..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/JarHostTest.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.DeviceTestResult.RuntimeDeviceNotAvailableException;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IAbiReceiver;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.JUnitRunUtil;
-import com.android.tradefed.util.CommandStatus;
-import com.android.tradefed.util.IRunUtil.IRunnableResult;
-import com.android.tradefed.util.RunUtil;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Collection;
-
-/**
- * A {@link IRemoteTest} that can run a set of JUnit tests from a CTS jar.
- */
-public class JarHostTest implements IDeviceTest, IRemoteTest, IBuildReceiver, Test {
-
- private static final String LOG_TAG = "JarHostTest";
-
- private ITestDevice mDevice;
- private String mJarFileName;
- private Collection<TestIdentifier> mTests;
- private long mTimeoutMs = 10 * 60 * 1000;
- private String mRunName;
- private CtsBuildHelper mCtsBuild = null;
- private IBuildInfo mBuildInfo = null;
- private IAbi mAbi;
- private ClassLoader mClassLoader;
-
- /**
- * @param abi the ABI to run the test on
- */
- public void setAbi(IAbi abi) {
- mAbi = abi;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setBuild(IBuildInfo buildInfo) {
- mBuildInfo = buildInfo;
- mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
- }
-
- /**
- * Set the CTS build container.
- * <p/>
- * Exposed so unit tests can mock the provided build.
- *
- * @param buildHelper
- */
- void setBuildHelper(CtsBuildHelper buildHelper) {
- mCtsBuild = buildHelper;
- }
-
- /**
- * Get the CTS build container.
- *
- * @return {@link CtsBuildHelper}
- */
- CtsBuildHelper getBuildHelper() {
- return mCtsBuild;
- }
-
- /**
- * Set the jar file to load tests from.
- *
- * @param jarFileName the file name of the CTS host test jar to use
- */
- void setJarFileName(String jarFileName) {
- mJarFileName = jarFileName;
- }
-
- /**
- * Gets the jar file to load tests from.
- *
- * @return jarFileName the file name of the CTS host test jar to use
- */
- String getJarFileName() {
- return mJarFileName;
- }
-
- /**
- * Sets the collection of tests to run
- *
- * @param tests
- */
- void setTests(Collection<TestIdentifier> tests) {
- mTests = tests;
- }
-
- /**
- * Gets the collection of tests to run
- *
- * @return Collection<{@link TestIdentifier}>
- */
- Collection<TestIdentifier> getTests() {
- return mTests;
- }
-
- /**
- * Set the maximum time in ms each test should run.
- * <p/>
- * Tests that take longer than this amount will be failed with a {@link TestTimeoutException}
- * as the cause.
- *
- * @param testTimeoutMs
- */
- void setTimeout(long testTimeoutMs) {
- mTimeoutMs = testTimeoutMs;
- }
-
- /**
- * Set the run name to report to {@link ITestInvocationListener#testRunStarted(String, int)}
- *
- * @param runName
- */
- void setRunName(String runName) {
- mRunName = runName;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ITestDevice getDevice() {
- return mDevice;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setDevice(ITestDevice device) {
- mDevice = device;
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- checkFields();
- Log.i(LOG_TAG, String.format("Running %s test package from jar, contains %d tests.",
- mRunName, mTests.size()));
- JUnitRunUtil.runTest(listener, this, mRunName);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run(TestResult junitResult) {
- for (TestIdentifier testId : mTests) {
- Test junitTest = loadTest(testId.getClassName(), testId.getTestName());
- if (junitTest != null) {
- runTest(testId, junitTest, junitResult);
- }
- }
- }
-
- /**
- * Run test with timeout support.
- */
- private void runTest(TestIdentifier testId, final Test junitTest, final TestResult junitResult) {
- if (junitTest instanceof IDeviceTest) {
- ((IDeviceTest)junitTest).setDevice(getDevice());
- } else if (junitTest instanceof com.android.hosttest.DeviceTest) {
- // legacy check - see if test uses hosttestlib. This check should go away once
- // all host tests are converted to use tradefed
- com.android.hosttest.DeviceTest deviceTest = (com.android.hosttest.DeviceTest)junitTest;
- deviceTest.setDevice(getDevice().getIDevice());
- deviceTest.setTestAppPath(mCtsBuild.getTestCasesDir().getAbsolutePath());
- }
- if (junitTest instanceof IAbiReceiver) {
- ((IAbiReceiver)junitTest).setAbi(mAbi);
- }
- if (junitTest instanceof IBuildReceiver) {
- ((IBuildReceiver)junitTest).setBuild(mBuildInfo);
- }
- TestRunnable testRunnable = new TestRunnable(junitTest, junitResult);
-
- CommandStatus status = RunUtil.getDefault().runTimed(mTimeoutMs, testRunnable, true);
- if (status.equals(CommandStatus.TIMED_OUT)) {
- junitResult.addError(junitTest, new TestTimeoutException());
- junitResult.endTest(junitTest);
- }
- if (testRunnable.getException() != null) {
- throw testRunnable.getException();
- }
- }
-
- private static class TestRunnable implements IRunnableResult {
-
- private final Test mJunitTest;
- private RuntimeDeviceNotAvailableException mException = null;
- private TestResult mJunitResult;
-
- TestRunnable(Test junitTest, TestResult junitResult) {
- mJunitTest = junitTest;
- mJunitResult = junitResult;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean run() throws Exception {
- try {
- mJunitTest.run(mJunitResult);
- } catch (RuntimeDeviceNotAvailableException e) {
- mException = e;
- }
- return true;
- }
-
- public RuntimeDeviceNotAvailableException getException() {
- return mException;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void cancel() {
- }
-
- }
-
- /**
- * Load the test with given names from the jar.
- *
- * @param className
- * @param testName
- * @return the loaded {@link Test} or <code>null</code> if test could not be loaded.
- */
- private Test loadTest(String className, String testName) {
- try {
- Class<?> testClass = loadClass(className);
- if (testClass == null) {
- return null;
- }
- if (TestCase.class.isAssignableFrom(testClass)) {
- TestCase testCase = (TestCase)testClass.newInstance();
- testCase.setName(testName);
- return testCase;
- } else if (Test.class.isAssignableFrom(testClass)) {
- Test test = (Test)testClass.newInstance();
- return test;
- } else {
- Log.e(LOG_TAG, String.format("Class '%s' from jar '%s' is not a Test",
- className, mJarFileName));
- }
- } catch (IllegalAccessException e) {
- reportLoadError(mJarFileName, className, e);
- } catch (InstantiationException e) {
- reportLoadError(mJarFileName, className, e);
- }
- return null;
- }
-
- private Class<?> loadClass(String className) {
- try {
- if (mClassLoader == null) {
- File jarFile = mCtsBuild.getTestApp(mJarFileName);
- URL urls[] = {jarFile.getCanonicalFile().toURI().toURL()};
- mClassLoader = new URLClassLoader(urls);
- }
- return mClassLoader.loadClass(className);
- } catch (FileNotFoundException fnfe) {
- reportLoadError(mJarFileName, className, fnfe);
- } catch (MalformedURLException mue) {
- reportLoadError(mJarFileName, className, mue);
- } catch (IOException ioe) {
- reportLoadError(mJarFileName, className, ioe);
- } catch (ClassNotFoundException cnfe) {
- reportLoadError(mJarFileName, className, cnfe);
- }
- return null;
- }
-
- /**
- * Loads a class from given URLs.
- * <p/>
- * Exposed so unit tests can mock
- *
- * @param className
- * @param urls
- * @return
- * @throws ClassNotFoundException
- */
- Class<?> loadClass(String className, URL[] urls) throws ClassNotFoundException {
- URLClassLoader cl = new URLClassLoader(urls);
- Class<?> testClass = cl.loadClass(className);
- return testClass;
- }
-
- private void reportLoadError(String jarFileName, String className, Exception e) {
- Log.e(LOG_TAG, String.format("Failed to load test class '%s' from jar '%s'",
- className, jarFileName));
- Log.e(LOG_TAG, e);
- }
-
- /**
- * Checks that all mandatory member fields has been set.
- */
- protected void checkFields() {
- if (mRunName == null) {
- throw new IllegalArgumentException("run name has not been set");
- }
- if (mDevice == null) {
- throw new IllegalArgumentException("Device has not been set");
- }
- if (mJarFileName == null) {
- throw new IllegalArgumentException("jar file name has not been set");
- }
- if (mTests == null) {
- throw new IllegalArgumentException("tests has not been set");
- }
- if (mCtsBuild == null) {
- throw new IllegalArgumentException("build has not been set");
- }
- try {
- mCtsBuild.getTestApp(mJarFileName);
- } catch (FileNotFoundException e) {
- throw new IllegalArgumentException(String.format(
- "Could not find jar %s in CTS build %s", mJarFileName,
- mCtsBuild.getRootDir().getAbsolutePath()));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int countTestCases() {
- return mTests.size();
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ResultFilter.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ResultFilter.java
deleted file mode 100644
index f4f2f5d..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ResultFilter.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.testtype.CtsTest.TestPackage;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.ResultForwarder;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A {@link ITestInvocationListener} that filters test results based on the set of expected tests
- * in CTS test package xml files.
- * <p/>
- * It will only report test results for expected tests, and at end of invocation, will report the
- * set of expected tests that were not executed.
- */
-class ResultFilter extends ResultForwarder {
-
- private final Set<TestIdentifier> mKnownTests;
- private final Set<TestIdentifier> mRemainingTests;
- private final String mTestRun;
-
- /**
- * Create a {@link ResultFilter}.
- *
- * @param listener the real {@link ITestInvocationListener} to forward results to
- */
- ResultFilter(ITestInvocationListener listener, TestPackage testPackage) {
- super(listener);
- mTestRun = testPackage.getTestRunName();
- Collection<TestIdentifier> tests = testPackage.getKnownTests();
- mKnownTests = new HashSet<TestIdentifier>(tests);
- // use LinkedHashMap for predictable test order
- mRemainingTests = new LinkedHashSet<TestIdentifier>(tests);
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunStarted(String runName, int testCount) {
- if (mTestRun.equals(runName)) {
- super.testRunStarted(runName, testCount);
- } else {
- CLog.d("Skipping reporting unknown test run %s", runName);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testStarted(TestIdentifier test) {
- if (isKnownTest(test)) {
- super.testStarted(test);
- } else {
- CLog.d("Skipping reporting unknown test %s", test);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testFailed(TestIdentifier test, String trace) {
- if (isKnownTest(test)) {
- super.testFailed(test, trace);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
- if (isKnownTest(test)) {
- super.testEnded(test, testMetrics);
- removeExecutedTest(test);
- }
- }
-
- /**
- * @param test
- * @return
- */
- private boolean isKnownTest(TestIdentifier test) {
- return mKnownTests.contains(test);
- }
-
- /**
- * Remove given test from the 'remaining tests' data structure.
- * @param test
- */
- private void removeExecutedTest(TestIdentifier test) {
- mRemainingTests.remove(test);
- }
-
- /**
- * Report the set of expected tests that were not executed
- */
- public void reportUnexecutedTests() {
- if (mRemainingTests.isEmpty()) {
- return;
- }
- super.testRunStarted(mTestRun, mRemainingTests.size());
- for (TestIdentifier test : mRemainingTests) {
- // an unexecuted test is currently reported as a 'testStarted' event without a
- // 'testEnded'. TODO: consider adding an explict API for reporting an unexecuted
- // test
- super.testStarted(test);
- }
- super.testRunEnded(0, new HashMap<String, String>());
- }
-
- /** @return the number of known tests */
- public int getKnownTestCount() {
- return mKnownTests.size();
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/SingleJUnitTestResultParser.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/SingleJUnitTestResultParser.java
deleted file mode 100644
index 150d265..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/SingleJUnitTestResultParser.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.testrunner.ITestRunListener;
-import com.android.ddmlib.testrunner.TestIdentifier;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * Parses the test results from {@link com.android.cts.junit.SingleJUnitTestRunner}
- */
-public class SingleJUnitTestResultParser extends MultiLineReceiver {
-
- private static final String PASSED_TEST_MARKER = "[ PASSED ]";
- private static final String FAILED_TEST_MARKER = "[ FAILED ]";
- private final TestIdentifier mTestId;
- private final Collection<ITestRunListener> mTestListeners;
- private StringBuilder mStackTrace = new StringBuilder();
-
- public SingleJUnitTestResultParser(TestIdentifier testId, Collection<ITestRunListener> listeners) {
- mTestId = testId;
- mTestListeners = new ArrayList<ITestRunListener>(listeners);
- }
-
- public SingleJUnitTestResultParser(TestIdentifier testId, ITestRunListener listener) {
- mTestId = testId;
- mTestListeners = new ArrayList<ITestRunListener>(1);
- mTestListeners.add(listener);
- }
-
- @Override
- public boolean isCancelled() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public void processNewLines(String[] lines) {
- for (String line : lines) {
- parse(line);
- }
- }
-
- /**
- * Parses a given string.
- * @param line
- */
- private void parse(String line) {
- if (line.startsWith(PASSED_TEST_MARKER)) {
- doTestEnded(true);
- } else if (line.startsWith(FAILED_TEST_MARKER)) {
- doTestEnded(false);
- } else {
- // Store everything in case there is a failure.
- mStackTrace.append("\n");
- mStackTrace.append(line);
- }
- }
-
- /**
- * Handle cases when test ends.
- * @param testPassed whether or not the test passed.
- */
- private void doTestEnded(boolean testPassed) {
- // If test failed.
- if (!testPassed) {
- for (ITestRunListener listener : mTestListeners) {
- listener.testFailed(mTestId, mStackTrace.toString());
- }
- }
- Map<String, String> emptyMap = Collections.emptyMap();
- for (ITestRunListener listener : mTestListeners) {
- listener.testEnded(mTestId, emptyMap);
- }
- mStackTrace = new StringBuilder();
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestFilter.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestFilter.java
deleted file mode 100644
index 4d1b3e2..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestFilter.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-/**
- * Filter for {@link TestIdentifier}s.
- */
-public class TestFilter {
-
- private final Set<String> mExcludedClasses;
- private final Set<TestIdentifier> mExcludedTests;
-
- private final Set<String> mIncludedClasses;
- private final Set<TestIdentifier> mIncludedTests;
-
- private String mIncludedClass = null;
- private Pattern mIncludedMethod = null;
-
- /**
- * Creates a {@link TestFilter}
- */
- public TestFilter() {
- mExcludedClasses = new HashSet<String>();
- mExcludedTests = new HashSet<TestIdentifier>();
-
- mIncludedClasses = new HashSet<String>();
- mIncludedTests = new HashSet<TestIdentifier>();
- }
-
- /**
- * Adds a test class to the filter.
- * <p/>
- * All tests in this class should be filtered.
- */
- public void addExcludedClass(String className) {
- mExcludedClasses.add(className);
- }
-
- /**
- * Adds a test class to the filter. All tests in this class should be excluded.
- */
- public void addExcludedTest(TestIdentifier test) {
- mExcludedTests.add(test);
- }
-
- /**
- * Get the test classes to exclude.
- * <p/>
- * Exposed for unit testing
- */
- Set<String> getExcludedClasses() {
- return mExcludedClasses;
- }
-
- /**
- * Get the tests to exclude.
- * <p/>
- * Exposed for unit testing
- */
- Set<TestIdentifier> getExcludedTests() {
- return mExcludedTests;
- }
-
- /**
- * Adds a test class to the filter.
- * <p/>
- * All tests in this class should be allowed.
- */
- public void addIncludedClass(String className) {
- mIncludedClasses.add(className);
- }
-
- /**
- * Adds a test class to the filter. All tests in this class should be excluded.
- */
- public void addIncludedTest(TestIdentifier test) {
- mIncludedTests.add(test);
- }
-
- /**
- * @return the mIncludedClasses
- */
- public Set<String> getIncludedClasses() {
- return mIncludedClasses;
- }
-
- /**
- * @return the mIncludedTests
- */
- public Set<TestIdentifier> getIncludedTests() {
- return mIncludedTests;
- }
-
- /**
- * Sets the class name and optionally method that should pass this filter. If non-null, all
- * other tests will be excluded.
- *
- * @param className the test class name to exclusively include
- * @param method the test method name to exclusively include
- */
- public void setTestInclusion(String className, String method) {
- mIncludedClass = className;
- if (method != null) {
- mIncludedMethod = Pattern.compile(method);
- }
- }
-
- /**
- * Filter the list of tests based on rules in this filter
- *
- * @param tests the list of tests to filter
- * @return a new sorted list of tests that passed the filter
- */
- public Collection<TestIdentifier> filter(Collection<TestIdentifier> tests) {
- List<TestIdentifier> filteredTests = new ArrayList<TestIdentifier>(tests.size());
- for (TestIdentifier test : tests) {
- if (mIncludedClass != null && !test.getClassName().equals(mIncludedClass)) {
- // skip
- continue;
- }
- if (mIncludedMethod != null && !mIncludedMethod.matcher(test.getTestName()).matches()) {
- // skip
- continue;
- }
- if (mExcludedClasses.contains(test.getClassName())) {
- // skip
- continue;
- }
- if (mExcludedTests.contains(test)) {
- // skip
- continue;
- }
- if ((!mIncludedTests.isEmpty() || !mIncludedClasses.isEmpty())
- && !(mIncludedClasses.contains(test.getClassName())
- || mIncludedTests.contains(test))) {
- // skip
- continue;
- }
- filteredTests.add(test);
- }
- Collections.sort(filteredTests, new TestIdComparator());
- return filteredTests;
- }
-
- /**
- * Return true if there are exclusions rules defined.
- */
- public boolean hasExclusion() {
- return !mExcludedClasses.isEmpty() || !mExcludedTests.isEmpty();
- }
-
- /**
- * @return true if there are inclusion rules defined.
- */
- public boolean hasInclusion() {
- return !mIncludedClasses.isEmpty() || !mIncludedTests.isEmpty();
- }
-
- /**
- * A {@link Comparator} for {@link TestIdentifier} that compares using
- * {@link TestIdentifier#toString()}
- */
- private class TestIdComparator implements Comparator<TestIdentifier> {
-
- @Override
- public int compare(TestIdentifier o1, TestIdentifier o2) {
- return o1.toString().compareTo(o2.toString());
- }
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestNGDeviceTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestNGDeviceTest.java
deleted file mode 100644
index 377c0c0..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestNGDeviceTest.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.Option.Importance;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.util.AbiFormatter;
-import com.android.tradefed.util.ArrayUtil;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-/**
- * {@code Test} for running CTS TestNG tests on the device.
- */
-public class TestNGDeviceTest implements IDeviceTest, IRemoteTest, IBuildReceiver {
-
- private static final String TMP_DIR = "/data/local/tmp/";
-
- @Option(name = "testng-device-runtime",
- description = "The name of the runtime to use on the device",
- importance = Importance.ALWAYS)
- private String mRuntimePath = "dalvikvm|#ABI#|";
-
- @Option(name = "testng-device-tmpdir", description = "Device path where to store the test jars."
- , importance = Importance.IF_UNSET)
- private String mDeviceTestTmpPath = TMP_DIR;
-
-
- // default to no timeout
- private long mMaxTimeToOutputResponse = 0;
-
- private ITestDevice mDevice;
- private String mRunName;
- private Collection<TestIdentifier> mTests;
- private CtsBuildHelper mCtsBuild = null;
-
- private List<String> mJarPaths = new ArrayList<String>();
-
- private String mRuntimeArgs;
-
- private IAbi mAbi;
-
- private static final String TESTNG_JAR = "cts-testng.jar";
-
- private Set<String> mTestJars = new HashSet<String>(Arrays.asList(TESTNG_JAR));
-
- /**
- * @param abi The ABI to run the test on
- */
- public void setAbi(IAbi abi) {
- mAbi = abi;
- }
-
- @Override
- public ITestDevice getDevice() {
- return mDevice;
- }
-
- @Override
- public void setDevice(ITestDevice device) {
- mDevice = device;
- }
-
- public void addTestJarFileName(String jarFileName) {
- mTestJars.add(jarFileName);
- }
-
- public void setRunName(String runName) {
- mRunName = runName;
- }
-
- public void setTests(Collection<TestIdentifier> tests) {
- mTests = tests;
- }
-
- public Collection<TestIdentifier> getTests() {
- return mTests;
- }
-
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- addTestJarFileName(TESTNG_JAR);
- checkFields();
- long startTime = System.currentTimeMillis();
- listener.testRunStarted(mRunName, mTests.size());
- try {
- installJars();
- String jarPath = ArrayUtil.join(":", mJarPaths);
- for (TestIdentifier testId : mTests) {
- SingleJUnitTestResultParser resultParser = new SingleJUnitTestResultParser(
- testId, listener);
- String cmdLine = String.format("ANDROID_DATA=%s %s -cp %s %s " +
- "com.android.cts.testng.SingleTestNGTestRunner %s#%s",
- mDeviceTestTmpPath, mRuntimePath, jarPath, getRuntimeArgsNotNull(),
- testId.getClassName(), testId.getTestName());
- String cmd = AbiFormatter.formatCmdForAbi(cmdLine, mAbi.getBitness());
- CLog.d("Running %s", cmd);
- listener.testStarted(testId);
- mDevice.executeShellCommand(cmd, resultParser, mMaxTimeToOutputResponse,
- TimeUnit.MILLISECONDS, 0);
- }
- } finally {
- listener.testRunEnded(System.currentTimeMillis() - startTime,
- Collections.<String, String> emptyMap());
- // Remove jar files from device
- removeJars();
- }
- }
-
- /**
- * Installs the jar files on the device under test.
- *
- * @throws DeviceNotAvailableException
- */
- protected void installJars() throws DeviceNotAvailableException {
- for (String f : mTestJars) {
- CLog.d("Installing %s on %s", f, getDevice().getSerialNumber());
- File jarFile;
- try {
- String fullJarPath = String.format("%s%s", mDeviceTestTmpPath, f);
- jarFile = mCtsBuild.getTestApp(f);
- boolean result = getDevice().pushFile(jarFile, fullJarPath);
- if (!result) {
- throw new AssertionError(String.format("Failed to push file to %s", fullJarPath));
- }
- mJarPaths.add(fullJarPath);
- } catch (FileNotFoundException e) {
- throw new AssertionError(String.format("Could not find file %s", f));
- }
- }
- }
-
- /**
- * Cleans up the jar files from the device under test.
- *
- * @throws DeviceNotAvailableException
- */
- protected void removeJars() throws DeviceNotAvailableException {
- for (String f : mTestJars) {
- String fullJarPath = String.format("%s%s", mDeviceTestTmpPath, f);
- CLog.d("Uninstalling %s on %s", fullJarPath, getDevice().getSerialNumber());
- getDevice().executeShellCommand(String.format("rm %s", fullJarPath));
- }
- }
-
- @Override
- public void setBuild(IBuildInfo buildInfo) {
- mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
- }
-
- /**
- * Checks that all mandatory member fields has been set.
- */
- protected void checkFields() {
- if (mRunName == null) {
- throw new IllegalArgumentException("run name has not been set");
- }
- if (mDevice == null) {
- throw new IllegalArgumentException("Device has not been set");
- }
- if (mTestJars.isEmpty()) {
- throw new IllegalArgumentException("No test jar has been set");
- }
- if (mTests == null) {
- throw new IllegalArgumentException("tests has not been set");
- }
- if (mCtsBuild == null) {
- throw new IllegalArgumentException("build has not been set");
- }
- for (String f : mTestJars) {
- try {
-
- mCtsBuild.getTestApp(f);
- } catch (FileNotFoundException e) {
- throw new IllegalArgumentException(String.format(
- "Could not find jar %s in CTS build %s", f,
- mCtsBuild.getRootDir().getAbsolutePath()));
- }
- }
- }
-
- /**
- * Add runtime arguments to run the tests with.
- *
- * @param mRunTimeArgs
- */
- public void addRunTimeArgs(String mRunTimeArgs) {
- mRuntimeArgs = mRunTimeArgs;
- }
-
- private String getRuntimeArgsNotNull() {
- if (mRuntimeArgs == null) {
- return "";
- }
- return mRuntimeArgs;
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
deleted file mode 100644
index 20edd9e..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.InstrumentationTest;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.StreamUtil;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.DigestInputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Container for CTS test info.
- * <p/>
- * Knows how to translate this info into a runnable {@link IRemoteTest}.
- */
-class TestPackageDef implements ITestPackageDef {
-
- public static final String HOST_SIDE_ONLY_TEST = "hostSideOnly";
- public static final String NATIVE_TEST = "native";
- public static final String WRAPPED_NATIVE_TEST = "wrappednative";
- public static final String VM_HOST_TEST = "vmHostTest";
- public static final String DEQP_TEST = "deqpTest";
- public static final String JUNIT_DEVICE_TEST = "jUnitDeviceTest";
- public static final String TESTNG_DEVICE_TEST = "testNGDeviceTest";
-
- private String mAppPackageName = null;
- private String mAppNameSpace = null;
- private String mName = null;
- private String mRunner = null;
- private String mTestType = null;
- private String mJarPath = null;
- private String mRunTimeArgs = null;
- private String mTestPackageName = null;
- private String mDigest = null;
- private IAbi mAbi = null;
- private List<ITargetPreparer> mPreparers = null;
-
- // use a LinkedHashSet for predictable iteration insertion-order, and fast
- // lookups
- private Collection<TestIdentifier> mTests = new LinkedHashSet<TestIdentifier>();
- // also maintain an index of known test classes
- private Collection<String> mTestClasses = new LinkedHashSet<String>();
- // store instance arguments in order too for consistency
- private Map<TestIdentifier, List<Map<String, String>>> mTestInstanceArguments =
- new LinkedHashMap<>();
-
- // dynamic options, not parsed from package xml
- private String mClassName;
- private String mMethodName;
- private TestFilter mTestFilter = new TestFilter();
- private String mTargetBinaryName;
- private String mTargetNameSpace;
- // only timeout per package is supported. To change this to method granularity,
- // test invocation should be done in method level.
- // So for now, only max timeout for the package is used.
- private int mTimeoutInMins = -1;
-
- @Override
- public IAbi getAbi() {
- return mAbi;
- }
-
- /**
- * @param abi the ABI to run this package on
- */
- public void setAbi(IAbi abi) {
- mAbi = abi;
- }
-
- /**
- * @return unique id representing this test package for this ABI.
- */
- @Override
- public String getId() {
- return AbiUtils.createId(getAbi().getName(), getAppPackageName());
- }
-
- void setAppPackageName(String appPackageName) {
- mAppPackageName = appPackageName;
- }
-
- String getAppPackageName() {
- return mAppPackageName;
- }
-
- void setRunTimeArgs(String runTimeArgs) {
- mRunTimeArgs = runTimeArgs;
- }
-
- void setAppNameSpace(String appNameSpace) {
- mAppNameSpace = appNameSpace;
- }
-
- String getAppNameSpace() {
- return mAppNameSpace;
- }
-
- void setName(String name) {
- mName = name;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getName() {
- return mName;
- }
-
- void setRunner(String runnerName) {
- mRunner = runnerName;
- }
-
- String getRunner() {
- return mRunner;
- }
-
- void setTestType(String testType) {
- mTestType = testType;
- }
-
- String getTestType() {
- return mTestType;
- }
-
- void setJarPath(String jarPath) {
- mJarPath = jarPath;
- }
-
- String getJarPath() {
- return mJarPath;
- }
-
- void setTestPackageName(String testPackageName) {
- mTestPackageName = testPackageName;
- }
-
- void setTargetBinaryName(String targetBinaryName) {
- mTargetBinaryName = targetBinaryName;
- }
-
- void setTargetNameSpace(String targetNameSpace) {
- mTargetNameSpace = targetNameSpace;
- }
-
- @Override
- public String getTargetApkName() {
- if (mTargetBinaryName != null && !mTargetBinaryName.isEmpty()) {
- return String.format("%s.apk", mTargetBinaryName);
- }
- return null;
- }
-
- @Override
- public String getTargetPackageName() {
- if (mTargetNameSpace != null && mTargetNameSpace.isEmpty()) {
- return null;
- }
- return mTargetNameSpace;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setTestFilter(TestFilter testFilter) {
- mTestFilter = testFilter;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setClassName(String className, String methodName) {
- mClassName = className;
- mMethodName = methodName;
- }
-
- /**
- * Setter for injecting a list of {@link ITargetPreparer}s as configured in module test config.
- * @param preparers
- */
- void setPackagePreparers(List<ITargetPreparer> preparers) {
- mPreparers = preparers;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<ITargetPreparer> getPackagePreparers() {
- return mPreparers;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IRemoteTest createTest(File testCaseDir) {
- mTestFilter.setTestInclusion(mClassName, mMethodName);
- mTests = filterTests();
-
- if (HOST_SIDE_ONLY_TEST.equals(mTestType)) {
- CLog.d("Creating host test for %s", mName);
- JarHostTest hostTest = new JarHostTest();
- if (mTimeoutInMins >= 0) {
- CLog.d("Setting new timeout to " + mTimeoutInMins + " mins");
- hostTest.setTimeout(mTimeoutInMins * 60 * 1000);
- }
- hostTest.setRunName(getId());
- hostTest.setJarFileName(mJarPath);
- hostTest.setTests(mTests);
- hostTest.setAbi(mAbi);
- mDigest = generateDigest(testCaseDir, mJarPath);
- return hostTest;
- } else if (VM_HOST_TEST.equals(mTestType)) {
- CLog.d("Creating vm host test for %s", mName);
- VMHostTest vmHostTest = new VMHostTest();
- vmHostTest.setRunName(getId());
- vmHostTest.setJarFileName(mJarPath);
- vmHostTest.setTests(mTests);
- vmHostTest.setAbi(mAbi);
- mDigest = generateDigest(testCaseDir, mJarPath);
- return vmHostTest;
- } else if (DEQP_TEST.equals(mTestType)) {
- DeqpTestRunner deqpTest =
- new DeqpTestRunner(mAppPackageName, mName, mTests, mTestInstanceArguments);
- deqpTest.setAbi(mAbi);
- return deqpTest;
- } else if (NATIVE_TEST.equals(mTestType)) {
- GeeTest geeTest = new GeeTest(mAppPackageName, mName);
- geeTest.setAbi(mAbi);
- return geeTest;
- } else if (WRAPPED_NATIVE_TEST.equals(mTestType)) {
- CLog.d("Creating new wrapped native test for %s", mName);
- WrappedGTest wrappedGeeTest = new WrappedGTest(mAppNameSpace, mAppPackageName, mName, mRunner);
- wrappedGeeTest.setAbi(mAbi);
- return wrappedGeeTest;
- } else if (JUNIT_DEVICE_TEST.equals(mTestType)){
- CLog.d("Creating JUnit device test %s", mName);
- JUnitDeviceTest jUnitDeviceTest = new JUnitDeviceTest();
- jUnitDeviceTest.setRunName(getId());
- jUnitDeviceTest.addTestJarFileName(mJarPath);
- jUnitDeviceTest.addRunTimeArgs(mRunTimeArgs);
- jUnitDeviceTest.setTests(mTests);
- jUnitDeviceTest.setAbi(mAbi);
- mDigest = generateDigest(testCaseDir, mJarPath);
- return jUnitDeviceTest;
- } else if (TESTNG_DEVICE_TEST.equals(mTestType)){
- CLog.d("Creating TestNG device test %s", mName);
- TestNGDeviceTest testNGDeviceTest = new TestNGDeviceTest();
- testNGDeviceTest.setRunName(getId());
- testNGDeviceTest.addTestJarFileName(mJarPath);
- testNGDeviceTest.addRunTimeArgs(mRunTimeArgs);
- testNGDeviceTest.setTests(mTests);
- testNGDeviceTest.setAbi(mAbi);
- mDigest = generateDigest(testCaseDir, mJarPath);
- return testNGDeviceTest;
- }
- else {
- CLog.d("Creating instrumentation test for %s", mName);
- CtsInstrumentationApkTest instrTest = new CtsInstrumentationApkTest();
- if (mTimeoutInMins >= 0) {
- // as timeout cannot be set for each test,
- // increase the time-out of the whole package
- CLog.d("Setting new timeout to " + mTimeoutInMins + " mins");
- instrTest.setTestTimeout(mTimeoutInMins * 60 * 1000);
- }
- return setInstrumentationTest(instrTest, testCaseDir);
- }
- }
-
- /**
- * Populates given {@link CtsInstrumentationApkTest} with data from the package xml.
- *
- * @param testCaseDir
- * @param instrTest
- * @return the populated {@link InstrumentationTest} or <code>null</code>
- */
- private InstrumentationTest setInstrumentationTest(CtsInstrumentationApkTest instrTest,
- File testCaseDir) {
- instrTest.setRunName(getId());
- instrTest.setPackageName(mAppNameSpace);
- instrTest.setRunnerName(mRunner);
- instrTest.setAbi(mAbi);
- instrTest.setTestsToRun(mTests, false
- /* force batch mode off to always run using testFile */);
- instrTest.setReRunUsingTestFile(true);
- // mName means 'apk file name' for instrumentation tests
- instrTest.addInstallApk(String.format("%s.apk", mName), mAppNameSpace);
- mDigest = generateDigest(testCaseDir, String.format("%s.apk", mName));
- return instrTest;
- }
-
- /**
- * Filter the tests to run based on list of included/excluded tests, class and method name.
- *
- * @return the filtered collection of tests
- */
- private Collection<TestIdentifier> filterTests() {
- mTestFilter.setTestInclusion(mClassName, mMethodName);
- return mTestFilter.filter(mTests);
- }
-
- boolean isKnownTestClass(String className) {
- return mTestClasses.contains(className);
- }
-
- /**
- * Add a {@link TestIdentifier} to the list of tests in this package.
- *
- * @param testDef
- * @param timeout in mins
- */
- void addTest(TestIdentifier testDef, int timeout) {
- mTests.add(testDef);
- mTestClasses.add(testDef.getClassName());
- mTestInstanceArguments.put(testDef, new LinkedList<Map<String, String>>());
- // 0 means no timeout, so keep 0 if already is.
- if ((timeout > mTimeoutInMins) && (mTimeoutInMins != 0)) {
- mTimeoutInMins = timeout;
- }
- }
-
- /**
- * Add a test instance to an existing {@link TestIdentifier}.
- */
- void addTestInstance(TestIdentifier testDef, Map<String, String> instanceArguments) {
- if (!mTestInstanceArguments.containsKey(testDef)) {
- throw new IllegalStateException("test id does not name an existing test");
- }
- mTestInstanceArguments.get(testDef).add(instanceArguments);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<TestIdentifier> getTests() {
- return mTests;
- }
-
- /**
- * Get the instance argument map for tests.
- * <p/>
- * Exposed for unit testing.
- */
- public Map<TestIdentifier, List<Map<String, String>>> getTestInstanceArguments() {
- return mTestInstanceArguments;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getDigest() {
- return mDigest;
- }
-
- /**
- * Generate a sha1sum digest for a file.
- * <p/>
- * Exposed for unit testing.
- *
- * @param fileDir the directory of the file
- * @param fileName the name of the file
- * @return a hex {@link String} of the digest
- */
- String generateDigest(File fileDir, String fileName) {
- final String algorithm = "SHA-1";
- InputStream fileStream = null;
- DigestInputStream d = null;
- try {
- fileStream = getFileStream(fileDir, fileName);
- MessageDigest md = MessageDigest.getInstance(algorithm);
- d = new DigestInputStream(fileStream, md);
- byte[] buffer = new byte[8196];
- while (d.read(buffer) != -1) {
- }
- return toHexString(md.digest());
- } catch (NoSuchAlgorithmException e) {
- return algorithm + " not found";
- } catch (IOException e) {
- CLog.e(e);
- } finally {
- StreamUtil.close(d);
- StreamUtil.close(fileStream);
- }
- return "failed to generate digest";
- }
-
- /**
- * Retrieve an input stream for given file
- * <p/>
- * Exposed so unit tests can mock.
- */
- InputStream getFileStream(File fileDir, String fileName) throws FileNotFoundException {
- InputStream fileStream;
- fileStream = new BufferedInputStream(new FileInputStream(new File(fileDir, fileName)));
- return fileStream;
- }
-
- /**
- * Convert the given byte array into a lowercase hex string.
- *
- * @param arr The array to convert.
- * @return The hex encoded string.
- */
- private String toHexString(byte[] arr) {
- StringBuilder buf = new StringBuilder(arr.length * 2);
- for (byte b : arr) {
- buf.append(String.format("%02x", b & 0xFF));
- }
- return buf.toString();
- }
-
- @Override
- public int compareTo(ITestPackageDef testPackageDef) {
- return getId().compareTo(testPackageDef.getId());
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageRepo.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageRepo.java
deleted file mode 100644
index caac67b..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageRepo.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.Log;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.config.ConfigurationFactory;
-import com.android.tradefed.config.IConfiguration;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Retrieves CTS test package definitions from the repository.
- */
-public class TestPackageRepo implements ITestPackageRepo {
-
- private static final String LOG_TAG = "TestCaseRepo";
-
- /** mapping of ABI to a mapping of appPackageName to test definition */
- private final Map<String, Map<String, TestPackageDef>> mTestMap;
- private final boolean mIncludeKnownFailures;
-
- /**
- * Creates a {@link TestPackageRepo}, initialized from provided repo files
- *
- * @param testCaseDir directory containing all test case definition xml and build files
- * ABIs supported by the device under test.
- * @param includeKnownFailures Whether to run tests which are known to fail.
- */
- public TestPackageRepo(File testCaseDir, boolean includeKnownFailures) {
- mTestMap = new HashMap<>();
- mIncludeKnownFailures = includeKnownFailures;
- parse(testCaseDir);
- }
-
- /**
- * Builds mTestMap based on directory contents
- */
- private void parse(File dir) {
- File[] xmlFiles = dir.listFiles(new XmlFilter());
- for (File xmlFile : xmlFiles) {
- parseModuleTestConfigs(xmlFile);
- }
- }
-
- /**
- * Infer package preparer config from package XML definition file and return if exists
- * @param pkgXml {@link File} instance referencing the package XML definition
- * @return the matching package preparer if exists, <code>null</code> otherwise
- */
- private File getPreparerDefForPackage(File pkgXml) {
- String fullPath = pkgXml.getAbsolutePath();
- int lastDot = fullPath.lastIndexOf('.');
- if (lastDot == -1) {
- // huh?
- return null;
- }
- File preparer = new File(fullPath.substring(0, lastDot) + ".config");
- if (preparer.exists()) {
- return preparer;
- }
- return null;
- }
-
- /**
- * Processes test module definition XML file, and stores parsed data structure in class member
- * variable. Parsed config objects will be associated with each applicable ABI type so multiple
- * {@link TestPackageDef}s will be generated accordingly. In addition, based on
- * <module name>.config file naming convention, this method also looks for the optional
- * module test config, and attaches defined configuration objects to the {@link TestPackageDef}
- * representing the module accordingly.
- * @param xmlFile the module definition XML
- */
- private void parseModuleTestConfigs(File xmlFile) {
- TestPackageXmlParser parser = new TestPackageXmlParser(mIncludeKnownFailures);
- try {
- parser.parse(createStreamFromFile(xmlFile));
- // based on test module XML file path, and the <module name>.config naming convention,
- // infers the module test config file, and parses it
- File preparer = getPreparerDefForPackage(xmlFile);
- IConfiguration config = null;
- if (preparer != null) {
- try {
- // invokes parser to process the test module config file
- config = ConfigurationFactory.getInstance().createConfigurationFromArgs(
- new String[]{preparer.getAbsolutePath()});
- } catch (ConfigurationException e) {
- throw new RuntimeException(
- String.format("error parsing config file: %s", xmlFile.getName()), e);
- }
- }
- Set<TestPackageDef> defs = parser.getTestPackageDefs();
- if (defs.isEmpty()) {
- Log.w(LOG_TAG, String.format("Could not find test package info in xml file %s",
- xmlFile.getAbsolutePath()));
- }
- // loops over multiple package defs defined for each ABI type
- for (TestPackageDef def : defs) {
- String name = def.getAppPackageName();
- String abi = def.getAbi().getName();
- if (config != null) {
- def.setPackagePreparers(config.getTargetPreparers());
- }
- if (!mTestMap.containsKey(abi)) {
- mTestMap.put(abi, new HashMap<String, TestPackageDef>());
- }
- mTestMap.get(abi).put(name, def);
- }
- } catch (FileNotFoundException e) {
- Log.e(LOG_TAG, String.format("Could not find test case xml file %s",
- xmlFile.getAbsolutePath()));
- Log.e(LOG_TAG, e);
- } catch (ParseException e) {
- Log.e(LOG_TAG, String.format("Failed to parse test case xml file %s",
- xmlFile.getAbsolutePath()));
- Log.e(LOG_TAG, e);
- }
- }
-
- /**
- * Helper method to create a stream to read data from given file
- * <p/>
- * Exposed for unit testing
- *
- * @param xmlFile The file containing the xml description of the package
- * @return stream to read data
- *
- */
- InputStream createStreamFromFile(File xmlFile) throws FileNotFoundException {
- return new BufferedInputStream(new FileInputStream(xmlFile));
- }
-
- private static class XmlFilter implements FilenameFilter {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".xml");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ITestPackageDef getTestPackage(String id) {
- String[] parts = AbiUtils.parseId(id);
- String abi = parts[0];
- String name = parts[1];
- if (mTestMap.containsKey(abi) && mTestMap.get(abi).containsKey(name)) {
- return mTestMap.get(abi).get(name);
- }
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<String> getPackageIds() {
- Set<String> ids = new HashSet<>();
- for (String abi : mTestMap.keySet()) {
- Map<String, TestPackageDef> testNameMap = mTestMap.get(abi);
- for (TestPackageDef testPackageDef : testNameMap.values()) {
- ids.add(testPackageDef.getId());
- }
- }
- List<String> idList = new ArrayList<>(ids);
- Collections.sort(idList);
- return idList;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<String> getPackageNames() {
- Set<String> nameSet = new HashSet<String>();
- for (String abi : mTestMap.keySet()) {
- Map<String, TestPackageDef> testNameMap = mTestMap.get(abi);
- for (TestPackageDef testPackageDef : testNameMap.values()) {
- nameSet.add(AbiUtils.parseTestName(testPackageDef.getId()));
- }
- }
- List<String> nameList = new ArrayList<>(nameSet);
- Collections.sort(nameList);
- return nameList;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Map<String, List<ITestPackageDef>> getTestPackageDefsByName() {
- Map<String, List<ITestPackageDef>> packageDefMap =
- new HashMap<String, List<ITestPackageDef>>();
-
- for (String abi : mTestMap.keySet()) {
- Map<String, TestPackageDef> testNameMap = mTestMap.get(abi);
- for (String packageName : testNameMap.keySet()) {
- if (!packageDefMap.containsKey(packageName)) {
- packageDefMap.put(packageName, new ArrayList<ITestPackageDef>());
- }
- packageDefMap.get(packageName).add(testNameMap.get(packageName));
- }
- }
- return packageDefMap;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<String> findPackageIdsForTest(String testClassName) {
- Set<String> ids = new HashSet<String>();
- for (String abi : mTestMap.keySet()) {
- for (String name : mTestMap.get(abi).keySet()) {
- if (mTestMap.get(abi).get(name).isKnownTestClass(testClassName)) {
- ids.add(AbiUtils.createId(abi, name));
- }
- }
- }
- List<String> idList = new ArrayList<String>(ids);
- Collections.sort(idList);
- return idList;
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageXmlParser.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageXmlParser.java
deleted file mode 100644
index 5e08872..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageXmlParser.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.Log;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.testtype.Abi;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.xml.AbstractXmlParser;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.DefaultHandler;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Stack;
-
-/**
- * Parser for CTS test case XML.
- * <p/>
- * Dumb parser that just retrieves data from in the test case xml and stuff it into a
- * {@link TestPackageDef}. Currently performs limited error checking.
- */
-public class TestPackageXmlParser extends AbstractXmlParser {
-
- private static final String LOG_TAG = "TestPackageXmlParser";
-
- private final boolean mIncludeKnownFailures;
-
- private Map<String, TestPackageDef> mPackageDefs = new HashMap<String, TestPackageDef>();
-
- /**
- * @param includeKnownFailures Whether to run tests which are known to fail.
- */
- public TestPackageXmlParser(boolean includeKnownFailures) {
- mIncludeKnownFailures = includeKnownFailures;
- }
-
- /**
- * SAX callback object. Handles parsing data from the xml tags.
- * <p/>
- * Expected structure:
- * <TestPackage>
- * <TestSuite ...>
- * <TestCase>
- * <Test>
- * <TestInstance> (optional)
- */
- private class TestPackageHandler extends DefaultHandler {
-
- private static final String TEST_PACKAGE_TAG = "TestPackage";
- private static final String TEST_SUITE_TAG = "TestSuite";
- private static final String TEST_CASE_TAG = "TestCase";
- private static final String TEST_TAG = "Test";
- private static final String TEST_INSTANCE_TAG = "TestInstance";
-
- // holds current class name segments
- private Stack<String> mClassNameStack = new Stack<String>();
- private TestIdentifier mTestId;
-
- @Override
- public void startElement(String uri, String localName, String name, Attributes attributes) {
- if (TEST_PACKAGE_TAG.equals(localName)) {
- final String appPackageName = attributes.getValue("appPackageName");
- final String testPackageNameSpace = attributes.getValue("appNameSpace");
- final String packageName = attributes.getValue("name");
- final String runnerName = attributes.getValue("runner");
- final String jarPath = attributes.getValue("jarPath");
- final String javaPackageFilter = attributes.getValue("javaPackageFilter");
- final String targetBinaryName = attributes.getValue("targetBinaryName");
- final String targetNameSpace = attributes.getValue("targetNameSpace");
- final String runTimeArgs = attributes.getValue("runtimeArgs");
- final String testType = getTestType(attributes);
-
- for (String abiName : AbiUtils.getAbisSupportedByCompatibility()) {
- Abi abi = new Abi(abiName, AbiUtils.getBitness(abiName));
- TestPackageDef packageDef = new TestPackageDef();
- packageDef.setAppPackageName(appPackageName);
- packageDef.setAppNameSpace(testPackageNameSpace);
- packageDef.setName(packageName);
- packageDef.setRunner(runnerName);
- packageDef.setTestType(testType);
- packageDef.setJarPath(jarPath);
- packageDef.setRunTimeArgs(runTimeArgs);
- if (!"".equals(javaPackageFilter)) {
- packageDef.setTestPackageName(javaPackageFilter);
- }
- packageDef.setTargetBinaryName(targetBinaryName);
- packageDef.setTargetNameSpace(targetNameSpace);
- packageDef.setAbi(abi);
- mPackageDefs.put(abiName, packageDef);
- }
-
- // reset the class name
- mClassNameStack = new Stack<String>();
- } else if (TEST_SUITE_TAG.equals(localName)) {
- String packageSegment = attributes.getValue("name");
- if (packageSegment != null) {
- mClassNameStack.push(packageSegment);
- } else {
- Log.e(LOG_TAG, String.format("Invalid XML: missing 'name' attribute for '%s'",
- TEST_SUITE_TAG));
- }
- } else if (TEST_CASE_TAG.equals(localName)) {
- String classSegment = attributes.getValue("name");
- if (classSegment != null) {
- mClassNameStack.push(classSegment);
- } else {
- Log.e(LOG_TAG, String.format("Invalid XML: missing 'name' attribute for '%s'",
- TEST_CASE_TAG));
- }
- } else if (TEST_TAG.equals(localName)) {
- String methodName = attributes.getValue("name");
- if (mPackageDefs.isEmpty()) {
- Log.e(LOG_TAG, String.format(
- "Invalid XML: encountered a '%s' tag not enclosed within a '%s' tag",
- TEST_TAG, TEST_PACKAGE_TAG));
- } else if (methodName == null) {
- Log.e(LOG_TAG, String.format("Invalid XML: missing 'name' attribute for '%s'",
- TEST_TAG));
- } else {
- // build class name from package segments
- StringBuilder classNameBuilder = new StringBuilder();
- for (Iterator<String> iter = mClassNameStack.iterator(); iter.hasNext(); ) {
- classNameBuilder.append(iter.next());
- if (iter.hasNext()) {
- classNameBuilder.append(".");
- }
- }
- mTestId = new TestIdentifier(classNameBuilder.toString(), methodName);
- int timeout = -1;
- String timeoutStr = attributes.getValue("timeout");
- if (timeoutStr != null) {
- timeout = Integer.parseInt(timeoutStr);
- }
- boolean isKnownFailure = "failure".equals(attributes.getValue("expectation"));
- if (!isKnownFailure || mIncludeKnownFailures) {
- String abiList = attributes.getValue("abis");
- Set<String> abis = new HashSet<String>();
- if (abiList == null) {
- // If no specification, add all supported abis
- abis.addAll(AbiUtils.getAbisSupportedByCompatibility());
- } else {
- for (String abi : abiList.split(",")) {
- // Else only add the abi which are supported
- abis.add(abi.trim());
- }
- }
- for (String abi : abis) {
- mPackageDefs.get(abi).addTest(mTestId, timeout);
- }
- }
- }
- } else if (TEST_INSTANCE_TAG.equals(localName)) {
- if (mTestId != null) {
- final Map<String, String> instanceArguments = genAttributeMap(attributes);
- for (TestPackageDef packageDef : mPackageDefs.values()) {
- if (packageDef.getTests().contains(mTestId)) {
- packageDef.addTestInstance(mTestId, instanceArguments);
- }
- }
- } else {
- Log.e(LOG_TAG, String.format(
- "Invalid XML: encountered a '%s' tag not enclosed within a '%s' tag",
- TEST_INSTANCE_TAG, TEST_TAG));
- }
- }
- }
-
- private String getTestType(Attributes attributes) {
- if (parseBoolean(attributes.getValue("hostSideOnly"))) {
- return TestPackageDef.HOST_SIDE_ONLY_TEST;
- } else if (parseBoolean(attributes.getValue("vmHostTest"))) {
- return TestPackageDef.VM_HOST_TEST;
- } else {
- return attributes.getValue("testType");
- }
- }
-
- @Override
- public void endElement (String uri, String localName, String qName) {
- if (TEST_SUITE_TAG.equals(localName) || TEST_CASE_TAG.equals(localName)) {
- mClassNameStack.pop();
- } else if (TEST_TAG.equals(localName)) {
- mTestId = null;
- }
- }
-
- /**
- * Parse a boolean attribute value
- */
- private boolean parseBoolean(final String stringValue) {
- return stringValue != null &&
- Boolean.parseBoolean(stringValue);
- }
-
- private Map<String, String> genAttributeMap(Attributes attributes) {
- final Map<String, String> attribMap = new HashMap<String, String>();
- for (int i = 0; i < attributes.getLength(); ++i) {
- final String localName = attributes.getLocalName(i);
- final String namespace = attributes.getURI(i);
- final String fullyQualifiedName =
- (namespace.isEmpty()) ? (localName) : (namespace + ":" + localName);
-
- attribMap.put(fullyQualifiedName, attributes.getValue(i));
- }
- return attribMap;
- }
- }
-
- @Override
- protected DefaultHandler createXmlHandler() {
- return new TestPackageHandler();
- }
-
- /**
- * @return the set of {@link TestPackageDef} containing data parsed from xml
- */
- public Set<TestPackageDef> getTestPackageDefs() {
- return new HashSet<>(mPackageDefs.values());
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPlan.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPlan.java
deleted file mode 100644
index bf6dd61..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPlan.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.ArrayUtil;
-import com.android.tradefed.util.xml.AbstractXmlParser;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Implementation of {@link TestPlan}.
- */
-public class TestPlan extends AbstractXmlParser implements ITestPlan {
-
- /**
- * Map of ids found in plan, and their filters
- */
- private Map<String, TestFilter> mIdFilterMap;
-
- private static final String ENTRY_TAG = "Entry";
- private static final String TEST_DELIM = ";";
- private static final String METHOD_DELIM = "#";
- private static final String EXCLUDE_ATTR = "exclude";
- private static final String INCLUDE_ATTR = "include";
- private static final String ABI_ATTR = "abi";
- private static final String NAME_ATTR = "name";
-
- private final String mName;
- private final Set<String> mAbis;
-
- /**
- * SAX callback object. Handles parsing data from the xml tags.
- */
- private class EntryHandler extends DefaultHandler {
-
- @Override
- public void startElement(String uri, String localName, String name, Attributes attributes)
- throws SAXException {
- if (ENTRY_TAG.equals(localName)) {
- TestFilter filter = parseTestList(
- attributes.getValue(EXCLUDE_ATTR), attributes.getValue(INCLUDE_ATTR));
- final String entryNameValue = attributes.getValue(NAME_ATTR);
- final String entryAbiValue = attributes.getValue(ABI_ATTR);
- if (entryAbiValue != null) {
- mIdFilterMap.put(AbiUtils.createId(entryAbiValue, entryNameValue), filter);
- } else {
- for (String abi : mAbis) {
- mIdFilterMap.put(AbiUtils.createId(abi, entryNameValue), filter);
- }
- }
- }
- }
-
- /**
- * Parse a semicolon separated list of tests.
- * <p/>
- * Expected format:
- * testClassName[#testMethodName][;testClassName2...]
- *
- * @param excludedString the excluded string list
- * @param includedString the included string list
- * @return
- */
- private TestFilter parseTestList(String excludedString, String includedString) {
- TestFilter filter = new TestFilter();
- if (excludedString != null) {
- String[] testStrings = excludedString.split(TEST_DELIM);
- for (String testString : testStrings) {
- String[] classMethodPair = testString.split(METHOD_DELIM);
- if (classMethodPair.length == 2) {
- filter.addExcludedTest(new TestIdentifier(classMethodPair[0],
- classMethodPair[1]));
- } else {
- filter.addExcludedClass(testString);
- }
- }
- }
- if (includedString != null) {
- String[] testStrings = includedString.split(TEST_DELIM);
- for (String testString : testStrings) {
- String[] classMethodPair = testString.split(METHOD_DELIM);
- if (classMethodPair.length == 2) {
- filter.addIncludedTest(new TestIdentifier(classMethodPair[0],
- classMethodPair[1]));
- } else {
- filter.addIncludedClass(testString);
- }
- }
- }
-
- return filter;
- }
- }
-
- public TestPlan(String name, Set<String> abis) {
- mName = name;
- mAbis = abis;
- // Uses a LinkedHashMap to have predictable iteration order
- mIdFilterMap = new LinkedHashMap<String, TestFilter>();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getName() {
- return mName;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<String> getTestIds() {
- List<String> ids = new ArrayList<String>(mIdFilterMap.keySet());
- Collections.sort(ids);
- return ids;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<String> getTestNames() {
- TreeSet<String> testNameSet = new TreeSet<>();
- for (String id : mIdFilterMap.keySet()) {
- testNameSet.add(AbiUtils.parseTestName(id));
- }
- return new ArrayList<>(testNameSet);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TestFilter getTestFilter(String id) {
- return mIdFilterMap.get(id);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addPackage(String id) {
- mIdFilterMap.put(id, new TestFilter());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected DefaultHandler createXmlHandler() {
- return new EntryHandler();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addExcludedTest(String id, TestIdentifier testToExclude) {
- TestFilter filter = mIdFilterMap.get(id);
- if (filter != null) {
- filter.addExcludedTest(testToExclude);
- } else {
- throw new IllegalArgumentException(String.format("Could not find package %s", id));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addExcludedTests(String id, Collection<TestIdentifier> excludedTests) {
- TestFilter filter = mIdFilterMap.get(id);
- if (filter != null) {
- filter.getExcludedTests().addAll(excludedTests);
- } else {
- throw new IllegalArgumentException(String.format("Could not find package %s", id));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void serialize(OutputStream stream) throws IOException {
- KXmlSerializer serializer = new KXmlSerializer();
- serializer.setOutput(stream, "UTF-8");
- serializer.startDocument("UTF-8", false);
- serializer.setFeature(
- "http://xmlpull.org/v1/doc/features.html#indent-output", true);
- serializer.startTag(null, "TestPlan");
- serializer.attribute(null, "version", "1.0");
- for (Map.Entry<String, TestFilter> packageEntry : mIdFilterMap.entrySet()) {
- serializer.startTag(null, ENTRY_TAG);
- String[] parts = AbiUtils.parseId(packageEntry.getKey());
- serializer.attribute(null, ABI_ATTR, parts[0]);
- serializer.attribute(null, NAME_ATTR, parts[1]);
- serializeFilter(serializer, packageEntry.getValue());
- serializer.endTag(null, ENTRY_TAG);
- }
- serializer.endTag(null, "TestPlan");
- serializer.endDocument();
- }
-
- /**
- * Adds an xml attribute containing {@link TestFilter} contents.
- * <p/>
- * If {@link TestFilter} is empty, no data will be output.
- *
- * @param serializer
- * @param testFilter
- * @throws IOException
- */
- private void serializeFilter(KXmlSerializer serializer, TestFilter testFilter)
- throws IOException {
- if (testFilter.hasExclusion()) {
- List<String> exclusionStrings = new ArrayList<String>();
- exclusionStrings.addAll(testFilter.getExcludedClasses());
- for (TestIdentifier test : testFilter.getExcludedTests()) {
- // TODO: this relies on TestIdentifier.toString() using METHOD_DELIM.
- exclusionStrings.add(test.toString());
- }
- String exclusionAttrValue = ArrayUtil.join(TEST_DELIM, exclusionStrings);
- serializer.attribute(null, EXCLUDE_ATTR, exclusionAttrValue);
- }
-
- if (testFilter.hasInclusion()) {
- List<String> inclusionStrings = new ArrayList<String>();
- inclusionStrings.addAll(testFilter.getIncludedClasses());
- for (TestIdentifier test : testFilter.getIncludedTests()) {
- // TODO: this relies on TestIdentifier.toString() using METHOD_DELIM.
- inclusionStrings.add(test.toString());
- }
- String exclusionAttrValue = ArrayUtil.join(TEST_DELIM, inclusionStrings);
- serializer.attribute(null, INCLUDE_ATTR, exclusionAttrValue);
- }
-
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestTimeoutException.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestTimeoutException.java
deleted file mode 100644
index c436658..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestTimeoutException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-/**
- * An exception that indicates a test has timed out.
- * TODO: consider moving this to tradefed proper
- */
-public class TestTimeoutException extends Exception {
-
- private static final long serialVersionUID = 941691916057121118L;
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java
deleted file mode 100644
index 0ebdeea..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.zip.ZipFile;
-
-/**
- * A wrapper around {@link JarHostTest} that includes additional device setup and clean up.
- *
- */
-public class VMHostTest extends JarHostTest {
-
- private static final String VM_TEST_TEMP_DIR = "/data/local/tmp/vm-tests";
- private static final String EMULATOR_TEMP_DIR = "/data/local/tmp";
-
- /**
- * {@inheritDoc}
- */
- @Override
- @SuppressWarnings("unchecked")
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- if (!installVmPrereqs(getDevice(), getBuildHelper())) {
- throw new RuntimeException(String.format(
- "Failed to install vm-tests prereqs on device %s",
- getDevice().getSerialNumber()));
- }
- super.run(listener);
- cleanupDeviceFiles(getDevice());
- }
-
- /**
- * Install pre-requisite jars for running vm-tests, creates temp directories for test.
- *
- * @param device the {@link ITestDevice}
- * @param ctsBuild the {@link CtsBuildHelper}
- * @throws DeviceNotAvailableException
- * @return true if test jar files are extracted and pushed to device successfully
- */
- private boolean installVmPrereqs(ITestDevice device, CtsBuildHelper ctsBuild)
- throws DeviceNotAvailableException {
- cleanupDeviceFiles(device);
- // Creates temp directory recursively. We also need to create the dalvik-cache directory
- // which is used by the dalvikvm to optimize things. Without the dalvik-cache, there will be
- // a sigsev thrown by the vm.
- CLog.d("Creating device temp directory, including dalvik-cache.");
- createRemoteDir(device, VM_TEST_TEMP_DIR + "/dalvik-cache" );
- try {
- File localTmpDir = FileUtil.createTempDir("cts-vm", new File(System.getProperty("java.io.tmpdir")));
- CLog.d("Creating host temp dir %s", localTmpDir.getPath());
- File jarFile = new File(ctsBuild.getTestCasesDir(), getJarFileName());
- if (!jarFile.exists()) {
- CLog.e("Missing jar file %s", jarFile.getPath());
- return false;
- }
- CLog.d("Extracting jar file %s to host temp directory %s.",
- jarFile.getPath(), localTmpDir.getPath());
- ZipFile zipFile = new ZipFile(jarFile);
- FileUtil.extractZip(zipFile, localTmpDir);
- File localTestTmpDir = new File(localTmpDir, "tests");
- CLog.d("Syncing host dir %s to device dir %s",
- localTestTmpDir.getPath(), VM_TEST_TEMP_DIR);
- if (!device.pushDir(localTestTmpDir, VM_TEST_TEMP_DIR)) {
- CLog.e("Failed to push vm test files");
- return false;
- }
- CLog.d("Cleaning up host temp dir %s", localTmpDir.getPath());
- FileUtil.recursiveDelete(localTmpDir);
- } catch (IOException e) {
- CLog.e("Failed to extract jar file %s and sync it to device %s.",
- getJarFileName(), device.getSerialNumber());
- return false;
- }
- return true;
- }
-
- /**
- * Removes temporary file directory from device
- *
- * @param device
- * @throws DeviceNotAvailableException
- */
- private void cleanupDeviceFiles(ITestDevice device) throws DeviceNotAvailableException {
- if (device.doesFileExist(VM_TEST_TEMP_DIR)) {
- CLog.d("Removing device's temp dir %s from previous runs.", VM_TEST_TEMP_DIR);
- device.executeShellCommand(String.format("rm -r %s", VM_TEST_TEMP_DIR));
- }
- }
-
- /**
- * Creates the file directory recursively in the device.
- *
- * @param device the {@link ITestDevice}
- * @param remoteFilePath the absolute path.
- * @throws DeviceNotAvailableException
- */
- private void createRemoteDir(ITestDevice device, String remoteFilePath)
- throws DeviceNotAvailableException {
- if (device.doesFileExist(remoteFilePath)) {
- return;
- }
- if (!(device.doesFileExist(EMULATOR_TEMP_DIR))) {
- CLog.e("Error: Can not found the /data/local/tmp directory!!!");
- }
- device.executeShellCommand(String.format("mkdir %s", VM_TEST_TEMP_DIR));
- device.executeShellCommand(String.format("mkdir %s", remoteFilePath));
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTest.java
deleted file mode 100644
index 1791dae..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.testrunner.ITestRunListener;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.util.AbiUtils;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Test runner for wrapped (native) GTests
- */
-public class WrappedGTest implements IBuildReceiver, IDeviceTest, IRemoteTest {
-
- private static final String LOG_TAG = WrappedGTest.class.getSimpleName();
-
- private int mMaxTestTimeMs = 1 * 60 * 1000;
-
- private CtsBuildHelper mCtsBuild;
- private ITestDevice mDevice;
- private IAbi mAbi;
-
- private final String mAppNameSpace;
- private final String mPackageName;
- private final String mName;
- private final String mRunner;
-
- public WrappedGTest(String appNameSpace, String packageName, String name, String runner) {
- mAppNameSpace = appNameSpace;
- mPackageName = packageName;
- mName = name;
- mRunner = runner;
- }
-
- /**
- * @param abi The ABI to run the test on
- */
- public void setAbi(IAbi abi) {
- mAbi = abi;
- }
-
- @Override
- public void setBuild(IBuildInfo buildInfo) {
- mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
- }
-
- @Override
- public void setDevice(ITestDevice device) {
- mDevice = device;
- }
-
- @Override
- public ITestDevice getDevice() {
- return mDevice;
- }
-
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- if (installTest()) {
- runTest(listener);
- uninstallTest();
- } else {
- CLog.e("Failed to install test");
- }
- }
-
- private boolean installTest() throws DeviceNotAvailableException {
- try {
- File testApp = mCtsBuild.getTestApp(String.format("%s.apk", mName));
- String[] options = {AbiUtils.createAbiFlag(mAbi.getName())};
- String installCode = mDevice.installPackage(testApp, true, options);
-
- if (installCode != null) {
- CLog.e("Failed to install %s.apk on %s. Reason: %s", mName,
- mDevice.getSerialNumber(), installCode);
- return false;
- }
- }
- catch (FileNotFoundException e) {
- CLog.e("Package %s.apk not found", mName);
- return false;
- }
- return true;
- }
-
- private void runTest(ITestRunListener listener) throws DeviceNotAvailableException {
- String id = AbiUtils.createId(mAbi.getName(), mPackageName);
- WrappedGTestResultParser resultParser = new WrappedGTestResultParser(id, listener);
- resultParser.setFakePackagePrefix(mPackageName + ".");
- try {
- String options = mAbi == null ? "" : String.format("--abi %s ", mAbi.getName());
- String command = String.format("am instrument -w %s%s/.%s", options, mAppNameSpace, mRunner);
- mDevice.executeShellCommand(command, resultParser, mMaxTestTimeMs,
- TimeUnit.MILLISECONDS, 0);
- } catch (DeviceNotAvailableException e) {
- resultParser.flush();
- throw e;
- } catch (RuntimeException e) {
- resultParser.flush();
- throw e;
- }
- }
-
- private void uninstallTest() throws DeviceNotAvailableException {
- mDevice.uninstallPackage(mAppNameSpace);
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTestResultParser.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTestResultParser.java
deleted file mode 100644
index 3050738..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTestResultParser.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.ITestRunListener;
-import com.android.tradefed.log.LogUtil.CLog;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.ArrayList;
-
-public class WrappedGTestResultParser extends GeeTestResultParser {
-
- private boolean mInstrumentationError;
-
- /**
- * Creates the WrappedGTestResultParser.
- *
- * @param testRunId the test run id to provide to
- * {@link ITestRunListener#testRunStarted(String, int)}
- * @param listeners informed of test results as the tests are executing
- */
- public WrappedGTestResultParser(String testRunId, Collection<ITestRunListener> listeners) {
- super(testRunId, listeners);
- }
-
- /**
- * Creates the WrappedGTestResultParser for a single listener.
- *
- * @param testRunId the test run id to provide to
- * {@link ITestRunListener#testRunStarted(String, int)}
- * @param listener informed of test results as the tests are executing
- */
- public WrappedGTestResultParser(String testRunId, ITestRunListener listener) {
- super(testRunId, listener);
- }
-
- /**
- * Strips the instrumentation information and then forwards
- * the raw gtest output to the {@link GeeTestResultParser}.
- */
- @Override
- public void processNewLines(String[] lines) {
- if (mInstrumentationError) {
- return;
- }
-
- String[] gtestOutput = parseInstrumentation(lines);
- super.processNewLines(gtestOutput);
- }
-
- /**
- * Parses raw instrumentation output and returns the
- * contained gtest output
- *
- * @param lines the raw instrumentation output
- * @return the gtest output
- */
- public String[] parseInstrumentation(String[] lines) {
- List<String> output = new ArrayList<String>();
- boolean readMultiLine = false;
- for (String line : lines) {
-
- if (line.startsWith("INSTRUMENTATION_RESULT: ")) {
- CLog.e("Instrumentation Error:");
- mInstrumentationError = true;
- }
-
- if (mInstrumentationError) {
- CLog.e(line);
- continue;
- }
-
- if (line.startsWith("INSTRUMENTATION_STATUS: gtest=")) {
- output.add(line.replace("INSTRUMENTATION_STATUS: gtest=", ""));
- readMultiLine = true;
- continue;
- }
-
- if (line.startsWith("INSTRUMENTATION_")) {
- readMultiLine = false;
- continue;
- }
-
- if (readMultiLine) {
- output.add(line);
- }
- }
-
- return output.toArray(new String[output.size()]);
- }
-}
-
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/util/ReportLogUtil.java b/tools/tradefed-host/src/com/android/cts/tradefed/util/ReportLogUtil.java
deleted file mode 100644
index 9233a4a..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/util/ReportLogUtil.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.util;
-
-import com.android.cts.tradefed.result.CtsXmlResultReporter;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.util.FileUtil;
-
-import java.io.File;
-
-/**
- * Collects report logs from device and host after cts_v1 test runs.
- */
-public class ReportLogUtil{
-
- /**
- * Directory values must match the src-dir, dest-dir and temp-dir values configured in
- * ReportLogCollector target preparer in
- * cts/tools/cts-tradefed/res/config/cts-preconditions.xml.
- */
- private static final String SRC_DIR = "/sdcard/report-log-files/";
- private static final String DEST_DIR = "report-log-files/";
- private static final String TEMP_REPORT_DIR= "temp-report-logs/";
-
- public static void prepareReportLogContainers(ITestDevice device, IBuildInfo buildInfo) {
- try {
- // Delete earlier report logs if present on device.
- String command = String.format("adb -s %s shell rm -rf %s", device.getSerialNumber(),
- SRC_DIR);
- if (device.doesFileExist(SRC_DIR)) {
- Process process = Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c",
- command});
- if (process.waitFor() != 0) {
- CLog.e("Failed to run %s", command);
- }
- }
- // Create folder in result directory to store report logs.
- File resultDir = new File(buildInfo.getBuildAttributes().get(
- CtsXmlResultReporter.CTS_RESULT_DIR));
- if (DEST_DIR != null) {
- resultDir = new File(resultDir, DEST_DIR);
- }
- resultDir.mkdirs();
- if (!resultDir.isDirectory()) {
- CLog.e("%s is not a directory", resultDir.getAbsolutePath());
- return;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static void collectReportLogs(ITestDevice device, IBuildInfo buildInfo) {
- // Pull report log files from device and host.
- try {
- File resultDir = new File(buildInfo.getBuildAttributes().get(
- CtsXmlResultReporter.CTS_RESULT_DIR));
- if (DEST_DIR != null) {
- resultDir = new File(resultDir, DEST_DIR);
- }
- resultDir.mkdirs();
- if (!resultDir.isDirectory()) {
- CLog.e("%s is not a directory", resultDir.getAbsolutePath());
- return;
- }
- final File hostReportDir = FileUtil.createNamedTempDir(TEMP_REPORT_DIR);
- if (!hostReportDir.isDirectory()) {
- CLog.e("%s is not a directory", hostReportDir.getAbsolutePath());
- return;
- }
- pull(device, SRC_DIR, hostReportDir, resultDir);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private static void pull(ITestDevice device, String deviceSrc, File hostDir, File destDir) {
- String hostSrc = hostDir.getAbsolutePath();
- String dest = destDir.getAbsolutePath();
- String deviceSideCommand = String.format("adb -s %s pull %s %s", device.getSerialNumber(),
- deviceSrc, dest);
- CLog.e(deviceSideCommand);
- try {
- if (device.doesFileExist(deviceSrc)) {
- Process deviceProcess = Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c",
- deviceSideCommand});
- if (deviceProcess.waitFor() != 0) {
- CLog.e("Failed to run %s", deviceSideCommand);
- }
- }
- FileUtil.recursiveCopy(hostDir, destDir);
- FileUtil.recursiveDelete(hostDir);
- } catch (Exception e) {
- CLog.e("Caught exception during pull.");
- CLog.e(e);
- }
- }
-}
diff --git a/tools/tradefed-host/tests/.classpath b/tools/tradefed-host/tests/.classpath
deleted file mode 100644
index 10ad23c..0000000
--- a/tools/tradefed-host/tests/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/tradefederation"/>
- <classpathentry combineaccessrules="false" kind="src" path="/cts-tradefed-host"/>
- <classpathentry kind="var" path="CTS_SRC_ROOT/out/host/common/obj/JAVA_LIBRARIES/easymock_intermediates/javalib.jar" sourcepath="/CTS_SRC_ROOT/external/easymock/src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/tools/tradefed-host/tests/.project b/tools/tradefed-host/tests/.project
deleted file mode 100644
index 1c385d8..0000000
--- a/tools/tradefed-host/tests/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>cts-tradefed-host-tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/tools/tradefed-host/tests/Android.mk b/tools/tradefed-host/tests/Android.mk
deleted file mode 100644
index 365deb8..0000000
--- a/tools/tradefed-host/tests/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-# Only compile source java files in this lib.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_MODULE := old-cts-tradefed-tests
-LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := tradefed-prebuilt old-cts-tradefed
-LOCAL_STATIC_JAVA_LIBRARIES := easymock
-
-include $(BUILD_HOST_JAVA_LIBRARY)
\ No newline at end of file
diff --git a/tools/tradefed-host/tests/run_unit_func_tests.sh b/tools/tradefed-host/tests/run_unit_func_tests.sh
deleted file mode 100755
index 8c08c4e..0000000
--- a/tools/tradefed-host/tests/run_unit_func_tests.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# helper script for running the cts-tradefed unit tests
-
-checkFile() {
- if [ ! -f "$1" ]; then
- echo "Unable to locate $1"
- exit
- fi;
-}
-
-# check if in Android build env
-if [ ! -z ${ANDROID_BUILD_TOP} ]; then
- HOST=`uname`
- if [ "$HOST" == "Linux" ]; then
- OS="linux-x86"
- elif [ "$HOST" == "Darwin" ]; then
- OS="darwin-x86"
- else
- echo "Unrecognized OS"
- exit
- fi;
-fi;
-
-JAR_DIR=${ANDROID_BUILD_TOP}/out/host/$OS/framework
-JARS="tradefed-prebuilt.jar hosttestlib.jar old-cts-tradefed.jar old-cts-tradefed-tests.jar"
-
-for JAR in $JARS; do
- checkFile ${JAR_DIR}/${JAR}
- JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}
-done
-
-java $RDBG_FLAG \
- -cp ${JAR_PATH} com.android.tradefed.command.Console run singleCommand host --class com.android.cts.tradefed.FuncTests "$@"
diff --git a/tools/tradefed-host/tests/run_unit_tests.sh b/tools/tradefed-host/tests/run_unit_tests.sh
deleted file mode 100755
index a1bb12c..0000000
--- a/tools/tradefed-host/tests/run_unit_tests.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# helper script for running the cts-tradefed unit tests
-
-checkFile() {
- if [ ! -f "$1" ]; then
- echo "Unable to locate $1"
- exit
- fi;
-}
-
-# check if in Android build env
-if [ ! -z ${ANDROID_BUILD_TOP} ]; then
- HOST=`uname`
- if [ "$HOST" == "Linux" ]; then
- OS="linux-x86"
- elif [ "$HOST" == "Darwin" ]; then
- OS="darwin-x86"
- else
- echo "Unrecognized OS"
- exit
- fi;
-fi;
-
-JAR_DIR=${ANDROID_BUILD_TOP}/out/host/$OS/framework
-JARS="tradefed-prebuilt.jar hosttestlib.jar old-cts-tradefed.jar old-cts-tradefed-tests.jar"
-
-for JAR in $JARS; do
- checkFile ${JAR_DIR}/${JAR}
- JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}
-done
-
-java $RDBG_FLAG \
- -cp ${JAR_PATH} com.android.tradefed.command.Console run singleCommand host -n --class com.android.cts.tradefed.UnitTests "$@"
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/FuncTests.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/FuncTests.java
deleted file mode 100644
index a9420d2..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/FuncTests.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed;
-
-import com.android.cts.tradefed.device.DeviceInfoCollectorFuncTest;
-import com.android.tradefed.testtype.DeviceTestSuite;
-
-import junit.framework.Test;
-
-/**
- * A test suite for all cts-tradefed functional tests.
- * <p/>
- * Tests listed here should require a device.
- */
-public class FuncTests extends DeviceTestSuite {
-
- public FuncTests() {
- super();
-
- // device package
- addTestSuite(DeviceInfoCollectorFuncTest.class);
- }
-
- public static Test suite() {
- return new FuncTests();
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/UnitTests.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/UnitTests.java
deleted file mode 100644
index fce7604..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/UnitTests.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed;
-
-import com.android.cts.tradefed.result.CtsXmlResultReporterTest;
-import com.android.cts.tradefed.result.DeviceInfoResultTest;
-import com.android.cts.tradefed.result.TestPackageResultTest;
-import com.android.cts.tradefed.result.TestResultsTest;
-import com.android.cts.tradefed.result.TestSummaryXmlTest;
-import com.android.cts.tradefed.result.TestTest;
-import com.android.cts.tradefed.result.TestLogTest;
-import com.android.cts.tradefed.testtype.CtsTestTest;
-import com.android.cts.tradefed.testtype.DeqpTestRunnerTest;
-import com.android.cts.tradefed.testtype.GeeTestTest;
-import com.android.cts.tradefed.testtype.JarHostTestTest;
-import com.android.cts.tradefed.testtype.TestFilterTest;
-import com.android.cts.tradefed.testtype.TestPackageDefTest;
-import com.android.cts.tradefed.testtype.TestPackageXmlParserTest;
-import com.android.cts.tradefed.testtype.TestPlanTest;
-import com.android.cts.tradefed.testtype.WrappedGTestResultParserTest;
-import com.android.tradefed.testtype.Abi;
-import com.android.tradefed.testtype.IAbi;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * A test suite for all cts-tradefed unit tests.
- * <p/>
- * All tests listed here should be self-contained, and do not require any external dependencies
- * (such as a full CTS build with XML etc).
- */
-public class UnitTests extends TestSuite {
-
- public static final IAbi ABI = new Abi("armeabi-v7a", "32");
-
- public UnitTests() {
- super();
-
- // result package
- addTestSuite(CtsXmlResultReporterTest.class);
- addTestSuite(DeviceInfoResultTest.class);
- addTestSuite(TestPackageResultTest.class);
- addTestSuite(TestResultsTest.class);
- addTestSuite(TestSummaryXmlTest.class);
- addTestSuite(TestTest.class);
- addTestSuite(TestLogTest.class);
-
- // testtype package
- addTestSuite(CtsTestTest.class);
- addTestSuite(DeqpTestRunnerTest.class);
- addTestSuite(GeeTestTest.class);
- addTestSuite(JarHostTestTest.class);
- addTestSuite(TestFilterTest.class);
- addTestSuite(TestPackageDefTest.class);
- addTestSuite(TestPackageXmlParserTest.class);
- addTestSuite(TestPlanTest.class);
- addTestSuite(WrappedGTestResultParserTest.class);
- }
-
- public static Test suite() {
- return new UnitTests();
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/build/StubCtsBuildHelper.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/build/StubCtsBuildHelper.java
deleted file mode 100644
index 0fe2f7a..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/build/StubCtsBuildHelper.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.build;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-
-/**
- * Stub implementation of CtsBuildHelper that returns empty files for all methods
- */
-public class StubCtsBuildHelper extends CtsBuildHelper {
-
- public StubCtsBuildHelper() {
- super(new File("tmp"));
- }
-
- @Override
- public void validateStructure() {
- // ignore
- }
-
- @Override
- public File getTestApp(String appFileName) throws FileNotFoundException {
- return new File("tmp");
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/device/DeviceInfoCollectorFuncTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/device/DeviceInfoCollectorFuncTest.java
deleted file mode 100644
index 60e30cc..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/device/DeviceInfoCollectorFuncTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.device;
-
-import com.android.ddmlib.Log.LogLevel;
-import com.android.cts.tradefed.UnitTests;
-import com.android.cts.tradefed.result.CtsXmlResultReporter;
-import com.android.tradefed.build.BuildInfo;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.CollectingTestListener;
-import com.android.tradefed.testtype.DeviceTestCase;
-import com.android.tradefed.util.FileUtil;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.easymock.EasyMock;
-
-/**
- * Functional test for {@link DeviceInfoCollector}.
- * <p/>
- * TODO: this test assumes the TestDeviceSetup and DeviceInfoCollector apks are located in the
- * "java.io.tmpdir"
- */
-public class DeviceInfoCollectorFuncTest extends DeviceTestCase {
-
- private CollectingTestListener testListener;
- private File mResultDir;
- private IFolderBuildInfo mMockBuildInfo;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- testListener = new CollectingTestListener();
- mResultDir = FileUtil.createTempDir("cts-result-dir");
- mMockBuildInfo = EasyMock.createMock(IFolderBuildInfo.class);
- Map<String, String> attributes = new HashMap<>();
- attributes.put(CtsXmlResultReporter.CTS_RESULT_DIR, mResultDir.getAbsolutePath());
- EasyMock.expect(mMockBuildInfo.getBuildAttributes()).andStubReturn(attributes);
- EasyMock.replay(mMockBuildInfo);
-
- assertNotNull(getDevice().getSerialNumber());
- }
-
- public void testCollectDeviceInfo() throws DeviceNotAvailableException {
- testListener.invocationStarted(mMockBuildInfo);
- DeviceInfoCollector.collectDeviceInfo(getDevice(), UnitTests.ABI.getName(), new File(
- System.getProperty("java.io.tmpdir")), testListener);
- assertNotNull(testListener.getCurrentRunResults());
-
- Map<String, String> runMetrics = testListener.getCurrentRunResults().getRunMetrics();
- assertTrue(runMetrics.size() > 0);
- displayMetrics(runMetrics);
- testListener.invocationEnded(0);
- }
-
- public void testExtendedDeviceInfo() throws DeviceNotAvailableException {
- testListener.invocationStarted(mMockBuildInfo);
- DeviceInfoCollector.collectExtendedDeviceInfo(getDevice(), UnitTests.ABI.getName(),
- new File(System.getProperty("java.io.tmpdir")), testListener, mMockBuildInfo);
- assertNotNull(testListener.getCurrentRunResults());
-
- Map<String, String> runMetrics = testListener.getCurrentRunResults().getRunMetrics();
- assertTrue(runMetrics.size() > 0);
- displayMetrics(runMetrics);
- testListener.invocationEnded(0);
- }
-
- private void displayMetrics(Map<String, String> runMetrics) {
- for (Map.Entry<String, String> metricEntry : runMetrics.entrySet()) {
- CLog.logAndDisplay(LogLevel.INFO,
- String.format("%s=%s", metricEntry.getKey(), metricEntry.getValue()));
- }
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/CtsXmlResultReporterTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/CtsXmlResultReporterTest.java
deleted file mode 100644
index 411b8f4..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/CtsXmlResultReporterTest.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import static com.android.cts.tradefed.result.CtsXmlResultReporter.CTS_RESULT_FILE_VERSION;
-
-import com.android.cts.tradefed.UnitTests;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.LogFile;
-import com.android.tradefed.result.TestSummary;
-import com.android.tradefed.result.XmlResultReporter;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.FileUtil;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Unit tests for {@link XmlResultReporter}.
- */
-public class CtsXmlResultReporterTest extends TestCase {
-
- private static final String TEST_SUMMARY_URL = "http://www.google.com?q=android";
- private static final List<TestSummary> SUMMARY_LIST =
- new ArrayList<>(Arrays.asList(new TestSummary(TEST_SUMMARY_URL)));
- private CtsXmlResultReporter mResultReporter;
- private ByteArrayOutputStream mOutputStream;
- private File mBuildDir;
- private File mReportDir;
- private IFolderBuildInfo mMockBuild;
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- mOutputStream = new ByteArrayOutputStream();
- mResultReporter = new CtsXmlResultReporter() {
- @Override
- OutputStream createOutputResultStream(File reportDir) throws IOException {
- return mOutputStream;
- }
-
- @Override
- String getTimestamp() {
- return "ignore";
- }
- };
- // TODO: use mock file dir instead
- mReportDir = FileUtil.createTempDir("foo");
- mResultReporter.setReportDir(mReportDir);
- mBuildDir = FileUtil.createTempDir("build");
- File ctsDir = new File(mBuildDir, "android-cts");
- File repoDir = new File(ctsDir, "repository");
- File casesDir = new File(repoDir, "testcases");
- File plansDir = new File(repoDir, "plans");
- assertTrue(casesDir.mkdirs());
- assertTrue(plansDir.mkdirs());
- mMockBuild = EasyMock.createMock(IFolderBuildInfo.class);
- EasyMock.expect(mMockBuild.getDeviceSerial()).andStubReturn(null);
- EasyMock.expect(mMockBuild.getRootDir()).andStubReturn(mBuildDir);
- mMockBuild.addBuildAttribute(EasyMock.cmpEq(CtsXmlResultReporter.CTS_RESULT_DIR),
- (String) EasyMock.anyObject());
- EasyMock.expectLastCall();
- Map<String, String> attributes = new HashMap<>();
- attributes.put(CtsXmlResultReporter.CTS_RESULT_DIR, "");
- EasyMock.expect(mMockBuild.getBuildAttributes()).andStubReturn(attributes);
- EasyMock.expect(mMockBuild.getBuildId()).andStubReturn("");
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (mReportDir != null) {
- FileUtil.recursiveDelete(mReportDir);
- }
- if (mBuildDir != null) {
- FileUtil.recursiveDelete(mBuildDir);
- }
- super.tearDown();
- }
-
- /**
- * A simple test to ensure expected output is generated for test run with no tests.
- */
- public void testEmptyGeneration() {
- final String expectedHeaderOutput = "<?xml version='1.0' encoding='UTF-8' standalone='no' ?>" +
- "<?xml-stylesheet type=\"text/xsl\" href=\"cts_result.xsl\"?>";
- final String expectedTestOutput = String.format(
- "<TestResult testPlan=\"NA\" starttime=\"ignore\" endtime=\"ignore\" " +
- "version=\"%s\" suite=\"%s\"> ", CTS_RESULT_FILE_VERSION, "CTS");
- final String expectedSummaryOutput =
- "<Summary failed=\"0\" notExecuted=\"0\" timeout=\"0\" pass=\"0\" />";
- final String expectedEndTag = "</TestResult>";
- EasyMock.replay(mMockBuild);
- mResultReporter.invocationStarted(mMockBuild);
- mResultReporter.invocationEnded(1);
- String actualOutput = getOutput();
- assertTrue(actualOutput.startsWith(expectedHeaderOutput));
- assertTrue(String.format("test output did not contain expected test result [%s]. Got %s",
- expectedTestOutput, actualOutput), actualOutput.contains(expectedTestOutput));
- assertTrue(String.format("test output did not contain expected test summary [%s]. Got %s",
- expectedSummaryOutput, actualOutput), actualOutput.contains(expectedSummaryOutput));
- assertTrue(String.format("test output did not contain expected TestResult end tag. Got %s",
- actualOutput), actualOutput.endsWith(expectedEndTag));
- EasyMock.verify(mMockBuild);
- }
-
- /**
- * A simple test to ensure expected output is generated for test run with a single passed test.
- */
- public void testSinglePass() {
- Map<String, String> emptyMap = Collections.emptyMap();
- final TestIdentifier testId = new TestIdentifier("com.foo.FooTest", "testFoo");
- EasyMock.replay(mMockBuild);
- mResultReporter.invocationStarted(mMockBuild);
- mResultReporter.testRunStarted(AbiUtils.createId(UnitTests.ABI.getName(), "run"), 1);
- mResultReporter.testStarted(testId);
- mResultReporter.testEnded(testId, emptyMap);
- mResultReporter.testRunEnded(3000, emptyMap);
- mResultReporter.putSummary(SUMMARY_LIST);
- mResultReporter.invocationEnded(1);
- String output = getOutput();
- // TODO: consider doing xml based compare
- final String expectedTestOutput = String.format(
- "<TestResult testPlan=\"NA\" starttime=\"ignore\" endtime=\"ignore\" " +
- "version=\"%s\" suite=\"%s\" referenceUrl=\"%s\"> ",
- CTS_RESULT_FILE_VERSION, "CTS", TEST_SUMMARY_URL);
- assertTrue("Found output: " + output, output.contains(expectedTestOutput));
- assertTrue(output.contains(
- "<Summary failed=\"0\" notExecuted=\"0\" timeout=\"0\" pass=\"1\" />"));
- assertTrue(output.contains("<TestPackage name=\"\" appPackageName=\"run\" abi=\"" +
- UnitTests.ABI.getName() + "\" digest=\"\">"));
- assertTrue(output.contains("<TestCase name=\"FooTest\" priority=\"\">"));
-
- final String testCaseTag = String.format(
- "<Test name=\"%s\" result=\"pass\"", testId.getTestName());
- assertTrue(output.contains(testCaseTag));
- EasyMock.verify(mMockBuild);
- }
-
- /**
- * A simple test to ensure expected output is generated for test run with a single failed test.
- */
- public void testSingleFail() {
- Map<String, String> emptyMap = Collections.emptyMap();
- final TestIdentifier testId = new TestIdentifier("FooTest", "testFoo");
- final String trace = "this is a trace\nmore trace\nyet more trace";
- EasyMock.replay(mMockBuild);
- mResultReporter.invocationStarted(mMockBuild);
- mResultReporter.testRunStarted(AbiUtils.createId(UnitTests.ABI.getName(), "run"), 1);
- mResultReporter.testStarted(testId);
- mResultReporter.testFailed(testId, trace);
- mResultReporter.testEnded(testId, emptyMap);
- mResultReporter.testRunEnded(3, emptyMap);
- mResultReporter.testLogSaved("logcat-foo-bar", LogDataType.TEXT, null,
- new LogFile("path", "url"));
- mResultReporter.invocationEnded(1);
- String output = getOutput();
- // TODO: consider doing xml based compare
- assertTrue(output.contains(
- "<Summary failed=\"1\" notExecuted=\"0\" timeout=\"0\" pass=\"0\" />"));
- final String failureTag =
- "<FailedScene message=\"this is a trace more trace\"> " +
- "<StackTrace>this is a tracemore traceyet more trace</StackTrace>";
- assertTrue(output.contains(failureTag));
-
- // Check that no TestLog tags were added, because the flag wasn't enabled.
- final String testLogTag = String.format("<TestLog type=\"logcat\" url=\"url\" />");
- assertFalse(output, output.contains(testLogTag));
- EasyMock.verify(mMockBuild);
- }
-
- /**
- * Test that flips the include-test-log-tags flag and checks that logs are written to the XML.
- */
- public void testIncludeTestLogTags() {
- Map<String, String> emptyMap = Collections.emptyMap();
- final TestIdentifier testId = new TestIdentifier("FooTest", "testFoo");
- final String trace = "this is a trace\nmore trace\nyet more trace";
-
- // Include TestLogTags in the XML.
- mResultReporter.setIncludeTestLogTags(true);
-
- EasyMock.replay(mMockBuild);
- mResultReporter.invocationStarted(mMockBuild);
- mResultReporter.testRunStarted(AbiUtils.createId(UnitTests.ABI.getName(), "run"), 1);
- mResultReporter.testStarted(testId);
- mResultReporter.testFailed(testId, trace);
- mResultReporter.testEnded(testId, emptyMap);
- mResultReporter.testRunEnded(3, emptyMap);
- mResultReporter.testLogSaved("logcat-foo-bar", LogDataType.TEXT, null,
- new LogFile("path", "url"));
- mResultReporter.invocationEnded(1);
-
- // Check for TestLog tags because the flag was enabled via setIncludeTestLogTags.
- final String output = getOutput();
- final String testLogTag = String.format("<TestLog type=\"logcat\" url=\"url\" />");
- assertTrue(output, output.contains(testLogTag));
- EasyMock.verify(mMockBuild);
- }
-
- public void testDeviceSetup() {
- Map<String, String> emptyMap = Collections.emptyMap();
- final TestIdentifier testId = new TestIdentifier("android.tests.devicesetup", "TestDeviceSetup");
- EasyMock.replay(mMockBuild);
- mResultReporter.invocationStarted(mMockBuild);
- mResultReporter.testRunStarted(AbiUtils.createId(UnitTests.ABI.getName(), testId.getClassName()), 1);
- mResultReporter.testStarted(testId);
- mResultReporter.testEnded(testId, emptyMap);
- mResultReporter.testRunEnded(3, emptyMap);
- mResultReporter.invocationEnded(1);
- String output = getOutput();
- // TODO: consider doing xml based compare
- final String deviceSetupTag = "appPackageName=\"android.tests.devicesetup\"";
- assertFalse(output, output.contains(deviceSetupTag));
- EasyMock.verify(mMockBuild);
- }
-
- /**
- * Gets the output produced, stripping it of extraneous whitespace characters.
- */
- private String getOutput() {
- String output = mOutputStream.toString();
- // ignore newlines and tabs whitespace
- output = output.replaceAll("[\\r\\n\\t]", "");
- // replace two ws chars with one
- return output.replaceAll(" ", " ");
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/DeviceInfoResultTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/DeviceInfoResultTest.java
deleted file mode 100644
index fa36430..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/DeviceInfoResultTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import android.tests.getinfo.DeviceInfoConstants;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link DeviceInfoResult}
- */
-public class DeviceInfoResultTest extends TestCase {
-
- private DeviceInfoResult mDeserializingInfo;
-
- @Override
- protected void setUp() throws Exception {
- mDeserializingInfo = new DeviceInfoResult() {
- // override parent to advance xml parser to correct tag
- @Override
- void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
- int eventType = parser.getEventType();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG && parser.getName().equals(TAG)) {
- super.parse(parser);
- return;
- }
- eventType = parser.next();
- }
- throw new XmlPullParserException(String.format("Could not find tag %s", TAG));
- }
- };
- }
-
- public void testFeatures() throws Exception {
- assertSerializeParse(DeviceInfoConstants.FEATURES, "");
- assertSerializeParse(DeviceInfoConstants.FEATURES,
- "android.hardware.audio.low_latency:sdk:false;");
- assertSerializeParse(DeviceInfoConstants.FEATURES, "android.hardware.audio.low_latency:"
- + "sdk:false;android.hardware.bluetooth:sdk:true;");
- }
-
- public void testProcesses() throws Exception {
- assertSerializeParse(DeviceInfoConstants.PROCESSES, "");
- assertSerializeParse(DeviceInfoConstants.PROCESSES, "ueventd:0;");
- assertSerializeParse(DeviceInfoConstants.PROCESSES, "ueventd:0;netd:0;");
- }
-
- public void testOpenGlTextureFormats() throws Exception {
- assertSerializeParse(DeviceInfoConstants.OPEN_GL_COMPRESSED_TEXTURE_FORMATS, "");
- assertSerializeParse(DeviceInfoConstants.OPEN_GL_COMPRESSED_TEXTURE_FORMATS, "texture1;");
- assertSerializeParse(DeviceInfoConstants.OPEN_GL_COMPRESSED_TEXTURE_FORMATS,
- "texture1;texture2;");
- }
-
- public void testSystemLibraries() throws Exception {
- assertSerializeParse(DeviceInfoConstants.SYS_LIBRARIES, "");
- assertSerializeParse(DeviceInfoConstants.SYS_LIBRARIES, "lib1;");
- assertSerializeParse(DeviceInfoConstants.SYS_LIBRARIES, "lib1;lib2;");
- }
-
- private void assertSerializeParse(String name, String value)
- throws IOException, ParseException {
- DeviceInfoResult serializedInfo = new DeviceInfoResult();
- addMetric(name, value, serializedInfo);
- String serializedOutput = serialize(serializedInfo);
- mDeserializingInfo.parse(new StringReader(serializedOutput));
- assertEquals(value, mDeserializingInfo.getMetrics().get(name));
- }
-
- /**
- * Test populating a combined metric like device serial
- */
- public void testPopulateMetrics_combinedSerial() throws Exception {
- DeviceInfoResult info = new DeviceInfoResult();
- // first add another metric to make hashmap non empty, so combined logic is triggered
- addMetric(DeviceInfoConstants.PROCESSES, "proc", info);
- addMetric(DeviceInfoConstants.SERIAL_NUMBER, "device1", info);
- // ensure the stored serial number equals the value that was just set
- assertEquals("device1", info.getMetrics().get(
- DeviceInfoConstants.SERIAL_NUMBER));
- // now add it again
- addMetric(DeviceInfoConstants.SERIAL_NUMBER, "device1", info);
- // should still equal same value
- assertEquals("device1", info.getMetrics().get(
- DeviceInfoConstants.SERIAL_NUMBER));
- // now store different serial, and expect csv
- addMetric(DeviceInfoConstants.SERIAL_NUMBER, "device2", info);
- assertEquals("device1,device2", info.getMetrics().get(
- DeviceInfoConstants.SERIAL_NUMBER));
- }
-
- /**
- * Test populating a verified-to-be-identical metric like DeviceInfoConstants.BUILD_FINGERPRINT
- */
- public void testPopulateMetrics_verify() throws Exception {
- DeviceInfoResult info = new DeviceInfoResult();
- addMetric(DeviceInfoConstants.BUILD_FINGERPRINT, "fingerprint1", info);
- // ensure the stored fingerprint equals the value that was just set
- assertEquals("fingerprint1", info.getMetrics().get(
- DeviceInfoConstants.BUILD_FINGERPRINT));
- // now add it again
- addMetric(DeviceInfoConstants.BUILD_FINGERPRINT, "fingerprint1", info);
- // should still equal same value
- assertEquals("fingerprint1", info.getMetrics().get(
- DeviceInfoConstants.BUILD_FINGERPRINT));
- // now store different serial, and expect error message
- addMetric(DeviceInfoConstants.BUILD_FINGERPRINT, "fingerprint2", info);
- assertTrue(info.getMetrics().get(
- DeviceInfoConstants.BUILD_FINGERPRINT).contains("ERROR"));
- }
-
- /**
- * Helper method to add given metric to the {@link DeviceInfoResult}
- */
- private void addMetric(String metricName, String metricValue, DeviceInfoResult serializedInfo) {
- Map<String, String> collectedMetrics = new HashMap<String, String>();
- collectedMetrics.put(metricName, metricValue);
- serializedInfo.populateMetrics(collectedMetrics);
- }
-
- /**
- * Helper method to serialize given object to XML
- */
- private String serialize(DeviceInfoResult serializedInfo)
- throws IOException {
- KXmlSerializer xmlSerializer = new KXmlSerializer();
- StringWriter serializedOutput = new StringWriter();
- xmlSerializer.setOutput(serializedOutput);
- serializedInfo.serialize(xmlSerializer);
- return serializedOutput.toString();
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestLogTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestLogTest.java
deleted file mode 100644
index 55c3071..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestLogTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.cts.tradefed.result.TestLog.TestLogType;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-
-import junit.framework.TestCase;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-
-/** Tests for {@link TestLog}. */
-public class TestLogTest extends TestCase {
-
- public void testTestLogType_fromDataName() {
- assertNull(TestLogType.fromDataName(null));
- assertNull(TestLogType.fromDataName(""));
- assertNull(TestLogType.fromDataName("kmsg-foo_bar_test"));
-
- assertEquals(TestLogType.LOGCAT,
- TestLogType.fromDataName("logcat-foo_bar_test"));
- assertEquals(TestLogType.BUGREPORT,
- TestLogType.fromDataName("bug-foo_bar_test"));
- }
-
- public void testTestLogType_getAttrValue() {
- assertEquals("logcat", TestLogType.LOGCAT.getAttrValue());
- assertEquals("bugreport", TestLogType.BUGREPORT.getAttrValue());
- }
-
- public void testFromDataName() {
- TestLog log = TestLog.fromDataName("logcat-baz_test", "http://logs/baz_test");
- assertEquals(TestLogType.LOGCAT, log.getLogType());
- assertEquals("http://logs/baz_test", log.getUrl());
- }
-
- public void testFromDataName_unrecognizedDataName() {
- assertNull(TestLog.fromDataName("kmsg-baz_test", null));
- }
-
- public void testFromDataName_nullDataName() {
- assertNull(TestLog.fromDataName(null, "http://logs/baz_test"));
- }
-
- public void testFromDataName_nullUrl() {
- assertNull(TestLog.fromDataName("logcat-bar_test", null));
- }
-
- public void testFromDataName_allNull() {
- assertNull(TestLog.fromDataName(null, null));
- }
-
- public void testFromXml() throws Exception {
- TestLog log = TestLog.fromXml(newXml("<TestLog type=\"logcat\" url=\"http://logs/baz_test\">"));
- assertEquals(TestLogType.LOGCAT, log.getLogType());
- assertEquals("http://logs/baz_test", log.getUrl());
- }
-
- public void testFromXml_unrecognizedType() throws Exception {
- assertNull(TestLog.fromXml(newXml("<TestLog type=\"kmsg\" url=\"http://logs/baz_test\">")));
- }
-
- public void testFromXml_noTypeAttribute() throws Exception {
- assertNull(TestLog.fromXml(newXml("<TestLog url=\"http://logs/baz_test\">")));
- }
-
- public void testFromXml_noUrlAttribute() throws Exception {
- assertNull(TestLog.fromXml(newXml("<TestLog type=\"bugreport\">")));
- }
-
- public void testFromXml_allNull() throws Exception {
- assertNull(TestLog.fromXml(newXml("<TestLog>")));
- }
-
- public void testSerialize() throws Exception {
- KXmlSerializer serializer = new KXmlSerializer();
- StringWriter writer = new StringWriter();
- serializer.setOutput(writer);
-
- TestLog log = TestLog.of(TestLogType.LOGCAT, "http://logs/foo/bar");
- log.serialize(serializer);
- assertEquals("<TestLog type=\"logcat\" url=\"http://logs/foo/bar\" />", writer.toString());
- }
-
- public void testIsTag() {
- assertTrue(TestLog.isTag("TestLog"));
- assertFalse(TestLog.isTag("TestResult"));
- }
-
- private XmlPullParser newXml(String xml) throws Exception {
- XmlPullParserFactory factory = org.xmlpull.v1.XmlPullParserFactory.newInstance();
- XmlPullParser parser = factory.newPullParser();
- parser.setInput(new StringReader(xml));
-
- // Move the parser from the START_DOCUMENT stage to the START_TAG of the data.
- parser.next();
-
- return parser;
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestPackageResultTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestPackageResultTest.java
deleted file mode 100644
index 57d322e..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestPackageResultTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-
-import junit.framework.TestCase;
-
-import java.util.Collection;
-import java.util.HashMap;
-
-/**
- * Unit tests for {@link TestPackageResult}.
- */
-public class TestPackageResultTest extends TestCase {
-
- /**
- * Simple test for {@link TestPackageResult#getTestsWithStatus(CtsTestStatus)}.
- */
- public void testGetTestsWithStatus() {
- TestPackageResult pkgResult = new TestPackageResult();
- TestIdentifier excludedTest = new TestIdentifier("com.example.ExampleTest", "testPass");
- pkgResult.insertTest(excludedTest);
- pkgResult.reportTestEnded(excludedTest, new HashMap<String, String>());
- TestIdentifier includedTest = new TestIdentifier("com.example.ExampleTest",
- "testNotExecuted");
- pkgResult.insertTest(includedTest);
- Collection<TestIdentifier> tests = pkgResult.getTestsWithStatus(
- CtsTestStatus.NOT_EXECUTED);
- assertEquals(1, tests.size());
- assertEquals(includedTest, tests.iterator().next());
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestResultsTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestResultsTest.java
deleted file mode 100644
index 75f545e..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestResultsTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import java.io.StringReader;
-
-/**
- * Unit tests for {@link TestResults} parsing.
- */
-public class TestResultsTest extends junit.framework.TestCase {
-
- private static final String RESULT_START = "<TestResult>";
- private static final String RESULT_END = "</TestResult>";
- private static final String TEST_PACKAGE_START =
- "<TestPackage name=\"pkgName\" appPackageName=\"appPkgName\" digest=\"digValue\" >";
- private static final String TEST_PACKAGE_END = "</TestPackage>";
-
- private static final String TEST_PACKAGE_FULL =
- RESULT_START +TEST_PACKAGE_START + TEST_PACKAGE_END + RESULT_END;
-
- private static final String TEST_FULL =
- RESULT_START + TEST_PACKAGE_START +
- "<TestSuite name=\"com\" >" +
- "<TestSuite name=\"example\" >" +
- "<TestCase name=\"ExampleTest\" >" +
- "<Test name=\"testExample\" endtime=\"et\" starttime=\"st\" result=\"fail\" >" +
- "<FailedScene message=\"msg\" >" +
- "<StackTrace>at ExampleTest.testExample()" +
- "</StackTrace>" +
- "</FailedScene>" +
- "</Test>" +
- "</TestCase>" +
- "</TestSuite>" +
- "</TestSuite>";
-
- /**
- * Test parsing data with no result content
- */
- public void testParse_empty() throws Exception {
- TestResults parser = new TestResults();
- parser.parse(new StringReader("<Empty/>"));
- assertEquals(0, parser.getPackages().size());
- }
-
- /**
- * Test parsing data with a single test package
- */
- public void testParse_package() throws Exception {
- TestResults parser = new TestResults();
- parser.parse(new StringReader(TEST_PACKAGE_FULL));
- assertEquals(1, parser.getPackages().size());
- TestPackageResult pkg = parser.getPackages().iterator().next();
- assertEquals("pkgName", pkg.getName());
- assertEquals("appPkgName", pkg.getAppPackageName());
- assertEquals("digValue", pkg.getDigest());
- }
-
- /**
- * Test parsing not well formed XML data
- */
- public void testParse_corrupt() throws Exception {
- TestResults parser = new TestResults();
- // missing TEST_PACKAGE_END
- try {
- parser.parse(new StringReader(RESULT_START + TEST_PACKAGE_START + RESULT_END));
- fail("ParseException not thrown");
- } catch (ParseException e) {
- // expected
- }
- }
-
- /**
- * Test parsing a result with a single failed test
- */
- public void testParse_test() throws Exception {
- TestResults parser = new TestResults();
- parser.parse(new StringReader(TEST_FULL));
- assertEquals(1, parser.getPackages().size());
- TestPackageResult pkg = parser.getPackages().iterator().next();
- TestSuite comSuite = pkg.getTestSuites().iterator().next();
- assertEquals("com", comSuite.getName());
- TestSuite exampleSuite = comSuite.getTestSuites().iterator().next();
- assertEquals("example", exampleSuite.getName());
- TestCase exampleCase = exampleSuite.getTestCases().iterator().next();
- assertEquals("ExampleTest", exampleCase.getName());
- Test exampleTest = exampleCase.getTests().iterator().next();
- assertEquals("testExample", exampleTest.getName());
- assertEquals("msg", exampleTest.getMessage());
- assertEquals("at ExampleTest.testExample()", exampleTest.getStackTrace());
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestSummaryXmlTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestSummaryXmlTest.java
deleted file mode 100644
index f8b135a..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestSummaryXmlTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.result;
-
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import java.io.Reader;
-import java.io.StringReader;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link TestSummaryXml}.
- */
-public class TestSummaryXmlTest extends TestCase {
-
- static final String TEST_DATA =
- "<TestResult>" +
- "<Summary failed=\"1\" notExecuted=\"2\" pass=\"3\" timeout=\"4\"/>" +
- "</TestResult>";
-
- static final String MISSING_DATA =
- "<TestResult>" +
- "<Foo failed=\"1\" notExecuted=\"2\" pass=\"3\" timeout=\"4\"/>" +
- "</TestResult>";
-
- public void testConstructor() {
- TestSummaryXml result = new TestSummaryXml(1, "2011-11-01");
- assertEquals(1, result.getId());
- assertEquals("2011-11-01", result.getTimestamp());
- }
-
- /**
- * Simple test for parsing summary data
- */
- public void testParse() throws ParseException {
- TestSummaryXml result = new TestSummaryXml(1, "2011-11-01");
- result.parse(getStringAsReader(TEST_DATA));
- // expect failed and timeout to be summed
- assertEquals(5, result.getNumFailed());
- assertEquals(2, result.getNumIncomplete());
- assertEquals(3, result.getNumPassed());
- }
-
- /**
- * Test data where Summary tag is missing
- */
- public void testParse_missing() {
- TestSummaryXml result = new TestSummaryXml(1, "2011-11-01");
- try {
- result.parse(getStringAsReader(MISSING_DATA));
- fail("ParseException not thrown");
- } catch (ParseException e) {
- // expected
- }
- }
-
- private Reader getStringAsReader(String input) {
- return new StringReader(input);
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestTest.java
deleted file mode 100644
index 6494171..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.result;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link Test}.
- * <p/>
- * Lets hope a TestTestTest is not needed...
- */
-public class TestTest extends TestCase {
-
- /**
- * Test {@link Test#getFailureMessageFromStackTrace(String)} for an empty stack
- */
- public void testGetFailureMessageFromStackTrace_empty() {
- final String stack = "";
- assertEquals(stack, Test.getFailureMessageFromStackTrace(stack));
- }
-
- /**
- * Test {@link Test#getFailureMessageFromStackTrace(String)} for a one line stack
- */
- public void testGetFailureMessageFromStackTrace_oneLine() {
- final String stack = "this is a line";
- assertEquals(stack, Test.getFailureMessageFromStackTrace(stack));
- }
-
- /**
- * Test {@link Test#getFailureMessageFromStackTrace(String)} for a one line stack with a newline
- * char
- */
- public void testGetFailureMessageFromStackTrace_oneNewLine() {
- final String stack = "this is a line\n";
- assertEquals(stack, Test.getFailureMessageFromStackTrace(stack));
- }
-
- /**
- * Test {@link Test#getFailureMessageFromStackTrace(String)} for a two line stack
- */
- public void testGetFailureMessageFromStackTrace_twoLines() {
- final String stack = "this is a line\nthis is also a line";
- assertEquals(stack, Test.getFailureMessageFromStackTrace(stack));
- }
-
- /**
- * Test {@link Test#getFailureMessageFromStackTrace(String)} for a multi line stack
- */
- public void testGetFailureMessageFromStackTrace_multiLines() {
- final String stack = "this is a line\nthis is also a line\n oh look another line";
- assertEquals("this is a line\nthis is also a line",
- Test.getFailureMessageFromStackTrace(stack));
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/CtsTestTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/CtsTestTest.java
deleted file mode 100644
index 777eeb5..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/CtsTestTest.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.UnitTests;
-import com.android.cts.tradefed.build.StubCtsBuildHelper;
-import com.android.cts.tradefed.result.PlanCreator;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Unit tests for {@link CtsTest}.
- */
-public class CtsTestTest extends TestCase {
-
- private static final String PLAN_NAME = "CTS";
- private static final String PACKAGE_NAME = "test-name";
- private static final String ID = AbiUtils.createId(UnitTests.ABI.getName(), PACKAGE_NAME);
- private static final TestIdentifier TEST_IDENTIFIER =
- new TestIdentifier("CLASS_NAME", "TEST_NAME");
- private static final List<String> NAMES = new ArrayList<>();
- private static final List<String> IDS = new ArrayList<>();
- private static final List<TestIdentifier> TEST_IDENTIFIER_LIST = new ArrayList<>();
-
- static {
- NAMES.add(PACKAGE_NAME);
- IDS.add(ID);
- TEST_IDENTIFIER_LIST.add(TEST_IDENTIFIER);
- }
-
- /** the test fixture under test, with all external dependencies mocked out */
- private CtsTest mCtsTest;
- private ITestPackageRepo mMockRepo;
- private ITestPlan mMockPlan;
- private ITestDevice mMockDevice;
- private ITestInvocationListener mMockListener;
- private StubCtsBuildHelper mStubBuildHelper;
- private ITestPackageDef mMockPackageDef;
- private Set<ITestPackageDef> mMockPackageDefs;
- private IRemoteTest mMockTest;
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mMockRepo = EasyMock.createMock(ITestPackageRepo.class);
- mMockPlan = EasyMock.createMock(ITestPlan.class);
- mMockDevice = EasyMock.createMock(ITestDevice.class);
- mMockListener = EasyMock.createNiceMock(ITestInvocationListener.class);
- mStubBuildHelper = new StubCtsBuildHelper();
- mMockPackageDefs = new HashSet<>();
- mMockPackageDef = EasyMock.createMock(ITestPackageDef.class);
- mMockPackageDefs.add(mMockPackageDef);
- EasyMock.expect(mMockPackageDef.getTargetApkName()).andStubReturn(null);
- EasyMock.expect(mMockPackageDef.getTargetPackageName()).andStubReturn(null);
- mMockTest = EasyMock.createMock(IRemoteTest.class);
-
- mCtsTest = new CtsTest() {
- @Override
- ITestPackageRepo createTestCaseRepo() {
- return mMockRepo;
- }
-
- @Override
- ITestPlan createPlan(String planName) {
- return mMockPlan;
- }
-
- @Override
- ITestPlan createPlan(PlanCreator planCreator) {
- return mMockPlan;
- }
-
- @Override
- InputStream createXmlStream(File xmlFile) throws FileNotFoundException {
- // return empty stream, not used
- return new ByteArrayInputStream(new byte[0]);
- }
- };
- mCtsTest.setDevice(mMockDevice);
- mCtsTest.setBuildHelper(mStubBuildHelper);
- // turn off device collection for simplicity
- mCtsTest.setSkipDeviceInfo(true);
- // only run tests on one ABI
- EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist"))
- .andReturn(UnitTests.ABI.getName()).anyTimes();
- }
-
- /**
- * Test normal case {@link CtsTest#run(ITestInvocationListener)} when running a plan.
- */
- @SuppressWarnings("unchecked")
- public void testRun_plan() throws DeviceNotAvailableException, ParseException {
- setParsePlanExpectations();
-
- setCreateAndRunTestExpectations();
-
- replayMocks();
- mCtsTest.run(mMockListener);
- verifyMocks();
- }
-
- /**
- * Test normal case {@link CtsTest#run(ITestInvocationListener)} when running a package.
- */
- @SuppressWarnings("unchecked")
- public void testRun_package() throws DeviceNotAvailableException {
- mCtsTest.addPackageName(PACKAGE_NAME);
- Map<String, List<ITestPackageDef>> nameMap = new HashMap<>();
- List<ITestPackageDef> testPackageDefList = new ArrayList<>();
- testPackageDefList.add(mMockPackageDef);
- nameMap.put(PACKAGE_NAME, testPackageDefList);
-
- EasyMock.expect(mMockRepo.getTestPackageDefsByName()).andReturn(nameMap);
-
- setCreateAndRunTestExpectations();
-
- replayMocks();
- mCtsTest.run(mMockListener);
- verifyMocks();
- }
-
- /**
- * Test a resumed run
- */
- @SuppressWarnings("unchecked")
- public void testRun_resume() throws DeviceNotAvailableException {
- mCtsTest.addPackageName(PACKAGE_NAME);
- Map<String, List<ITestPackageDef>> nameMap = new HashMap<>();
- List<ITestPackageDef> testPackageDefList = new ArrayList<>();
- testPackageDefList.add(mMockPackageDef);
- nameMap.put(PACKAGE_NAME, testPackageDefList);
-
- EasyMock.expect(mMockRepo.getTestPackageDefsByName()).andReturn(nameMap);
- setCreateAndRunTestExpectations();
- // abort the first run
- EasyMock.expectLastCall().andThrow(new DeviceNotAvailableException());
-
- // now expect test to be resumed
- mMockTest.run((ITestInvocationListener)EasyMock.anyObject());
-
- replayMocks();
- try {
- mCtsTest.run(mMockListener);
- fail("Did not throw DeviceNotAvailableException");
- } catch (DeviceNotAvailableException e) {
- // expected
- }
- // now resume, and expect same test's run method to be called again
- mCtsTest.run(mMockListener);
- verifyMocks();
- }
-
- /**
- * Test normal case {@link CtsTest#run(ITestInvocationListener)} when running a class.
- */
- @SuppressWarnings("unchecked")
- public void testRun_class() throws DeviceNotAvailableException {
- final String className = "className";
- final String methodName = "methodName";
- mCtsTest.setClassName(className);
- mCtsTest.setMethodName(methodName);
-
- EasyMock.expect(mMockRepo.findPackageIdsForTest(className)).andReturn(IDS);
- mMockPackageDef.setClassName(className, methodName);
-
- setCreateAndRunTestExpectations();
-
- replayMocks();
- mCtsTest.run(mMockListener);
- verifyMocks();
- }
-
- /**
- * Test normal case {@link CtsTest#run(ITestInvocationListener)} when running a class.
- */
- @SuppressWarnings("unchecked")
- public void testRun_test() throws DeviceNotAvailableException {
- final String className = "className";
- final String methodName = "methodName";
- final String testName = String.format("%s#%s", className, methodName);
- mCtsTest.setTestName(testName);
-
- EasyMock.expect(mMockRepo.findPackageIdsForTest(className)).andReturn(IDS);
- mMockPackageDef.setClassName(className, methodName);
-
- setCreateAndRunTestExpectations();
-
- replayMocks();
- mCtsTest.run(mMockListener);
- verifyMocks();
- }
-
- /**
- * Test {@link CtsTest#run(ITestInvocationListener)} when --excluded-package is specified
- */
- public void testRun_excludedPackage() throws DeviceNotAvailableException, ParseException {
- mCtsTest.setPlanName(PLAN_NAME);
- mMockPlan.parse((InputStream) EasyMock.anyObject());
- EasyMock.expect(mMockPlan.getTestIds()).andReturn(IDS);
-
- mCtsTest.addExcludedPackageName(PACKAGE_NAME);
-
- // PACKAGE_NAME would normally be run, but it has been excluded. Expect nothing to happen
- replayMocks();
- mCtsTest.run(mMockListener);
- verifyMocks();
- }
-
- /**
- * Test {@link CtsTest#run(ITestInvocationListener)} when --continue-session is specified
- */
- public void testRun_continueSession() throws DeviceNotAvailableException {
- mCtsTest.setContinueSessionId(1);
- EasyMock.expect(mMockPlan.getTestIds()).andReturn(IDS);
- TestFilter filter = new TestFilter();
- EasyMock.expect(mMockPlan.getTestFilter(ID)).andReturn(filter);
-
- mMockPackageDef.setTestFilter(filter);
-
- setCreateAndRunTestExpectations();
-
- replayMocks();
- mCtsTest.run(mMockListener);
- verifyMocks();
- }
-
- /**
- * Set EasyMock expectations for parsing {@link #PLAN_NAME}
- */
- private void setParsePlanExpectations() throws ParseException {
- mCtsTest.setPlanName(PLAN_NAME);
- mMockPlan.parse((InputStream) EasyMock.anyObject());
- EasyMock.expect(mMockPlan.getTestIds()).andReturn(IDS);
- TestFilter filter = new TestFilter();
- EasyMock.expect(mMockPlan.getTestFilter(ID)).andReturn(filter);
- mMockPackageDef.setTestFilter(filter);
- }
-
- /**
- * Set EasyMock expectations for creating and running a package with PACKAGE_NAME
- */
- private void setCreateAndRunTestExpectations() throws DeviceNotAvailableException {
- EasyMock.expect(mMockRepo.getPackageNames()).andReturn(NAMES).anyTimes();
- EasyMock.expect(mMockRepo.getPackageIds()).andReturn(IDS).anyTimes();
- EasyMock.expect(mMockRepo.getTestPackage(ID)).andReturn(mMockPackageDef).anyTimes();
- EasyMock.expect(mMockPackageDef.createTest((File) EasyMock.anyObject())).andReturn(mMockTest);
- EasyMock.expect(mMockPackageDef.getTests()).andReturn(TEST_IDENTIFIER_LIST).times(2);
- EasyMock.expect(mMockPackageDef.getName()).andReturn(PACKAGE_NAME).atLeastOnce();
- EasyMock.expect(mMockPackageDef.getAbi()).andReturn(UnitTests.ABI).atLeastOnce();
- EasyMock.expect(mMockPackageDef.getId()).andReturn(ID).atLeastOnce();
- EasyMock.expect(mMockPackageDef.getDigest()).andReturn("digest").atLeastOnce();
- EasyMock.expect(mMockPackageDef.getPackagePreparers()).andReturn(
- new ArrayList<ITargetPreparer>()).atLeastOnce();
- mMockTest.run((ITestInvocationListener) EasyMock.anyObject());
- }
-
- /**
- * Test {@link CtsTest#run(ITestInvocationListener)} when --plan and --package options have not
- * been specified
- */
- public void testRun_nothingToRun() throws DeviceNotAvailableException {
- replayMocks();
- try {
- mCtsTest.run(mMockListener);
- fail("IllegalArgumentException not thrown");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- /**
- * Test {@link CtsTest#run(ITestInvocationListener)} when --plan and --package options have
- * been specified.
- */
- public void testRun_packagePlan() throws DeviceNotAvailableException {
- mCtsTest.setPlanName(PLAN_NAME);
- mCtsTest.addPackageName(PACKAGE_NAME);
- replayMocks();
- try {
- mCtsTest.run(mMockListener);
- fail("IllegalArgumentException not thrown");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- /**
- * Test {@link CtsTest#run(ITestInvocationListener)} when --plan and --class options have been
- * specified
- */
- public void testRun_planClass() throws DeviceNotAvailableException {
- mCtsTest.setPlanName(PLAN_NAME);
- mCtsTest.setClassName("class");
- replayMocks();
- try {
- mCtsTest.run(mMockListener);
- fail("IllegalArgumentException not thrown");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- /**
- * Test {@link CtsTest#run(ITestInvocationListener)} when --package and --class options have
- * been specified
- */
- public void testRun_packageClass() throws DeviceNotAvailableException {
- mCtsTest.addPackageName(PACKAGE_NAME);
- mCtsTest.setClassName("class");
- replayMocks();
- try {
- mCtsTest.run(mMockListener);
- fail("IllegalArgumentException not thrown");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- /**
- * Test {@link CtsTest#run(ITestInvocationListener)} when --plan, --package and --class options
- * have been specified
- */
- public void testRun_planPackageClass() throws DeviceNotAvailableException {
- mCtsTest.setPlanName(PLAN_NAME);
- mCtsTest.addPackageName(PACKAGE_NAME);
- mCtsTest.setClassName("class");
- replayMocks();
- try {
- mCtsTest.run(mMockListener);
- fail("IllegalArgumentException not thrown");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- /**
- * Test {@link CtsTest#run(ITestInvocationListener)} when --plan, --continue-option options
- * have been specified
- */
- public void testRun_planContinue() throws DeviceNotAvailableException {
- mCtsTest.setPlanName(PLAN_NAME);
- mCtsTest.setContinueSessionId(1);
- replayMocks();
- try {
- mCtsTest.run(mMockListener);
- fail("IllegalArgumentException not thrown");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- /**
- * Test {@link CtsTestTest#join} works.
- * @throws DeviceNotAvailableException
- */
- public void testJoin() throws DeviceNotAvailableException {
- String expected = "a@b@c";
- String actual = mCtsTest.join(new ArrayList<String>(Arrays.asList("a", "b", "c")), "@");
- assertEquals(expected, actual);
- }
-
- /**
- * Test {@link CtsTestTest#join} for a single element list.
- * @throws DeviceNotAvailableException
- */
- public void testSingleJoin() throws DeviceNotAvailableException {
- String actual = mCtsTest.join(new ArrayList<String>(Arrays.asList("foo")), "@");
- assertEquals("foo", actual);
- }
-
- /**
- * Test {@link CtsTestTest#join} for an empty list.
- * @throws DeviceNotAvailableException
- */
- public void testEmptyJoin() throws DeviceNotAvailableException {
- String actual = mCtsTest.join(new ArrayList<String>(), "@");
- assertEquals("", actual);
- }
-
- private void replayMocks(Object... mocks) {
- EasyMock.replay(mMockRepo, mMockPlan, mMockDevice, mMockPackageDef, mMockListener, mMockTest);
- EasyMock.replay(mocks);
- }
-
- private void verifyMocks(Object... mocks) {
- EasyMock.verify(mMockRepo, mMockPlan, mMockDevice, mMockPackageDef, mMockListener, mMockTest);
- EasyMock.verify(mocks);
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java
deleted file mode 100644
index b38cc56..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java
+++ /dev/null
@@ -1,3076 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.UnitTests;
-import com.android.cts.tradefed.build.StubCtsBuildHelper;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.IRunUtil;
-import com.android.tradefed.util.RunInterruptedException;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.easymock.IMocksControl;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Unit tests for {@link DeqpTestRunner}.
- */
-public class DeqpTestRunnerTest extends TestCase {
- private static final String NAME = "dEQP-GLES3";
- private static final String ID = AbiUtils.createId(UnitTests.ABI.getName(), NAME);
- private static final String CASE_LIST_FILE_NAME = "/sdcard/dEQP-TestCaseList.txt";
- private static final String LOG_FILE_NAME = "/sdcard/TestLog.qpa";
- private static final String INSTRUMENTATION_NAME =
- "com.drawelements.deqp/com.drawelements.deqp.testercore.DeqpInstrumentation";
- private static final String QUERY_INSTRUMENTATION_NAME =
- "com.drawelements.deqp/com.drawelements.deqp.platformutil.DeqpPlatformCapabilityQueryInstrumentation";
- private static final String DEQP_ONDEVICE_APK = "com.drawelements.deqp.apk";
- private static final String DEQP_ONDEVICE_PKG = "com.drawelements.deqp";
- private static final String ONLY_LANDSCAPE_FEATURES =
- "feature:"+DeqpTestRunner.FEATURE_LANDSCAPE;
- private static final String ALL_FEATURES =
- ONLY_LANDSCAPE_FEATURES + "\nfeature:"+DeqpTestRunner.FEATURE_PORTRAIT;
- private static List<Map<String,String>> DEFAULT_INSTANCE_ARGS;
-
- static {
- DEFAULT_INSTANCE_ARGS = new ArrayList<>(1);
- DEFAULT_INSTANCE_ARGS.add(new HashMap<String,String>());
- DEFAULT_INSTANCE_ARGS.iterator().next().put("glconfig", "rgba8888d24s8");
- DEFAULT_INSTANCE_ARGS.iterator().next().put("rotation", "unspecified");
- DEFAULT_INSTANCE_ARGS.iterator().next().put("surfacetype", "window");
- }
-
- private static class StubRecovery implements DeqpTestRunner.IRecovery {
- /**
- * {@inheritDoc}
- */
- @Override
- public void setSleepProvider(DeqpTestRunner.ISleepProvider sleepProvider) {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setDevice(ITestDevice device) {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onExecutionProgressed() {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void recoverConnectionRefused() throws DeviceNotAvailableException {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void recoverComLinkKilled() throws DeviceNotAvailableException {
- }
- };
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Test version of OpenGL ES.
- */
- private void testGlesVersion(int requiredMajorVersion, int requiredMinorVersion, int majorVersion, int minorVersion) throws Exception {
- final TestIdentifier testId = new TestIdentifier("dEQP-GLES"
- + Integer.toString(requiredMajorVersion) + Integer.toString(requiredMinorVersion)
- + ".info", "version");
-
- final String testPath = "dEQP-GLES"
- + Integer.toString(requiredMajorVersion) + Integer.toString(requiredMinorVersion)
- +".info.version";
-
- final String testTrie = "{dEQP-GLES"
- + Integer.toString(requiredMajorVersion) + Integer.toString(requiredMinorVersion)
- + "{info{version}}}";
-
- final String resultCode = "Pass";
-
- /* MultiLineReceiver expects "\r\n" line ending. */
- final String output = "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=" + testPath + "\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=" + resultCode + "\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Detail" + resultCode + "\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
-
- ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- IDevice mockIDevice = EasyMock.createMock(IDevice.class);
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- tests.add(testId);
-
- Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
- instance.put(testId, DEFAULT_INSTANCE_ARGS);
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME,
- "dEQP-GLES" + Integer.toString(requiredMajorVersion)
- + (requiredMinorVersion > 0 ? Integer.toString(requiredMinorVersion) : ""),
- tests, instance);
- deqpTest.setAbi(UnitTests.ABI);
-
- int version = (majorVersion << 16) | minorVersion;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- if (majorVersion > requiredMajorVersion
- || (majorVersion == requiredMajorVersion && minorVersion >= requiredMinorVersion)) {
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
- .andReturn("").once();
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName()))))
- .andReturn(null).once();
-
- expectRenderConfigQuery(mockDevice, requiredMajorVersion,
- requiredMinorVersion);
-
- String commandLine = String.format(
- "--deqp-caselist-file=%s --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable",
- CASE_LIST_FILE_NAME);
-
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice, testTrie, commandLine,
- output);
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
- .andReturn("").once();
- }
-
- mockListener.testRunStarted(ID, 1);
- EasyMock.expectLastCall().once();
-
- mockListener.testStarted(EasyMock.eq(testId));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testId), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- EasyMock.replay(mockDevice, mockIDevice);
- EasyMock.replay(mockListener);
-
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
- deqpTest.run(mockListener);
-
- EasyMock.verify(mockListener);
- EasyMock.verify(mockDevice, mockIDevice);
- }
-
- private void expectRenderConfigQuery(ITestDevice mockDevice, int majorVersion,
- int minorVersion) throws Exception {
- expectRenderConfigQuery(mockDevice,
- String.format("--deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=%d "
- + "--deqp-gl-minor-version=%d", majorVersion, minorVersion));
- }
-
- private void expectRenderConfigQuery(ITestDevice mockDevice, String commandLine)
- throws Exception {
- expectRenderConfigQueryAndReturn(mockDevice, commandLine, "Yes");
- }
-
- private void expectRenderConfigQueryAndReturn(ITestDevice mockDevice, String commandLine,
- String output) throws Exception {
- final String queryOutput = "INSTRUMENTATION_RESULT: Supported=" + output + "\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
- final String command = String.format(
- "am instrument %s -w -e deqpQueryType renderConfigSupported -e deqpCmdLine "
- + "\"%s\" %s",
- AbiUtils.createAbiFlag(UnitTests.ABI.getName()), commandLine,
- QUERY_INSTRUMENTATION_NAME);
-
- mockDevice.executeShellCommand(EasyMock.eq(command),
- EasyMock.<IShellOutputReceiver>notNull());
-
- EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
- @Override
- public Object answer() {
- IShellOutputReceiver receiver
- = (IShellOutputReceiver)EasyMock.getCurrentArguments()[1];
-
- receiver.addOutput(queryOutput.getBytes(), 0, queryOutput.length());
- receiver.flush();
-
- return null;
- }
- });
- }
-
- /**
- * Test that result code produces correctly pass or fail.
- */
- private void testResultCode(final String resultCode, boolean pass) throws Exception {
- final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.info", "version");
- final String testPath = "dEQP-GLES3.info.version";
- final String testTrie = "{dEQP-GLES3{info{version}}}";
-
- /* MultiLineReceiver expects "\r\n" line ending. */
- final String output = "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=" + testPath + "\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=" + resultCode + "\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Detail" + resultCode + "\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
-
- ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- IDevice mockIDevice = EasyMock.createMock(IDevice.class);
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- tests.add(testId);
-
- Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
- instance.put(testId, DEFAULT_INSTANCE_ARGS);
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
- deqpTest.setAbi(UnitTests.ABI);
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
- .once();
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true), EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName()))))
- .andReturn(null).once();
-
- expectRenderConfigQuery(mockDevice, 3, 0);
-
- String commandLine = String.format(
- "--deqp-caselist-file=%s --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable",
- CASE_LIST_FILE_NAME);
-
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice, testTrie, commandLine, output);
-
- mockListener.testRunStarted(ID, 1);
- EasyMock.expectLastCall().once();
-
- mockListener.testStarted(EasyMock.eq(testId));
- EasyMock.expectLastCall().once();
-
- if (!pass) {
- mockListener.testFailed(testId,
- "=== with config {glformat=rgba8888d24s8,rotation=unspecified,surfacetype=window} ===\n"
- + resultCode + ": Detail" + resultCode);
-
- EasyMock.expectLastCall().once();
- }
-
- mockListener.testEnded(EasyMock.eq(testId), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
- .once();
-
- EasyMock.replay(mockDevice, mockIDevice);
- EasyMock.replay(mockListener);
-
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
- deqpTest.run(mockListener);
-
- EasyMock.verify(mockListener);
- EasyMock.verify(mockDevice, mockIDevice);
- }
-
- /**
- * Test running multiple test cases.
- */
- public void testRun_multipleTests() throws Exception {
- /* MultiLineReceiver expects "\r\n" line ending. */
- final String output = "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.info.vendor\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.info.renderer\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.info.version\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.info.shading_language_version\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.info.extensions\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.info.render_target\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
-
- final TestIdentifier[] testIds = {
- new TestIdentifier("dEQP-GLES3.info", "vendor"),
- new TestIdentifier("dEQP-GLES3.info", "renderer"),
- new TestIdentifier("dEQP-GLES3.info", "version"),
- new TestIdentifier("dEQP-GLES3.info", "shading_language_version"),
- new TestIdentifier("dEQP-GLES3.info", "extensions"),
- new TestIdentifier("dEQP-GLES3.info", "render_target")
- };
-
- final String[] testPaths = {
- "dEQP-GLES3.info.vendor",
- "dEQP-GLES3.info.renderer",
- "dEQP-GLES3.info.version",
- "dEQP-GLES3.info.shading_language_version",
- "dEQP-GLES3.info.extensions",
- "dEQP-GLES3.info.render_target"
- };
-
- final String testTrie
- = "{dEQP-GLES3{info{vendor,renderer,version,shading_language_version,extensions,render_target}}}";
-
- ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- IDevice mockIDevice = EasyMock.createMock(IDevice.class);
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
- for (TestIdentifier id : testIds) {
- tests.add(id);
- instances.put(id, DEFAULT_INSTANCE_ARGS);
- }
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
- deqpTest.setAbi(UnitTests.ABI);
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
- .once();
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true), EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName()))))
- .andReturn(null).once();
-
- expectRenderConfigQuery(mockDevice, 3, 0);
-
- String commandLine = String.format(
- "--deqp-caselist-file=%s --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable",
- CASE_LIST_FILE_NAME);
-
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice, testTrie, commandLine, output);
-
- mockListener.testRunStarted(ID, testPaths.length);
- EasyMock.expectLastCall().once();
-
- for (int i = 0; i < testPaths.length; i++) {
- mockListener.testStarted(EasyMock.eq(testIds[i]));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testIds[i]),
- EasyMock.<Map<String, String>>notNull());
-
- EasyMock.expectLastCall().once();
- }
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
- .once();
-
- EasyMock.replay(mockDevice, mockIDevice);
- EasyMock.replay(mockListener);
-
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
- deqpTest.run(mockListener);
-
- EasyMock.verify(mockListener);
- EasyMock.verify(mockDevice, mockIDevice);
- }
-
- /**
- * Test running a unexecutable test.
- */
- public void testRun_unexecutableTests() throws Exception {
- final String instrumentationAnswerNoExecs =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
-
- final TestIdentifier[] testIds = {
- new TestIdentifier("dEQP-GLES3.missing", "no"),
- new TestIdentifier("dEQP-GLES3.missing", "nope"),
- new TestIdentifier("dEQP-GLES3.missing", "donotwant"),
- };
-
- final String[] testPaths = {
- "dEQP-GLES3.missing.no",
- "dEQP-GLES3.missing.nope",
- "dEQP-GLES3.missing.donotwant",
- };
-
- ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- IDevice mockIDevice = EasyMock.createMock(IDevice.class);
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
- for (TestIdentifier id : testIds) {
- tests.add(id);
- instances.put(id, DEFAULT_INSTANCE_ARGS);
- }
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
- deqpTest.setAbi(UnitTests.ABI);
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
- .once();
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true), EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName()))))
- .andReturn(null).once();
-
- expectRenderConfigQuery(mockDevice, 3, 0);
-
- String commandLine = String.format(
- "--deqp-caselist-file=%s --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable",
- CASE_LIST_FILE_NAME);
-
- // first try
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{missing{no,nope,donotwant}}}", commandLine, instrumentationAnswerNoExecs);
-
- // splitting begins
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{missing{no}}}", commandLine, instrumentationAnswerNoExecs);
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{missing{nope,donotwant}}}", commandLine, instrumentationAnswerNoExecs);
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{missing{nope}}}", commandLine, instrumentationAnswerNoExecs);
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{missing{donotwant}}}", commandLine, instrumentationAnswerNoExecs);
-
- mockListener.testRunStarted(ID, testPaths.length);
- EasyMock.expectLastCall().once();
-
- for (int i = 0; i < testPaths.length; i++) {
- mockListener.testStarted(EasyMock.eq(testIds[i]));
- EasyMock.expectLastCall().once();
-
- mockListener.testFailed(EasyMock.eq(testIds[i]),
- EasyMock.eq("=== with config {glformat=rgba8888d24s8,rotation=unspecified,surfacetype=window} ===\n"
- + "Abort: Test cannot be executed"));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testIds[i]),
- EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
- }
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
- .once();
-
- EasyMock.replay(mockDevice, mockIDevice);
- EasyMock.replay(mockListener);
-
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
- deqpTest.run(mockListener);
-
- EasyMock.verify(mockListener);
- EasyMock.verify(mockDevice, mockIDevice);
- }
-
- /**
- * Test that test are left unexecuted if pm list query fails
- */
- public void testRun_queryPmListFailure()
- throws Exception {
- final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.orientation", "test");
-
- ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- tests.add(testId);
-
- Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
- instance.put(testId, new ArrayList<Map<String,String>>(1));
- instance.get(testId).add(new HashMap<String,String>());
- instance.get(testId).iterator().next().put("glconfig", "rgba8888d24s8");
- instance.get(testId).iterator().next().put("rotation", "90");
- instance.get(testId).iterator().next().put("surfacetype", "window");
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
- deqpTest.setAbi(UnitTests.ABI);
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- EasyMock.expect(mockDevice.executeShellCommand("pm list features"))
- .andReturn("not a valid format");
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").once();
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
- .once();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
- .andReturn("").once();
-
- mockListener.testRunStarted(ID, 1);
- EasyMock.expectLastCall().once();
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- EasyMock.replay(mockDevice);
- EasyMock.replay(mockListener);
- deqpTest.run(mockListener);
- EasyMock.verify(mockListener);
- EasyMock.verify(mockDevice);
- }
-
- /**
- * Test that test are left unexecuted if renderablity query fails
- */
- public void testRun_queryRenderabilityFailure()
- throws Exception {
- final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.orientation", "test");
-
- ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- tests.add(testId);
-
- Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
- instance.put(testId, new ArrayList<Map<String,String>>(1));
- instance.get(testId).add(new HashMap<String,String>());
- instance.get(testId).iterator().next().put("glconfig", "rgba8888d24s8");
- instance.get(testId).iterator().next().put("rotation", "unspecified");
- instance.get(testId).iterator().next().put("surfacetype", "window");
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
- deqpTest.setAbi(UnitTests.ABI);
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").once();
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
- .once();
-
- expectRenderConfigQueryAndReturn(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", "Maybe?");
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
- .andReturn("").once();
-
- mockListener.testRunStarted(ID, 1);
- EasyMock.expectLastCall().once();
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- EasyMock.replay(mockDevice);
- EasyMock.replay(mockListener);
- deqpTest.run(mockListener);
- EasyMock.verify(mockListener);
- EasyMock.verify(mockDevice);
- }
-
- /**
- * Test that orientation is supplied to runner correctly
- */
- private void testOrientation(final String rotation, final String featureString)
- throws Exception {
- final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.orientation", "test");
- final String testPath = "dEQP-GLES3.orientation.test";
- final String testTrie = "{dEQP-GLES3{orientation{test}}}";
- final String output = "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=" + testPath + "\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
-
- ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- IDevice mockIDevice = EasyMock.createMock(IDevice.class);
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- tests.add(testId);
-
- Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
- instance.put(testId, new ArrayList<Map<String,String>>(1));
- instance.get(testId).add(new HashMap<String,String>());
- instance.get(testId).iterator().next().put("glconfig", "rgba8888d24s8");
- instance.get(testId).iterator().next().put("rotation", rotation);
- instance.get(testId).iterator().next().put("surfacetype", "window");
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
- deqpTest.setAbi(UnitTests.ABI);
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- if (!rotation.equals(DeqpTestRunner.BatchRunConfiguration.ROTATION_UNSPECIFIED)) {
- EasyMock.expect(mockDevice.executeShellCommand("pm list features"))
- .andReturn(featureString);
- }
-
- final boolean isPortraitOrientation =
- rotation.equals(DeqpTestRunner.BatchRunConfiguration.ROTATION_PORTRAIT) ||
- rotation.equals(DeqpTestRunner.BatchRunConfiguration.ROTATION_REVERSE_PORTRAIT);
- final boolean isLandscapeOrientation =
- rotation.equals(DeqpTestRunner.BatchRunConfiguration.ROTATION_LANDSCAPE) ||
- rotation.equals(DeqpTestRunner.BatchRunConfiguration.ROTATION_REVERSE_LANDSCAPE);
- final boolean executable =
- rotation.equals(DeqpTestRunner.BatchRunConfiguration.ROTATION_UNSPECIFIED) ||
- (isPortraitOrientation &&
- featureString.contains(DeqpTestRunner.FEATURE_PORTRAIT)) ||
- (isLandscapeOrientation &&
- featureString.contains(DeqpTestRunner.FEATURE_LANDSCAPE));
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").once();
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
- .once();
-
- if (executable) {
- expectRenderConfigQuery(mockDevice, String.format(
- "--deqp-gl-config-name=rgba8888d24s8 --deqp-screen-rotation=%s "
- + "--deqp-surface-type=window --deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", rotation));
-
- String commandLine = String.format(
- "--deqp-caselist-file=%s --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=%s "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable",
- CASE_LIST_FILE_NAME, rotation);
-
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice, testTrie, commandLine,
- output);
- }
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
- .andReturn("").once();
-
- mockListener.testRunStarted(ID, 1);
- EasyMock.expectLastCall().once();
-
- mockListener.testStarted(EasyMock.eq(testId));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testId), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- EasyMock.replay(mockDevice, mockIDevice);
- EasyMock.replay(mockListener);
- deqpTest.run(mockListener);
- EasyMock.verify(mockListener);
- EasyMock.verify(mockDevice, mockIDevice);
- }
-
- /**
- * Test OpeGL ES3 tests on device with OpenGL ES2.
- */
- public void testRun_require30DeviceVersion20() throws Exception {
- testGlesVersion(3, 0, 2, 0);
- }
-
- /**
- * Test OpeGL ES3.1 tests on device with OpenGL ES2.
- */
- public void testRun_require31DeviceVersion20() throws Exception {
- testGlesVersion(3, 1, 2, 0);
- }
-
- /**
- * Test OpeGL ES3 tests on device with OpenGL ES3.
- */
- public void testRun_require30DeviceVersion30() throws Exception {
- testGlesVersion(3, 0, 3, 0);
- }
-
- /**
- * Test OpeGL ES3.1 tests on device with OpenGL ES3.
- */
- public void testRun_require31DeviceVersion30() throws Exception {
- testGlesVersion(3, 1, 3, 0);
- }
-
- /**
- * Test OpeGL ES3 tests on device with OpenGL ES3.1.
- */
- public void testRun_require30DeviceVersion31() throws Exception {
- testGlesVersion(3, 0, 3, 1);
- }
-
- /**
- * Test OpeGL ES3.1 tests on device with OpenGL ES3.1.
- */
- public void testRun_require31DeviceVersion31() throws Exception {
- testGlesVersion(3, 1, 3, 1);
- }
-
- /**
- * Test dEQP Pass result code.
- */
- public void testRun_resultPass() throws Exception {
- testResultCode("Pass", true);
- }
-
- /**
- * Test dEQP Fail result code.
- */
- public void testRun_resultFail() throws Exception {
- testResultCode("Fail", false);
- }
-
- /**
- * Test dEQP NotSupported result code.
- */
- public void testRun_resultNotSupported() throws Exception {
- testResultCode("NotSupported", true);
- }
-
- /**
- * Test dEQP QualityWarning result code.
- */
- public void testRun_resultQualityWarning() throws Exception {
- testResultCode("QualityWarning", true);
- }
-
- /**
- * Test dEQP CompatibilityWarning result code.
- */
- public void testRun_resultCompatibilityWarning() throws Exception {
- testResultCode("CompatibilityWarning", true);
- }
-
- /**
- * Test dEQP ResourceError result code.
- */
- public void testRun_resultResourceError() throws Exception {
- testResultCode("ResourceError", false);
- }
-
- /**
- * Test dEQP InternalError result code.
- */
- public void testRun_resultInternalError() throws Exception {
- testResultCode("InternalError", false);
- }
-
- /**
- * Test dEQP Crash result code.
- */
- public void testRun_resultCrash() throws Exception {
- testResultCode("Crash", false);
- }
-
- /**
- * Test dEQP Timeout result code.
- */
- public void testRun_resultTimeout() throws Exception {
- testResultCode("Timeout", false);
- }
- /**
- * Test dEQP Orientation
- */
- public void testRun_orientationLandscape() throws Exception {
- testOrientation("90", ALL_FEATURES);
- }
-
- /**
- * Test dEQP Orientation
- */
- public void testRun_orientationPortrait() throws Exception {
- testOrientation("0", ALL_FEATURES);
- }
-
- /**
- * Test dEQP Orientation
- */
- public void testRun_orientationReverseLandscape() throws Exception {
- testOrientation("270", ALL_FEATURES);
- }
-
- /**
- * Test dEQP Orientation
- */
- public void testRun_orientationReversePortrait() throws Exception {
- testOrientation("180", ALL_FEATURES);
- }
-
- /**
- * Test dEQP Orientation
- */
- public void testRun_orientationUnspecified() throws Exception {
- testOrientation("unspecified", ALL_FEATURES);
- }
-
- /**
- * Test dEQP Orientation with limited features
- */
- public void testRun_orientationUnspecifiedLimitedFeatures() throws Exception {
- testOrientation("unspecified", ONLY_LANDSCAPE_FEATURES);
- }
-
- /**
- * Test dEQP Orientation with limited features
- */
- public void testRun_orientationLandscapeLimitedFeatures() throws Exception {
- testOrientation("90", ONLY_LANDSCAPE_FEATURES);
- }
-
- /**
- * Test dEQP Orientation with limited features
- */
- public void testRun_orientationPortraitLimitedFeatures() throws Exception {
- testOrientation("0", ONLY_LANDSCAPE_FEATURES);
- }
-
- /**
- * Test dEQP unsupported pixel format
- */
- public void testRun_unsupportedPixelFormat() throws Exception {
- final String pixelFormat = "rgba5658d16m4";
- final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.pixelformat", "test");
- final String testPath = "dEQP-GLES3.pixelformat.test";
- final String testTrie = "{dEQP-GLES3{pixelformat{test}}}";
- final String output = "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=" + testPath + "\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
-
- ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- tests.add(testId);
-
- Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
- instance.put(testId, new ArrayList<Map<String,String>>(1));
- instance.get(testId).add(new HashMap<String,String>());
- instance.get(testId).iterator().next().put("glconfig", pixelFormat);
- instance.get(testId).iterator().next().put("rotation", "unspecified");
- instance.get(testId).iterator().next().put("surfacetype", "window");
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
- deqpTest.setAbi(UnitTests.ABI);
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").once();
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
- .once();
-
- expectRenderConfigQueryAndReturn(mockDevice, String.format(
- "--deqp-gl-config-name=%s --deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", pixelFormat), "No");
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
- .andReturn("").once();
-
- mockListener.testRunStarted(ID, 1);
- EasyMock.expectLastCall().once();
-
- mockListener.testStarted(EasyMock.eq(testId));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testId), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- EasyMock.replay(mockDevice);
- EasyMock.replay(mockListener);
- deqpTest.run(mockListener);
- EasyMock.verify(mockListener);
- EasyMock.verify(mockDevice);
- }
-
- public void testRun_sessionInfoValueMissing() throws Exception {
- final String instrumentationAnswerOk =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
-
- final String instrumentationAnswerBroken =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n";
-
- final TestIdentifier[] testIds = {
- new TestIdentifier("dEQP-GLES3.instances", "test1"),
- };
-
- final String[] testPaths = {
- "dEQP-GLES3.instances.test1",
- };
-
- Map<String,String> config = new HashMap<>();
- config.put("glconfig", "rgba8888d24s8");
- config.put("rotation", "unspecified");
- config.put("surfacetype", "window");
-
- Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
- instances.put(testIds[0], new ArrayList<Map<String,String>>());
- instances.get(testIds[0]).add(config);
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- for (TestIdentifier id : testIds) {
- tests.add(id);
- }
-
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- IMocksControl orderedControl = EasyMock.createStrictControl();
- ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
- IDevice mockIDevice = orderedControl.createMock(IDevice.class);
-
- DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
- deqpTest.setAbi(UnitTests.ABI);
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
- deqpTest.setRecovery(mockRecovery);
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- mockRecovery.onExecutionProgressed();
- EasyMock.expectLastCall().atLeastOnce();
-
- mockRecovery.setDevice(mockDevice);
- EasyMock.expectLastCall().atLeastOnce();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").once();
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
- .once();
-
- // query config
- expectRenderConfigQueryAndReturn(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", "Yes");
-
- // run config and fail
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{test1}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerBroken);
-
- mockRecovery.recoverComLinkKilled();
- EasyMock.expectLastCall().once();
-
- // Re-try
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{test1}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerOk);
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
- .andReturn("").once();
-
- mockListener.testRunStarted(ID, 1);
- EasyMock.expectLastCall().once();
-
- // test1
- mockListener.testStarted(EasyMock.eq(testIds[0]));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- orderedControl.replay();
- EasyMock.replay(mockListener);
- EasyMock.replay(mockRecovery);
- deqpTest.run(mockListener);
-
- EasyMock.verify(mockListener);
- orderedControl.verify();
- EasyMock.verify(mockRecovery);
- }
-
- public void testRun_resultEventTypeMissing() throws Exception {
- final String instrumentationAnswerOk =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
-
- final String instrumentationAnswerBroken =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n";
-
- final TestIdentifier[] testIds = {
- new TestIdentifier("dEQP-GLES3.instances", "test1"),
- };
-
- final String[] testPaths = {
- "dEQP-GLES3.instances.test1",
- };
-
- Map<String,String> config = new HashMap<>();
- config.put("glconfig", "rgba8888d24s8");
- config.put("rotation", "unspecified");
- config.put("surfacetype", "window");
-
- Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
- instances.put(testIds[0], new ArrayList<Map<String,String>>());
- instances.get(testIds[0]).add(config);
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- for (TestIdentifier id : testIds) {
- tests.add(id);
- }
-
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- IMocksControl orderedControl = EasyMock.createStrictControl();
- ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
- IDevice mockIDevice = orderedControl.createMock(IDevice.class);
-
- DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
- deqpTest.setAbi(UnitTests.ABI);
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
- deqpTest.setRecovery(mockRecovery);
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- mockRecovery.onExecutionProgressed();
- EasyMock.expectLastCall().atLeastOnce();
-
- mockRecovery.setDevice(mockDevice);
- EasyMock.expectLastCall().atLeastOnce();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").once();
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
- .once();
-
- // query config
- expectRenderConfigQueryAndReturn(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", "Yes");
-
- // run config and fail
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{test1}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerBroken);
-
- mockRecovery.recoverComLinkKilled();
- EasyMock.expectLastCall().once();
-
- // Re-try
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{test1}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerOk);
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
- .andReturn("").once();
-
- mockListener.testRunStarted(ID, 1);
- EasyMock.expectLastCall().once();
-
- // test1
- mockListener.testStarted(EasyMock.eq(testIds[0]));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- orderedControl.replay();
- EasyMock.replay(mockListener);
- EasyMock.replay(mockRecovery);
- deqpTest.run(mockListener);
-
- EasyMock.verify(mockListener);
- orderedControl.verify();
- EasyMock.verify(mockRecovery);
- }
-
- /**
- * Test handling of interrupted line in the instrumentation output
- * and recovery from the error.
- */
- public void testRun_testCasePathInterrupted() throws Exception {
- final String instrumentationAnswerOk1 =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
- final String instrumentationAnswerOk2 =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test2\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
- final String instrumentationAnswerBroken =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePat";
-
- final TestIdentifier[] testIds = {
- new TestIdentifier("dEQP-GLES3.instances", "test1"),
- new TestIdentifier("dEQP-GLES3.instances", "test2"),
- };
-
- final String[] testPaths = {
- "dEQP-GLES3.instances.test1",
- "dEQP-GLES3.instances.test2",
- };
-
- Map<String,String> config = new HashMap<>();
- config.put("glconfig", "rgba8888d24s8");
- config.put("rotation", "unspecified");
- config.put("surfacetype", "window");
-
- Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
- instances.put(testIds[0], new ArrayList<Map<String,String>>());
- instances.get(testIds[0]).add(config);
- instances.put(testIds[1], new ArrayList<Map<String,String>>());
- instances.get(testIds[1]).add(config);
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- for (TestIdentifier id : testIds) {
- tests.add(id);
- }
-
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- IMocksControl orderedControl = EasyMock.createStrictControl();
- ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
- IDevice mockIDevice = orderedControl.createMock(IDevice.class);
-
- DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
- deqpTest.setAbi(UnitTests.ABI);
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
- deqpTest.setRecovery(mockRecovery);
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- mockRecovery.onExecutionProgressed();
- EasyMock.expectLastCall().atLeastOnce();
-
- mockRecovery.setDevice(mockDevice);
- EasyMock.expectLastCall().atLeastOnce();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").once();
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
- .once();
-
- // query config
- expectRenderConfigQueryAndReturn(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", "Yes");
-
- // run config and fail
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{test1,test2}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerBroken);
-
- mockRecovery.recoverComLinkKilled();
- EasyMock.expectLastCall().once();
-
- // Re-try
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{test1}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerOk1);
-
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{test2}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerOk2);
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
- .andReturn("").once();
-
- mockListener.testRunStarted(ID, 2);
- EasyMock.expectLastCall().once();
-
- // test1
- mockListener.testStarted(EasyMock.eq(testIds[0]));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- // test2
- mockListener.testStarted(EasyMock.eq(testIds[1]));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testIds[1]), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- orderedControl.replay();
- EasyMock.replay(mockListener);
- EasyMock.replay(mockRecovery);
- deqpTest.run(mockListener);
-
- EasyMock.verify(mockListener);
- orderedControl.verify();
- EasyMock.verify(mockRecovery);
- }
-
- /**
- * Test handling of interrupted line in the instrumentation output
- * and recovery from the error.
- */
- public void testRun_testCasePathMissing() throws Exception {
- final String instrumentationAnswerOk1 =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
- final String instrumentationAnswerOk2 =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test2\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
- final String instrumentationAnswerBroken =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n";
-
-
- final TestIdentifier[] testIds = {
- new TestIdentifier("dEQP-GLES3.instances", "test1"),
- new TestIdentifier("dEQP-GLES3.instances", "test2"),
- };
-
- final String[] testPaths = {
- "dEQP-GLES3.instances.test1",
- "dEQP-GLES3.instances.test2",
- };
-
- Map<String,String> config = new HashMap<>();
- config.put("glconfig", "rgba8888d24s8");
- config.put("rotation", "unspecified");
- config.put("surfacetype", "window");
-
- Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
- instances.put(testIds[0], new ArrayList<Map<String,String>>());
- instances.get(testIds[0]).add(config);
- instances.put(testIds[1], new ArrayList<Map<String,String>>());
- instances.get(testIds[1]).add(config);
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- for (TestIdentifier id : testIds) {
- tests.add(id);
- }
-
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- IMocksControl orderedControl = EasyMock.createStrictControl();
- ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
- IDevice mockIDevice = orderedControl.createMock(IDevice.class);
-
- DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
- deqpTest.setAbi(UnitTests.ABI);
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
- deqpTest.setRecovery(mockRecovery);
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- mockRecovery.onExecutionProgressed();
- EasyMock.expectLastCall().atLeastOnce();
-
- mockRecovery.setDevice(mockDevice);
- EasyMock.expectLastCall().atLeastOnce();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").once();
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
- .once();
-
- // query config
- expectRenderConfigQueryAndReturn(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", "Yes");
-
- // run config and fail
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{test1,test2}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerBroken);
-
- mockRecovery.recoverComLinkKilled();
- EasyMock.expectLastCall().once();
-
- // Re-try
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{test1}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerOk1);
-
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{test2}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerOk2);
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
- .andReturn("").once();
-
- mockListener.testRunStarted(ID, 2);
- EasyMock.expectLastCall().once();
-
- // test1
- mockListener.testStarted(EasyMock.eq(testIds[0]));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- // test2
- mockListener.testStarted(EasyMock.eq(testIds[1]));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testIds[1]), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- orderedControl.replay();
- EasyMock.replay(mockListener);
- EasyMock.replay(mockRecovery);
- deqpTest.run(mockListener);
-
- EasyMock.verify(mockListener);
- orderedControl.verify();
- EasyMock.verify(mockRecovery);
- }
-
- /**
- * Test dEQP with multiple instances
- */
- public void testRun_multipleInstances() throws Exception {
- final String instrumentationAnswerConfigAPass1 =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.passall\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.failone\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.crashtwo\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"; // early eof
- final String instrumentationAnswerConfigAPass2 =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.crashtwo\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"; // early eof
- final String instrumentationAnswerConfigBPass1 =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.passall\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.skipone\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
- final String instrumentationAnswerConfigBPass2 =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.crashtwo\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TerminateTestCase-Reason=Magic\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TerminateTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
- final String instrumentationAnswerConfigCPass1 =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.failone\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Fail\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Fail\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
- final String instrumentationAnswerConfigCPass2 =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.crashtwo\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
-
- final TestIdentifier[] testIds = {
- new TestIdentifier("dEQP-GLES3.instances", "passall"),
- new TestIdentifier("dEQP-GLES3.instances", "failone"),
- new TestIdentifier("dEQP-GLES3.instances", "crashtwo"),
- new TestIdentifier("dEQP-GLES3.instances", "skipone"),
- };
-
- final String[] testPaths = {
- "dEQP-GLES3.instances.passall",
- "dEQP-GLES3.instances.failone",
- "dEQP-GLES3.instances.crashtwo",
- "dEQP-GLES3.instances.skipone",
- };
-
- Map<String,String> supportedConfigA = new HashMap<>();
- supportedConfigA.put("glconfig", "rgba8888d24s8");
- supportedConfigA.put("rotation", "unspecified");
- supportedConfigA.put("surfacetype", "window");
-
- Map<String,String> supportedConfigB = new HashMap<>();
- supportedConfigB.put("glconfig", "rgba8888d24s8");
- supportedConfigB.put("rotation", "90");
- supportedConfigB.put("surfacetype", "window");
-
- Map<String,String> supportedConfigC = new HashMap<>();
- supportedConfigC.put("glconfig", "rgba8888d24s8");
- supportedConfigC.put("rotation", "180");
- supportedConfigC.put("surfacetype", "window");
-
- Map<String,String> unsupportedConfig = new HashMap<>();
- unsupportedConfig.put("glconfig", "rgb565d16s0");
- unsupportedConfig.put("rotation", "unspecified");
- unsupportedConfig.put("surfacetype", "window");
-
- Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
- // pass all
- instances.put(testIds[0], new ArrayList<Map<String,String>>());
- instances.get(testIds[0]).add(supportedConfigA);
- instances.get(testIds[0]).add(supportedConfigB);
-
- // fail one
- instances.put(testIds[1], new ArrayList<Map<String,String>>());
- instances.get(testIds[1]).add(supportedConfigA);
- instances.get(testIds[1]).add(supportedConfigC);
-
- // crash two
- instances.put(testIds[2], new ArrayList<Map<String,String>>());
- instances.get(testIds[2]).add(supportedConfigA);
- instances.get(testIds[2]).add(supportedConfigC);
- instances.get(testIds[2]).add(supportedConfigB);
-
- // skip one
- instances.put(testIds[3], new ArrayList<Map<String,String>>());
- instances.get(testIds[3]).add(supportedConfigB);
- instances.get(testIds[3]).add(unsupportedConfig);
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- for (TestIdentifier id : testIds) {
- tests.add(id);
- }
-
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- IMocksControl orderedControl = EasyMock.createStrictControl();
- ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
- IDevice mockIDevice = orderedControl.createMock(IDevice.class);
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
- deqpTest.setAbi(UnitTests.ABI);
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").once();
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
- .once();
-
- // query config A
- expectRenderConfigQueryAndReturn(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", "Yes");
-
- // run config A - first pass
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{passall,failone,crashtwo}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerConfigAPass1);
-
- // run config A - second pass
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{crashtwo}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerConfigAPass2);
-
- // query for config B
-
- EasyMock.expect(mockDevice.executeShellCommand("pm list features")).andReturn(ALL_FEATURES)
- .once();
-
- expectRenderConfigQueryAndReturn(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=90 "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", "Yes");
-
- // run for config B - first pass
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{passall,skipone}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=90 "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerConfigBPass1);
-
- // query for config C
- expectRenderConfigQueryAndReturn(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=180 "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", "Yes");
-
- // run for config C - first pass
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{failone}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=180 "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerConfigCPass1);
-
- // run for config C - second pass
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{crashtwo}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=180 "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerConfigCPass2);
-
- // run for config B - second pass (crashtwo has been deferred due to its instability)
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{instances{crashtwo}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=90 "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerConfigBPass2);
-
- // query for unsupported config
- expectRenderConfigQueryAndReturn(mockDevice,
- "--deqp-gl-config-name=rgb565d16s0 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", "No");
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
- .andReturn("").once();
-
- mockListener.testRunStarted(ID, 4);
- EasyMock.expectLastCall().once();
-
- // pass all
- mockListener.testStarted(EasyMock.eq(testIds[0]));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- // fail one
- mockListener.testStarted(EasyMock.eq(testIds[1]));
- EasyMock.expectLastCall().once();
-
- mockListener.testFailed(testIds[1],
- "=== with config {glformat=rgba8888d24s8,rotation=180,surfacetype=window} ===\n"
- + "Fail: Fail");
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testIds[1]), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- // crash two
- mockListener.testStarted(EasyMock.eq(testIds[2]));
- EasyMock.expectLastCall().once();
-
- mockListener.testFailed(testIds[2],
- "=== with config {glformat=rgba8888d24s8,rotation=unspecified,surfacetype=window} ===\n"
- + "Crash: Incomplete test log\n"
- + "=== with config {glformat=rgba8888d24s8,rotation=90,surfacetype=window} ===\n"
- + "Terminated: Magic");
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testIds[2]), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- // skip one
- mockListener.testStarted(EasyMock.eq(testIds[3]));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testIds[3]), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- orderedControl.replay();
- EasyMock.replay(mockListener);
- deqpTest.setRecovery(new StubRecovery());
- deqpTest.run(mockListener);
- EasyMock.verify(mockListener);
- orderedControl.verify();
- }
-
- private void testMultipleInstancesLossOfDeviceMidInstance(final boolean recoverySuccessful)
- throws Exception {
- final String instrumentationAnswerFine =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.loss.instance\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
- final String instrumentationAnswerCrash =
- "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.loss.instance\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"; // early <EOF>
-
- final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.loss", "instance");
-
- Map<String,String> supportedConfigA = new HashMap<>();
- supportedConfigA.put("glconfig", "rgba8888d24s8");
- supportedConfigA.put("rotation", "unspecified");
- supportedConfigA.put("surfacetype", "window");
-
- Map<String,String> supportedConfigB = new HashMap<>();
- supportedConfigB.put("glconfig", "rgba8888d24s8");
- supportedConfigB.put("rotation", "90");
- supportedConfigB.put("surfacetype", "window");
-
- Map<String,String> supportedConfigC = new HashMap<>();
- supportedConfigC.put("glconfig", "rgba8888d24s8");
- supportedConfigC.put("rotation", "180");
- supportedConfigC.put("surfacetype", "window");
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- tests.add(testId);
-
- Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
- instance.put(testId, new ArrayList<Map<String,String>>());
- instance.get(testId).add(supportedConfigA);
- instance.get(testId).add(supportedConfigB);
- instance.get(testId).add(supportedConfigC);
-
- ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- IDevice mockIDevice = EasyMock.createMock(IDevice.class);
- DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
- deqpTest.setAbi(UnitTests.ABI);
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
- deqpTest.setRecovery(mockRecovery);
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
- EasyMock.expect(mockDevice.executeShellCommand("pm list features")).andReturn(ALL_FEATURES)
- .anyTimes();
-
- mockRecovery.onExecutionProgressed();
- EasyMock.expectLastCall().atLeastOnce();
-
- mockRecovery.setDevice(mockDevice);
- EasyMock.expectLastCall().atLeastOnce();
-
- if (!recoverySuccessful) {
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").once();
- } else {
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").times(2);
- }
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
- .once();
-
- // query config A
- expectRenderConfigQueryAndReturn(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", "Yes");
-
- // run config A
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{loss{instance}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerFine);
-
- // query config B
- expectRenderConfigQueryAndReturn(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=90 "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", "Yes");
-
- // run config B
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("rm " + CASE_LIST_FILE_NAME)))
- .andReturn("").once();
-
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("rm " + LOG_FILE_NAME)))
- .andReturn("").once();
-
- EasyMock.expect(mockDevice.pushString("{dEQP-GLES3{loss{instance}}}\n", CASE_LIST_FILE_NAME))
- .andReturn(true).once();
-
- String command = String.format(
- "am instrument %s -w -e deqpLogFileName \"%s\" -e deqpCmdLine \""
- + "--deqp-caselist-file=%s"
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=90 "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable\" "
- + "-e deqpLogData \"%s\" %s",
- AbiUtils.createAbiFlag(UnitTests.ABI.getName()), LOG_FILE_NAME,
- CASE_LIST_FILE_NAME, false, INSTRUMENTATION_NAME);
-
- EasyMock.expect(mockDevice.getIDevice()).andReturn(mockIDevice);
- mockIDevice.executeShellCommand(EasyMock.eq(command),
- EasyMock.<IShellOutputReceiver>notNull(), EasyMock.anyLong(),
- EasyMock.isA(TimeUnit.class));
-
- EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
- @Override
- public Object answer() throws ShellCommandUnresponsiveException {
- IShellOutputReceiver receiver
- = (IShellOutputReceiver)EasyMock.getCurrentArguments()[1];
-
- receiver.addOutput(instrumentationAnswerCrash.getBytes(), 0,
- instrumentationAnswerCrash.length());
- throw new ShellCommandUnresponsiveException();
- }
- });
-
- if (!recoverySuccessful) {
- mockRecovery.recoverComLinkKilled();
- EasyMock.expectLastCall().andThrow(new DeviceNotAvailableException()).once();
- } else {
- mockRecovery.recoverComLinkKilled();
- EasyMock.expectLastCall().once();
-
- // retry running config B
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{loss{instance}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=90 "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerFine);
-
- // query config C
- expectRenderConfigQueryAndReturn(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=180 "
- + "--deqp-surface-type=window "
- + "--deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0", "Yes");
-
- // run config C
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
- "{dEQP-GLES3{loss{instance}}}",
- "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
- + " --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=180 "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable", instrumentationAnswerFine);
- }
-
- mockListener.testRunStarted(ID, 1);
- EasyMock.expectLastCall().once();
-
- // result is reported only if device is available
- if (recoverySuccessful) {
- mockListener.testStarted(EasyMock.eq(testId));
- EasyMock.expectLastCall().once();
-
- mockListener.testEnded(EasyMock.eq(testId), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
-
- mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
- EasyMock.expectLastCall().once();
- }
-
- EasyMock.replay(mockDevice, mockIDevice);
- EasyMock.replay(mockListener);
- EasyMock.replay(mockRecovery);
-
- try {
- deqpTest.run(mockListener);
-
- if (!recoverySuccessful) {
- fail("did not get DeviceNotAvailableException");
- }
- } catch (DeviceNotAvailableException ex) {
- if (recoverySuccessful) {
- fail("got DeviceNotAvailableException");
- }
- }
-
- EasyMock.verify(mockRecovery);
- EasyMock.verify(mockListener);
- EasyMock.verify(mockDevice, mockIDevice);
- }
-
- /**
- * Test dEQP with runner if device is lost during one of multiple instances.
- */
- public void testRun_multipleInstancesLossOfDeviceMidInstance() throws Exception {
- testMultipleInstancesLossOfDeviceMidInstance(false);
- }
-
- /**
- * Test dEQP with runner if device is lost during one of multiple instances but recovery
- * is successful.
- */
- public void testRun_multipleInstancesLossOfDeviceMidInstanceAndRecovery() throws Exception {
- testMultipleInstancesLossOfDeviceMidInstance(true);
- }
-
- public static interface RecoverableTestDevice extends ITestDevice {
- public void recoverDevice() throws DeviceNotAvailableException;
- }
-
- private static enum RecoveryEvent {
- PROGRESS,
- FAIL_CONNECTION_REFUSED,
- FAIL_LINK_KILLED,
- };
-
- private void runRecoveryWithPattern(DeqpTestRunner.Recovery recovery, RecoveryEvent[] events)
- throws DeviceNotAvailableException {
- for (RecoveryEvent event : events) {
- switch (event) {
- case PROGRESS:
- recovery.onExecutionProgressed();
- break;
- case FAIL_CONNECTION_REFUSED:
- recovery.recoverConnectionRefused();
- break;
- case FAIL_LINK_KILLED:
- recovery.recoverComLinkKilled();
- break;
- }
- }
- }
-
- private void setRecoveryExpectationWait(DeqpTestRunner.ISleepProvider mockSleepProvider) {
- mockSleepProvider.sleep(EasyMock.gt(0));
- EasyMock.expectLastCall().once();
- }
-
- private void setRecoveryExpectationKillProcess(RecoverableTestDevice mockDevice,
- DeqpTestRunner.ISleepProvider mockSleepProvider) throws DeviceNotAvailableException {
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.contains("ps"))).
- andReturn("root 1234 com.drawelement.deqp").once();
-
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("kill -9 1234"))).
- andReturn("").once();
-
- // Recovery checks if kill failed
- mockSleepProvider.sleep(EasyMock.gt(0));
- EasyMock.expectLastCall().once();
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.contains("ps"))).
- andReturn("").once();
- }
-
- private void setRecoveryExpectationRecovery(RecoverableTestDevice mockDevice)
- throws DeviceNotAvailableException {
- mockDevice.recoverDevice();
- EasyMock.expectLastCall().once();
- }
-
- private void setRecoveryExpectationReboot(RecoverableTestDevice mockDevice)
- throws DeviceNotAvailableException {
- mockDevice.reboot();
- EasyMock.expectLastCall().once();
- }
-
- private int setRecoveryExpectationOfAConnFailure(RecoverableTestDevice mockDevice,
- DeqpTestRunner.ISleepProvider mockSleepProvider, int numConsecutiveErrors)
- throws DeviceNotAvailableException {
- switch (numConsecutiveErrors) {
- case 0:
- case 1:
- setRecoveryExpectationRecovery(mockDevice);
- return 2;
- case 2:
- setRecoveryExpectationReboot(mockDevice);
- return 3;
- default:
- return 4;
- }
- }
-
- private int setRecoveryExpectationOfAComKilled(RecoverableTestDevice mockDevice,
- DeqpTestRunner.ISleepProvider mockSleepProvider, int numConsecutiveErrors)
- throws DeviceNotAvailableException {
- switch (numConsecutiveErrors) {
- case 0:
- setRecoveryExpectationWait(mockSleepProvider);
- setRecoveryExpectationKillProcess(mockDevice, mockSleepProvider);
- return 1;
- case 1:
- setRecoveryExpectationRecovery(mockDevice);
- setRecoveryExpectationKillProcess(mockDevice, mockSleepProvider);
- return 2;
- case 2:
- setRecoveryExpectationReboot(mockDevice);
- return 3;
- default:
- return 4;
- }
- }
-
- private void setRecoveryExpectationsOfAPattern(RecoverableTestDevice mockDevice,
- DeqpTestRunner.ISleepProvider mockSleepProvider, RecoveryEvent[] events)
- throws DeviceNotAvailableException {
- int numConsecutiveErrors = 0;
- for (RecoveryEvent event : events) {
- switch (event) {
- case PROGRESS:
- numConsecutiveErrors = 0;
- break;
- case FAIL_CONNECTION_REFUSED:
- numConsecutiveErrors = setRecoveryExpectationOfAConnFailure(mockDevice,
- mockSleepProvider, numConsecutiveErrors);
- break;
- case FAIL_LINK_KILLED:
- numConsecutiveErrors = setRecoveryExpectationOfAComKilled(mockDevice,
- mockSleepProvider, numConsecutiveErrors);
- break;
- }
- }
- }
-
- /**
- * Test dEQP runner recovery state machine.
- */
- private void testRecoveryWithPattern(boolean expectSuccess, RecoveryEvent...pattern)
- throws Exception {
- DeqpTestRunner.Recovery recovery = new DeqpTestRunner.Recovery();
- IMocksControl orderedControl = EasyMock.createStrictControl();
- RecoverableTestDevice mockDevice = orderedControl.createMock(RecoverableTestDevice.class);
- DeqpTestRunner.ISleepProvider mockSleepProvider =
- orderedControl.createMock(DeqpTestRunner.ISleepProvider.class);
-
- setRecoveryExpectationsOfAPattern(mockDevice, mockSleepProvider, pattern);
-
- orderedControl.replay();
-
- recovery.setDevice(mockDevice);
- recovery.setSleepProvider(mockSleepProvider);
- try {
- runRecoveryWithPattern(recovery, pattern);
- if (!expectSuccess) {
- fail("Expected DeviceNotAvailableException");
- }
- } catch (DeviceNotAvailableException ex) {
- if (expectSuccess) {
- fail("Did not expect DeviceNotAvailableException");
- }
- }
-
- orderedControl.verify();
- }
-
- // basic patterns
-
- public void testRecovery_NoEvents() throws Exception {
- testRecoveryWithPattern(true);
- }
-
- public void testRecovery_AllOk() throws Exception {
- testRecoveryWithPattern(true, RecoveryEvent.PROGRESS, RecoveryEvent.PROGRESS);
- }
-
- // conn fail patterns
-
- public void testRecovery_OneConnectionFailureBegin() throws Exception {
- testRecoveryWithPattern(true, RecoveryEvent.FAIL_CONNECTION_REFUSED,
- RecoveryEvent.PROGRESS);
- }
-
- public void testRecovery_TwoConnectionFailuresBegin() throws Exception {
- testRecoveryWithPattern(true, RecoveryEvent.FAIL_CONNECTION_REFUSED,
- RecoveryEvent.FAIL_CONNECTION_REFUSED, RecoveryEvent.PROGRESS);
- }
-
- public void testRecovery_ThreeConnectionFailuresBegin() throws Exception {
- testRecoveryWithPattern(false, RecoveryEvent.FAIL_CONNECTION_REFUSED,
- RecoveryEvent.FAIL_CONNECTION_REFUSED, RecoveryEvent.FAIL_CONNECTION_REFUSED);
- }
-
- public void testRecovery_OneConnectionFailureMid() throws Exception {
- testRecoveryWithPattern(true, RecoveryEvent.PROGRESS,
- RecoveryEvent.FAIL_CONNECTION_REFUSED, RecoveryEvent.PROGRESS);
- }
-
- public void testRecovery_TwoConnectionFailuresMid() throws Exception {
- testRecoveryWithPattern(true, RecoveryEvent.PROGRESS,
- RecoveryEvent.FAIL_CONNECTION_REFUSED, RecoveryEvent.FAIL_CONNECTION_REFUSED,
- RecoveryEvent.PROGRESS);
- }
-
- public void testRecovery_ThreeConnectionFailuresMid() throws Exception {
- testRecoveryWithPattern(false, RecoveryEvent.PROGRESS,
- RecoveryEvent.FAIL_CONNECTION_REFUSED, RecoveryEvent.FAIL_CONNECTION_REFUSED,
- RecoveryEvent.FAIL_CONNECTION_REFUSED);
- }
-
- // link fail patterns
-
- public void testRecovery_OneLinkFailureBegin() throws Exception {
- testRecoveryWithPattern(true, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.PROGRESS);
- }
-
- public void testRecovery_TwoLinkFailuresBegin() throws Exception {
- testRecoveryWithPattern(true, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.PROGRESS);
- }
-
- public void testRecovery_ThreeLinkFailuresBegin() throws Exception {
- testRecoveryWithPattern(true, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.PROGRESS);
- }
-
- public void testRecovery_FourLinkFailuresBegin() throws Exception {
- testRecoveryWithPattern(false, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.FAIL_LINK_KILLED);
- }
-
- public void testRecovery_OneLinkFailureMid() throws Exception {
- testRecoveryWithPattern(true, RecoveryEvent.PROGRESS,
- RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.PROGRESS);
- }
-
- public void testRecovery_TwoLinkFailuresMid() throws Exception {
- testRecoveryWithPattern(true, RecoveryEvent.PROGRESS,
- RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.PROGRESS);
- }
-
- public void testRecovery_ThreeLinkFailuresMid() throws Exception {
- testRecoveryWithPattern(true, RecoveryEvent.PROGRESS,
- RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.PROGRESS);
- }
-
- public void testRecovery_FourLinkFailuresMid() throws Exception {
- testRecoveryWithPattern(false, RecoveryEvent.PROGRESS, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.FAIL_LINK_KILLED);
- }
-
- // mixed patterns
-
- public void testRecovery_MixedFailuresProgressBetween() throws Exception {
- testRecoveryWithPattern(true,
- RecoveryEvent.PROGRESS, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.PROGRESS, RecoveryEvent.FAIL_CONNECTION_REFUSED,
- RecoveryEvent.PROGRESS, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.PROGRESS, RecoveryEvent.FAIL_CONNECTION_REFUSED,
- RecoveryEvent.PROGRESS);
- }
-
- public void testRecovery_MixedFailuresNoProgressBetween() throws Exception {
- testRecoveryWithPattern(true,
- RecoveryEvent.PROGRESS, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.FAIL_CONNECTION_REFUSED, RecoveryEvent.FAIL_LINK_KILLED,
- RecoveryEvent.PROGRESS);
- }
-
- /**
- * Test recovery if process cannot be killed
- */
- public void testRecovery_unkillableProcess () throws Exception {
- DeqpTestRunner.Recovery recovery = new DeqpTestRunner.Recovery();
- IMocksControl orderedControl = EasyMock.createStrictControl();
- RecoverableTestDevice mockDevice = orderedControl.createMock(RecoverableTestDevice.class);
- DeqpTestRunner.ISleepProvider mockSleepProvider =
- orderedControl.createMock(DeqpTestRunner.ISleepProvider.class);
-
- // recovery attempts to kill the process after a timeout
- mockSleepProvider.sleep(EasyMock.gt(0));
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.contains("ps"))).
- andReturn("root 1234 com.drawelement.deqp").once();
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("kill -9 1234"))).
- andReturn("").once();
-
- // Recovery checks if kill failed
- mockSleepProvider.sleep(EasyMock.gt(0));
- EasyMock.expectLastCall().once();
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.contains("ps"))).
- andReturn("root 1234 com.drawelement.deqp").once();
-
- // Recovery resets the connection
- mockDevice.recoverDevice();
- EasyMock.expectLastCall().once();
-
- // and attempts to kill the process again
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.contains("ps"))).
- andReturn("root 1234 com.drawelement.deqp").once();
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("kill -9 1234"))).
- andReturn("").once();
-
- // Recovery checks if kill failed
- mockSleepProvider.sleep(EasyMock.gt(0));
- EasyMock.expectLastCall().once();
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.contains("ps"))).
- andReturn("root 1234 com.drawelement.deqp").once();
-
- // recovery reboots the device
- mockDevice.reboot();
- EasyMock.expectLastCall().once();
-
- orderedControl.replay();
- recovery.setDevice(mockDevice);
- recovery.setSleepProvider(mockSleepProvider);
- recovery.recoverComLinkKilled();
- orderedControl.verify();
- }
-
- /**
- * Test external interruption before batch run.
- */
- public void testInterrupt_killBeforeBatch() throws Exception {
- final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.interrupt", "test");
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- tests.add(testId);
-
- Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
- instance.put(testId, DEFAULT_INSTANCE_ARGS);
-
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
- IDevice mockIDevice = EasyMock.createMock(IDevice.class);
- IRunUtil mockRunUtil = EasyMock.createMock(IRunUtil.class);
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
- deqpTest.setAbi(UnitTests.ABI);
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
- deqpTest.setRunUtil(mockRunUtil);
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").once();
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
- .once();
-
- expectRenderConfigQuery(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 --deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window --deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0");
-
- mockRunUtil.sleep(0);
- EasyMock.expectLastCall().andThrow(new RunInterruptedException());
-
- mockListener.testRunStarted(ID, 1);
- EasyMock.expectLastCall().once();
-
- EasyMock.replay(mockDevice, mockIDevice);
- EasyMock.replay(mockListener);
- EasyMock.replay(mockRunUtil);
- try {
- deqpTest.run(mockListener);
- fail("expected RunInterruptedException");
- } catch (RunInterruptedException ex) {
- // expected
- }
- EasyMock.verify(mockRunUtil);
- EasyMock.verify(mockListener);
- EasyMock.verify(mockDevice, mockIDevice);
- }
-
- /**
- * Test external interruption in testFailed().
- */
- public void testInterrupt_killReportTestFailed() throws Exception {
- final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.interrupt", "test");
- final String testPath = "dEQP-GLES3.interrupt.test";
- final String testTrie = "{dEQP-GLES3{interrupt{test}}}";
- final String output = "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=" + testPath + "\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Fail\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Fail\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
- + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
- + "INSTRUMENTATION_CODE: 0\r\n";
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
- tests.add(testId);
-
- Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
- instance.put(testId, DEFAULT_INSTANCE_ARGS);
-
- ITestInvocationListener mockListener
- = EasyMock.createStrictMock(ITestInvocationListener.class);
- ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
- IDevice mockIDevice = EasyMock.createMock(IDevice.class);
- IRunUtil mockRunUtil = EasyMock.createMock(IRunUtil.class);
-
- DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
- deqpTest.setAbi(UnitTests.ABI);
- deqpTest.setDevice(mockDevice);
- deqpTest.setBuildHelper(new StubCtsBuildHelper());
- deqpTest.setRunUtil(mockRunUtil);
-
- int version = 3 << 16;
- EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
- .andReturn(Integer.toString(version)).atLeastOnce();
-
- EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
- andReturn("").once();
-
- EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
- EasyMock.eq(true),
- EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
- .once();
-
- expectRenderConfigQuery(mockDevice,
- "--deqp-gl-config-name=rgba8888d24s8 --deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window --deqp-gl-major-version=3 "
- + "--deqp-gl-minor-version=0");
-
- mockRunUtil.sleep(0);
- EasyMock.expectLastCall().once();
-
- String commandLine = String.format(
- "--deqp-caselist-file=%s --deqp-gl-config-name=rgba8888d24s8 "
- + "--deqp-screen-rotation=unspecified "
- + "--deqp-surface-type=window "
- + "--deqp-log-images=disable "
- + "--deqp-watchdog=enable",
- CASE_LIST_FILE_NAME);
-
- runInstrumentationLineAndAnswer(mockDevice, mockIDevice, testTrie, commandLine,
- output);
-
- mockListener.testRunStarted(ID, 1);
- EasyMock.expectLastCall().once();
-
- mockListener.testStarted(EasyMock.eq(testId));
- EasyMock.expectLastCall().once();
-
- mockListener.testFailed(EasyMock.eq(testId), EasyMock.<String>notNull());
- EasyMock.expectLastCall().andThrow(new RunInterruptedException());
-
- EasyMock.replay(mockDevice, mockIDevice);
- EasyMock.replay(mockListener);
- EasyMock.replay(mockRunUtil);
- try {
- deqpTest.run(mockListener);
- fail("expected RunInterruptedException");
- } catch (RunInterruptedException ex) {
- // expected
- }
- EasyMock.verify(mockRunUtil);
- EasyMock.verify(mockListener);
- EasyMock.verify(mockDevice, mockIDevice);
- }
-
- private void runInstrumentationLineAndAnswer(ITestDevice mockDevice, IDevice mockIDevice,
- final String testTrie, final String cmd, final String output) throws Exception {
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("rm " + CASE_LIST_FILE_NAME)))
- .andReturn("").once();
-
- EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("rm " + LOG_FILE_NAME)))
- .andReturn("").once();
-
- EasyMock.expect(mockDevice.pushString(testTrie + "\n", CASE_LIST_FILE_NAME))
- .andReturn(true).once();
-
- String command = String.format(
- "am instrument %s -w -e deqpLogFileName \"%s\" -e deqpCmdLine \"%s\" "
- + "-e deqpLogData \"%s\" %s",
- AbiUtils.createAbiFlag(UnitTests.ABI.getName()), LOG_FILE_NAME, cmd, false,
- INSTRUMENTATION_NAME);
-
- EasyMock.expect(mockDevice.getIDevice()).andReturn(mockIDevice);
- mockIDevice.executeShellCommand(EasyMock.eq(command),
- EasyMock.<IShellOutputReceiver>notNull(), EasyMock.anyLong(),
- EasyMock.isA(TimeUnit.class));
-
- EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
- @Override
- public Object answer() {
- IShellOutputReceiver receiver
- = (IShellOutputReceiver)EasyMock.getCurrentArguments()[1];
-
- receiver.addOutput(output.getBytes(), 0, output.length());
- receiver.flush();
-
- return null;
- }
- });
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/GeeTestTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/GeeTestTest.java
deleted file mode 100644
index 93272be..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/GeeTestTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.UnitTests;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link GeeTest}.
- */
-public class GeeTestTest extends TestCase {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Test {@link GeeTestTest#getGTestFilters}
- * @throws DeviceNotAvailableException
- */
- public void testGetGTestFilters() {
- GeeTest test = new GeeTest("package_foo", "exe_foo");
- test.setPositiveFilters("a");
- test.setNegativeFilters("b");
- String actual = test.getGTestFilters();
- assertEquals("--gtest_filter=a:-b", actual);
- }
-
- /**
- * Test {@link GeeTestTest#getGTestFilters} with only positive filters
- * @throws DeviceNotAvailableException
- */
- public void testGetGTestFiltersPositiveOnly() {
- GeeTest test = new GeeTest("package_foo", "exe_foo");
- test.setPositiveFilters("a");
- String actual = test.getGTestFilters();
- assertEquals("--gtest_filter=a", actual);
- }
-
- /**
- * Test {@link GeeTestTest#getGTestFilters} with only negative filters
- * @throws DeviceNotAvailableException
- */
- public void testGetGTestFiltersNegativeOnly() {
- GeeTest test = new GeeTest("package_foo", "exe_foo");
- test.setNegativeFilters("b");
- String actual = test.getGTestFilters();
- assertEquals("--gtest_filter=-b", actual);
- }
-
- /**
- * Test {@link GeeTestTest#getGTestFilters} with empty filters
- * @throws DeviceNotAvailableException
- */
- public void testGetGTestFiltersWithNoFilters() {
- GeeTest test = new GeeTest("package_foo", "exe_foo");
- String actual = test.getGTestFilters();
- assertEquals("", actual);
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/JarHostTestTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/JarHostTestTest.java
deleted file mode 100644
index dfe4413..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/JarHostTestTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.StubCtsBuildHelper;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.ITestInvocationListener;
-
-import org.easymock.EasyMock;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link JarHostTest}.
- */
-public class JarHostTestTest extends TestCase {
-
- private static final String RUN_NAME = "run";
- private JarHostTest mJarTest;
- private StubCtsBuildHelper mStubBuildHelper;
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mJarTest = new JarHostTest() {
- // mock out the loading from jar
- @Override
- Class<?> loadClass(String className, URL[] urls) throws ClassNotFoundException {
- return MockTest.class;
- }
- };
- mStubBuildHelper = new StubCtsBuildHelper();
- mJarTest.setBuildHelper(mStubBuildHelper);
- }
-
- public static class MockTest extends TestCase {
- public MockTest(String name) {
- super(name);
- }
-
- public MockTest() {
- super();
- }
-
- public void testFoo() {
- }
- }
-
- /**
- * Test normal case for
- * {@link JarHostTest#run(com.android.tradefed.result.ITestInvocationListener)}.
- */
- @SuppressWarnings("unchecked")
- public void testRun() throws DeviceNotAvailableException {
- ITestInvocationListener listener = EasyMock.createMock(ITestInvocationListener.class);
- TestIdentifier expectedTest = new TestIdentifier(MockTest.class.getName(), "testFoo");
-
- Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>(1);
- tests.add(expectedTest);
- listener.testRunStarted(RUN_NAME, 1);
- listener.testStarted(expectedTest);
- listener.testEnded(expectedTest, Collections.EMPTY_MAP);
- listener.testRunEnded(EasyMock.anyLong(), EasyMock.eq(Collections.EMPTY_MAP));
- mJarTest.setTests(tests);
- mJarTest.setDevice(EasyMock.createMock(ITestDevice.class));
- mJarTest.setJarFileName("fakefile");
- mJarTest.setRunName(RUN_NAME);
-
- EasyMock.replay(listener);
- mJarTest.run(listener);
- EasyMock.verify(listener);
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestFilterTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestFilterTest.java
deleted file mode 100644
index 2f76e1f..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestFilterTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-
-import junit.framework.TestCase;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Unit tests for {@link TestFilter}.
- */
-public class TestFilterTest extends TestCase {
-
- private TestFilter mFilter;
- private List<TestIdentifier> mTestList;
-
- private static final TestIdentifier TEST1 = new TestIdentifier("FooTest", "testFoo");
- private static final TestIdentifier TEST2 = new TestIdentifier("FooTest", "testFoo2");
- private static final TestIdentifier TEST3 = new TestIdentifier("FooTest2", "testFoo3");
-
- @Override
- protected void setUp() throws Exception {
- mFilter = new TestFilter();
- mTestList = new ArrayList<TestIdentifier>();
- mTestList.add(TEST1);
- mTestList.add(TEST2);
- mTestList.add(TEST3);
- }
-
- /**
- * Test {@link TestFilter#filter(java.util.Collection)} with no rules defined
- */
- public void testFilter_empty() {
- assertEquals(mTestList.size(), mFilter.filter(mTestList).size());
- }
-
- /**
- * Test {@link TestFilter#filter(java.util.Collection)} with an excluded test filter
- */
- public void testFilter_excludeTest() {
- mFilter.addExcludedTest(TEST1);
- Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
- assertEquals(2, filteredList.size());
- Iterator<TestIdentifier> iter = filteredList.iterator();
- assertEquals(TEST2, iter.next());
- assertEquals(TEST3, iter.next());
- }
-
- /**
- * Test {@link TestFilter#filter(java.util.Collection)} with an excluded test filter
- */
- public void testFilter_excludeClass() {
- mFilter.addExcludedClass(TEST1.getClassName());
- Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
- assertEquals(1, filteredList.size());
- assertEquals(TEST3, filteredList.iterator().next());
- }
-
- /**
- * Test {@link TestFilter#filter(java.util.Collection)} with a class inclusion rule
- */
- public void testFilter_includeClass() {
- mFilter.setTestInclusion(TEST1.getClassName(), null);
- Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
- assertEquals(2, filteredList.size());
- Iterator<TestIdentifier> iter = filteredList.iterator();
- assertEquals(TEST1, iter.next());
- assertEquals(TEST2, iter.next());
- }
-
- /**
- * Test {@link TestFilter#filter(java.util.Collection)} with a class
- */
- public void testFilter_includeTest() {
- mFilter.setTestInclusion(TEST1.getClassName(), TEST1.getTestName());
- Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
- assertEquals(1, filteredList.size());
- Iterator<TestIdentifier> iter = filteredList.iterator();
- assertEquals(TEST1, iter.next());
- }
-
- /**
- * Test {@link TestFilter#filter(java.util.Collection)} with an included test filter
- */
- public void testFilter_includeClasses() {
- mFilter.addIncludedClass(TEST3.getClassName());
- Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
- assertEquals(1, filteredList.size());
- assertEquals(TEST3, filteredList.iterator().next());
- }
-
- /**
- * Test {@link TestFilter#filter(java.util.Collection)} with an included test filter
- */
- public void testFilter_includeTests() {
- mFilter.addIncludedTest(TEST1);
- mFilter.addIncludedTest(TEST3);
- Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
- assertEquals(2, filteredList.size());
- Iterator<TestIdentifier> iter = filteredList.iterator();
- assertEquals(TEST1, iter.next());
- assertEquals(TEST3, iter.next());
- }
-
- /**
- * Test {@link TestFilter#filter(java.util.Collection)}. Exclusion overrides
- * inclusion.
- */
- public void testFilter_includeAndExcludeClasses() {
- String className = TEST3.getClassName();
- mFilter.addExcludedClass(className);
- mFilter.addIncludedClass(className);
- assertTrue(mFilter.filter(mTestList).isEmpty());
- }
-
- /**
- * Test {@link TestFilter#filter(java.util.Collection)} Exclusion overrides
- * inclusion.
- */
- public void testFilter_includeAndExcludeTests() {
- mFilter.addExcludedTest(TEST1);
- mFilter.addIncludedTest(TEST1);
- assertTrue(mFilter.filter(mTestList).isEmpty());
- }
-
- /**
- * Test {@link TestFilter#filter(java.util.Collection)} Exclusion overrides
- * inclusion.
- */
- public void testFilter_includeTestAndExcludeClass() {
- mFilter.addExcludedClass(TEST1.getClassName());
- mFilter.addIncludedTest(TEST1);
- assertTrue(mFilter.filter(mTestList).isEmpty());
- }
-
- /**
- * Test {@link TestFilter#filter(java.util.Collection)} Exclusion overrides
- * inclusion.
- */
- public void testFilter_includeClassAndExcludeTest() {
- mFilter.addExcludedTest(TEST1);
- mFilter.addIncludedClass(TEST1.getClassName());
- Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
- assertEquals(1, filteredList.size());
- Iterator<TestIdentifier> iter = filteredList.iterator();
- assertEquals(TEST2, iter.next());
- }
-
- /**
- * Test {@link TestFilter#filter(java.util.Collection)} Exclusion overrides
- * inclusion.
- */
- public void testFilter_includeClassAndExcludeTests() {
- mFilter.addExcludedTest(TEST1);
- mFilter.addExcludedTest(TEST2);
- mFilter.addIncludedClass(TEST1.getClassName());
- assertTrue(mFilter.filter(mTestList).isEmpty());
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageDefTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageDefTest.java
deleted file mode 100644
index 2a5777b..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageDefTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.InputStream;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link TestPackageDef}.
- */
-public class TestPackageDefTest extends TestCase {
-
- /**
- * Regression test for {@link TestPackageDef#generateDigest(File, String)} that ensures expected
- * digest is generated for fixed data.
- */
- public void testGenerateDigest() {
- TestPackageDef def = new TestPackageDef() {
- @Override
- InputStream getFileStream(File dir, String fileName) {
- return new ByteArrayInputStream("test data for digest".getBytes());
- }
- };
- String digest = def.generateDigest(new File("unused"), "alsounused");
- assertNotNull(digest);
- assertEquals("58c222b5f5f81b4b58891ec59924b9b2f530452e", digest);
-
- }
-
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageXmlParserTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageXmlParserTest.java
deleted file mode 100644
index 23a39cf..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageXmlParserTest.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Unit tests for {@link TestPackageXmlParser}.
- */
-public class TestPackageXmlParserTest extends TestCase {
-
- private static final String INSTR_TEST_DATA =
- "<TestPackage AndroidFramework=\"Android 1.0\" appNameSpace=\"com.example\" " +
- "appPackageName=\"android.example\" name=\"CtsExampleTestCases\" " +
- "runner=\"android.test.InstrumentationTestRunner\" version=\"1.0\">" +
- "</TestPackage>";
-
- private static final String HOST_TEST_DATA =
- "<TestPackage hostSideOnly=\"true\" >\n" +
- " <TestSuite name=\"com\" >\n" +
- " <TestSuite name=\"example\" >\n" +
- " <TestCase name=\"ExampleTest\" >\n" +
- " <Test name=\"testFoo\" />\n" +
- " <Test name=\"testFoo2\" expectation=\"failure\" />\n" +
- " </TestCase>\n" +
- " </TestSuite>\n" +
- " <TestSuite name=\"example2\" >\n" +
- " <TestCase name=\"Example2Test\" >\n" +
- " <Test name=\"testFoo\" />\n" +
- " </TestCase>\n" +
- " </TestSuite>\n" +
- " </TestSuite>\n" +
- "</TestPackage>";
-
- private static final String BAD_HOST_TEST_DATA =
- "<TestPackage hostSideOnly=\"blah\" >" +
- "</TestPackage>";
-
- private static final String VM_HOST_TEST_XML =
- "<TestPackage vmHostTest=\"true\"></TestPackage>";
-
- private static final String NATIVE_TEST_XML = "<TestPackage testType=\"native\"></TestPackage>";
-
- private static final String NO_TEST_DATA = "<invalid />";
-
- private static final String INSTANCED_TEST_DATA =
- "<TestPackage>\n" +
- " <TestSuite name=\"com\" >\n" +
- " <TestSuite name=\"example\" >\n" +
- " <TestCase name=\"ExampleTest\" >\n" +
- " <Test name=\"testMultiInstanced\" >\n" +
- " <TestInstance foo=\"bar\" />\n" +
- " <TestInstance foo=\"baz\" foo2=\"baz2\"/>\n" +
- " </Test>\n" +
- " <Test name=\"testSingleInstanced\" >\n" +
- " <TestInstance foo=\"bar\" />\n" +
- " </Test>\n" +
- " <Test name=\"testEmptyInstances\" >\n" +
- " <TestInstance />\n" +
- " <TestInstance />\n" +
- " </Test>\n" +
- " <Test name=\"testNotInstanced\" >\n" +
- " </Test>\n" +
- " </TestCase>\n" +
- " </TestSuite>\n" +
- " </TestSuite>\n" +
- "</TestPackage>";
-
- /**
- * Test parsing test case xml containing an instrumentation test definition.
- */
- public void testParse_instrPackage() throws ParseException {
- TestPackageXmlParser parser = new TestPackageXmlParser(true);
- parser.parse(getStringAsStream(INSTR_TEST_DATA));
- for (TestPackageDef def : parser.getTestPackageDefs()) {
- assertEquals("com.example", def.getAppNameSpace());
- assertEquals("android.example", def.getAppPackageName());
- assertEquals("android.test.InstrumentationTestRunner", def.getRunner());
- assertTrue(AbiUtils.isAbiSupportedByCompatibility(def.getAbi().getName()));
- }
- }
-
- /**
- * Test parsing test case xml containing an host test attribute and test data.
- */
- public void testParse_hostTest() throws ParseException {
- TestPackageXmlParser parser = new TestPackageXmlParser(true);
- parser.parse(getStringAsStream(HOST_TEST_DATA));
- for (TestPackageDef def : parser.getTestPackageDefs()) {
- assertEquals(TestPackageDef.HOST_SIDE_ONLY_TEST, def.getTestType());
- assertEquals(3, def.getTests().size());
- Iterator<TestIdentifier> iterator = def.getTests().iterator();
-
- TestIdentifier firstTest = iterator.next();
- assertEquals("com.example.ExampleTest", firstTest.getClassName());
- assertEquals("testFoo", firstTest.getTestName());
-
- TestIdentifier secondTest = iterator.next();
- assertEquals("com.example.ExampleTest", secondTest.getClassName());
- assertEquals("testFoo2", secondTest.getTestName());
-
- TestIdentifier thirdTest = iterator.next();
- assertEquals("com.example2.Example2Test", thirdTest.getClassName());
- assertEquals("testFoo", thirdTest.getTestName());
-
- assertFalse(iterator.hasNext());
- }
- }
-
- public void testParse_hostTest_noKnownFailures() throws ParseException {
- TestPackageXmlParser parser = new TestPackageXmlParser(false);
- parser.parse(getStringAsStream(HOST_TEST_DATA));
- for (TestPackageDef def : parser.getTestPackageDefs()) {
- assertEquals(TestPackageDef.HOST_SIDE_ONLY_TEST, def.getTestType());
- assertEquals(2, def.getTests().size());
- Iterator<TestIdentifier> iterator = def.getTests().iterator();
-
- TestIdentifier firstTest = iterator.next();
- assertEquals("com.example.ExampleTest", firstTest.getClassName());
- assertEquals("testFoo", firstTest.getTestName());
-
- TestIdentifier thirdTest = iterator.next();
- assertEquals("com.example2.Example2Test", thirdTest.getClassName());
- assertEquals("testFoo", thirdTest.getTestName());
-
- assertFalse(iterator.hasNext());
- }
- }
-
- /**
- * Test parsing test case xml containing an invalid host test attribute.
- */
- public void testParse_badHostTest() throws ParseException {
- TestPackageXmlParser parser = new TestPackageXmlParser(true);
- parser.parse(getStringAsStream(BAD_HOST_TEST_DATA));
- for (TestPackageDef def : parser.getTestPackageDefs()) {
- assertFalse(TestPackageDef.HOST_SIDE_ONLY_TEST.equals(def.getTestType()));
- }
- }
-
- public void testParse_vmHostTest() throws ParseException {
- assertTestType(TestPackageDef.VM_HOST_TEST, VM_HOST_TEST_XML);
- }
-
- public void testParse_nativeTest() throws ParseException {
- assertTestType(TestPackageDef.NATIVE_TEST, NATIVE_TEST_XML);
- }
-
- private void assertTestType(String expectedType, String xml) throws ParseException {
- TestPackageXmlParser parser = new TestPackageXmlParser(true);
- parser.parse(getStringAsStream(xml));
- for (TestPackageDef def : parser.getTestPackageDefs()) {
- assertEquals(expectedType, def.getTestType());
- }
- }
-
- /**
- * Test parsing a test case xml with no test package data.
- */
- public void testParse_noData() throws ParseException {
- TestPackageXmlParser parser = new TestPackageXmlParser(true);
- parser.parse(getStringAsStream(NO_TEST_DATA));
- assertTrue(parser.getTestPackageDefs().isEmpty());
- }
-
- /**
- * Test parsing a test case xml with multiple test instances
- */
- public void testParse_instancedMultiple() throws ParseException {
- TestPackageXmlParser parser = new TestPackageXmlParser(true);
- parser.parse(getStringAsStream(INSTANCED_TEST_DATA));
- for (TestPackageDef def : parser.getTestPackageDefs()) {
- final TestIdentifier testId =
- new TestIdentifier("com.example.ExampleTest", "testMultiInstanced");
- final List<Map<String, String>> targetInstances =
- def.getTestInstanceArguments().get(testId);
- assertNotNull(targetInstances);
- assertEquals(2, targetInstances.size());
-
- final Iterator<Map<String, String>> iterator = targetInstances.iterator();
- final Map<String, String> firstInstance = iterator.next();
- final Map<String, String> secondInstance = iterator.next();
-
- assertEquals("bar", firstInstance.get("foo"));
- assertEquals("baz", secondInstance.get("foo"));
- assertEquals("baz2", secondInstance.get("foo2"));
- }
- }
-
- /**
- * Test parsing a test case xml with single test instance
- */
- public void testParse_instancedSingle() throws ParseException {
- TestPackageXmlParser parser = new TestPackageXmlParser(true);
- parser.parse(getStringAsStream(INSTANCED_TEST_DATA));
- for (TestPackageDef def : parser.getTestPackageDefs()) {
- final TestIdentifier testId =
- new TestIdentifier("com.example.ExampleTest", "testSingleInstanced");
- final List<Map<String, String>> targetInstances =
- def.getTestInstanceArguments().get(testId);
- assertNotNull(targetInstances);
- assertEquals(1, targetInstances.size());
-
- final Iterator<Map<String, String>> iterator = targetInstances.iterator();
- final Map<String, String> firstInstance = iterator.next();
-
- assertEquals("bar", firstInstance.get("foo"));
- }
- }
-
- /**
- * Test parsing a test case xml with multiple test instances with no data
- */
- public void testParse_instancedEmptys() throws ParseException {
- TestPackageXmlParser parser = new TestPackageXmlParser(true);
- parser.parse(getStringAsStream(INSTANCED_TEST_DATA));
- for (TestPackageDef def : parser.getTestPackageDefs()) {
- final TestIdentifier testId =
- new TestIdentifier("com.example.ExampleTest", "testEmptyInstances");
- final List<Map<String, String>> targetInstances =
- def.getTestInstanceArguments().get(testId);
- assertNotNull(targetInstances);
- assertEquals(2, targetInstances.size());
-
- final Iterator<Map<String, String>> iterator = targetInstances.iterator();
- final Map<String, String> firstInstance = iterator.next();
- final Map<String, String> secondInstance = iterator.next();
-
- assertTrue(firstInstance.isEmpty());
- assertTrue(secondInstance.isEmpty());
- }
- }
-
- /**
- * Test parsing a test case xml with no test instances
- */
- public void testParse_instancedNoInstances() throws ParseException {
- TestPackageXmlParser parser = new TestPackageXmlParser(true);
- parser.parse(getStringAsStream(INSTANCED_TEST_DATA));
- for (TestPackageDef def : parser.getTestPackageDefs()) {
- final TestIdentifier testId =
- new TestIdentifier("com.example.ExampleTest", "testNotInstanced");
- final List<Map<String, String>> targetInstances =
- def.getTestInstanceArguments().get(testId);
- assertNotNull(targetInstances);
- assertTrue(targetInstances.isEmpty());
- }
- }
-
- private InputStream getStringAsStream(String input) {
- return new ByteArrayInputStream(input.getBytes());
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPlanTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPlanTest.java
deleted file mode 100644
index c2d970b..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPlanTest.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Unit tests for {@link TestPlan}.
- */
-public class TestPlanTest extends TestCase {
-
- private static final String TEST_NAME1 = "foo";
- private static final String TEST_NAME2 = "foo2";
- private static final String EXCLUDE_TEST_CLASS = "com.example.FooTest";
- private static final String EXCLUDE_TEST_METHOD = "testFoo";
- private static final String EXCLUDE_TEST_METHOD2 = "testFoo2";
-
- static final String EMPTY_DATA = "<TestPlan version=\"1.0\" />";
-
- static final String TEST_DATA =
- "<TestPlan version=\"1.0\">" +
- String.format("<Entry name=\"%s\" />", TEST_NAME1) +
- String.format("<Entry name=\"%s\" />", TEST_NAME2) +
- "</TestPlan>";
-
- static final String TEST_EXCLUDED_DATA =
- "<TestPlan version=\"1.0\">" +
- String.format("<Entry name=\"%s\" exclude=\"%s#%s\" />", TEST_NAME1, EXCLUDE_TEST_CLASS,
- EXCLUDE_TEST_METHOD) +
- "</TestPlan>";
-
- static final String TEST_MULTI_EXCLUDED_DATA =
- "<TestPlan version=\"1.0\">" +
- String.format("<Entry name=\"%s\" exclude=\"%s#%s;%s#%s\" />", TEST_NAME1,
- EXCLUDE_TEST_CLASS, EXCLUDE_TEST_METHOD, EXCLUDE_TEST_CLASS,
- EXCLUDE_TEST_METHOD2) +
- "</TestPlan>";
-
- static final String TEST_CLASS_EXCLUDED_DATA =
- "<TestPlan version=\"1.0\">" +
- String.format("<Entry name=\"%s\" exclude=\"%s\" />", TEST_NAME1,
- EXCLUDE_TEST_CLASS) +
- "</TestPlan>";
-
- private TestPlan mPlan;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mPlan = new TestPlan("plan", AbiUtils.getAbisSupportedByCompatibility());
- }
-
- /**
- * Simple test for parsing a plan containing two names
- */
- public void testParse() throws ParseException {
- mPlan.parse(getStringAsStream(TEST_DATA));
- assertTestData(mPlan);
- }
-
- /**
- * Perform checks to ensure TEST_DATA was parsed correctly
- * @param plan
- */
- private void assertTestData(TestPlan plan) {
- Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
- assertEquals(2 * abis.size(), plan.getTestIds().size());
- List<String> sortedAbis = new ArrayList<String>(abis);
- Collections.sort(sortedAbis);
- Iterator<String> iter = plan.getTestIds().iterator();
- for (String abi : sortedAbis) {
- String test1Id = AbiUtils.createId(abi, TEST_NAME1);
- String test2Id = AbiUtils.createId(abi, TEST_NAME2);
- // assert names in order
- assertEquals(test1Id, iter.next());
- assertEquals(test2Id, iter.next());
- assertFalse(plan.getTestFilter(test1Id).hasExclusion());
- assertFalse(plan.getTestFilter(test2Id).hasExclusion());
- }
- }
-
- /**
- * Test parsing a plan containing a single excluded test
- */
- public void testParse_exclude() throws ParseException {
- mPlan.parse(getStringAsStream(TEST_EXCLUDED_DATA));
- Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
- assertEquals(abis.size(), mPlan.getTestIds().size());
-
- for (String abi : abis) {
- String test1Id = AbiUtils.createId(abi, TEST_NAME1);
- TestFilter filter = mPlan.getTestFilter(test1Id);
- assertTrue(filter.getExcludedTests().contains(new TestIdentifier(EXCLUDE_TEST_CLASS,
- EXCLUDE_TEST_METHOD)));
- }
- }
-
- /**
- * Test parsing a plan containing multiple excluded tests
- */
- public void testParse_multiExclude() throws ParseException {
- mPlan.parse(getStringAsStream(TEST_MULTI_EXCLUDED_DATA));
- assertMultiExcluded(mPlan);
- }
-
- /**
- * Perform checks to ensure TEST_MULTI_EXCLUDED_DATA was parsed correctly
- * @param plan
- */
- private void assertMultiExcluded(TestPlan plan) {
- Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
- assertEquals(abis.size(), plan.getTestIds().size());
-
- for (String abi : abis) {
- String test1Id = AbiUtils.createId(abi, TEST_NAME1);
- TestFilter filter = plan.getTestFilter(test1Id);
- assertTrue(filter.getExcludedTests().contains(new TestIdentifier(EXCLUDE_TEST_CLASS,
- EXCLUDE_TEST_METHOD)));
- assertTrue(filter.getExcludedTests().contains(new TestIdentifier(EXCLUDE_TEST_CLASS,
- EXCLUDE_TEST_METHOD2)));
- }
- }
-
- /**
- * Test parsing a plan containing an excluded class
- */
- public void testParse_classExclude() throws ParseException {
- mPlan.parse(getStringAsStream(TEST_CLASS_EXCLUDED_DATA));
- Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
- assertEquals(abis.size(), mPlan.getTestIds().size());
-
- for (String abi : abis) {
- String test1Id = AbiUtils.createId(abi, TEST_NAME1);
- TestFilter filter = mPlan.getTestFilter(test1Id);
- assertTrue(filter.getExcludedClasses().contains(EXCLUDE_TEST_CLASS));
- }
- }
-
- /**
- * Test serializing an empty plan
- * @throws IOException
- */
- public void testSerialize_empty() throws IOException {
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- mPlan.serialize(outStream);
- assertTrue(outStream.toString().contains(EMPTY_DATA));
- }
-
- /**
- * Test serializing and deserializing plan with two packages
- * @throws IOException
- */
- public void testSerialize_packages() throws ParseException, IOException {
- Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
- for (String abi : abis) {
- mPlan.addPackage(AbiUtils.createId(abi, TEST_NAME1));
- mPlan.addPackage(AbiUtils.createId(abi, TEST_NAME2));
- }
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- mPlan.serialize(outStream);
- TestPlan parsedPlan = new TestPlan("parsed", AbiUtils.getAbisSupportedByCompatibility());
- parsedPlan.parse(getStringAsStream(outStream.toString()));
- // parsedPlan should contain same contents as TEST_DATA
- assertTestData(parsedPlan);
- }
-
- /**
- * Test serializing and deserializing plan with multiple excluded tests
- */
- public void testSerialize_multiExclude() throws ParseException, IOException {
- Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
-
- for (String abi : abis) {
- String test1Id = AbiUtils.createId(abi, TEST_NAME1);
- mPlan.addPackage(test1Id);
- mPlan.addExcludedTest(test1Id, new TestIdentifier(EXCLUDE_TEST_CLASS,
- EXCLUDE_TEST_METHOD));
- mPlan.addExcludedTest(test1Id, new TestIdentifier(EXCLUDE_TEST_CLASS,
- EXCLUDE_TEST_METHOD2));
- }
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- mPlan.serialize(outStream);
- TestPlan parsedPlan = new TestPlan("parsed", AbiUtils.getAbisSupportedByCompatibility());
- parsedPlan.parse(getStringAsStream(outStream.toString()));
- // parsedPlan should contain same contents as TEST_DATA
- assertMultiExcluded(parsedPlan);
- }
-
- private InputStream getStringAsStream(String input) {
- return new ByteArrayInputStream(input.getBytes());
- }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/WrappedGTestResultParserTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/WrappedGTestResultParserTest.java
deleted file mode 100644
index d386c7a..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/WrappedGTestResultParserTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.ITestRunListener;
-
-import junit.framework.TestCase;
-
-
-
-/**
- * Unit tests for {@link WrappedGTestResultParser}.
- */
-public class WrappedGTestResultParserTest extends TestCase {
-
- private WrappedGTestResultParser mParser;
- private final String[] INPUT1 = new String[] {
- "INSTRUMENTATION_STATUS: gtest=[==========] Running 9 tests from 2 test cases.",
- "INSTRUMENTATION_STATUS_CODE: 1",
- "INSTRUMENTATION_STATUS: gtest=[ RUN ] GLTest.Test1",
- "INSTRUMENTATION_STATUS: gtest=[ OK ] GLTest.Test1 (10 ms)",
- "INSTRUMENTATION_STATUS: gtest=/tests/SomeTestFile.cpp:1337: Failure",
- "Value of: 1 == 0",
- " Actual: false",
- "Expected: true",
- "INSTRUMENTATION_STATUS: gtest=[ FAILED ] GLTest.Test2 (1016 ms)",
- "INSTRUMENTATION_STATUS: gtest=[==========] 2 tests from 1 test cases ran. (17 ms total)",
- "INSTRUMENTATION_CODE: -1"
- };
-
- private final String[] EXPECTED_OUTPUT1 = new String[] {
- "[==========] Running 9 tests from 2 test cases.",
- "[ RUN ] GLTest.Test1",
- "[ OK ] GLTest.Test1 (10 ms)",
- "/tests/SomeTestFile.cpp:1337: Failure",
- "Value of: 1 == 0",
- " Actual: false",
- "Expected: true",
- "[ FAILED ] GLTest.Test2 (1016 ms)",
- "[==========] 2 tests from 1 test cases ran. (17 ms total)",
- };
-
- private final String[] INPUT2 = new String[] {
- "INSTRUMENTATION_STATUS_CODE: 1",
- "invalid text",
- "INSTRUMENTATION_STATUS: gtest=[==========] Running 9 tests from 2 test cases.",
- "INSTRUMENTATION_RESULT: some error",
- "INSTRUMENTATION_STATUS: gtest=[ RUN ] GLTest.ExpectTestThatShouldBeSuccessful",
- };
-
- private final String[] EXPECTED_OUTPUT2 = new String[] {
- "[==========] Running 9 tests from 2 test cases.",
- };
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mParser = new WrappedGTestResultParser("unused", (ITestRunListener)null);
- }
-
- private void assertArrayEquals(String[] expected, String[] result) throws Exception {
- if (expected == null) {
- assertNull(result);
- return;
- }
-
- assertEquals(expected.length, result.length);
-
- for (int i = 0; i < expected.length; i++) {
- assertEquals(expected[i], result[i]);
- }
- }
-
- /**
- * Test normal case {@link WrappedGTestResultParser#getRawGTestOutput(java.lang.String[])}
- * with all kinds of valid input lines.
- */
- public void testGetRawGTestOutput_valid() throws Exception {
- assertArrayEquals(EXPECTED_OUTPUT1, mParser.parseInstrumentation(INPUT1));
- }
-
- /**
- * Test normal case {@link WrappedGTestResultParser#getRawGTestOutput(java.lang.String[])}
- * with a instrumentation error/invalid input.
- */
- public void testGetRawGTestOutput_invalid() throws Exception {
- assertArrayEquals(EXPECTED_OUTPUT2, mParser.parseInstrumentation(INPUT2));
- }
-}