[automerger skipped] Merge "[RESTRICT AUTOMERGE] Exclude @SecurityTest tests from CTS. These are tested in STS." into pie-cts-dev am: fdd7b291a9 -s ours am: df718505b9 -s ours am: cb7abfb721 am: ab5bbc3f33 -s ours am: 0922ca7a43
Original change: https://android-review.googlesource.com/c/platform/test/suite_harness/+/1595512
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: Ib4cd9c0485760c630e00db9b62a70afebca8d0c6
diff --git a/OWNERS b/OWNERS
index 07967d1..e6419de 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,15 +1,5 @@
-# Android EngProd Approvers
+# Suite test harness Approvers
+dshi@google.com
+frankfeng@google.com
guangzhu@google.com
-fdeng@google.com
-moonk@google.com
jdesprez@google.com
-sbasi@google.com
-
-# Android Partner Eng Approvers
-aaronholden@google.com
-yuji@google.com
-nickrose@google.com
-
-# File Specific Approvers
-per-file Backup* = alsutton@google.com, anniemeng@google.com, brufino@google.com, nathch@google.com, rthakohov@google.com
-per-file cts-meerkat.xml = alanstokes@google.com, brufino@google.com, lus@google.com, rickywai@google.com
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index 12604f9..2cabacc 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -8,4 +8,4 @@
[Hook Scripts]
# `^.` is a RegExr that matches any character at the beginning, so this hook
# is basically applied to ALL files in a git commit.
-aospcheck_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "^."
+aospcheck_hook = ${REPO_ROOT}/tools/tradefederation/core/aosp_sha.sh ${PREUPLOAD_COMMIT} "^."
diff --git a/build/Android.bp b/build/Android.bp
deleted file mode 100644
index fcf438f..0000000
--- a/build/Android.bp
+++ /dev/null
@@ -1,16 +0,0 @@
-bootstrap_go_package {
- name: "soong-suite-harness",
- pkgPath: "android/soong/suite_harness",
- deps: [
- "blueprint",
- "blueprint-pathtools",
- "blueprint-proptools",
- "soong",
- "soong-android",
- "soong-java",
- ],
- srcs: [
- "tradefed_binary.go",
- ],
- pluginFor: ["soong_build"],
-}
diff --git a/build/tradefed_binary.go b/build/tradefed_binary.go
deleted file mode 100644
index 8598458..0000000
--- a/build/tradefed_binary.go
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright 2018 Google Inc. All rights reserved.
-//
-// 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 suite_harness
-
-import (
- "strings"
-
- "github.com/google/blueprint"
-
- "android/soong/android"
- "android/soong/java"
-)
-
-var pctx = android.NewPackageContext("android/soong/suite_harness")
-
-func init() {
- android.RegisterModuleType("tradefed_binary_host", tradefedBinaryFactory)
-
- pctx.Import("android/soong/android")
-}
-
-type TradefedBinaryProperties struct {
- Short_name string
- Full_name string
- Version string
- Prepend_platform_version_name bool
-}
-
-// tradefedBinaryFactory creates an empty module for the tradefed_binary module type,
-// which is a java_binary with some additional processing in tradefedBinaryLoadHook.
-func tradefedBinaryFactory() android.Module {
- props := &TradefedBinaryProperties{}
- module := java.BinaryHostFactory()
- module.AddProperties(props)
- android.AddLoadHook(module, tradefedBinaryLoadHook(props))
-
- return module
-}
-
-const genSuffix = "-gen"
-
-// tradefedBinaryLoadHook adds extra resources and libraries to tradefed_binary modules.
-func tradefedBinaryLoadHook(tfb *TradefedBinaryProperties) func(ctx android.LoadHookContext) {
- return func(ctx android.LoadHookContext) {
- genName := ctx.ModuleName() + genSuffix
- version := tfb.Version
- if (tfb.Prepend_platform_version_name) {
- version = ctx.Config().PlatformVersionName() + tfb.Version
- }
-
- // Create a submodule that generates the test-suite-info.properties file
- // and copies DynamicConfig.xml if it is present.
- ctx.CreateModule(tradefedBinaryGenFactory,
- &TradefedBinaryGenProperties{
- Name: &genName,
- Short_name: tfb.Short_name,
- Full_name: tfb.Full_name,
- Version: version,
- })
-
- props := struct {
- Java_resources []string
- Libs []string
- }{}
-
- // Add dependencies required by all tradefed_binary modules.
- props.Libs = []string{
- "tradefed",
- "tradefed-test-framework",
- "loganalysis",
- "hosttestlib",
- "compatibility-host-util",
- }
-
- // Add the files generated by the submodule created above to the resources.
- props.Java_resources = []string{":" + genName}
-
- ctx.AppendProperties(&props)
-
- }
-}
-
-type TradefedBinaryGenProperties struct {
- Name *string
- Short_name string
- Full_name string
- Version string
-}
-
-type tradefedBinaryGen struct {
- android.ModuleBase
-
- properties TradefedBinaryGenProperties
-
- gen android.Paths
-}
-
-func tradefedBinaryGenFactory() android.Module {
- tfg := &tradefedBinaryGen{}
- tfg.AddProperties(&tfg.properties)
- android.InitAndroidModule(tfg)
- return tfg
-}
-
-func (tfg *tradefedBinaryGen) DepsMutator(android.BottomUpMutatorContext) {}
-
-var tradefedBinaryGenRule = pctx.StaticRule("tradefedBinaryGenRule", blueprint.RuleParams{
- Command: `rm -f $out && touch $out && ` +
- `echo "# This file is auto generated by Android.mk. Do not modify." >> $out && ` +
- `echo "build_number = $$(cat ${buildNumberFile})" >> $out && ` +
- `echo "target_arch = ${arch}" >> $out && ` +
- `echo "name = ${name}" >> $out && ` +
- `echo "fullname = ${fullname}" >> $out && ` +
- `echo "version = ${version}" >> $out`,
-}, "buildNumberFile", "arch", "name", "fullname", "version")
-
-func (tfg *tradefedBinaryGen) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- buildNumberFile := ctx.Config().BuildNumberFile(ctx)
- outputFile := android.PathForModuleOut(ctx, "test-suite-info.properties")
- ctx.Build(pctx, android.BuildParams{
- Rule: tradefedBinaryGenRule,
- Output: outputFile,
- OrderOnly: android.Paths{buildNumberFile},
- Args: map[string]string{
- "buildNumberFile": buildNumberFile.String(),
- "arch": ctx.Config().DevicePrimaryArchType().String(),
- "name": tfg.properties.Short_name,
- "fullname": tfg.properties.Full_name,
- "version": tfg.properties.Version,
- },
- })
-
- tfg.gen = append(tfg.gen, outputFile)
-
- dynamicConfig := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "DynamicConfig.xml")
- if dynamicConfig.Valid() {
- outputFile := android.PathForModuleOut(ctx, strings.TrimSuffix(ctx.ModuleName(), genSuffix)+".dynamic")
- ctx.Build(pctx, android.BuildParams{
- Rule: android.Cp,
- Input: dynamicConfig.Path(),
- Output: outputFile,
- })
-
- tfg.gen = append(tfg.gen, outputFile)
- }
-}
-
-func (tfg *tradefedBinaryGen) Srcs() android.Paths {
- return append(android.Paths(nil), tfg.gen...)
-}
-
-var _ android.SourceFileProducer = (*tradefedBinaryGen)(nil)
diff --git a/common/host-side/manifest-generator/Android.bp b/common/host-side/manifest-generator/Android.bp
deleted file mode 100644
index 9d6cdb8..0000000
--- a/common/host-side/manifest-generator/Android.bp
+++ /dev/null
@@ -1,25 +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.
-
-java_library_host {
- name: "compatibility-manifest-generator",
-
- srcs: ["src/**/*.java"],
-
- static_libs: ["kxml2-2.3.0"],
-
- manifest: "MANIFEST.mf",
-
- use_tools_jar: true,
-}
diff --git a/common/host-side/manifest-generator/MANIFEST.mf b/common/host-side/manifest-generator/MANIFEST.mf
deleted file mode 100644
index 4f62631..0000000
--- a/common/host-side/manifest-generator/MANIFEST.mf
+++ /dev/null
@@ -1,2 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.android.compatibility.common.generator.ManifestGenerator
diff --git a/common/host-side/manifest-generator/src/com/android/compatibility/common/generator/ManifestGenerator.java b/common/host-side/manifest-generator/src/com/android/compatibility/common/generator/ManifestGenerator.java
deleted file mode 100644
index 6e48ca9..0000000
--- a/common/host-side/manifest-generator/src/com/android/compatibility/common/generator/ManifestGenerator.java
+++ /dev/null
@@ -1,148 +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.compatibility.common.generator;
-
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.kxml2.io.KXmlSerializer;
-
-public class ManifestGenerator {
-
- private static final String DEFAULT_MIN_SDK = "8";
-
- private static final String USAGE = "Usage: "
- + "manifest-generator -n NAME -p PACKAGE_NAME -o OUTPUT_FILE -i INSTRUMENT_NAME "
- + "[-s MIN_SDK_VERSION] [-t TARGET_SDK_VERSION] [-r PERMISSION]+ [-a ACTIVITY]+";
- private static final String MANIFEST = "manifest";
- private static final String USES_SDK = "uses-sdk";
- private static final String USES_PERMISSION = "uses-permission";
- private static final String APPLICATION = "application";
- private static final String INSTRUMENTATION = "instrumentation";
- private static final String ACTIVITY = "activity";
- private static final String USES_LIBRARY = "uses-library";
-
- public static void main(String[] args) {
- String pkgName = null;
- String instrumentName = null;
- String minSdk = DEFAULT_MIN_SDK;
- String targetSdk = null;
- List<String> permissions = new ArrayList<>();
- List<String> activities = new ArrayList<>();
- List<String> libraries = new ArrayList<>();
- String output = null;
-
- for (int i = 0; i < args.length - 1; i++) {
- if (args[i].equals("-p")) {
- pkgName = args[++i];
- } else if (args[i].equals("-a")) {
- activities.add(args[++i]);
- } else if (args[i].equals("-l")) {
- libraries.add(args[++i]);
- } else if (args[i].equals("-o")) {
- output = args[++i];
- } else if (args[i].equals("-i")) {
- instrumentName = args[++i];
- } else if (args[i].equals("-r")) {
- permissions.add(args[++i]);
- } else if (args[i].equals("-s")) {
- minSdk = args[++i];
- } else if (args[i].equals("-t")) {
- targetSdk = args[++i];
- }
- }
-
- if (pkgName == null) {
- error("Missing package name");
- } else if (instrumentName == null) {
- error("Missing instrumentation name");
- } else if (activities.isEmpty()) {
- error("No activities");
- } else if (output == null) {
- error("Missing output file");
- }
-
- FileOutputStream out = null;
- try {
- out = new FileOutputStream(output);
- generate(out, pkgName, instrumentName, minSdk, targetSdk, permissions, activities,
- libraries);
- } catch (Exception e) {
- System.err.println("Couldn't create manifest file");
- } finally {
- if (out != null) {
- try {
- out.close();
- } catch (Exception e) {
- // Ignore
- }
- }
- }
- }
-
- /*package*/ static void generate(OutputStream out, String pkgName, String instrumentName,
- String minSdk, String targetSdk, List<String> permissions, List<String> activities,
- List<String> libraries)
- throws Exception {
- final String ns = null;
- KXmlSerializer serializer = new KXmlSerializer();
- serializer.setOutput(out, "UTF-8");
- serializer.startDocument("UTF-8", true);
- serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
- serializer.startTag(ns, MANIFEST);
- serializer.attribute(ns, "xmlns:android", "http://schemas.android.com/apk/res/android");
- serializer.attribute(ns, "package", pkgName);
- serializer.startTag(ns, USES_SDK);
- serializer.attribute(ns, "android:minSdkVersion", minSdk);
- if (targetSdk != null) {
- serializer.attribute(ns, "android:targetSdkVersion", targetSdk);
- }
- serializer.endTag(ns, USES_SDK);
- for (String permission : permissions) {
- serializer.startTag(ns, USES_PERMISSION);
- serializer.attribute(ns, "android:name", permission);
- serializer.endTag(ns, USES_PERMISSION);
- }
- serializer.startTag(ns, APPLICATION);
- for (String library : libraries) {
- serializer.startTag(ns, USES_LIBRARY);
- serializer.attribute(ns, "android:name", library);
- serializer.endTag(ns, USES_LIBRARY);
- }
- for (String activity : activities) {
- serializer.startTag(ns, ACTIVITY);
- serializer.attribute(ns, "android:name", activity);
- serializer.endTag(ns, ACTIVITY);
- }
- serializer.endTag(ns, APPLICATION);
- serializer.startTag(ns, INSTRUMENTATION);
- serializer.attribute(ns, "android:name", instrumentName);
- serializer.attribute(ns, "android:targetPackage", pkgName);
- serializer.endTag(ns, INSTRUMENTATION);
- serializer.endTag(ns, MANIFEST);
- serializer.endDocument();
- out.flush();
- }
-
- private static void error(String message) {
- System.err.println(message);
- System.err.println(USAGE);
- System.exit(1);
- }
-}
diff --git a/common/host-side/manifest-generator/tests/Android.bp b/common/host-side/manifest-generator/tests/Android.bp
deleted file mode 100644
index b8f012d..0000000
--- a/common/host-side/manifest-generator/tests/Android.bp
+++ /dev/null
@@ -1,24 +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.
-
-java_test_host {
- name: "compatibility-manifest-generator-tests",
-
- srcs: ["src/**/*.java"],
-
- libs: [
- "compatibility-manifest-generator",
- "junit",
- ],
-}
diff --git a/common/host-side/manifest-generator/tests/run_tests.sh b/common/host-side/manifest-generator/tests/run_tests.sh
deleted file mode 100755
index 0a77a9b..0000000
--- a/common/host-side/manifest-generator/tests/run_tests.sh
+++ /dev/null
@@ -1,27 +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 unit tests for compatibility libraries
-
-HARNESS_DIR=$(dirname ${0})/../../../..
-source ${HARNESS_DIR}/test_defs.sh
-
-JARS="
- compatibility-manifest-generator\
- compatibility-manifest-generator-tests"
-
-run_tests "com.android.compatibility.common.generator.ManifestGeneratorTest" "${JARS}" "${@}"
-
diff --git a/common/host-side/manifest-generator/tests/src/com/android/compatibility/common/generator/ManifestGeneratorTest.java b/common/host-side/manifest-generator/tests/src/com/android/compatibility/common/generator/ManifestGeneratorTest.java
deleted file mode 100644
index b68b34c..0000000
--- a/common/host-side/manifest-generator/tests/src/com/android/compatibility/common/generator/ManifestGeneratorTest.java
+++ /dev/null
@@ -1,87 +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.compatibility.common.generator;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-/** Unit tests for {@link ManifestGenerator}. */
-public class ManifestGeneratorTest extends TestCase {
-
- private static final String PACKAGE = "test.package";
- private static final String INSTRUMENT = "test.package.TestInstrument";
- private static final String MIN_SDK = "8";
- private static final String TARGET_SDK = "17";
- private static final String MANIFEST = "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\r\n"
- + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" "
- + "package=\"test.package\">\r\n"
- + " <uses-sdk android:minSdkVersion=\"8\" android:targetSdkVersion=\"17\" />\r\n"
- + "%s"
- + " <application>\r\n"
- + "%s"
- + "%s"
- + " </application>\r\n"
- + " <instrumentation android:name=\"test.package.TestInstrument\" "
- + "android:targetPackage=\"test.package\" />\r\n"
- + "</manifest>";
- private static final String PERMISSION = " <uses-permission android:name=\"%s\" />\r\n";
- private static final String PERMISSION_A = "android.permission.PermissionA";
- private static final String PERMISSION_B = "android.permission.PermissionB";
- private static final String ACTIVITY = " <activity android:name=\"%s\" />\r\n";
- private static final String ACTIVITY_A = "test.package.ActivityA";
- private static final String ACTIVITY_B = "test.package.ActivityB";
- private static final String USES_LIBRARY = " <uses-library android:name=\"%s\" />\r\n";
- private static final String LIBRARY = "test.runner.library";
-
- public void testManifest() throws Exception {
- List<String> permissions = new ArrayList<>();
- permissions.add(PERMISSION_A);
- permissions.add(PERMISSION_B);
- List<String> activities = new ArrayList<>();
- activities.add(ACTIVITY_A);
- activities.add(ACTIVITY_B);
- List<String> libraries = new ArrayList<>();
- libraries.add(LIBRARY);
- OutputStream output = new OutputStream() {
- private StringBuilder string = new StringBuilder();
- @Override
- public void write(int b) throws IOException {
- this.string.append((char) b);
- }
-
- @Override
- public String toString(){
- return this.string.toString();
- }
- };
- ManifestGenerator.generate(output, PACKAGE, INSTRUMENT, MIN_SDK, TARGET_SDK,
- permissions, activities, libraries);
- String permissionXml = String.format(PERMISSION, PERMISSION_A)
- + String.format(PERMISSION, PERMISSION_B);
- String activityXml = String.format(ACTIVITY, ACTIVITY_A)
- + String.format(ACTIVITY, ACTIVITY_B);
- String libraryXml = String.format(USES_LIBRARY, LIBRARY);
- String expected = String.format(MANIFEST, permissionXml, libraryXml, activityXml);
- assertEquals("Wrong manifest output", expected, output.toString());
- }
-
-}
diff --git a/common/host-side/tradefed/.classpath b/common/host-side/tradefed/.classpath
index 8786b5a..400fb70 100644
--- a/common/host-side/tradefed/.classpath
+++ b/common/host-side/tradefed/.classpath
@@ -12,7 +12,6 @@
<classpathentry kind="lib" path="tests/res/testtype/testJar1.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
<classpathentry combineaccessrules="false" kind="src" path="/tradefederation"/>
- <classpathentry combineaccessrules="false" kind="src" path="/cts-common-util"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry combineaccessrules="false" kind="src" path="/cts-hostside-util"/>
<classpathentry kind="var" path="TRADEFED_ROOT/out/soong/.intermediates/prebuilts/misc/common/json/json-prebuilt/linux_glibc_common/combined/json-prebuilt.jar"/>
@@ -21,5 +20,6 @@
<classpathentry kind="var" path="TRADEFED_ROOT/prebuilts/tools/common/google-api-java-client/1.23.0/google-api-java-client-min-repackaged-1.23.0.jar"/>
<classpathentry kind="var" path="TRADEFED_ROOT/prebuilts/tools/common/m2/repository/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar"/>
<classpathentry kind="var" path="TRADEFED_ROOT/out/soong/.intermediates/external/guava/guava-jre/linux_glibc_common/combined/guava-jre.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/cts-common-util"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/common/host-side/tradefed/res/config/cts-unit-tests.xml b/common/host-side/tradefed/res/config/cts-unit-tests.xml
deleted file mode 100644
index fabdb25..0000000
--- a/common/host-side/tradefed/res/config/cts-unit-tests.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Executes the CTS unit tests">
- <option name="null-device" value="true" />
- <build_provider class="com.android.tradefed.build.StubBuildProvider" />
- <test class="com.android.tradefed.testtype.HostTest" >
- <option name="class" value="com.android.compatibility.common.tradefed.UnitTests" />
- <option name="class" value="com.android.compatibility.common.util.HostUnitTests" />
- <option name="class" value="com.android.compatibility.common.util.UnitTests" />
- <option name="class" value="com.android.compatibility.tradefed.CtsTradefedTest" />
- <option name="class" value="com.drawelements.deqp.runner.DeqpTestRunnerTest" />
- </test>
- <logger class="com.android.tradefed.log.FileLogger" />
-
- <result_reporter class="com.android.tradefed.result.ConsoleResultReporter">
- <option name="suppress-passed-tests" value="true" />
- </result_reporter>
- <template-include name="reporters" default="empty" />
-</configuration>
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java
index 696423a..69bfb30 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java
@@ -19,7 +19,6 @@
import com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider;
import com.android.compatibility.common.tradefed.result.SubPlanHelper;
import com.android.compatibility.common.tradefed.result.suite.CertificationResultXml;
-import com.android.compatibility.common.tradefed.testtype.ModuleRepo;
import com.android.compatibility.common.tradefed.testtype.suite.CompatibilityTestSuite;
import com.android.compatibility.common.util.ResultHandler;
import com.android.tradefed.build.BuildRetrievalError;
@@ -30,14 +29,14 @@
import com.android.tradefed.config.ConfigurationFactory;
import com.android.tradefed.config.IConfiguration;
import com.android.tradefed.config.IConfigurationFactory;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.suite.SuiteResultHolder;
import com.android.tradefed.testtype.Abi;
import com.android.tradefed.testtype.IAbi;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.testtype.IRuntimeHintProvider;
+import com.android.tradefed.testtype.suite.ITestSuite;
+import com.android.tradefed.testtype.suite.SuiteModuleLoader;
import com.android.tradefed.testtype.suite.TestSuiteInfo;
import com.android.tradefed.testtype.suite.params.ModuleParameters;
import com.android.tradefed.util.AbiUtils;
@@ -280,19 +279,15 @@
* @param moduleParameter The parameter requested to be displayed. Null if all should be shown.
*/
private void listModules(String moduleParameter) {
- CompatibilityTestSuite test = new CompatibilityTestSuite() {
- @Override
- public Set<IAbi> getAbis(ITestDevice device) throws DeviceNotAvailableException {
- Set<String> abiStrings = getAbisForBuildTargetArch();
- Set<IAbi> abis = new LinkedHashSet<>();
- for (String abi : abiStrings) {
- if (AbiUtils.isAbiSupportedByCompatibility(abi)) {
- abis.add(new Abi(abi, AbiUtils.getBitness(abi)));
- }
- }
- return abis;
+ CompatibilityTestSuite test = new CompatibilityTestSuite();
+ Set<String> abiStrings = ITestSuite.getAbisForBuildTargetArchFromSuite();
+ Set<IAbi> abis = new LinkedHashSet<>();
+ for (String abi : abiStrings) {
+ if (AbiUtils.isAbiSupportedByCompatibility(abi)) {
+ abis.add(new Abi(abi, AbiUtils.getBitness(abi)));
}
- };
+ }
+ test.setAbis(abis);
if (getBuild() != null) {
test.setEnableParameterizedModules(true);
test.setEnableOptionalParameterizedModules(true);
@@ -315,7 +310,7 @@
private void splitModules(int shards) {
File[] files = null;
try {
- files = getBuildHelper().getTestsDir().listFiles(new ModuleRepo.ConfigFilter());
+ files = getBuildHelper().getTestsDir().listFiles(new SuiteModuleLoader.ConfigFilter());
} catch (FileNotFoundException e) {
printLine(e.getMessage());
e.printStackTrace();
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/IModuleListener.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/IModuleListener.java
deleted file mode 100644
index 213d293..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/IModuleListener.java
+++ /dev/null
@@ -1,27 +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.compatibility.common.tradefed.result;
-
-import com.android.tradefed.result.ITestInvocationListener;
-
-/**
- * Listener for Compatibility tests.
- * <p>
- * This listener wraps around the normal listener to convert from module name to module id.
- */
-public interface IModuleListener extends ITestInvocationListener {
-
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/InvocationFailureHandler.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/InvocationFailureHandler.java
deleted file mode 100644
index abbf14c..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/InvocationFailureHandler.java
+++ /dev/null
@@ -1,71 +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.compatibility.common.tradefed.result;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.util.FileUtil;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-
-/**
- * A helper class for setting and checking whether an invocation has failed.
- */
-public class InvocationFailureHandler {
-
- /**
- * Determine whether the invocation for this session has previously failed.
- *
- * @param buildHelper the {@link CompatibilityBuildHelper} from which to retrieve invocation
- * failure file
- * @return if invocation has previously failed
- */
- public static boolean hasFailed(final CompatibilityBuildHelper buildHelper) {
- try {
- File f = buildHelper.getInvocationFailureFile();
- return (f.exists() && f.length() != 0);
- } catch (FileNotFoundException e) {
- CLog.e("Could not find invocation failure file for session %s",
- CompatibilityBuildHelper.getDirSuffix(buildHelper.getStartTime()));
- CLog.e(e);
- return false;
- }
- }
-
- /**
- * Write the cause of invocation failure to the result's invocation failure file.
- *
- * @param buildHelper the {@link CompatibilityBuildHelper} from which to retrieve the
- * invocation failure file
- * @param cause the throwable responsible for invocation failure
- */
- public static void setFailed(final CompatibilityBuildHelper buildHelper, Throwable cause) {
- try {
- File f = buildHelper.getInvocationFailureFile();
- if (!f.exists()) {
- f.createNewFile();
- }
- // Append to previous failures to get them all.
- FileUtil.writeToFile(cause.toString(), f, true);
- } catch (IOException e) {
- CLog.e("Exception while writing invocation failure file.");
- CLog.e(e);
- }
- }
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ModuleListener.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ModuleListener.java
deleted file mode 100644
index e37f608..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ModuleListener.java
+++ /dev/null
@@ -1,184 +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.compatibility.common.tradefed.result;
-
-import com.android.compatibility.common.tradefed.testtype.IModuleDef;
-import com.android.tradefed.invoker.IInvocationContext;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.InputStreamSource;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.TestDescription;
-import com.android.tradefed.result.TestSummary;
-import com.android.tradefed.util.proto.TfMetricProtoUtil;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Listener for Compatibility test info.
- * <p>
- * This listener wraps around the normal listener to convert from module name to module id.
- */
-public class ModuleListener implements IModuleListener {
-
- private IModuleDef mModule;
- private ITestInvocationListener mListener;
-
- /**
- * @param module
- * @param listener
- */
- public ModuleListener(IModuleDef module, ITestInvocationListener listener) {
- mModule = module;
- mListener = listener;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void invocationStarted(IInvocationContext context) {
- CLog.d("ModuleListener.invocationStarted(%s)", context.getBuildInfos());
- mListener.invocationStarted(context);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunStarted(String name, int numTests) {
- CLog.d("ModuleListener.testRunStarted(%s, %d)", name, numTests);
- mListener.testRunStarted(mModule.getId(), numTests);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testStarted(TestDescription test) {
- CLog.d("ModuleListener.testStarted(%s)", test.toString());
- mListener.testStarted(test);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testEnded(TestDescription test, HashMap<String, Metric> metrics) {
- CLog.d("ModuleListener.testEnded(%s, %s)", test.toString(), metrics.toString());
- mListener.testEnded(test, metrics);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testIgnored(TestDescription test) {
- CLog.d("ModuleListener.testIgnored(%s)", test.toString());
- mListener.testIgnored(test);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testFailed(TestDescription test, String trace) {
- CLog.d("ModuleListener.testFailed(%s, %s)", test.toString(), trace);
- mListener.testFailed(test, trace);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testAssumptionFailure(TestDescription test, String trace) {
- CLog.d("ModuleListener.testAssumptionFailure(%s, %s)", test.toString(), trace);
- mListener.testAssumptionFailure(test, trace);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunStopped(long elapsedTime) {
- CLog.d("ModuleListener.testRunStopped(%d)", elapsedTime);
- mListener.testRunStopped(elapsedTime);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunEnded(long elapsedTime, HashMap<String, Metric> metrics) {
- CLog.d("ModuleListener.testRunEnded(%d, %s)", elapsedTime, metrics.toString());
- mListener.testRunEnded(elapsedTime, metrics);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunEnded(long elapsedTime, Map<String, String> metrics) {
- testRunEnded(elapsedTime, TfMetricProtoUtil.upgradeConvert(metrics));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunFailed(String errorMessage) {
- CLog.d("ModuleListener.testRunFailed(%s)", errorMessage);
- mListener.testRunFailed(errorMessage);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TestSummary getSummary() {
- return mListener.getSummary();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void invocationEnded(long elapsedTime) {
- CLog.d("ModuleListener.invocationEnded(%d)", elapsedTime);
- mListener.invocationEnded(elapsedTime);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void invocationFailed(Throwable cause) {
- CLog.d("ModuleListener.invocationFailed(%s)", cause.toString());
- mListener.invocationFailed(cause);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testLog(String name, LogDataType type, InputStreamSource stream) {
- CLog.d("ModuleListener.testLog(%s, %s, %s)", name, type.toString(), stream.toString());
- mListener.testLog(name, type, stream);
- }
-
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
deleted file mode 100644
index 227fcf5..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
+++ /dev/null
@@ -1,1155 +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.compatibility.common.tradefed.result;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.compatibility.common.tradefed.testtype.retry.RetryFactoryTest;
-import com.android.compatibility.common.tradefed.testtype.suite.CompatibilityTestSuite;
-import com.android.compatibility.common.tradefed.util.FingerprintComparisonException;
-import com.android.compatibility.common.tradefed.util.RetryType;
-import com.android.compatibility.common.util.ChecksumReporter;
-import com.android.compatibility.common.util.DeviceInfo;
-import com.android.compatibility.common.util.ICaseResult;
-import com.android.compatibility.common.util.IInvocationResult;
-import com.android.compatibility.common.util.IModuleResult;
-import com.android.compatibility.common.util.ITestResult;
-import com.android.compatibility.common.util.InvocationResult;
-import com.android.compatibility.common.util.InvocationResult.RunHistory;
-import com.android.compatibility.common.util.MetricsStore;
-import com.android.compatibility.common.util.ReportLog;
-import com.android.compatibility.common.util.ResultHandler;
-import com.android.compatibility.common.util.ResultUploader;
-import com.android.compatibility.common.util.TestStatus;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.IConfiguration;
-import com.android.tradefed.config.IConfigurationReceiver;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.Option.Importance;
-import com.android.tradefed.config.OptionClass;
-import com.android.tradefed.config.OptionCopier;
-import com.android.tradefed.invoker.IInvocationContext;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
-import com.android.tradefed.result.FileInputStreamSource;
-import com.android.tradefed.result.ILogSaver;
-import com.android.tradefed.result.ILogSaverListener;
-import com.android.tradefed.result.IShardableListener;
-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.TestDescription;
-import com.android.tradefed.result.TestSummary;
-import com.android.tradefed.result.suite.SuiteResultReporter;
-import com.android.tradefed.util.FileUtil;
-import com.android.tradefed.util.StreamUtil;
-import com.android.tradefed.util.TimeUtil;
-import com.android.tradefed.util.ZipUtil;
-import com.android.tradefed.util.proto.TfMetricProtoUtil;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.xml.XmlEscapers;
-import com.google.gson.Gson;
-
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Collect test results for an entire invocation and output test results to disk.
- */
-@OptionClass(alias="result-reporter")
-public class ResultReporter implements ILogSaverListener, ITestInvocationListener,
- ITestSummaryListener, IShardableListener, IConfigurationReceiver {
-
- public static final String INCLUDE_HTML_IN_ZIP = "html-in-zip";
- private static final String UNKNOWN_DEVICE = "unknown_device";
- private static final String RESULT_KEY = "COMPATIBILITY_TEST_RESULT";
- private static final String CTS_PREFIX = "cts:";
- private static final String BUILD_INFO = CTS_PREFIX + "build_";
- private static final String LATEST_LINK_NAME = "latest";
- /** Used to get run history from the test result of last run. */
- private static final String RUN_HISTORY_KEY = "run_history";
-
-
- public static final String BUILD_BRAND = "build_brand";
- public static final String BUILD_DEVICE = "build_device";
- public static final String BUILD_FINGERPRINT = "build_fingerprint";
- public static final String BUILD_ID = "build_id";
- public static final String BUILD_MANUFACTURER = "build_manufacturer";
- public static final String BUILD_MODEL = "build_model";
- public static final String BUILD_PRODUCT = "build_product";
- public static final String BUILD_VERSION_RELEASE = "build_version_release";
-
- private static final List<String> NOT_RETRY_FILES = Arrays.asList(
- ChecksumReporter.NAME,
- ChecksumReporter.PREV_NAME,
- ResultHandler.FAILURE_REPORT_NAME,
- "diffs");
-
- @Option(name = RetryFactoryTest.RETRY_OPTION,
- shortName = 'r',
- description = "retry a previous session.",
- importance = Importance.IF_UNSET)
- private Integer mRetrySessionId = null;
-
- @Option(name = RetryFactoryTest.RETRY_TYPE_OPTION,
- description = "used with " + RetryFactoryTest.RETRY_OPTION
- + ", retry tests of a certain status. Possible values include \"failed\", "
- + "\"not_executed\", and \"custom\".",
- importance = Importance.IF_UNSET)
- private RetryType mRetryType = null;
-
- @Option(name = "result-server", description = "Server to publish test results.")
- private String mResultServer;
-
- @Option(name = "disable-result-posting", description = "Disable result posting into report server.")
- private boolean mDisableResultPosting = false;
-
- @Option(name = "include-test-log-tags", description = "Include test log tags in report.")
- private boolean mIncludeTestLogTags = false;
-
- @Option(name = "use-log-saver", description = "Also saves generated result with log saver")
- private boolean mUseLogSaver = false;
-
- @Option(name = "compress-logs", description = "Whether logs will be saved with compression")
- private boolean mCompressLogs = true;
-
- @Option(name = INCLUDE_HTML_IN_ZIP,
- description = "Whether failure summary report is included in the zip fie.")
- private boolean mIncludeHtml = false;
-
- @Option(
- name = "result-attribute",
- description =
- "Extra key-value pairs to be added as attributes and corresponding"
- + "values of the \"Result\" tag in the result XML.")
- private Map<String, String> mResultAttributes = new HashMap<String, String>();
-
- private CompatibilityBuildHelper mBuildHelper;
- private File mResultDir = null;
- private File mLogDir = null;
- private ResultUploader mUploader;
- private String mReferenceUrl;
- private ILogSaver mLogSaver;
- private int invocationEndedCount = 0;
- private CountDownLatch mFinalized = null;
-
- protected IInvocationResult mResult = new InvocationResult();
- private IModuleResult mCurrentModuleResult;
- private ICaseResult mCurrentCaseResult;
- private ITestResult mCurrentResult;
- private String mDeviceSerial = UNKNOWN_DEVICE;
- private Set<String> mMasterDeviceSerials = new HashSet<>();
- private Set<IBuildInfo> mMasterBuildInfos = new HashSet<>();
- // Whether or not we failed the fingerprint check
- private boolean mFingerprintFailure = false;
-
- // mCurrentTestNum and mTotalTestsInModule track the progress within the module
- // Note that this count is not necessarily equal to the count of tests contained
- // in mCurrentModuleResult because of how special cases like ignored tests are reported.
- private int mCurrentTestNum;
- private int mTotalTestsInModule;
-
- // Whether modules can be marked done for this invocation. Initialized in invocationStarted()
- // Visible for unit testing
- protected boolean mCanMarkDone;
- // Whether the current test run has failed. If true, we will not mark the current module done
- protected boolean mTestRunFailed;
- // Whether the current module has previously been marked done
- private boolean mModuleWasDone;
-
- // Nullable. If null, "this" is considered the master and must handle
- // result aggregation and reporting. When not null, it should forward events
- // to the master.
- private final ResultReporter mMasterResultReporter;
-
- private LogFileSaver mTestLogSaver;
-
- // Elapsed time from invocation started to ended.
- private long mElapsedTime;
-
- /** Invocation level configuration */
- private IConfiguration mConfiguration = null;
-
- /**
- * Default constructor.
- */
- public ResultReporter() {
- this(null);
- mFinalized = new CountDownLatch(1);
- }
-
- /**
- * Construct a shard ResultReporter that forwards module results to the
- * masterResultReporter.
- */
- public ResultReporter(ResultReporter masterResultReporter) {
- mMasterResultReporter = masterResultReporter;
- }
-
- /** {@inheritDoc} */
- @Override
- public void setConfiguration(IConfiguration configuration) {
- mConfiguration = configuration;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void invocationStarted(IInvocationContext context) {
- IBuildInfo primaryBuild = context.getBuildInfos().get(0);
- synchronized(this) {
- if (mBuildHelper == null) {
- mBuildHelper = new CompatibilityBuildHelper(primaryBuild);
- }
- if (mDeviceSerial == null && primaryBuild.getDeviceSerial() != null) {
- mDeviceSerial = primaryBuild.getDeviceSerial();
- }
- mCanMarkDone = canMarkDone(mBuildHelper.getRecentCommandLineArgs());
- }
-
- if (isShardResultReporter()) {
- // Shard ResultReporters forward invocationStarted to the mMasterResultReporter
- mMasterResultReporter.invocationStarted(context);
- return;
- }
-
- // NOTE: Everything after this line only applies to the master ResultReporter.
-
- synchronized(this) {
- if (primaryBuild.getDeviceSerial() != null) {
- // The master ResultReporter collects all device serials being used
- // for the current implementation.
- mMasterDeviceSerials.add(primaryBuild.getDeviceSerial());
- }
-
- // The master ResultReporter collects all buildInfos.
- mMasterBuildInfos.add(primaryBuild);
-
- if (mResultDir == null) {
- // For the non-sharding case, invocationStarted is only called once,
- // but for the sharding case, this might be called multiple times.
- // Logic used to initialize the result directory should not be
- // invoked twice during the same invocation.
- initializeResultDirectories();
- }
- }
- }
-
- /**
- * Create directory structure where results and logs will be written.
- */
- private void initializeResultDirectories() {
- debug("Initializing result directory");
-
- try {
- // Initialize the result directory. Either a new directory or reusing
- // an existing session.
- if (mRetrySessionId != null) {
- // Overwrite the mResult with the test results of the previous session
- mResult = ResultHandler.findResult(mBuildHelper.getResultsDir(), mRetrySessionId);
- }
- mResult.setStartTime(mBuildHelper.getStartTime());
- mResultDir = mBuildHelper.getResultDir();
- if (mResultDir != null) {
- mResultDir.mkdirs();
- }
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- }
-
- if (mResultDir == null) {
- throw new RuntimeException("Result Directory was not created");
- }
- if (!mResultDir.exists()) {
- throw new RuntimeException("Result Directory was not created: " +
- mResultDir.getAbsolutePath());
- }
-
- debug("Results Directory: %s", mResultDir.getAbsolutePath());
-
- mUploader = new ResultUploader(mResultServer, mBuildHelper.getSuiteName());
- try {
- mLogDir = new File(mBuildHelper.getLogsDir(),
- CompatibilityBuildHelper.getDirSuffix(mBuildHelper.getStartTime()));
- } catch (FileNotFoundException e) {
- CLog.e(e);
- }
- if (mLogDir != null && mLogDir.mkdirs()) {
- debug("Created log dir %s", mLogDir.getAbsolutePath());
- }
- if (mLogDir == null || !mLogDir.exists()) {
- throw new IllegalArgumentException(String.format("Could not create log dir %s",
- mLogDir.getAbsolutePath()));
- }
- if (mTestLogSaver == null) {
- mTestLogSaver = new LogFileSaver(mLogDir);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunStarted(String id, int numTests) {
- if (mCurrentModuleResult != null && mCurrentModuleResult.getId().equals(id)
- && mCurrentModuleResult.isDone()) {
- // Modules run with JarHostTest treat each test class as a separate module,
- // resulting in additional unexpected test runs.
- // This case exists only for N
- mTotalTestsInModule += numTests;
- } else {
- // Handle non-JarHostTest case
- mCurrentModuleResult = mResult.getOrCreateModule(id);
- mModuleWasDone = mCurrentModuleResult.isDone();
- mTestRunFailed = false;
- if (!mModuleWasDone) {
- // we only want to update testRun variables if the IModuleResult is not yet done
- // otherwise leave testRun variables alone so isDone evaluates to true.
- if (mCurrentModuleResult.getExpectedTestRuns() == 0) {
- mCurrentModuleResult.setExpectedTestRuns(TestRunHandler.getTestRuns(
- mBuildHelper, mCurrentModuleResult.getId()));
- }
- mCurrentModuleResult.addTestRun();
- }
- // Reset counters
- mTotalTestsInModule = numTests;
- mCurrentTestNum = 0;
- }
- mCurrentModuleResult.inProgress(true);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testStarted(TestDescription test) {
- mCurrentCaseResult = mCurrentModuleResult.getOrCreateResult(test.getClassName());
- mCurrentResult = mCurrentCaseResult.getOrCreateResult(test.getTestName().trim());
- if (mCurrentResult.isRetry()) {
- mCurrentResult.reset(); // clear result status for this invocation
- }
- mCurrentTestNum++;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testEnded(TestDescription test, HashMap<String, Metric> metrics) {
- if (mCurrentResult.getResultStatus() == TestStatus.FAIL) {
- // Test has previously failed.
- return;
- }
- // device test can have performance results in test metrics
- Metric perfResult = metrics.get(RESULT_KEY);
- ReportLog report = null;
- if (perfResult != null) {
- try {
- report = ReportLog.parse(perfResult.getMeasurements().getSingleString());
- } catch (XmlPullParserException | IOException e) {
- e.printStackTrace();
- }
- } else {
- // host test should be checked into MetricsStore.
- report = MetricsStore.removeResult(mBuildHelper.getBuildInfo(),
- mCurrentModuleResult.getAbi(), test.toString());
- }
- if (mCurrentResult.getResultStatus() == null) {
- // Only claim that we passed when we're certain our result was
- // not any other state.
- mCurrentResult.passed(report);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testIgnored(TestDescription test) {
- mCurrentResult.skipped();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testFailed(TestDescription test, String trace) {
- mCurrentResult.failed(sanitizeXmlContent(trace));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testAssumptionFailure(TestDescription test, String trace) {
- mCurrentResult.skipped();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunStopped(long elapsedTime) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunEnded(long elapsedTime, Map<String, String> metrics) {
- testRunEnded(elapsedTime, TfMetricProtoUtil.upgradeConvert(metrics));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunEnded(long elapsedTime, HashMap<String, Metric> metrics) {
- mCurrentModuleResult.inProgress(false);
- mCurrentModuleResult.addRuntime(elapsedTime);
- if (!mModuleWasDone && mCanMarkDone) {
- if (mTestRunFailed) {
- // set done to false for test run failures
- mCurrentModuleResult.setDone(false);
- } else {
- // Only mark module done if:
- // - status of the invocation allows it (mCanMarkDone), and
- // - module has not already been marked done, and
- // - no test run failure has been detected
- mCurrentModuleResult.setDone(mCurrentTestNum >= mTotalTestsInModule);
- }
- }
- if (isShardResultReporter()) {
- // Forward module results to the master.
- mMasterResultReporter.mergeModuleResult(mCurrentModuleResult);
- mCurrentModuleResult.resetTestRuns();
- mCurrentModuleResult.resetRuntime();
- }
- }
-
- /**
- * Directly add a module result. Note: this method is meant to be used by
- * a shard ResultReporter.
- */
- private void mergeModuleResult(IModuleResult moduleResult) {
- // This merges the results in moduleResult to any existing results already
- // contained in mResult. This is useful for retries and allows the final
- // report from a retry to contain all test results.
- synchronized(this) {
- mResult.mergeModuleResult(moduleResult);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunFailed(String errorMessage) {
- mTestRunFailed = true;
- mCurrentModuleResult.setFailed();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TestSummary getSummary() {
- // ignore
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void putSummary(List<TestSummary> summaries) {
- for (TestSummary summary : summaries) {
- // If one summary is from SuiteResultReporter, log it as an extra file.
- if (SuiteResultReporter.SUITE_REPORTER_SOURCE.equals(summary.getSource())) {
- File summaryFile = null;
- try {
- summaryFile = FileUtil.createTempFile("summary", ".txt");
- FileUtil.writeToFile(summary.getSummary().getString(), summaryFile);
- try (InputStreamSource stream = new FileInputStreamSource(summaryFile)) {
- testLog("summary", LogDataType.TEXT, stream);
- }
- } catch (IOException e) {
- CLog.e(e);
- } finally {
- FileUtil.deleteFile(summaryFile);
- }
- } else if (mReferenceUrl == null && summary.getSummary().getString() != null) {
- mReferenceUrl = summary.getSummary().getString();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void invocationEnded(long elapsedTime) {
- if (isShardResultReporter()) {
- // Shard ResultReporters report
- mMasterResultReporter.invocationEnded(elapsedTime);
- return;
- }
-
- // NOTE: Everything after this line only applies to the master ResultReporter.
-
- synchronized(this) {
- // The master ResultReporter tracks the progress of all invocations across
- // shard ResultReporters. Writing results should not proceed until all
- // ResultReporters have completed.
- if (++invocationEndedCount < mMasterBuildInfos.size()) {
- return;
- }
- mElapsedTime = elapsedTime;
- finalizeResults();
- mFinalized.countDown();
- }
- }
-
- /**
- * Returns whether a report creation should be skipped.
- */
- protected boolean shouldSkipReportCreation() {
- // This value is always false here for backwards compatibility.
- // Extended classes have the option to override this.
- return false;
- }
-
- private void finalizeResults() {
- if (mFingerprintFailure) {
- CLog.w("Failed the fingerprint check. Skip result reporting.");
- return;
- }
- // Add all device serials into the result to be serialized
- for (String deviceSerial : mMasterDeviceSerials) {
- mResult.addDeviceSerial(deviceSerial);
- }
-
- addDeviceBuildInfoToResult();
-
- Set<String> allExpectedModules = new HashSet<>();
- for (IBuildInfo buildInfo : mMasterBuildInfos) {
- for (Map.Entry<String, String> entry : buildInfo.getBuildAttributes().entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- if (key.equals(CompatibilityBuildHelper.MODULE_IDS) && value.length() > 0) {
- Collections.addAll(allExpectedModules, value.split(","));
- }
- }
- }
-
- // Include a record in the report of all expected modules ids, even if they weren't
- // executed.
- for (String moduleId : allExpectedModules) {
- mResult.getOrCreateModule(moduleId);
- }
-
- String moduleProgress = String.format("%d of %d",
- mResult.getModuleCompleteCount(), mResult.getModules().size());
-
-
- if (shouldSkipReportCreation()) {
- return;
- }
-
- // Get run history from the test result of last run and add the run history of the current
- // run to it.
- // TODO(b/137973382): avoid casting by move the method to interface level.
- Collection<RunHistory> runHistories = ((InvocationResult) mResult).getRunHistories();
- String runHistoryJSON = mResult.getInvocationInfo().get(RUN_HISTORY_KEY);
- Gson gson = new Gson();
- if (runHistoryJSON != null) {
- RunHistory[] runHistoryArray = gson.fromJson(runHistoryJSON, RunHistory[].class);
- Collections.addAll(runHistories, runHistoryArray);
- }
- RunHistory newRun = new RunHistory();
- newRun.startTime = mResult.getStartTime();
- newRun.endTime = newRun.startTime + mElapsedTime;
- runHistories.add(newRun);
- mResult.addInvocationInfo(RUN_HISTORY_KEY, gson.toJson(runHistories));
-
- try {
- // Zip the full test results directory.
- copyDynamicConfigFiles();
- copyFormattingFiles(mResultDir, mBuildHelper.getSuiteName());
-
- File resultFile = generateResultXmlFile();
- if (mRetrySessionId != null) {
- copyRetryFiles(ResultHandler.getResultDirectory(
- mBuildHelper.getResultsDir(), mRetrySessionId), mResultDir);
- }
- File failureReport = null;
- if (mIncludeHtml) {
- // Create the html report before the zip file.
- failureReport = ResultHandler.createFailureReport(resultFile);
- }
- File zippedResults = zipResults(mResultDir);
- if (!mIncludeHtml) {
- // Create failure report after zip file so extra data is not uploaded
- failureReport = ResultHandler.createFailureReport(resultFile);
- }
- if (failureReport != null && failureReport.exists()) {
- info("Test Result: %s", failureReport.getCanonicalPath());
- } else {
- info("Test Result: %s", resultFile.getCanonicalPath());
- }
- info("Test Logs: %s", mLogDir.getCanonicalPath());
- debug("Full Result: %s", zippedResults.getCanonicalPath());
-
- Path latestLink = createLatestLinkDirectory(mResultDir.toPath());
- if (latestLink != null) {
- info("Latest results link: " + latestLink.toAbsolutePath());
- }
-
- latestLink = createLatestLinkDirectory(mLogDir.toPath());
- if (latestLink != null) {
- info("Latest logs link: " + latestLink.toAbsolutePath());
- }
-
- saveLog(resultFile, zippedResults);
-
- uploadResult(resultFile);
-
- } catch (IOException | XmlPullParserException e) {
- CLog.e("[%s] Exception while saving result XML.", mDeviceSerial);
- CLog.e(e);
- }
- // print the run results last.
- info("Invocation finished in %s. PASSED: %d, FAILED: %d, MODULES: %s",
- TimeUtil.formatElapsedTime(mElapsedTime),
- mResult.countResults(TestStatus.PASS),
- mResult.countResults(TestStatus.FAIL),
- moduleProgress);
- }
-
- private Path createLatestLinkDirectory(Path directory) {
- Path link = null;
-
- Path parent = directory.getParent();
-
- if (parent != null) {
- link = parent.resolve(LATEST_LINK_NAME);
- try {
- // if latest already exists, we have to remove it before creating
- Files.deleteIfExists(link);
- Files.createSymbolicLink(link, directory);
- } catch (IOException ioe) {
- CLog.e("Exception while attempting to create 'latest' link to: [%s]",
- directory);
- CLog.e(ioe);
- return null;
- } catch (UnsupportedOperationException uoe) {
- CLog.e("Failed to create 'latest' symbolic link - unsupported operation");
- return null;
- }
- }
- return link;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void invocationFailed(Throwable cause) {
- warn("Invocation failed: %s", cause);
- InvocationFailureHandler.setFailed(mBuildHelper, cause);
- if (cause instanceof FingerprintComparisonException) {
- mFingerprintFailure = true;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testLog(String name, LogDataType type, InputStreamSource stream) {
- // This is safe to be invoked on either the master or a shard ResultReporter
- if (isShardResultReporter()) {
- // Shard ResultReporters forward testLog to the mMasterResultReporter
- mMasterResultReporter.testLog(name, type, stream);
- return;
- }
- if (name.endsWith(DeviceInfo.FILE_SUFFIX)) {
- // Handle device info file case
- testLogDeviceInfo(name, stream);
- } else {
- // Handle default case
- try {
- File logFile = null;
- if (mCompressLogs) {
- try (InputStream inputStream = stream.createInputStream()) {
- logFile = mTestLogSaver.saveAndGZipLogData(name, type, inputStream);
- }
- } else {
- try (InputStream inputStream = stream.createInputStream()) {
- logFile = mTestLogSaver.saveLogData(name, type, inputStream);
- }
- }
- debug("Saved logs for %s in %s", name, logFile.getAbsolutePath());
- } catch (IOException e) {
- warn("Failed to write log for %s", name);
- CLog.e(e);
- }
- }
- }
-
- /* Write device-info files to the result, invoked only by the master result reporter */
- private void testLogDeviceInfo(String name, InputStreamSource stream) {
- try {
- File ediDir = new File(mResultDir, DeviceInfo.RESULT_DIR_NAME);
- ediDir.mkdirs();
- File ediFile = new File(ediDir, name);
- if (!ediFile.exists()) {
- // only write this file to the results if not already present
- FileUtil.writeToFile(stream.createInputStream(), ediFile);
- }
- } catch (IOException e) {
- warn("Failed to write device info %s to result", name);
- CLog.e(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream,
- LogFile logFile) {
- // This is safe to be invoked on either the master or a shard ResultReporter
- if (mIncludeTestLogTags && mCurrentResult != null
- && dataName.startsWith(mCurrentResult.getFullName())) {
-
- if (dataType == LogDataType.BUGREPORT) {
- mCurrentResult.setBugReport(logFile.getUrl());
- } else if (dataType == LogDataType.LOGCAT) {
- mCurrentResult.setLog(logFile.getUrl());
- } else if (dataType == LogDataType.PNG) {
- mCurrentResult.setScreenshot(logFile.getUrl());
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setLogSaver(ILogSaver saver) {
- // This is safe to be invoked on either the master or a shard ResultReporter
- mLogSaver = saver;
- }
-
- /**
- * When enabled, save log data using log saver
- */
- private void saveLog(File resultFile, File zippedResults) throws IOException {
- if (!mUseLogSaver) {
- return;
- }
-
- FileInputStream fis = null;
- LogFile logFile = null;
- try {
- fis = new FileInputStream(resultFile);
- logFile = mLogSaver.saveLogData("log-result", LogDataType.XML, fis);
- debug("Result XML URL: %s", logFile.getUrl());
- logReportFiles(mConfiguration, resultFile, resultFile.getName(), LogDataType.XML);
- } catch (IOException ioe) {
- CLog.e("[%s] error saving XML with log saver", mDeviceSerial);
- CLog.e(ioe);
- } finally {
- StreamUtil.close(fis);
- }
- // Save the full results folder.
- if (zippedResults != null) {
- FileInputStream zipResultStream = null;
- try {
- zipResultStream = new FileInputStream(zippedResults);
- logFile = mLogSaver.saveLogData("results", LogDataType.ZIP, zipResultStream);
- debug("Result zip URL: %s", logFile.getUrl());
- logReportFiles(
- mConfiguration, zippedResults, "results", LogDataType.ZIP);
- } finally {
- StreamUtil.close(zipResultStream);
- }
- }
- }
-
- /**
- * Return the path in which log saver persists log files or null if
- * logSaver is not enabled.
- */
- private String getLogUrl() {
- if (!mUseLogSaver || mLogSaver == null) {
- return null;
- }
-
- return mLogSaver.getLogReportDir().getUrl();
- }
-
- @Override
- public IShardableListener clone() {
- ResultReporter clone = new ResultReporter(this);
- OptionCopier.copyOptionsNoThrow(this, clone);
- return clone;
- }
-
- /**
- * Create results file compatible with CTSv2 (xml) report format.
- */
- protected File generateResultXmlFile()
- throws IOException, XmlPullParserException {
- return ResultHandler.writeResults(
- mBuildHelper.getSuiteName(),
- mBuildHelper.getSuiteVersion(),
- getSuitePlan(mBuildHelper),
- mBuildHelper.getSuiteBuild(),
- mResult,
- mResultDir,
- mResult.getStartTime(),
- mElapsedTime + mResult.getStartTime(),
- mReferenceUrl,
- getLogUrl(),
- mBuildHelper.getCommandLineArgs(),
- mResultAttributes);
- }
-
- /**
- * Add build info collected from the device attributes to the results.
- */
- protected void addDeviceBuildInfoToResult() {
- // Add all build info to the result to be serialized
- Map<String, String> buildProperties = mapBuildInfo();
- addBuildInfoToResult(buildProperties, mResult);
- }
-
- /**
- * Override specific build properties so the report will be associated with the
- * build fingerprint being certified.
- */
- protected void addDeviceBuildInfoToResult(String buildFingerprintOverride,
- String manufactureOverride, String modelOverride) {
-
- Map<String, String> buildProperties = mapBuildInfo();
-
- // Extract and override values from build fingerprint.
- // Build fingerprint format: brand/product/device:version/build_id/tags
- String fingerprintPrefix = buildFingerprintOverride.split(":")[0];
- String fingerprintTail = buildFingerprintOverride.split(":")[1];
- String buildIdOverride = fingerprintTail.split("/")[1];
- buildProperties.put(BUILD_ID, buildIdOverride);
- String brandOverride = fingerprintPrefix.split("/")[0];
- buildProperties.put(BUILD_BRAND, brandOverride);
- String deviceOverride = fingerprintPrefix.split("/")[2];
- buildProperties.put(BUILD_DEVICE, deviceOverride);
- String productOverride = fingerprintPrefix.split("/")[1];
- buildProperties.put(BUILD_PRODUCT, productOverride);
- String versionOverride = fingerprintTail.split("/")[0];
- buildProperties.put(BUILD_VERSION_RELEASE, versionOverride);
- buildProperties.put(BUILD_FINGERPRINT, buildFingerprintOverride);
- buildProperties.put(BUILD_MANUFACTURER, manufactureOverride);
- buildProperties.put(BUILD_MODEL, modelOverride);
-
- // Add modified values to results.
- addBuildInfoToResult(buildProperties, mResult);
- mResult.setBuildFingerprint(buildFingerprintOverride);
- }
- /** Aggregate build info from member device info. */
- protected Map<String, String> mapBuildInfo() {
- Map<String, String> buildProperties = new HashMap<>();
- for (IBuildInfo buildInfo : mMasterBuildInfos) {
- for (Map.Entry<String, String> entry : buildInfo.getBuildAttributes().entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- if (key.startsWith(BUILD_INFO)) {
- buildProperties.put(key.substring(CTS_PREFIX.length()), value);
- }
- }
- }
- return buildProperties;
- }
-
- /**
- * Add build info to results.
- * @param buildProperties Build info to add.
- */
- protected static void addBuildInfoToResult(Map<String, String> buildProperties,
- IInvocationResult invocationResult) {
- buildProperties.entrySet().stream().forEach(entry ->
- invocationResult.addInvocationInfo(entry.getKey(), entry.getValue()));
- }
-
- /**
- * Get the suite plan. This protected method was created for overrides.
- * Extending classes can decide on the content of the output's suite_plan field.
- *
- * @param mBuildHelper Helper that contains build information.
- * @return string Suite plan to use.
- */
- protected String getSuitePlan(CompatibilityBuildHelper mBuildHelper) {
- return mBuildHelper.getSuitePlan();
- }
-
- /**
- * Return true if this instance is a shard ResultReporter and should propagate
- * certain events to the master.
- */
- private boolean isShardResultReporter() {
- return mMasterResultReporter != null;
- }
-
- /**
- * When enabled, upload the result to a server.
- */
- private void uploadResult(File resultFile) {
- if (mResultServer != null && !mResultServer.trim().isEmpty() && !mDisableResultPosting) {
- try {
- debug("Result Server: %d", mUploader.uploadResult(resultFile, mReferenceUrl));
- } catch (IOException ioe) {
- CLog.e("[%s] IOException while uploading result.", mDeviceSerial);
- CLog.e(ioe);
- }
- }
- }
-
- /**
- * Returns whether it is safe to mark modules as "done", given the invocation command-line
- * arguments. Returns true unless this is a retry and specific filtering techniques are applied
- * on the command-line, such as:
- * --retry-type failed
- * --include-filter
- * --exclude-filter
- * -t/--test
- * --subplan
- */
- private boolean canMarkDone(String args) {
- if (mRetrySessionId == null) {
- return true; // always allow modules to be marked done if not retry
- }
- return !(RetryType.FAILED.equals(mRetryType)
- || RetryType.CUSTOM.equals(mRetryType)
- || args.contains(CompatibilityTestSuite.INCLUDE_FILTER_OPTION)
- || args.contains(CompatibilityTestSuite.EXCLUDE_FILTER_OPTION)
- || args.contains(CompatibilityTestSuite.SUBPLAN_OPTION)
- || args.matches(String.format(".* (-%s|--%s) .*",
- CompatibilityTestSuite.TEST_OPTION_SHORT_NAME, CompatibilityTestSuite.TEST_OPTION)));
- }
-
- /**
- * Copy the xml formatting files stored in this jar to the results directory
- *
- * @param resultsDir
- */
- static void copyFormattingFiles(File resultsDir, String suiteName) {
- for (String resultFileName : ResultHandler.RESULT_RESOURCES) {
- InputStream configStream = ResultHandler.class.getResourceAsStream(
- String.format("/report/%s-%s", suiteName, resultFileName));
- if (configStream == null) {
- // If suite specific files are not available, fallback to common.
- configStream = ResultHandler.class.getResourceAsStream(
- String.format("/report/%s", resultFileName));
- }
- if (configStream != null) {
- File resultFile = new File(resultsDir, resultFileName);
- try {
- FileUtil.writeToFile(configStream, resultFile);
- } catch (IOException e) {
- warn("Failed to write %s to file", resultFileName);
- }
- } else {
- warn("Failed to load %s from jar", resultFileName);
- }
- }
- }
-
- /**
- * move the dynamic config files to the results directory
- */
- private void copyDynamicConfigFiles() {
- File configDir = new File(mResultDir, "config");
- if (!configDir.mkdir()) {
- warn("Failed to make dynamic config directory \"%s\" in the result",
- configDir.getAbsolutePath());
- }
-
- Set<String> uniqueModules = new HashSet<>();
- for (IBuildInfo buildInfo : mMasterBuildInfos) {
- CompatibilityBuildHelper helper = new CompatibilityBuildHelper(buildInfo);
- Map<String, File> dcFiles = helper.getDynamicConfigFiles();
- for (String moduleName : dcFiles.keySet()) {
- File srcFile = dcFiles.get(moduleName);
- if (!uniqueModules.contains(moduleName)) {
- // have not seen config for this module yet, copy into result
- File destFile = new File(configDir, moduleName + ".dynamic");
- try {
- FileUtil.copyFile(srcFile, destFile);
- uniqueModules.add(moduleName); // Add to uniqueModules if copy succeeds
- } catch (IOException e) {
- warn("Failure when copying config file \"%s\" to \"%s\" for module %s",
- srcFile.getAbsolutePath(), destFile.getAbsolutePath(), moduleName);
- CLog.e(e);
- }
- }
- FileUtil.deleteFile(srcFile);
- }
- }
- }
-
- /**
- * Recursively copy any other files found in the previous session's result directory to the
- * new result directory, so long as they don't already exist. For example, a "screenshots"
- * directory generated in a previous session by a passing test will not be generated on retry
- * unless copied from the old result directory.
- *
- * @param oldDir
- * @param newDir
- */
- static void copyRetryFiles(File oldDir, File newDir) {
- File[] oldChildren = oldDir.listFiles();
- for (File oldChild : oldChildren) {
- if (NOT_RETRY_FILES.contains(oldChild.getName())) {
- continue; // do not copy this file/directory or its children
- }
- File newChild = new File(newDir, oldChild.getName());
- if (!newChild.exists()) {
- // If this old file or directory doesn't exist in new dir, simply copy it
- try {
- if (oldChild.isDirectory()) {
- FileUtil.recursiveCopy(oldChild, newChild);
- } else {
- FileUtil.copyFile(oldChild, newChild);
- }
- } catch (IOException e) {
- warn("Failed to copy file \"%s\" from previous session", oldChild.getName());
- }
- } else if (oldChild.isDirectory() && newChild.isDirectory()) {
- // If both children exist as directories, make sure the children of the old child
- // directory exist in the new child directory.
- copyRetryFiles(oldChild, newChild);
- }
- }
- }
-
- /**
- * Zip the contents of the given results directory.
- *
- * @param resultsDir
- */
- private static File zipResults(File resultsDir) {
- File zipResultFile = null;
- try {
- // create a file in parent directory, with same name as resultsDir
- zipResultFile = new File(resultsDir.getParent(), String.format("%s.zip",
- resultsDir.getName()));
- ZipUtil.createZip(resultsDir, zipResultFile);
- } catch (IOException e) {
- warn("Failed to create zip for %s", resultsDir.getName());
- }
- return zipResultFile;
- }
-
- /**
- * Log info to the console.
- */
- private static void info(String format, Object... args) {
- log(LogLevel.INFO, format, args);
- }
-
- /**
- * Log debug to the console.
- */
- private static void debug(String format, Object... args) {
- log(LogLevel.DEBUG, format, args);
- }
-
- /**
- * Log a warning to the console.
- */
- private static void warn(String format, Object... args) {
- log(LogLevel.WARN, format, args);
- }
-
- /**
- * Log a message to the console
- */
- private static void log(LogLevel level, String format, Object... args) {
- CLog.logAndDisplay(level, format, args);
- }
-
- /**
- * For testing purpose.
- */
- @VisibleForTesting
- public IInvocationResult getResult() {
- return mResult;
- }
-
- /**
- * Returns true if the reporter is finalized before the end of the timeout. False otherwise.
- */
- @VisibleForTesting
- public boolean waitForFinalized(long timeout, TimeUnit unit) throws InterruptedException {
- return mFinalized.await(timeout, unit);
- }
-
- private static String sanitizeXmlContent(String s) {
- return XmlEscapers.xmlContentEscaper().escape(s);
- }
-
- /** Re-log a result file to all reporters so they are aware of it. */
- private void logReportFiles(
- IConfiguration configuration, File resultFile, String dataName, LogDataType type) {
- if (configuration == null) {
- return;
- }
- List<ITestInvocationListener> listeners = configuration.getTestInvocationListeners();
- try (FileInputStreamSource source = new FileInputStreamSource(resultFile)) {
- for (ITestInvocationListener listener : listeners) {
- if (listener.equals(this)) {
- // Avoid logging agaisnt itself
- continue;
- }
- listener.testLog(dataName, type, source);
- }
- }
- }
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/TestRunHandler.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/TestRunHandler.java
deleted file mode 100644
index 4473eb8..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/TestRunHandler.java
+++ /dev/null
@@ -1,97 +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.compatibility.common.tradefed.result;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * A helper class for setting and checking the number of expected test runs.
- */
-public class TestRunHandler {
-
- private static final String MAP_DELIMITER = "->";
-
- /**
- * Determine the number of expected test runs for the module
- *
- * @param buildHelper the {@link CompatibilityBuildHelper} from which to retrieve invocation
- * failure file
- * @return the number of expected test runs, or 1 if module is not found
- */
- public static int getTestRuns(final CompatibilityBuildHelper buildHelper, String id) {
- try {
- File f = buildHelper.getTestRunsFile();
- if (!f.exists() || f.length() == 0) {
- return 1; // test runs file doesn't exist, expect one test run by default
- }
- String mapString = FileUtil.readStringFromFile(f);
- Map<String, Integer> map = stringToMap(mapString);
- Integer testRuns = map.get(id);
- return (testRuns == null) ? 1 : testRuns;
- } catch (IOException e) {
- CLog.e("Could not read test run file for session %s",
- buildHelper.getDirSuffix(buildHelper.getStartTime()));
- CLog.e(e);
- return 1;
- }
- }
-
- /**
- * Write the number of expected test runs to the result's test run file.
- *
- * @param buildHelper the {@link CompatibilityBuildHelper} used to write the
- * test run file
- * @param testRuns a mapping of module names to number of test runs expected
- */
- public static void setTestRuns(final CompatibilityBuildHelper buildHelper,
- Map<String, Integer> testRuns) {
- try {
- File f = buildHelper.getTestRunsFile();
- if (!f.exists()) {
- f.createNewFile();
- }
- FileUtil.writeToFile(mapToString(testRuns), f);
- } catch (IOException e) {
- CLog.e("Exception while writing test runs file.");
- CLog.e(e);
- }
- }
-
- private static String mapToString(Map<String, Integer> map) {
- StringBuilder sb = new StringBuilder("");
- for (Map.Entry<String, Integer> entry : map.entrySet()) {
- sb.append(String.format("%s%s%d\n", entry.getKey(), MAP_DELIMITER, entry.getValue()));
- }
- return sb.toString();
- }
-
- private static Map<String, Integer> stringToMap(String str) {
- Map<String, Integer> map = new HashMap<>();
- for (String entry : str.split("\n")) {
- String[] parts = entry.split(MAP_DELIMITER);
- map.put(parts[0], Integer.parseInt(parts[1]));
- }
- return map;
- }
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/CertificationSuiteResultReporter.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/CertificationSuiteResultReporter.java
index a7a94c4..6513b47 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/CertificationSuiteResultReporter.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/CertificationSuiteResultReporter.java
@@ -231,7 +231,7 @@
}
}
- /** Write device-info files to the result, invoked only by the master result reporter */
+ /** Write device-info files to the result */
private void testLogDeviceInfo(String name, InputStreamSource stream) {
try {
File ediDir = new File(mResultDir, DeviceInfo.RESULT_DIR_NAME);
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/CompatibilityProtoResultReporter.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/CompatibilityProtoResultReporter.java
index fe57e3a..6607c85 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/CompatibilityProtoResultReporter.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/CompatibilityProtoResultReporter.java
@@ -16,13 +16,18 @@
package com.android.compatibility.common.tradefed.result.suite;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
+import com.android.tradefed.config.Option;
import com.android.tradefed.invoker.IInvocationContext;
+import com.android.tradefed.invoker.InvocationContext;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.proto.FileProtoResultReporter;
+import com.android.tradefed.result.proto.ProtoResultParser;
import com.android.tradefed.result.proto.TestRecordProto.TestRecord;
+import com.android.tradefed.util.FileUtil;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.IOException;
/** Proto reporter that will drop a {@link TestRecord} protobuf in the result directory. */
public class CompatibilityProtoResultReporter extends FileProtoResultReporter {
@@ -30,23 +35,57 @@
public static final String PROTO_FILE_NAME = "test-record.pb";
public static final String PROTO_DIR = "proto";
+ @Option(
+ name = "skip-proto-compacting",
+ description = "Option to disable compacting the protos at the end")
+ private boolean mSkipProtoCompacting = false;
+
private CompatibilityBuildHelper mBuildHelper;
/** The directory containing the proto results */
private File mResultDir = null;
+ private File mBaseProtoFile = null;
+
@Override
public void processStartInvocation(
TestRecord invocationStartRecord, IInvocationContext invocationContext) {
if (mBuildHelper == null) {
mBuildHelper = new CompatibilityBuildHelper(invocationContext.getBuildInfos().get(0));
mResultDir = getProtoResultDirectory();
- File protoFile = new File(mResultDir, PROTO_FILE_NAME);
- setFileOutput(protoFile);
+ mBaseProtoFile = new File(mResultDir, PROTO_FILE_NAME);
+ setFileOutput(mBaseProtoFile);
}
super.processStartInvocation(invocationStartRecord, invocationContext);
}
+ @Override
+ public void processFinalProto(TestRecord invocationEndedProto) {
+ super.processFinalProto(invocationEndedProto);
+
+ if (!isPeriodicWriting()) {
+ return;
+ }
+ if (mSkipProtoCompacting) {
+ return;
+ }
+ // Compact all the protos
+ try {
+ compactAllProtos();
+ } catch (RuntimeException e) {
+ CLog.e("Failed to compact the protos");
+ CLog.e(e);
+ FileUtil.deleteFile(mBaseProtoFile);
+ return;
+ }
+ // Delete all the protos we compacted
+ int index = 0;
+ while (new File(mBaseProtoFile.getAbsolutePath() + index).exists()) {
+ FileUtil.deleteFile(new File(mBaseProtoFile.getAbsolutePath() + index));
+ index++;
+ }
+ }
+
private File getProtoResultDirectory() {
File protoDir = null;
try {
@@ -66,4 +105,19 @@
CLog.d("Proto Results Directory: %s", protoDir.getAbsolutePath());
return protoDir;
}
+
+ private void compactAllProtos() {
+ FileProtoResultReporter fprr = new FileProtoResultReporter();
+ fprr.setFileOutput(mBaseProtoFile);
+ ProtoResultParser parser = new ProtoResultParser(fprr, new InvocationContext(), true);
+ int index = 0;
+ while (new File(mBaseProtoFile.getAbsolutePath() + index).exists()) {
+ try {
+ parser.processFileProto(new File(mBaseProtoFile.getAbsolutePath() + index));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ index++;
+ }
+ }
}
\ No newline at end of file
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/PreviousResultLoader.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/PreviousResultLoader.java
index c459681..5ee0fbb 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/PreviousResultLoader.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/PreviousResultLoader.java
@@ -19,7 +19,6 @@
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider;
import com.android.compatibility.common.tradefed.targetprep.BuildFingerPrintPreparer;
-import com.android.compatibility.common.tradefed.testtype.retry.RetryFactoryTest;
import com.android.compatibility.common.util.ResultHandler;
import com.android.ddmlib.Log.LogLevel;
import com.android.tradefed.build.BuildRetrievalError;
@@ -73,7 +72,10 @@
private static final String COMMAND_LINE_ARGS = "command_line_args";
- @Option(name = RetryFactoryTest.RETRY_OPTION,
+ public static final String RETRY_OPTION = "retry";
+
+ @Option(
+ name = RETRY_OPTION,
shortName = 'r',
description = "retry a previous session's failed and not executed tests.",
mandatory = true)
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstaller.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstaller.java
index 77a12a8..32f8c7b 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstaller.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstaller.java
@@ -21,14 +21,18 @@
import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.targetprep.TargetSetupError;
import com.android.tradefed.targetprep.TestAppInstallSetup;
+import com.android.tradefed.targetprep.suite.SuiteApkInstaller;
import java.io.File;
import java.io.FileNotFoundException;
/**
* Installs specified APKs from Compatibility repository.
+ *
+ * @deprecated Use {@link SuiteApkInstaller} instead. Options will be unchanged.
*/
-@OptionClass(alias="apk-installer")
+@Deprecated
+@OptionClass(alias = "apk-installer")
public class ApkInstaller extends TestAppInstallSetup {
private CompatibilityBuildHelper mBuildHelper = null;
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstrumentationPreparer.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstrumentationPreparer.java
index 9b8862e..112cad6 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstrumentationPreparer.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstrumentationPreparer.java
@@ -30,13 +30,17 @@
import com.android.tradefed.result.TestDescription;
import com.android.tradefed.result.TestResult;
import com.android.tradefed.result.TestRunResult;
+import com.android.tradefed.result.error.DeviceErrorIdentifier;
+import com.android.tradefed.result.error.InfraErrorIdentifier;
import com.android.tradefed.targetprep.BuildError;
import com.android.tradefed.targetprep.TargetSetupError;
import com.android.tradefed.testtype.AndroidJUnitTest;
import java.io.File;
import java.io.FileNotFoundException;
+import java.util.HashSet;
import java.util.Map.Entry;
+import java.util.Set;
/** Target preparer that instruments an APK. */
@OptionClass(alias = "apk-instrumentation-preparer")
@@ -59,6 +63,12 @@
@Option(name = "throw-error", description = "Whether to throw error for device test failure")
protected boolean mThrowError = true;
+ @Option(
+ name = "apk-instrumentation-filter",
+ description = "The include filters of the test name to run in the apk",
+ requiredForRerun = true)
+ private Set<String> mIncludeFilters = new HashSet<>();
+
private IConfiguration mConfiguration = null;
/** {@inheritDoc} */
@@ -79,12 +89,17 @@
if (instrument(testInfo)) {
CLog.d("Target preparation successful");
} else if (mThrowError) {
- throw new TargetSetupError("Not all target preparation steps completed",
- device.getDeviceDescriptor());
+ throw new TargetSetupError(
+ "Not all target preparation steps completed",
+ device.getDeviceDescriptor(),
+ DeviceErrorIdentifier.DEVICE_UNEXPECTED_RESPONSE);
}
} catch (FileNotFoundException e) {
- throw new TargetSetupError("Couldn't find apk to instrument", e,
- device.getDeviceDescriptor());
+ throw new TargetSetupError(
+ "Couldn't find apk to instrument",
+ e,
+ device.getDeviceDescriptor(),
+ InfraErrorIdentifier.ARTIFACT_NOT_FOUND);
}
}
@@ -120,7 +135,8 @@
CLog.i("Package %s already present on the device, uninstalling ...", mPackageName);
device.uninstallPackage(mPackageName);
}
-
+ // Ensure device online before attempting instrumentation
+ testInfo.getDevice().waitForDeviceAvailable();
CLog.i("Instrumenting package: %s", mPackageName);
CollectingTestListener listener = new CollectingTestListener();
AndroidJUnitTest instrTest = new AndroidJUnitTest();
@@ -128,6 +144,7 @@
instrTest.setDevice(device);
instrTest.setInstallFile(apkFile);
instrTest.setPackageName(mPackageName);
+ instrTest.addAllIncludeFilters(mIncludeFilters);
instrTest.setRerunMode(false);
instrTest.setReRunUsingTestFile(false);
// TODO: Make this configurable.
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DeviceInfoCollector.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DeviceInfoCollector.java
index 735d187..9403015 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DeviceInfoCollector.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DeviceInfoCollector.java
@@ -75,6 +75,14 @@
description = "Whether device info collection should be skipped")
private boolean mSkipDeviceInfo = false;
+ @Option(
+ name = "force-collect-device-info",
+ description =
+ "Force device info collection. If set to true, "
+ + SKIP_DEVICE_INFO_OPTION
+ + " is ignored.")
+ private boolean mForceCollectDeviceInfo = false;
+
@Option(name= "src-dir", description = "The directory to copy to the results dir")
private String mSrcDir;
@@ -133,7 +141,7 @@
String property = nullToEmpty(device.getProperty(entry.getValue()));
buildInfo.addBuildAttribute(entry.getKey(), property);
}
- if (mSkipDeviceInfo) {
+ if (mSkipDeviceInfo && !mForceCollectDeviceInfo) {
return;
}
run(testInfo);
@@ -152,6 +160,9 @@
mLogger.testLog(deviceInfoFile.getName(), LogDataType.TEXT, source);
}
}
+ // Some host tests depends on this code. E.g. SELinuxHostTestCases reads device
+ // info files by querying DEVICE_INFO_DIR against buildInfo. Change this with
+ // caution.
buildInfo.setFile(
DEVICE_INFO_DIR,
deviceInfoDir,
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DeviceInteractionHelperInstaller.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DeviceInteractionHelperInstaller.java
index c980f81..8ca82a9 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DeviceInteractionHelperInstaller.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DeviceInteractionHelperInstaller.java
@@ -16,13 +16,10 @@
package com.android.compatibility.common.tradefed.targetprep;
import com.android.ddmlib.Log.LogLevel;
-import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.config.Option;
import com.android.tradefed.config.OptionClass;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.invoker.IInvocationContext;
-import com.android.tradefed.invoker.InvocationContext;
import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.targetprep.BaseTargetPreparer;
@@ -72,18 +69,6 @@
/** {@inheritDoc} */
@Override
- public void setUp(ITestDevice device, IBuildInfo buildInfo)
- throws TargetSetupError, BuildError, DeviceNotAvailableException {
- IInvocationContext context = new InvocationContext();
- context.addAllocatedDevice("device", device);
- context.addDeviceBuildInfo("device", buildInfo);
- TestInformation testInfo =
- TestInformation.newBuilder().setInvocationContext(context).build();
- setUp(testInfo);
- }
-
- /** {@inheritDoc} */
- @Override
public void setUp(TestInformation testInfo)
throws TargetSetupError, BuildError, DeviceNotAvailableException {
ITestDevice device = testInfo.getDevice();
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
index 52c2b79..693b0ce 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
@@ -27,6 +27,8 @@
import com.android.tradefed.invoker.IInvocationContext;
import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.result.error.DeviceErrorIdentifier;
+import com.android.tradefed.result.error.InfraErrorIdentifier;
import com.android.tradefed.targetprep.BaseTargetPreparer;
import com.android.tradefed.targetprep.BuildError;
import com.android.tradefed.targetprep.TargetSetupError;
@@ -136,19 +138,7 @@
mVersion = buildHelper.getSuiteVersion();
}
- String apfeConfigInJson = null;
- String requestUrl = null;
- try {
- requestUrl = mConfigUrl.replace("{suite-name}", suiteName)
- .replace("{module}", mModuleName)
- .replace("{version}", mVersion)
- .replace("{api-key}", mApiKey);
- java.net.URL request = new URL(requestUrl);
- apfeConfigInJson = StreamUtil.getStringFromStream(request.openStream());
- } catch (IOException e) {
- CLog.w(e);
- }
-
+ String apfeConfigInJson = resolveUrl(suiteName);
// Use DynamicConfigHandler to merge local and service configuration into one file
File hostFile = mergeConfigFiles(localConfigFile, apfeConfigInJson, mModuleName, device);
@@ -156,9 +146,12 @@
String deviceDest = String.format("%s%s.dynamic",
DynamicConfig.CONFIG_FOLDER_ON_DEVICE, mModuleName);
if (!device.pushFile(hostFile, deviceDest)) {
- throw new TargetSetupError(String.format(
- "Failed to push local '%s' to remote '%s'", hostFile.getAbsolutePath(),
- deviceDest), device.getDeviceDescriptor());
+ throw new TargetSetupError(
+ String.format(
+ "Failed to push local '%s' to remote '%s'",
+ hostFile.getAbsolutePath(), deviceDest),
+ device.getDeviceDescriptor(),
+ DeviceErrorIdentifier.FAIL_PUSH_FILE);
}
mDeviceFilePushed = deviceDest;
}
@@ -218,7 +211,9 @@
FileUtil.deleteFile(localConfigFile);
throw new TargetSetupError(
String.format("Fail to unpack '%s.dynamic' from resources", lookupName),
- e, device.getDeviceDescriptor());
+ e,
+ device.getDeviceDescriptor(),
+ InfraErrorIdentifier.ARTIFACT_NOT_FOUND);
}
return localConfigFile;
}
@@ -228,8 +223,11 @@
String lookupName = (mDynamicConfigName != null) ? mDynamicConfigName : mModuleName;
localConfigFile = buildHelper.getTestFile(String.format("%s.dynamic", lookupName));
} catch (FileNotFoundException e) {
- throw new TargetSetupError("Cannot get local dynamic config file from test directory",
- e, device.getDeviceDescriptor());
+ throw new TargetSetupError(
+ "Cannot get local dynamic config file from test directory",
+ e,
+ device.getDeviceDescriptor(),
+ InfraErrorIdentifier.ARTIFACT_NOT_FOUND);
}
return localConfigFile;
}
@@ -251,4 +249,28 @@
}
}
}
+
+ @VisibleForTesting
+ String resolveUrl(String suiteName) throws TargetSetupError {
+ try {
+ String requestUrl =
+ mConfigUrl
+ .replace("{suite-name}", suiteName)
+ .replace("{module}", mModuleName)
+ .replace("{version}", mVersion)
+ .replace("{api-key}", mApiKey);
+ java.net.URL request = new URL(requestUrl);
+ return StreamUtil.getStringFromStream(request.openStream());
+ } catch (IOException e) {
+ throw new TargetSetupError(
+ String.format(
+ "Trying to access android partner remote server over internet but"
+ + " failed: %s",
+ e.getMessage()),
+ e,
+ null,
+ false,
+ InfraErrorIdentifier.ANDROID_PARTNER_SERVER_ERROR);
+ }
+ }
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/PropertyCheck.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/PropertyCheck.java
index 06c1a4b..c61adbd 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/PropertyCheck.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/PropertyCheck.java
@@ -72,7 +72,7 @@
if (mThrowError) {
throw new TargetSetupError(msg, device.getDeviceDescriptor());
} else {
- logWarning(msg);
+ CLog.w(msg);
}
}
return;
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/SettingsPreparer.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/SettingsPreparer.java
index 186a142..5e90b39 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/SettingsPreparer.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/SettingsPreparer.java
@@ -21,6 +21,7 @@
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.result.error.DeviceErrorIdentifier;
import com.android.tradefed.targetprep.BuildError;
import com.android.tradefed.targetprep.TargetSetupError;
@@ -91,10 +92,12 @@
if (mSetValue != null && !mExpectedSettingValues.isEmpty()) {
// first ensure that the set-value given can be found in expected-values
if (!mExpectedSettingValues.contains(mSetValue)) {
- throw new TargetSetupError(String.format(
- "set-value for %s is %s, but value not found in expected-values: %s",
- mSettingName, mSetValue, mExpectedSettingValues.toString()),
- device.getDeviceDescriptor());
+ throw new TargetSetupError(
+ String.format(
+ "set-value for %s is %s, but value not found in expected-values: %s",
+ mSettingName, mSetValue, mExpectedSettingValues.toString()),
+ device.getDeviceDescriptor(),
+ DeviceErrorIdentifier.DEVICE_UNEXPECTED_RESPONSE);
}
String currentSettingValue = device.executeShellCommand(shellCmdGet).trim();
// only change unexpected setting value
@@ -121,7 +124,10 @@
"Device setting \"%s\" returned \"%s\", not found in %s",
mSettingName, currentSettingValue, mExpectedSettingValues.toString());
}
- throw new TargetSetupError(mFailureMessage, device.getDeviceDescriptor());
+ throw new TargetSetupError(
+ mFailureMessage,
+ device.getDeviceDescriptor(),
+ DeviceErrorIdentifier.DEVICE_UNEXPECTED_RESPONSE);
}
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/TokenRequirement.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/TokenRequirement.java
deleted file mode 100644
index eda26ce..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/TokenRequirement.java
+++ /dev/null
@@ -1,58 +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.compatibility.common.tradefed.targetprep;
-
-import com.android.tradefed.config.Option;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.invoker.TestInformation;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.targetprep.BaseTargetPreparer;
-import com.android.tradefed.targetprep.BuildError;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.targetprep.TargetSetupError;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * An {@link ITargetPreparer} that allows a test module to specify tokens that a device must have to
- * run the tests contained.
- *
- * <p>A token is string that is required by a test module and given to a device by the user, they
- * are used by the scheduler to ensure tests are scheduled on the correct devices. Eg if the user is
- * sharding the innvocation across 10 devices, they will not want to put a SIM card in every device,
- * instead they can use a single SIM card and use tokens to tell the scheduler which device should
- * be used to run the SIM card tests.
- */
-public class TokenRequirement extends BaseTargetPreparer {
-
- @Option(name = "token", description = "The token a device must have to run this module")
- private Set<String> mTokens = new HashSet<>();
-
- @Override
- public void setUp(TestInformation testInfo)
- throws TargetSetupError, BuildError, DeviceNotAvailableException {
- CLog.e("TokenRequirement is not expected to run");
- }
-
- /**
- * @return the {@link Set} of tokens required by this module.
- */
- public Set<String> getTokens() {
- return mTokens;
- }
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
deleted file mode 100644
index 951b1dc..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
+++ /dev/null
@@ -1,1001 +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.compatibility.common.tradefed.testtype;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.compatibility.common.tradefed.result.InvocationFailureHandler;
-import com.android.compatibility.common.tradefed.result.SubPlanHelper;
-import com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker;
-import com.android.compatibility.common.tradefed.testtype.suite.CompatibilityTestSuite;
-import com.android.compatibility.common.tradefed.util.RetryFilterHelper;
-import com.android.compatibility.common.tradefed.util.RetryType;
-import com.android.compatibility.common.tradefed.util.UniqueModuleCountUtil;
-import com.android.compatibility.common.util.IInvocationResult;
-import com.android.compatibility.common.util.ResultHandler;
-import com.android.compatibility.common.util.TestFilter;
-import com.android.ddmlib.Log.LogLevel;
-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.OptionClass;
-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.invoker.IInvocationContext;
-import com.android.tradefed.invoker.InvocationContext;
-import com.android.tradefed.log.ITestLogger;
-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.suite.checker.ISystemStatusChecker;
-import com.android.tradefed.suite.checker.ISystemStatusCheckerReceiver;
-import com.android.tradefed.suite.checker.StatusCheckerResult;
-import com.android.tradefed.suite.checker.StatusCheckerResult.CheckStatus;
-import com.android.tradefed.testtype.Abi;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IInvocationContextReceiver;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.IShardableTest;
-import com.android.tradefed.testtype.ITestCollector;
-import com.android.tradefed.testtype.suite.TestSuiteInfo;
-import com.android.tradefed.util.AbiFormatter;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.ArrayUtil;
-import com.android.tradefed.util.MultiMap;
-import com.android.tradefed.util.StreamUtil;
-import com.android.tradefed.util.TimeUtil;
-
-import com.google.common.annotations.VisibleForTesting;
-
-import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * A Test for running Compatibility Suites.
- * @deprecated use {@link CompatibilityTestSuite} instead.
- */
-@Deprecated
-@OptionClass(alias = "compatibility")
-public class CompatibilityTest implements IDeviceTest, IShardableTest, IBuildReceiver,
- ISystemStatusCheckerReceiver, ITestCollector,
- IInvocationContextReceiver {
-
- public static final String INCLUDE_FILTER_OPTION = "include-filter";
- public static final String EXCLUDE_FILTER_OPTION = "exclude-filter";
- public static final String SUBPLAN_OPTION = "subplan";
- public static final String MODULE_OPTION = "module";
- public static final String TEST_OPTION = "test";
- public static final String PRECONDITION_ARG_OPTION = "precondition-arg";
- public static final String MODULE_ARG_OPTION = "module-arg";
- public static final String TEST_ARG_OPTION = "test-arg";
- public static final char TEST_OPTION_SHORT_NAME = 't';
- public static final String RETRY_OPTION = "retry";
- public static final String RETRY_TYPE_OPTION = "retry-type";
- public static final String ABI_OPTION = "abi";
- public static final String SHARD_OPTION = "shards";
- public static final String SKIP_DEVICE_INFO_OPTION = "skip-device-info";
- public static final String SKIP_PRECONDITIONS_OPTION = "skip-preconditions";
- public static final String SKIP_HOST_ARCH_CHECK = "skip-host-arch-check";
- public static final String PRIMARY_ABI_RUN = "primary-abi-only";
- public static final String DEVICE_TOKEN_OPTION = "device-token";
- public static final String LOGCAT_ON_FAILURE_SIZE_OPTION = "logcat-on-failure-size";
-
- // Constants for checking invocation or preconditions preparation failure
- private static final int NUM_PREP_ATTEMPTS = 10;
- private static final int MINUTES_PER_PREP_ATTEMPT = 2;
-
- @Option(name = SUBPLAN_OPTION,
- description = "the subplan to run",
- importance = Importance.IF_UNSET)
- private String mSubPlan;
-
- @Option(name = INCLUDE_FILTER_OPTION,
- description = "the include module filters to apply.",
- importance = Importance.ALWAYS)
- private Set<String> mIncludeFilters = new HashSet<>();
-
- @Option(name = EXCLUDE_FILTER_OPTION,
- description = "the exclude module filters to apply.",
- importance = Importance.ALWAYS)
- private Set<String> mExcludeFilters = new HashSet<>();
-
- @Option(name = MODULE_OPTION,
- shortName = 'm',
- description = "the test module to run.",
- importance = Importance.IF_UNSET)
- private String mModuleName = null;
-
- @Option(name = TEST_OPTION,
- shortName = TEST_OPTION_SHORT_NAME,
- description = "the test run.",
- importance = Importance.IF_UNSET)
- private String mTestName = null;
-
- @Option(name = PRECONDITION_ARG_OPTION,
- description = "the arguments to pass to a precondition. The expected format is"
- + "\"<arg-name>:<arg-value>\"",
- importance = Importance.ALWAYS)
- private List<String> mPreconditionArgs = new ArrayList<>();
-
- @Option(name = MODULE_ARG_OPTION,
- description = "the arguments to pass to a module. The expected format is"
- + "\"<module-name>:<arg-name>:[<arg-key>:=]<arg-value>\"",
- importance = Importance.ALWAYS)
- private List<String> mModuleArgs = new ArrayList<>();
-
- @Option(name = TEST_ARG_OPTION,
- description = "the arguments to pass to a test. The expected format is"
- + "\"<test-class>:<arg-name>:[<arg-key>:=]<arg-value>\"",
- importance = Importance.ALWAYS)
- private List<String> mTestArgs = new ArrayList<>();
-
- @Option(name = RETRY_OPTION,
- shortName = 'r',
- description = "retry a previous session's failed and not executed tests.",
- importance = Importance.IF_UNSET)
- private Integer mRetrySessionId = null;
-
- @Option(name = RETRY_TYPE_OPTION,
- description = "used with " + RETRY_OPTION + ", retry tests of a certain status. "
- + "Possible values include \"failed\", \"not_executed\", and \"custom\".",
- importance = Importance.IF_UNSET)
- private RetryType mRetryType = null;
-
- @Option(name = ABI_OPTION,
- shortName = 'a',
- description = "the abi to test.",
- importance = Importance.IF_UNSET)
- private String mAbiName = null;
-
- @Option(name = SHARD_OPTION,
- description = "split the modules up to run on multiple devices concurrently. "
- + "Deprecated, use --shard-count instead.")
- @Deprecated
- private int mShards = 1;
-
- @Option(name = SKIP_DEVICE_INFO_OPTION,
- shortName = 'd',
- description = "Whether device info collection should be skipped")
- private boolean mSkipDeviceInfo = false;
-
- @Option(name = SKIP_HOST_ARCH_CHECK,
- description = "Whether host architecture check should be skipped")
- private boolean mSkipHostArchCheck = false;
-
- @Option(name = SKIP_PRECONDITIONS_OPTION,
- shortName = 'o',
- description = "Whether preconditions should be skipped")
- private boolean mSkipPreconditions = false;
-
- @Option(name = PRIMARY_ABI_RUN,
- description = "Whether to run tests with only the device primary abi. "
- + "This override the --abi option.")
- private boolean mPrimaryAbiRun = false;
-
- @Option(name = DEVICE_TOKEN_OPTION,
- description = "Holds the devices' tokens, used when scheduling tests that have"
- + "prerequisites such as requiring a SIM card. Format is <serial>:<token>",
- importance = Importance.ALWAYS)
- private List<String> mDeviceTokens = new ArrayList<>();
-
- @Option(name = "bugreport-on-failure",
- description = "Take a bugreport on every test failure. " +
- "Warning: can potentially use a lot of disk space.")
- private boolean mBugReportOnFailure = false;
-
- @Option(name = "logcat-on-failure",
- description = "Take a logcat snapshot on every test failure.")
- private boolean mLogcatOnFailure = false;
-
- @Option(name = LOGCAT_ON_FAILURE_SIZE_OPTION,
- 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 = "screenshot-on-failure",
- description = "Take a screenshot on every test failure.")
- private boolean mScreenshotOnFailure = false;
-
- @Option(name = "reboot-before-test",
- description = "Reboot the device before the test suite starts.")
- private boolean mRebootBeforeTest = false;
-
- @Option(name = "reboot-on-failure",
- description = "Reboot the device after every test failure.")
- private boolean mRebootOnFailure = false;
-
- @Option(name = "reboot-per-module",
- description = "Reboot the device before every module run.")
- private boolean mRebootPerModule = false;
-
- @Option(name = "skip-connectivity-check",
- description = "Don't verify device connectivity between module execution.")
- private boolean mSkipConnectivityCheck = false;
-
- @Option(name = "preparer-whitelist",
- description = "Only run specific preparers."
- + "Specify zero or more ITargetPreparers as canonical class names. "
- + "e.g. \"com.android.compatibility.common.tradefed.targetprep.ApkInstaller\" "
- + "If not specified, all configured preparers are run.")
- private Set<String> mPreparerWhitelist = new HashSet<>();
-
- @Option(name = "skip-all-system-status-check",
- description = "Whether all system status check between modules should be skipped")
- private boolean mSkipAllSystemStatusCheck = false;
-
- @Option(name = "skip-system-status-check",
- description = "Disable specific system status checkers."
- + "Specify zero or more SystemStatusChecker as canonical class names. e.g. "
- + "\"com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker\" "
- + "If not specified, all configured or whitelisted system status checkers are run.")
- private Set<String> mSystemStatusCheckBlacklist = new HashSet<>();
-
- @Option(name = "system-status-check-whitelist",
- description = "Only run specific system status checkers."
- + "Specify zero or more SystemStatusChecker as canonical class names. e.g. "
- + "\"com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker\" "
- + "If not specified, all configured system status checkers are run.")
- private Set<String> mSystemStatusCheckWhitelist = new HashSet<>();
-
- private List<ISystemStatusChecker> mListCheckers = new ArrayList<>();
-
- @Option(name = "collect-tests-only",
- description = "Only invoke the suite to collect list of applicable test cases. All "
- + "test run callbacks will be triggered, but test execution will not be "
- + "actually carried out.")
- private Boolean mCollectTestsOnly = null;
-
- @Option(name = "module-metadata-include-filter",
- description = "Include modules for execution based on matching of metadata fields: "
- + "for any of the specified filter name and value, if a module has a metadata "
- + "field with the same name and value, it will be included. When both module "
- + "inclusion and exclusion rules are applied, inclusion rules will be "
- + "evaluated first. Using this together with test filter inclusion rules may "
- + "result in no tests to execute if the rules don't overlap.")
- private MultiMap<String, String> mModuleMetadataIncludeFilter = new MultiMap<>();
-
- @Option(name = "module-metadata-exclude-filter",
- description = "Exclude modules for execution based on matching of metadata fields: "
- + "for any of the specified filter name and value, if a module has a metadata "
- + "field with the same name and value, it will be excluded. When both module "
- + "inclusion and exclusion rules are applied, inclusion rules will be "
- + "evaluated first.")
- private MultiMap<String, String> mModuleMetadataExcludeFilter = new MultiMap<>();
-
- private int mTotalShards;
- private Integer mShardIndex = null;
- private IModuleRepo mModuleRepo;
- private ITestDevice mDevice;
- private CompatibilityBuildHelper mBuildHelper;
-
- // variables used for local sharding scenario
- private static CountDownLatch sPreparedLatch;
- private boolean mIsLocalSharding = false;
- private boolean mIsSharded = false;
-
- private IInvocationContext mInvocationContext;
-
- /**
- * Create a new {@link CompatibilityTest} that will run the default list of
- * modules.
- */
- public CompatibilityTest() {
- this(1 /* totalShards */, new ModuleRepo(), 0);
- }
-
- /**
- * Create a new {@link CompatibilityTest} that will run a sublist of
- * modules.
- */
- public CompatibilityTest(int totalShards, IModuleRepo moduleRepo, Integer shardIndex) {
- if (totalShards < 1) {
- throw new IllegalArgumentException(
- "Must be at least 1 shard. Given:" + totalShards);
- }
- mTotalShards = totalShards;
- mModuleRepo = moduleRepo;
- mShardIndex = shardIndex;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ITestDevice getDevice() {
- return mDevice;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setDevice(ITestDevice device) {
- mDevice = device;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setBuild(IBuildInfo buildInfo) {
- mBuildHelper = new CompatibilityBuildHelper(buildInfo);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- try {
- List<ISystemStatusChecker> checkers = new ArrayList<>();
- // Get system status checkers
- if (mSkipAllSystemStatusCheck) {
- CLog.d("Skipping system status checkers");
- } else {
- checkSystemStatusBlackAndWhiteList();
- for (ISystemStatusChecker checker : mListCheckers) {
- if(shouldIncludeSystemStatusChecker(checker)) {
- checkers.add(checker);
- }
- }
- }
-
- LinkedList<IModuleDef> modules = initializeModuleRepo();
-
- mExcludeFilters.clear();
- mIncludeFilters.clear();
- // Update BuildInfo in each shard to store the original command-line arguments from
- // the session to be retried. These arguments will be serialized in the report later.
- if (mRetrySessionId != null) {
- loadRetryCommandLineArgs(mRetrySessionId);
- }
-
- listener = new FailureListener(listener, getDevice(), mBugReportOnFailure,
- mLogcatOnFailure, mScreenshotOnFailure, mRebootOnFailure, mMaxLogcatBytes);
- int moduleCount = modules.size();
- if (moduleCount == 0) {
- CLog.logAndDisplay(LogLevel.INFO, "No module to run on %s.",
- mDevice.getSerialNumber());
- // Make sure we unlock other shards.
- if (sPreparedLatch != null) {
- sPreparedLatch.countDown();
- }
- return;
- } else {
- int uniqueModuleCount = UniqueModuleCountUtil.countUniqueModules(modules);
- CLog.logAndDisplay(LogLevel.INFO, "Starting %d test sub-module%s on %s",
- uniqueModuleCount, (uniqueModuleCount > 1) ? "s" : "",
- mDevice.getSerialNumber());
- }
-
- if (mRebootBeforeTest) {
- CLog.d("Rebooting device before test starts as requested.");
- mDevice.reboot();
- }
-
- if (mSkipConnectivityCheck) {
- String clazz = NetworkConnectivityChecker.class.getCanonicalName();
- CLog.logAndDisplay(LogLevel.INFO, "\"--skip-connectivity-check\" is deprecated, "
- + "please use \"--skip-system-status-check %s\" instead", clazz);
- mSystemStatusCheckBlacklist.add(clazz);
- }
-
- // Set values and run preconditions
- boolean isPrepared = true; // whether the device has been successfully prepared
- for (int i = 0; i < moduleCount; i++) {
- IModuleDef module = modules.get(i);
- module.setBuild(mBuildHelper.getBuildInfo());
- module.setDevice(mDevice);
- module.setPreparerWhitelist(mPreparerWhitelist);
- // don't set a value if unspecified
- if (mCollectTestsOnly != null) {
- module.setCollectTestsOnly(mCollectTestsOnly);
- }
- isPrepared &= module.prepare(mSkipPreconditions, mPreconditionArgs);
- }
- if (!isPrepared) {
- throw new RuntimeException(String.format("Failed preconditions on %s",
- mDevice.getSerialNumber()));
- }
- if (mIsLocalSharding) {
- try {
- sPreparedLatch.countDown();
- int attempt = 1;
- while(!sPreparedLatch.await(MINUTES_PER_PREP_ATTEMPT, TimeUnit.MINUTES)) {
- if (attempt > NUM_PREP_ATTEMPTS ||
- InvocationFailureHandler.hasFailed(mBuildHelper)) {
- CLog.logAndDisplay(LogLevel.ERROR,
- "Incorrect preparation detected, exiting test run from %s",
- mDevice.getSerialNumber());
- return;
- }
- CLog.logAndDisplay(LogLevel.WARN, "waiting on preconditions");
- attempt++;
- }
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- // Module Repo is not useful anymore
- mModuleRepo.tearDown();
- mModuleRepo = null;
- // Run the tests
- while (!modules.isEmpty()) {
- // Make sure we remove the modules from the reference list when we are done with
- // them.
- IModuleDef module = modules.poll();
- long start = System.currentTimeMillis();
-
- if (mRebootPerModule) {
- if ("user".equals(mDevice.getProperty("ro.build.type"))) {
- CLog.e("reboot-per-module should only be used during development, "
- + "this is a\" user\" build device");
- } else {
- CLog.logAndDisplay(LogLevel.INFO, "Rebooting device before starting next "
- + "module");
- mDevice.reboot();
- }
- }
-
- // execute pre module execution checker
- if (checkers != null && !checkers.isEmpty()) {
- runPreModuleCheck(module.getName(), checkers, mDevice, listener);
- }
- IInvocationContext moduleContext = new InvocationContext();
- moduleContext.setConfigurationDescriptor(module.getConfigurationDescriptor());
- moduleContext.addInvocationAttribute(IModuleDef.MODULE_NAME, module.getName());
- moduleContext.addInvocationAttribute(IModuleDef.MODULE_ABI,
- module.getAbi().getName());
- // This format is not always true but for the deprecated runner this is best effort.
- moduleContext.addInvocationAttribute(
- IModuleDef.MODULE_ID,
- String.format("%s %s", module.getAbi().getName(), module.getName()));
- mInvocationContext.setModuleInvocationContext(moduleContext);
- // Populate the module context with devices and builds
- for (String deviceName : mInvocationContext.getDeviceConfigNames()) {
- moduleContext.addAllocatedDevice(
- deviceName, mInvocationContext.getDevice(deviceName));
- moduleContext.addDeviceBuildInfo(
- deviceName, mInvocationContext.getBuildInfo(deviceName));
- }
- module.setInvocationContext(moduleContext);
- try {
- listener.testModuleStarted(moduleContext);
- module.run(listener);
- } 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));
- StreamUtil.close(stack);
- CLog.w("Ignored DeviceUnresponsiveException because recovery was successful, "
- + "proceeding with next module. Stack trace: %s",
- stack.toString());
- CLog.w("This may be due to incorrect timeout setting on module %s",
- module.getName());
- } finally {
- // clear out module invocation context since we are now done with module
- // execution
- mInvocationContext.setModuleInvocationContext(null);
- listener.testModuleEnded();
- }
- long duration = System.currentTimeMillis() - start;
- long expected = module.getRuntimeHint();
- long delta = Math.abs(duration - expected);
- // Show warning if delta is more than 10% of expected
- if (expected > 0 && ((float)delta / (float)expected) > 0.1f) {
- CLog.logAndDisplay(LogLevel.WARN,
- "Inaccurate runtime hint for %s, expected %s was %s",
- module.getId(),
- TimeUtil.formatElapsedTime(expected),
- TimeUtil.formatElapsedTime(duration));
- }
- if (checkers != null && !checkers.isEmpty()) {
- runPostModuleCheck(module.getName(), checkers, mDevice, listener);
- }
- module = null;
- }
- } catch (FileNotFoundException fnfe) {
- throw new RuntimeException("Failed to initialize modules", fnfe);
- }
- }
-
- /**
- * Initialize module repo.
- *
- * @return A list of module definition
- * @throws DeviceNotAvailableException
- * @throws FileNotFoundException
- */
- protected LinkedList<IModuleDef> initializeModuleRepo()
- throws DeviceNotAvailableException, FileNotFoundException {
- // FIXME: Each shard will do a full initialization which is not optimal. Need a way
- // to be more specific on what to initialize.
- synchronized (mModuleRepo) {
- if (!mModuleRepo.isInitialized()) {
- setupFilters();
- // Initialize the repository, {@link CompatibilityBuildHelper#getTestsDir} can
- // throw a {@link FileNotFoundException}
- mModuleRepo.initialize(mTotalShards, mShardIndex, mBuildHelper.getTestsDir(),
- getAbis(), mDeviceTokens, mTestArgs, mModuleArgs, mIncludeFilters,
- mExcludeFilters, mModuleMetadataIncludeFilter, mModuleMetadataExcludeFilter,
- mBuildHelper.getBuildInfo());
-
- // Add the entire list of modules to the CompatibilityBuildHelper for reporting
- mBuildHelper.setModuleIds(mModuleRepo.getModuleIds());
-
- int count = UniqueModuleCountUtil.countUniqueModules(mModuleRepo.getTokenModules())
- + UniqueModuleCountUtil.countUniqueModules(
- mModuleRepo.getNonTokenModules());
- CLog.logAndDisplay(LogLevel.INFO, "========================================");
- CLog.logAndDisplay(LogLevel.INFO, "Starting a run with %s unique modules.", count);
- CLog.logAndDisplay(LogLevel.INFO, "========================================");
- } else {
- CLog.d("ModuleRepo already initialized.");
- }
- // Get the tests to run in this shard
- return mModuleRepo.getModules(getDevice().getSerialNumber(), mShardIndex);
- }
- }
-
- /**
- * Gets the set of ABIs supported by both Compatibility and the device under test
- *
- * @return The set of ABIs to run the tests on
- * @throws DeviceNotAvailableException
- */
- Set<IAbi> getAbis() throws DeviceNotAvailableException {
- Set<IAbi> abis = new LinkedHashSet<>();
- Set<String> archAbis = getAbisForBuildTargetArch();
- if (mPrimaryAbiRun) {
- if (mAbiName == null) {
- // Get the primary from the device and make it the --abi to run.
- mAbiName = mDevice.getProperty("ro.product.cpu.abi").trim();
- } else {
- CLog.d("Option --%s supersedes the option --%s, using abi: %s", ABI_OPTION,
- PRIMARY_ABI_RUN, mAbiName);
- }
- }
- if (mAbiName != null) {
- // A particular abi was requested, it still need to be supported by the build.
- if ((!mSkipHostArchCheck && !archAbis.contains(mAbiName)) ||
- !AbiUtils.isAbiSupportedByCompatibility(mAbiName)) {
- throw new IllegalArgumentException(String.format("Your CTS hasn't been built with "
- + "abi '%s' support, this CTS currently supports '%s'.",
- mAbiName, archAbis));
- } else {
- abis.add(new Abi(mAbiName, AbiUtils.getBitness(mAbiName)));
- return abis;
- }
- } else {
- // Run on all abi in common between the device and CTS.
- List<String> deviceAbis = Arrays.asList(AbiFormatter.getSupportedAbis(mDevice, ""));
- for (String abi : deviceAbis) {
- if ((mSkipHostArchCheck || archAbis.contains(abi)) &&
- AbiUtils.isAbiSupportedByCompatibility(abi)) {
- abis.add(new Abi(abi, AbiUtils.getBitness(abi)));
- } else {
- CLog.d("abi '%s' is supported by device but not by this CTS build (%s), tests "
- + "will not run against it.", abi, archAbis);
- }
- }
- if (abis.isEmpty()) {
- throw new IllegalArgumentException(String.format("None of the abi supported by this"
- + " CTS build ('%s') are supported by the device ('%s').",
- archAbis, deviceAbis));
- }
- return abis;
- }
- }
-
- /**
- * Return the abis supported by the Host build target architecture.
- * Exposed for testing.
- */
- protected Set<String> getAbisForBuildTargetArch() {
- return AbiUtils.getAbisForArch(TestSuiteInfo.getInstance().getTargetArchs().get(0));
- }
-
- /**
- * Check that the system status checker specified by option are valid.
- */
- protected void checkSystemStatusBlackAndWhiteList() {
- for (String checker : mSystemStatusCheckWhitelist) {
- try {
- Class.forName(checker);
- } catch (ClassNotFoundException e) {
- ConfigurationException ex = new ConfigurationException(
- String.format("--system-status-check-whitelist must contains valid class, "
- + "%s was not found", checker), e);
- throw new RuntimeException(ex);
- }
- }
- for (String checker : mSystemStatusCheckBlacklist) {
- try {
- Class.forName(checker);
- } catch (ClassNotFoundException e) {
- ConfigurationException ex = new ConfigurationException(
- String.format("--skip-system-status-check must contains valid class, "
- + "%s was not found", checker), e);
- throw new RuntimeException(ex);
- }
- }
- }
-
- /**
- * Resolve the inclusion and exclusion logic of system status checkers
- *
- * @param s the {@link ISystemStatusChecker} to perform filtering logic on
- * @return True if the {@link ISystemStatusChecker} should be included, false otherwise.
- */
- private boolean shouldIncludeSystemStatusChecker(ISystemStatusChecker s) {
- String clazz = s.getClass().getCanonicalName();
- boolean shouldInclude = mSystemStatusCheckWhitelist.isEmpty()
- || mSystemStatusCheckWhitelist.contains(clazz);
- boolean shouldExclude = !mSystemStatusCheckBlacklist.isEmpty()
- && mSystemStatusCheckBlacklist.contains(clazz);
- return shouldInclude && !shouldExclude;
- }
-
- @VisibleForTesting
- void runPreModuleCheck(String moduleName, List<ISystemStatusChecker> checkers,
- ITestDevice device, ITestLogger logger) throws DeviceNotAvailableException {
- CLog.i("Running system status checker before module execution: %s", moduleName);
- List<String> failures = new ArrayList<>();
- for (ISystemStatusChecker checker : checkers) {
- StatusCheckerResult result = checker.preExecutionCheck(device);
- if (!CheckStatus.SUCCESS.equals(result.getStatus())) {
- failures.add(checker.getClass().getCanonicalName());
- CLog.w("System status checker [%s] failed", checker.getClass().getCanonicalName());
- }
- }
- if (!failures.isEmpty()) {
- CLog.w("There are failed system status checkers: %s capturing a bugreport",
- failures.toString());
- try (InputStreamSource bugSource = device.getBugreport()) {
- logger.testLog(String.format("bugreport-checker-pre-module-%s", moduleName),
- LogDataType.BUGREPORT, bugSource);
- }
- }
- }
-
- @VisibleForTesting
- void runPostModuleCheck(String moduleName, List<ISystemStatusChecker> checkers,
- ITestDevice device, ITestLogger logger) throws DeviceNotAvailableException {
- CLog.i("Running system status checker after module execution: %s", moduleName);
- List<String> failures = new ArrayList<>();
- for (ISystemStatusChecker checker : checkers) {
- StatusCheckerResult result = checker.postExecutionCheck(device);
- if (!CheckStatus.SUCCESS.equals(result.getStatus())) {
- failures.add(checker.getClass().getCanonicalName());
- CLog.w("System status checker [%s] failed", checker.getClass().getCanonicalName());
- }
- }
- if (!failures.isEmpty()) {
- CLog.w("There are failed system status checkers: %s capturing a bugreport",
- failures.toString());
- try (InputStreamSource bugSource = device.getBugreport()) {
- logger.testLog(String.format("bugreport-checker-post-module-%s", moduleName),
- LogDataType.BUGREPORT, bugSource);
- }
- }
- }
-
- /**
- * Sets the retry command-line args to be stored in the BuildInfo and serialized into the
- * report upon completion of the invocation.
- */
- void loadRetryCommandLineArgs(Integer sessionId) {
- IInvocationResult result = null;
- try {
- result = ResultHandler.findResult(mBuildHelper.getResultsDir(), sessionId);
- } catch (FileNotFoundException e) {
- // We should never reach this point, because this method should only be called
- // after setupFilters(), so result exists if we've gotten this far
- throw new RuntimeException(e);
- }
- if (result == null) {
- // Again, this should never happen
- throw new IllegalArgumentException(String.format(
- "Could not find session with id %d", sessionId));
- }
- String retryCommandLineArgs = result.getCommandLineArgs();
- if (retryCommandLineArgs != null) {
- mBuildHelper.setRetryCommandLineArgs(retryCommandLineArgs);
- }
- }
-
- /**
- * Sets the include/exclude filters up based on if a module name was given or whether this is a
- * retry run.
- */
- void setupFilters() throws DeviceNotAvailableException {
- if (mRetrySessionId != null) {
- // Load the invocation result
- RetryFilterHelper helper = createRetryFilterHelper(mRetrySessionId);
- helper.validateBuildFingerprint(mDevice);
- helper.setCommandLineOptionsFor(this);
- helper.populateRetryFilters();
- mIncludeFilters = helper.getIncludeFilters();
- mExcludeFilters = helper.getExcludeFilters();
- helper.tearDown();
- } else {
- if (mSubPlan != null) {
- ISubPlan subPlan = SubPlanHelper.getSubPlanByName(mBuildHelper, mSubPlan);
- mIncludeFilters.addAll(subPlan.getIncludeFilters());
- mExcludeFilters.addAll(subPlan.getExcludeFilters());
- }
- if (mModuleName != null) {
- try {
- List<String> modules = ModuleRepo.getModuleNamesMatching(
- mBuildHelper.getTestsDir(), mModuleName);
- if (modules.size() == 0) {
- throw new IllegalArgumentException(
- String.format("No modules found matching %s", mModuleName));
- } else if (modules.size() > 1) {
- throw new IllegalArgumentException(String.format("Multiple modules found"
- + " matching %s:\n%s\nWhich one did you mean?\n",
- mModuleName, ArrayUtil.join("\n", modules)));
- } else {
- String module = modules.get(0);
- cleanFilters(mIncludeFilters, module);
- cleanFilters(mExcludeFilters, module);
- mIncludeFilters.add(
- new TestFilter(mAbiName, module, mTestName).toString());
- }
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- }
- } else if (mTestName != null) {
- throw new IllegalArgumentException(
- "Test name given without module name. Add --module <module-name>");
- }
- }
- }
-
- /* Creates a new {@link RetryFilterHelper} from attributes of this object. */
- protected RetryFilterHelper createRetryFilterHelper(Integer retrySessionId) {
- return new RetryFilterHelper(mBuildHelper, retrySessionId,
- mSubPlan, mIncludeFilters, mExcludeFilters, mAbiName, mModuleName, mTestName,
- mRetryType);
- }
-
- /* Helper method designed to remove filters in a list not applicable to the given module */
- private static void cleanFilters(Set<String> filters, String module) {
- Set<String> cleanedFilters = new HashSet<String>();
- for (String filter : filters) {
- if (module.equals(TestFilter.createFrom(filter).getName())) {
- cleanedFilters.add(filter); // Module name matches, filter passes
- }
- }
- filters.clear();
- filters.addAll(cleanedFilters);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<IRemoteTest> split() {
- if (mShards <= 1) {
- return null;
- }
- mIsLocalSharding = true;
- List<IRemoteTest> shardQueue = new LinkedList<>();
- for (int i = 0; i < mShards; i++) {
- CompatibilityTest test = (CompatibilityTest) getTestShard(mShards, i);
- test.mIsLocalSharding = true;
- shardQueue.add(test);
- }
- sPreparedLatch = new CountDownLatch(shardQueue.size());
- return shardQueue;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<IRemoteTest> split(int shardCount) {
- if (shardCount <= 1 || mIsSharded) {
- return null;
- }
- mIsSharded = true;
- List<IRemoteTest> shardQueue = new LinkedList<>();
- for (int i = 0; i < shardCount; i++) {
- CompatibilityTest test = (CompatibilityTest) getTestShard(shardCount, i);
- shardQueue.add(test);
- test.mIsSharded = true;
- }
- return shardQueue;
- }
-
- private IRemoteTest getTestShard(int shardCount, int shardIndex) {
- CompatibilityTest test = new CompatibilityTest(shardCount, mModuleRepo, shardIndex);
- OptionCopier.copyOptionsNoThrow(this, test);
- // Set the shard count because the copy option on the previous line
- // copies over the mShard value
- test.mShards = 0;
- return test;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setSystemStatusChecker(List<ISystemStatusChecker> systemCheckers) {
- mListCheckers = systemCheckers;
- }
-
- @Override
- public void setCollectTestsOnly(boolean collectTestsOnly) {
- mCollectTestsOnly = collectTestsOnly;
- }
-
- /**
- * Sets include-filters for the compatibility test
- */
- public void setIncludeFilter(Set<String> includeFilters) {
- mIncludeFilters.addAll(includeFilters);
- }
-
- /**
- * Sets exclude-filters for the compatibility test
- */
- public void setExcludeFilter(Set<String> excludeFilters) {
- mExcludeFilters.addAll(excludeFilters);
- }
-
- @Override
- public void setInvocationContext(IInvocationContext invocationContext) {
- mInvocationContext = invocationContext;
- }
-
- /**
- * @return the mSubPlan
- */
- protected String getSubPlan() {
- return mSubPlan;
- }
-
- /**
- * @return the mIncludeFilters
- */
- protected Set<String> getIncludeFilters() {
- return mIncludeFilters;
- }
-
- /**
- * @return the mExcludeFilters
- */
- protected Set<String> getExcludeFilters() {
- return mExcludeFilters;
- }
-
- /**
- * @return the mModuleName
- */
- protected String getModuleName() {
- return mModuleName;
- }
-
- /**
- * @return the mTestName
- */
- protected String getTestName() {
- return mTestName;
- }
-
- /**
- * @return the mModuleArgs
- */
- protected List<String> getModuleArgs() {
- return mModuleArgs;
- }
-
- /**
- * @return the mTestArgs
- */
- protected List<String> getTestArgs() {
- return mTestArgs;
- }
-
- /**
- * @return the mRetryType
- */
- protected RetryType getRetryType() {
- return mRetryType;
- }
-
- /**
- * @return the mAbiName
- */
- protected String getAbiName() {
- return mAbiName;
- }
-
- /**
- * @return the mDeviceTokens
- */
- protected List<String> getDeviceTokens() {
- return mDeviceTokens;
- }
-
- /**
- * @return the mModuleMetadataIncludeFilter
- */
- protected MultiMap<String, String> getModuleMetadataIncludeFilter() {
- return mModuleMetadataIncludeFilter;
- }
-
- /**
- * @return the mModuleMetadataExcludeFilter
- */
- protected MultiMap<String, String> getModuleMetadataExcludeFilter() {
- return mModuleMetadataExcludeFilter;
- }
-
- /**
- * @return the mTotalShards
- */
- protected int getTotalShards() {
- return mTotalShards;
- }
-
- /**
- * @return the mShardIndex
- */
- protected Integer getShardIndex() {
- return mShardIndex;
- }
-
- /**
- * @return the mBuildHelper
- */
- protected CompatibilityBuildHelper getBuildHelper() {
- return mBuildHelper;
- }
-
- /**
- * @return the mInvocationContext
- */
- protected IInvocationContext getInvocationContext() {
- return mInvocationContext;
- }
-
- /**
- * @return the mModuleRepo
- */
- protected IModuleRepo getModuleRepo() {
- return mModuleRepo;
- }
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/FailureListener.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/FailureListener.java
deleted file mode 100644
index d21ef81..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/FailureListener.java
+++ /dev/null
@@ -1,133 +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.compatibility.common.tradefed.testtype;
-
-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.result.InputStreamSource;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.ResultForwarder;
-import com.android.tradefed.result.TestDescription;
-import com.android.tradefed.util.RunUtil;
-
-public class FailureListener extends ResultForwarder {
-
- private static final int DEFAULT_MAX_LOGCAT_BYTES = 500 * 1024; // 500K
- /* Arbitrary upper limit for mMaxLogcatBytes, per b/30720850 */
- public static final int LOGCAT_BYTE_LIMIT = 20 * 1024 * 1024; // 20 MB
-
- private ITestDevice mDevice;
- private boolean mBugReportOnFailure;
- private boolean mLogcatOnFailure;
- private boolean mScreenshotOnFailure;
- private boolean mRebootOnFailure;
- private int mMaxLogcatBytes;
-
- public FailureListener(ITestInvocationListener listener, ITestDevice device,
- boolean bugReportOnFailure, boolean logcatOnFailure, boolean screenshotOnFailure,
- boolean rebootOnFailure, int maxLogcatBytes) {
- super(listener);
- mDevice = device;
- mBugReportOnFailure = bugReportOnFailure;
- mLogcatOnFailure = logcatOnFailure;
- mScreenshotOnFailure = screenshotOnFailure;
- mRebootOnFailure = rebootOnFailure;
- if (maxLogcatBytes < 0 ) {
- CLog.w("FailureListener could not set %s to '%d', using default value %d",
- CompatibilityTest.LOGCAT_ON_FAILURE_SIZE_OPTION, maxLogcatBytes,
- DEFAULT_MAX_LOGCAT_BYTES);
- mMaxLogcatBytes = DEFAULT_MAX_LOGCAT_BYTES;
- } else if (maxLogcatBytes > LOGCAT_BYTE_LIMIT) {
- CLog.w("Value %d for %s exceeds limit %d, using limit value", maxLogcatBytes,
- CompatibilityTest.LOGCAT_ON_FAILURE_SIZE_OPTION, LOGCAT_BYTE_LIMIT);
- mMaxLogcatBytes = LOGCAT_BYTE_LIMIT;
- } else {
- mMaxLogcatBytes = maxLogcatBytes;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testFailed(TestDescription test, String trace) {
- super.testFailed(test, trace);
- CLog.i("FailureListener.testFailed %s %b %b %b",
- test.toString(), mBugReportOnFailure, mLogcatOnFailure, mScreenshotOnFailure);
- if (mScreenshotOnFailure) {
- try {
- try (InputStreamSource screenSource = mDevice.getScreenshot()) {
- super.testLog(String.format("%s-screenshot", test.toString()), LogDataType.PNG,
- screenSource);
- }
- } catch (DeviceNotAvailableException e) {
- CLog.e(e);
- CLog.e("Device %s became unavailable while capturing screenshot",
- mDevice.getSerialNumber());
- }
- }
- if (mBugReportOnFailure) {
- int api = -1;
- try {
- api = mDevice.getApiLevel();
- } catch (DeviceNotAvailableException e) {
- // ignore, it will be raised later.
- }
- if (api < 24) {
- try (InputStreamSource fallback = mDevice.getBugreport()) {
- super.testLog(String.format("%s-bugreport", test.toString()),
- LogDataType.BUGREPORT, fallback);
- }
- } else {
- try (InputStreamSource bugSource = mDevice.getBugreportz()) {
- if (bugSource != null) {
- super.testLog(String.format("%s-bugreportz", test.toString()),
- LogDataType.BUGREPORTZ, bugSource);
- } else {
- CLog.e("Failed to capture bugreport for %s", test.toString());
- }
- }
- }
- }
- if (mLogcatOnFailure) {
- // sleep 2s to ensure test failure stack trace makes it into logcat capture
- RunUtil.getDefault().sleep(2 * 1000);
- try (InputStreamSource logSource = mDevice.getLogcat(mMaxLogcatBytes)) {
- super.testLog(String.format("%s-logcat", test.toString()), LogDataType.LOGCAT,
- logSource);
- }
- }
- if (mRebootOnFailure) {
- try {
- // Rebooting on all failures can hide legitimate issues and platform instabilities,
- // therefore only allowed on "user-debug" and "eng" builds.
- if ("user".equals(mDevice.getProperty("ro.build.type"))) {
- CLog.e("Reboot-on-failure should only be used during development," +
- " this is a\" user\" build device");
- } else {
- mDevice.reboot();
- }
- } catch (DeviceNotAvailableException e) {
- CLog.e(e);
- CLog.e("Device %s became unavailable while rebooting",
- mDevice.getSerialNumber());
- }
- }
- }
-
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java
deleted file mode 100644
index 5b49ed6..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java
+++ /dev/null
@@ -1,102 +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.compatibility.common.tradefed.testtype;
-
-import com.android.tradefed.config.ConfigurationDescriptor;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.invoker.IInvocationContext;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IInvocationContextReceiver;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.IRuntimeHintProvider;
-import com.android.tradefed.testtype.ITestCollector;
-import com.android.tradefed.testtype.suite.ModuleDefinition;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Container for Compatibility test info.
- *
- * @deprecated This class is associated with {@link CompatibilityTest} which is deprecated
- */
-@Deprecated
-public interface IModuleDef
- extends Comparable<IModuleDef>,
- IBuildReceiver,
- IDeviceTest,
- IRemoteTest,
- IRuntimeHintProvider,
- ITestCollector,
- IInvocationContextReceiver {
-
- /** key names used for saving module info into {@link IInvocationContext} */
- // This currently references ModuleDefinition so that there's only once source for String
- // literals and making it easier to converge IModuleDef and ModuleDefinition later
- public static String MODULE_NAME = ModuleDefinition.MODULE_NAME;
- public static String MODULE_ABI = ModuleDefinition.MODULE_ABI;
- public static String MODULE_ID = ModuleDefinition.MODULE_ID;
-
- /**
- * @return The name of this module.
- */
- String getName();
-
- /**
- * @return a {@link String} to uniquely identify this module.
- */
- String getId();
-
- /**
- * @return the abi of this test module.
- */
- IAbi getAbi();
-
- /**
- * @return the {@link Set} of tokens a device must have in order to run this module.
- */
- Set<String> getTokens();
-
- /**
- * @return the {@link IRemoteTest} that runs the tests.
- */
- IRemoteTest getTest();
-
- /**
- * Set a list of preparers to allow to run before or after a test.
- * If this list is empty, then all configured preparers will run.
- *
- * @param preparerWhitelist list containing the simple name of the preparer to run.
- */
- void setPreparerWhitelist(Set<String> preparerWhitelist);
-
- /**
- * Pushes dynamic configuration, then runs the module's precondition checks and setup tasks.
- * @param skipPrep whether preparation should be skipped
- * @param preconditionArgs arguments to set on precondition preparers for the module, taking
- * format arg-name:arg-value. If "arg-value" is unset, the value will default to "true".
- * @return whether preparation succeeded.
- */
- boolean prepare(boolean skipPrep, List<String> preconditionArgs)
- throws DeviceNotAvailableException;
-
- /**
- * Retrieves the {@link ConfigurationDescriptor} associated with module config
- */
- ConfigurationDescriptor getConfigurationDescriptor();
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleRepo.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleRepo.java
deleted file mode 100644
index 6989184..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleRepo.java
+++ /dev/null
@@ -1,80 +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.compatibility.common.tradefed.testtype;
-
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.util.MultiMap;
-
-import java.io.File;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Interface for accessing tests from the Compatibility repository.
- *
- * @deprecated This class is associated with {@link CompatibilityTest} which is deprecate
- */
-@Deprecated
-public interface IModuleRepo {
-
- /**
- * @return true if this repository has been initialized.
- */
- boolean isInitialized();
-
- /**
- * Initializes the repository.
- */
- void initialize(int shards, Integer shardIndex, File testsDir, Set<IAbi> abis,
- List<String> deviceTokens, List<String> testArgs, List<String> moduleArgs,
- Set<String> mIncludeFilters, Set<String> mExcludeFilters,
- MultiMap<String, String> metadataIncludeFilters,
- MultiMap<String, String> metadataExcludeFilters,
- IBuildInfo buildInfo);
-
- /**
- * @return a {@link LinkedList} of all modules to run on the device referenced by the given
- * serial.
- */
- LinkedList<IModuleDef> getModules(String serial, int shardIndex);
-
- /**
- * @return the number of shards this repo is initialized for.
- */
- int getNumberOfShards();
-
- /**
- * @return the modules which do not have token and have not been assigned to a device.
- */
- List<IModuleDef> getNonTokenModules();
-
- /**
- * @return the modules which have token and have not been assigned to a device.
- */
- List<IModuleDef> getTokenModules();
-
- /**
- * @return An array of all module ids in the repo.
- */
- String[] getModuleIds();
-
- /**
- * Clean up all internal references.
- */
- void tearDown();
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/JarHostTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/JarHostTest.java
deleted file mode 100644
index 91b767a..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/JarHostTest.java
+++ /dev/null
@@ -1,117 +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.compatibility.common.tradefed.testtype;
-
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.invoker.TestInformation;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.ResultForwarder;
-import com.android.tradefed.testtype.HostTest;
-import com.android.tradefed.util.proto.TfMetricProtoUtil;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Test runner for host-side JUnit tests.
- */
-public class JarHostTest extends HostTest {
-
- /** {@inheritDoc} */
- @Override
- public void run(TestInformation testInfo, ITestInvocationListener listener)
- throws DeviceNotAvailableException {
- // Set test information otherwise it might fail to countTestCases.
- setTestInformation(testInfo);
- int numTests = 0;
- RuntimeException bufferedException = null;
- try {
- numTests = countTestCases();
- } catch (RuntimeException e) {
- bufferedException = e;
- }
- long startTime = System.currentTimeMillis();
- listener.testRunStarted(getClass().getName(), numTests);
- HostTestListener hostListener = new HostTestListener(listener);
- try {
- if (bufferedException != null) {
- throw bufferedException;
- }
- super.run(testInfo, hostListener);
- } finally {
- HashMap<String, Metric> metrics = hostListener.getNewMetrics();
- metrics.putAll(TfMetricProtoUtil.upgradeConvert(hostListener.getMetrics()));
- listener.testRunEnded(System.currentTimeMillis() - startTime, metrics);
- }
- }
-
- /**
- * Wrapper listener that forwards all events except testRunStarted() and testRunEnded() to
- * the embedded listener. Each test class in the jar will invoke these events, which
- * HostTestListener withholds from listeners for console logging and result reporting.
- */
- public class HostTestListener extends ResultForwarder {
-
- private Map<String, String> mCollectedMetrics = new HashMap<>();
- private HashMap<String, Metric> mCollectedNewMetrics = new HashMap<>();
-
- public HostTestListener(ITestInvocationListener listener) {
- super(listener);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunStarted(String name, int numTests) {
- CLog.d("HostTestListener.testRunStarted(%s, %d)", name, numTests);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunEnded(long elapsedTime, Map<String, String> metrics) {
- CLog.d("HostTestListener.testRunEnded(%d, %s)", elapsedTime, metrics.toString());
- mCollectedMetrics.putAll(metrics);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunEnded(long elapsedTime, HashMap<String, Metric> metrics) {
- CLog.d("HostTestListener.testRunEnded(%d, %s)", elapsedTime, metrics.toString());
- mCollectedNewMetrics.putAll(metrics);
- }
-
- /**
- * Returns all the metrics reported by the tests
- */
- Map<String, String> getMetrics() {
- return mCollectedMetrics;
- }
-
- /**
- * Returns all the proto metrics reported by the tests
- */
- HashMap<String, Metric> getNewMetrics() {
- return mCollectedNewMetrics;
- }
- }
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
deleted file mode 100644
index afb59c8..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
+++ /dev/null
@@ -1,435 +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.compatibility.common.tradefed.testtype;
-
-import com.android.compatibility.common.tradefed.result.IModuleListener;
-import com.android.compatibility.common.tradefed.result.ModuleListener;
-import com.android.compatibility.common.tradefed.targetprep.DynamicConfigPusher;
-import com.android.compatibility.common.tradefed.targetprep.PreconditionPreparer;
-import com.android.compatibility.common.tradefed.targetprep.TokenRequirement;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.ConfigurationDescriptor;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.config.OptionSetter;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.invoker.IInvocationContext;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
-import com.android.tradefed.result.ITestInvocationListener;
-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.IInvocationContextReceiver;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.IRuntimeHintProvider;
-import com.android.tradefed.testtype.ITestCollector;
-import com.android.tradefed.testtype.ITestFilterReceiver;
-import com.android.tradefed.util.AbiUtils;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Container for Compatibility test module info.
- *
- * @deprecated This class is associated with {@link CompatibilityTest} which is deprecate
- */
-@Deprecated
-public class ModuleDef implements IModuleDef {
-
- private final String mId;
- private final String mName;
- private final IAbi mAbi;
- private final Set<String> mTokens = new HashSet<>();
- private IRemoteTest mTest = null;
- private List<ITargetPreparer> mDynamicConfigPreparers = new ArrayList<>();
- private List<ITargetPreparer> mPreconditions = new ArrayList<>();
- private List<ITargetPreparer> mPreparers = new ArrayList<>();
- private List<ITargetCleaner> mCleaners = new ArrayList<>();
- private IBuildInfo mBuild;
- private ITestDevice mDevice;
- private Set<String> mPreparerWhitelist = new HashSet<>();
- private ConfigurationDescriptor mConfigurationDescriptor;
- private IInvocationContext mContext;
-
- public ModuleDef(String name, IAbi abi, IRemoteTest test,
- List<ITargetPreparer> preparers, ConfigurationDescriptor configurationDescriptor) {
- mId = AbiUtils.createId(abi.getName(), name);
- mName = name;
- mAbi = abi;
- mTest = test;
- mConfigurationDescriptor = configurationDescriptor;
- initializePrepareLists(preparers);
- }
-
- /**
- * Sort preparers into different lists according to their types
- *
- * @param preparers target preparers
- * @throws IllegalArgumentException
- */
- protected void initializePrepareLists(List<ITargetPreparer> preparers)
- throws IllegalArgumentException {
- boolean hasAbiReceiver = false;
- for (ITargetPreparer preparer : preparers) {
- if (preparer instanceof IAbiReceiver) {
- hasAbiReceiver = true;
- }
- // Separate preconditions and dynamicconfigpushers from other target preparers.
- if (preparer instanceof PreconditionPreparer) {
- mPreconditions.add(preparer);
- } else if (preparer instanceof DynamicConfigPusher) {
- mDynamicConfigPreparers.add(preparer);
- } else if (preparer instanceof TokenRequirement) {
- mTokens.addAll(((TokenRequirement) preparer).getTokens());
- } else {
- mPreparers.add(preparer);
- }
- if (preparer instanceof ITargetCleaner) {
- mCleaners.add((ITargetCleaner) preparer);
- }
- }
- // Reverse cleaner order
- Collections.reverse(mCleaners);
-
- checkRequiredInterfaces(hasAbiReceiver);
- }
-
- /**
- * Check whether required interfaces are implemented.
- *
- * @param hasAbiReceiver whether at lease one of the preparers is AbiReceiver
- * @throws IllegalArgumentException
- */
- protected void checkRequiredInterfaces(boolean hasAbiReceiver) throws IllegalArgumentException {
- // Required interfaces:
- if (!hasAbiReceiver && !(mTest instanceof IAbiReceiver)) {
- throw new IllegalArgumentException(mTest + "does not implement IAbiReceiver"
- + " - for multi-abi testing (64bit)");
- } else if (!(mTest instanceof IRuntimeHintProvider)) {
- throw new IllegalArgumentException(mTest + " does not implement IRuntimeHintProvider"
- + " - to provide estimates of test invocation time");
- } else if (!(mTest instanceof ITestCollector)) {
- throw new IllegalArgumentException(mTest + " does not implement ITestCollector"
- + " - for test list collection");
- } else if (!(mTest instanceof ITestFilterReceiver)) {
- throw new IllegalArgumentException(mTest + " does not implement ITestFilterReceiver"
- + " - to allow tests to be filtered");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return mId;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getId() {
- return mId;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getName() {
- return mName;
- }
-
- /**
- * @return the mPreparerWhitelist
- */
- protected Set<String> getPreparerWhitelist() {
- return mPreparerWhitelist;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IAbi getAbi() {
- return mAbi;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set<String> getTokens() {
- return mTokens;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long getRuntimeHint() {
- if (mTest instanceof IRuntimeHintProvider) {
- return ((IRuntimeHintProvider) mTest).getRuntimeHint();
- }
- return TimeUnit.MINUTES.toMillis(1); // Default 1 minute.
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IRemoteTest getTest() {
- return mTest;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setPreparerWhitelist(Set<String> preparerWhitelist) {
- mPreparerWhitelist.addAll(preparerWhitelist);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int compareTo(IModuleDef moduleDef) {
- return getName().compareTo(moduleDef.getName());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setBuild(IBuildInfo build) {
- mBuild = build;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ITestDevice getDevice() {
- return mDevice;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setDevice(ITestDevice device) {
- mDevice = device;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- CLog.d("Running module %s", toString());
- runPreparerSetups();
-
- CLog.d("Test: %s", mTest.getClass().getSimpleName());
- prepareTestClass();
-
- IModuleListener moduleListener = new ModuleListener(this, listener);
- // Guarantee events testRunStarted and testRunEnded in case underlying test runner does not
- ModuleFinisher moduleFinisher = new ModuleFinisher(moduleListener);
- mTest.run(moduleFinisher);
- moduleFinisher.finish();
-
- // Tear down
- runPreparerTeardowns();
- }
-
- /**
- * Run preparers' teardown functions.
- */
- protected void runPreparerTeardowns() throws DeviceNotAvailableException {
- for (ITargetCleaner cleaner : mCleaners) {
- CLog.d("Cleaner: %s", cleaner.getClass().getSimpleName());
- cleaner.tearDown(mDevice, mBuild, null);
- }
- }
-
- /**
- * Run preparers' setup functions.
- *
- * @throws DeviceNotAvailableException
- */
- protected void runPreparerSetups() throws DeviceNotAvailableException {
- // Run DynamicConfigPusher setup once more, in case cleaner has previously
- // removed dynamic config file from the target (see b/32877809)
- for (ITargetPreparer preparer : mDynamicConfigPreparers) {
- runPreparerSetup(preparer);
- }
- // Setup
- for (ITargetPreparer preparer : mPreparers) {
- runPreparerSetup(preparer);
- }
- }
-
- /**
- * Set test classes attributes according to their interfaces.
- */
- protected void prepareTestClass() {
- if (mTest instanceof IAbiReceiver) {
- ((IAbiReceiver) mTest).setAbi(mAbi);
- }
- if (mTest instanceof IBuildReceiver) {
- ((IBuildReceiver) mTest).setBuild(mBuild);
- }
- if (mTest instanceof IDeviceTest) {
- ((IDeviceTest) mTest).setDevice(mDevice);
- }
- if (mTest instanceof IInvocationContextReceiver) {
- ((IInvocationContextReceiver) mTest).setInvocationContext(mContext);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean prepare(boolean skipPrep, List<String> preconditionArgs)
- throws DeviceNotAvailableException {
- for (ITargetPreparer preparer : mDynamicConfigPreparers) {
- runPreparerSetup(preparer);
- }
- for (ITargetPreparer preparer : mPreconditions) {
- setOption(preparer, CompatibilityTest.SKIP_PRECONDITIONS_OPTION,
- Boolean.toString(skipPrep));
- for (String preconditionArg : preconditionArgs) {
- setOption(preparer, CompatibilityTest.PRECONDITION_ARG_OPTION, preconditionArg);
- }
- try {
- runPreparerSetup(preparer);
- } catch (RuntimeException e) {
- CLog.e("Precondition class %s failed", preparer.getClass().getCanonicalName());
- return false;
- }
- }
- return true;
- }
-
- private void runPreparerSetup(ITargetPreparer preparer) throws DeviceNotAvailableException {
- String preparerName = preparer.getClass().getCanonicalName();
- if (!mPreparerWhitelist.isEmpty() && !mPreparerWhitelist.contains(preparerName)) {
- CLog.d("Skipping Preparer: %s since it is not in the whitelist %s",
- preparerName, mPreparerWhitelist);
- return;
- }
- CLog.d("Preparer: %s", preparer.getClass().getSimpleName());
- if (preparer instanceof IAbiReceiver) {
- ((IAbiReceiver) preparer).setAbi(mAbi);
- }
- try {
- preparer.setUp(mDevice, mBuild);
- } catch (BuildError e) {
- // This should only happen for flashing new build
- CLog.e("Unexpected BuildError from preparer: %s",
- preparer.getClass().getCanonicalName());
- throw new RuntimeException(e);
- } catch (TargetSetupError e) {
- // log preparer class then rethrow & let caller handle
- CLog.e("TargetSetupError in preparer: %s",
- preparer.getClass().getCanonicalName());
- throw new RuntimeException(e);
- }
- }
-
- private void setOption(Object target, String option, String value) {
- try {
- OptionSetter setter = new OptionSetter(target);
- setter.setOptionValue(option, value);
- } catch (ConfigurationException e) {
- CLog.e(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setCollectTestsOnly(boolean collectTestsOnly) {
- ((ITestCollector) mTest).setCollectTestsOnly(collectTestsOnly);
- }
-
- /*
- * ResultForwarder that tracks whether method testRunStarted() has been called for its
- * listener. If not, invoking finish() will call testRunStarted with 0 tests for this module,
- * as well as testRunEnded with 0 ms elapsed.
- */
- private class ModuleFinisher extends ResultForwarder {
-
- private boolean mFinished;
- private ITestInvocationListener mListener;
-
- public ModuleFinisher(ITestInvocationListener listener) {
- super(listener);
- mListener = listener;
- mFinished = false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void testRunStarted(String name, int numTests) {
- mListener.testRunStarted(name, numTests);
- mFinished = true;
- }
-
- public void finish() {
- if (!mFinished) {
- mListener.testRunStarted(mId, 0);
- mListener.testRunEnded(0, new HashMap<String, Metric>());
- }
- }
- }
-
- @Override
- public ConfigurationDescriptor getConfigurationDescriptor() {
- return mConfigurationDescriptor;
- }
-
- /**
- * @return the {@link IInvocationContext} for the module
- */
- protected IInvocationContext getInvocationContext() {
- return mContext;
- }
-
- @Override
- public void setInvocationContext(IInvocationContext invocationContext) {
- mContext = invocationContext;
- }
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
deleted file mode 100644
index 6884a5f..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
+++ /dev/null
@@ -1,668 +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.compatibility.common.tradefed.testtype;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.compatibility.common.tradefed.result.TestRunHandler;
-import com.android.compatibility.common.tradefed.util.LinearPartition;
-import com.android.compatibility.common.tradefed.util.UniqueModuleCountUtil;
-import com.android.compatibility.common.util.TestFilter;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.config.ConfigurationFactory;
-import com.android.tradefed.config.IConfiguration;
-import com.android.tradefed.config.IConfigurationFactory;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.ITestFileFilterReceiver;
-import com.android.tradefed.testtype.ITestFilterReceiver;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.FileUtil;
-import com.android.tradefed.util.MultiMap;
-import com.android.tradefed.util.TimeUtil;
-
-import com.google.common.annotations.VisibleForTesting;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-/**
- * Retrieves Compatibility test module definitions from the repository.
- *
- * @deprecated This class is associated with {@link CompatibilityTest} which is deprecate
- */
-@Deprecated
-public class ModuleRepo implements IModuleRepo {
-
- private static final String CONFIG_EXT = ".config";
- private static final Map<String, Integer> ENDING_MODULES = new HashMap<>();
- static {
- // b/62732298 put testFullDisk in the end to accommodate CTSMediaStressTest temporally
- ENDING_MODULES.put("CtsAppSecurityHostTestCases", 1);
- ENDING_MODULES.put("CtsMonkeyTestCases", 2);
- }
- // Synchronization objects for Token Modules.
- private int mInitCount = 0;
- private Set<IModuleDef> mTokenModuleScheduled;
- private static Object lock = new Object();
-
- private int mTotalShards;
- private Integer mShardIndex;
-
- private Map<String, Set<String>> mDeviceTokens = new HashMap<>();
- private Map<String, Map<String, List<String>>> mTestArgs = new HashMap<>();
- private Map<String, Map<String, List<String>>> mModuleArgs = new HashMap<>();
- private boolean mIncludeAll;
- private Map<String, List<TestFilter>> mIncludeFilters = new HashMap<>();
- private Map<String, List<TestFilter>> mExcludeFilters = new HashMap<>();
- private IConfigurationFactory mConfigFactory = ConfigurationFactory.getInstance();
-
- private volatile boolean mInitialized = false;
-
- // Holds all the tests with tokens waiting to be run. Meaning the DUT must have a specific token.
- private List<IModuleDef> mTokenModules = new ArrayList<>();
- private List<IModuleDef> mNonTokenModules = new ArrayList<>();
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getNumberOfShards() {
- return mTotalShards;
- }
-
- /**
- * Returns the device tokens of this module repo. Exposed for testing.
- */
- protected Map<String, Set<String>> getDeviceTokens() {
- return mDeviceTokens;
- }
-
- /**
- * A {@link FilenameFilter} to find all modules in a directory who match the given pattern.
- */
- public static class NameFilter implements FilenameFilter {
-
- private String mPattern;
-
- public NameFilter(String pattern) {
- mPattern = pattern;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean accept(File dir, String name) {
- return name.contains(mPattern) && name.endsWith(CONFIG_EXT);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<IModuleDef> getNonTokenModules() {
- return mNonTokenModules;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<IModuleDef> getTokenModules() {
- return mTokenModules;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String[] getModuleIds() {
- Set<String> moduleIdSet = new HashSet<>();
- for (IModuleDef moduleDef : mNonTokenModules) {
- moduleIdSet.add(moduleDef.getId());
- }
- for (IModuleDef moduleDef : mTokenModules) {
- moduleIdSet.add(moduleDef.getId());
- }
- return moduleIdSet.toArray(new String[moduleIdSet.size()]);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isInitialized() {
- return mInitialized;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void initialize(int totalShards, Integer shardIndex, File testsDir, Set<IAbi> abis,
- List<String> deviceTokens, List<String> testArgs, List<String> moduleArgs,
- Set<String> includeFilters, Set<String> excludeFilters,
- MultiMap<String, String> metadataIncludeFilters,
- MultiMap<String, String> metadataExcludeFilters,
- IBuildInfo buildInfo) {
- CLog.d("Initializing ModuleRepo\nShards:%d\nTests Dir:%s\nABIs:%s\nDevice Tokens:%s\n" +
- "Test Args:%s\nModule Args:%s\nIncludes:%s\nExcludes:%s",
- totalShards, testsDir.getAbsolutePath(), abis, deviceTokens, testArgs, moduleArgs,
- includeFilters, excludeFilters);
- mInitialized = true;
- mTotalShards = totalShards;
- mShardIndex = shardIndex;
- synchronized (lock) {
- if (mTokenModuleScheduled == null) {
- mTokenModuleScheduled = new HashSet<>();
- }
- }
-
- for (String line : deviceTokens) {
- String[] parts = line.split(":");
- if (parts.length == 2) {
- String key = parts[0];
- String value = parts[1];
- Set<String> list = mDeviceTokens.get(key);
- if (list == null) {
- list = new HashSet<>();
- mDeviceTokens.put(key, list);
- }
- list.add(value);
- } else {
- throw new IllegalArgumentException(
- String.format("Could not parse device token: %s", line));
- }
- }
- putArgs(testArgs, mTestArgs);
- putArgs(moduleArgs, mModuleArgs);
- mIncludeAll = includeFilters.isEmpty();
- // Include all the inclusions
- addFilters(includeFilters, mIncludeFilters, abis);
- // Exclude all the exclusions
- addFilters(excludeFilters, mExcludeFilters, abis);
-
- File[] configFiles = testsDir.listFiles(new ConfigFilter());
- if (configFiles.length == 0) {
- throw new IllegalArgumentException(
- String.format("No config files found in %s", testsDir.getAbsolutePath()));
- }
- Map<String, Integer> shardedTestCounts = new HashMap<>();
- for (File configFile : configFiles) {
- final String name = configFile.getName().replace(CONFIG_EXT, "");
- final String[] pathArg = new String[] { configFile.getAbsolutePath() };
- try {
- // Invokes parser to process the test module config file
- // Need to generate a different config for each ABI as we cannot guarantee the
- // configs are idempotent. This however means we parse the same file multiple times
- for (IAbi abi : abis) {
- String id = AbiUtils.createId(abi.getName(), name);
- if (!shouldRunModule(id)) {
- // If the module should not run tests based on the state of filters,
- // skip this name/abi combination.
- continue;
- }
-
- IConfiguration config = mConfigFactory.createConfigurationFromArgs(pathArg);
- if (!filterByConfigMetadata(config,
- metadataIncludeFilters, metadataExcludeFilters)) {
- // if the module config did not pass the metadata filters, it's excluded
- // from execution
- continue;
- }
- Map<String, List<String>> args = new HashMap<>();
- if (mModuleArgs.containsKey(name)) {
- args.putAll(mModuleArgs.get(name));
- }
- if (mModuleArgs.containsKey(id)) {
- args.putAll(mModuleArgs.get(id));
- }
- injectOptionsToConfig(args, config);
-
- List<IRemoteTest> tests = config.getTests();
- for (IRemoteTest test : tests) {
- prepareTestClass(name, abi, config, test);
- }
- List<IRemoteTest> shardedTests = tests;
- if (shardedTests.size() > 1) {
- shardedTestCounts.put(id, shardedTests.size());
- }
- for (IRemoteTest test : shardedTests) {
- addModuleDef(name, abi, test, pathArg);
- }
- }
- } catch (ConfigurationException e) {
- throw new RuntimeException(String.format("error parsing config file: %s",
- configFile.getName()), e);
- }
- }
- mExcludeFilters.clear();
- TestRunHandler.setTestRuns(new CompatibilityBuildHelper(buildInfo), shardedTestCounts);
- }
-
- /**
- * Prepare to run test classes.
- *
- * @param name module name
- * @param abi IAbi object that contains abi information
- * @param config IConfiguration object created from config file
- * @param test test class
- * @throws ConfigurationException
- */
- protected void prepareTestClass(final String name, IAbi abi, IConfiguration config,
- IRemoteTest test) throws ConfigurationException {
- String className = test.getClass().getName();
- Map<String, List<String>> testArgsMap = new HashMap<>();
- if (mTestArgs.containsKey(className)) {
- testArgsMap.putAll(mTestArgs.get(className));
- }
- injectOptionsToConfig(testArgsMap, config);
- addFiltersToTest(test, abi, name);
- }
-
- /**
- * Helper to inject options to a config.
- */
- @VisibleForTesting
- void injectOptionsToConfig(Map<String, List<String>> optionMap, IConfiguration config)
- throws ConfigurationException{
- for (Entry<String, List<String>> entry : optionMap.entrySet()) {
- for (String entryValue : entry.getValue()) {
- String entryName = entry.getKey();
- if (entryValue.contains(":=")) {
- // entryValue is key-value pair
- String key = entryValue.substring(0, entryValue.indexOf(":="));
- String value = entryValue.substring(entryValue.indexOf(":=") + 2);
- config.injectOptionValue(entryName, key, value);
- } else {
- // entryValue is just the argument value
- config.injectOptionValue(entryName, entryValue);
- }
- }
- }
- }
-
- private void addFilters(Set<String> stringFilters,
- Map<String, List<TestFilter>> filters, Set<IAbi> abis) {
- for (String filterString : stringFilters) {
- TestFilter filter = TestFilter.createFrom(filterString);
- String abi = filter.getAbi();
- if (abi == null) {
- for (IAbi a : abis) {
- addFilter(a.getName(), filter, filters);
- }
- } else {
- addFilter(abi, filter, filters);
- }
- }
- }
-
- private void addFilter(String abi, TestFilter filter,
- Map<String, List<TestFilter>> filters) {
- getFilter(filters, AbiUtils.createId(abi, filter.getName())).add(filter);
- }
-
- private List<TestFilter> getFilter(Map<String, List<TestFilter>> filters, String id) {
- List<TestFilter> fs = filters.get(id);
- if (fs == null) {
- fs = new ArrayList<>();
- filters.put(id, fs);
- }
- return fs;
- }
-
- protected void addModuleDef(String name, IAbi abi, IRemoteTest test, String[] configPaths)
- throws ConfigurationException {
- // Invokes parser to process the test module config file
- IConfiguration config = mConfigFactory.createConfigurationFromArgs(configPaths);
- addModuleDef(new ModuleDef(name, abi, test, config.getTargetPreparers(),
- config.getConfigurationDescription()));
- }
-
- protected void addModuleDef(IModuleDef moduleDef) {
- Set<String> tokens = moduleDef.getTokens();
- if (tokens != null && !tokens.isEmpty()) {
- mTokenModules.add(moduleDef);
- } else {
- mNonTokenModules.add(moduleDef);
- }
- }
-
- private void addFiltersToTest(IRemoteTest test, IAbi abi, String name) {
- String moduleId = AbiUtils.createId(abi.getName(), name);
- if (!(test instanceof ITestFilterReceiver)) {
- throw new IllegalArgumentException(String.format(
- "Test in module %s must implement ITestFilterReceiver.", moduleId));
- }
- List<TestFilter> mdIncludes = getFilter(mIncludeFilters, moduleId);
- List<TestFilter> mdExcludes = getFilter(mExcludeFilters, moduleId);
- if (!mdIncludes.isEmpty()) {
- addTestIncludes((ITestFilterReceiver) test, mdIncludes, name);
- }
- if (!mdExcludes.isEmpty()) {
- addTestExcludes((ITestFilterReceiver) test, mdExcludes, name);
- }
- }
-
- @VisibleForTesting
- protected boolean filterByConfigMetadata(IConfiguration config,
- MultiMap<String, String> include, MultiMap<String, String> exclude) {
- MultiMap<String, String> metadata = config.getConfigurationDescription().getAllMetaData();
- boolean shouldInclude = false;
- for (String key : include.keySet()) {
- Set<String> filters = new HashSet<>(include.get(key));
- if (metadata.containsKey(key)) {
- filters.retainAll(metadata.get(key));
- if (!filters.isEmpty()) {
- // inclusion filter is not empty and there's at least one matching inclusion
- // rule so there's no need to match other inclusion rules
- shouldInclude = true;
- break;
- }
- }
- }
- if (!include.isEmpty() && !shouldInclude) {
- // if inclusion filter is not empty and we didn't find a match, the module will not be
- // included
- return false;
- }
- // Now evaluate exclusion rules, this ordering also means that exclusion rules may override
- // inclusion rules: a config already matched for inclusion may still be excluded if matching
- // rules exist
- for (String key : exclude.keySet()) {
- Set<String> filters = new HashSet<>(exclude.get(key));
- if (metadata.containsKey(key)) {
- filters.retainAll(metadata.get(key));
- if (!filters.isEmpty()) {
- // we found at least one matching exclusion rules, so we are excluding this
- // this module
- return false;
- }
- }
- }
- // we've matched at least one inclusion rule (if there's any) AND we didn't match any of the
- // exclusion rules (if there's any)
- return true;
- }
-
- private boolean shouldRunModule(String moduleId) {
- List<TestFilter> mdIncludes = getFilter(mIncludeFilters, moduleId);
- List<TestFilter> mdExcludes = getFilter(mExcludeFilters, moduleId);
- // if including all modules or includes exist for this module, and there are not excludes
- // for the entire module, this module should be run.
- return (mIncludeAll || !mdIncludes.isEmpty()) && !containsModuleExclude(mdExcludes);
- }
-
- private void addTestIncludes(ITestFilterReceiver test, List<TestFilter> includes,
- String name) {
- if (test instanceof ITestFileFilterReceiver) {
- File includeFile = createFilterFile(name, ".include", includes);
- ((ITestFileFilterReceiver)test).setIncludeTestFile(includeFile);
- } else {
- // add test includes one at a time
- for (TestFilter include : includes) {
- String filterTestName = include.getTest();
- if (filterTestName != null) {
- test.addIncludeFilter(filterTestName);
- }
- }
- }
- }
-
- private void addTestExcludes(ITestFilterReceiver test, List<TestFilter> excludes,
- String name) {
- if (test instanceof ITestFileFilterReceiver) {
- File excludeFile = createFilterFile(name, ".exclude", excludes);
- ((ITestFileFilterReceiver)test).setExcludeTestFile(excludeFile);
- } else {
- // add test excludes one at a time
- for (TestFilter exclude : excludes) {
- test.addExcludeFilter(exclude.getTest());
- }
- }
- }
-
- private File createFilterFile(String prefix, String suffix, List<TestFilter> filters) {
- File filterFile = null;
- PrintWriter out = null;
- try {
- filterFile = FileUtil.createTempFile(prefix, suffix);
- out = new PrintWriter(filterFile);
- for (TestFilter filter : filters) {
- String filterTest = filter.getTest();
- if (filterTest != null) {
- out.println(filterTest);
- }
- }
- out.flush();
- } catch (IOException e) {
- throw new RuntimeException("Failed to create filter file");
- } finally {
- if (out != null) {
- out.close();
- }
- }
- filterFile.deleteOnExit();
- return filterFile;
- }
-
- /*
- * Returns true iff one or more test filters in excludes apply to the entire module.
- */
- private boolean containsModuleExclude(Collection<TestFilter> excludes) {
- for (TestFilter exclude : excludes) {
- if (exclude.getTest() == null) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * A {@link FilenameFilter} to find all the config files in a directory.
- */
- public static class ConfigFilter implements FilenameFilter {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean accept(File dir, String name) {
- CLog.d("%s/%s", dir.getAbsolutePath(), name);
- return name.endsWith(CONFIG_EXT);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public LinkedList<IModuleDef> getModules(String serial, int shardIndex) {
- Collections.sort(mNonTokenModules, new ExecutionOrderComparator());
- List<IModuleDef> modules = getShard(mNonTokenModules, shardIndex, mTotalShards);
- if (modules == null) {
- modules = new LinkedList<IModuleDef>();
- }
- long estimatedTime = 0;
- for (IModuleDef def : modules) {
- estimatedTime += def.getRuntimeHint();
- }
-
- // FIXME: Token Modules are the only last part that is not deterministic.
- synchronized (lock) {
- // Get tokens from the device
- Set<String> tokens = mDeviceTokens.get(serial);
- if (tokens != null && !tokens.isEmpty()) {
- // if it matches any of the token modules, add them
- for (IModuleDef def : mTokenModules) {
- if (!mTokenModuleScheduled.contains(def)) {
- if (tokens.equals(def.getTokens())) {
- modules.add(def);
- CLog.d("Adding %s to scheduled token", def);
- mTokenModuleScheduled.add(def);
- }
- }
- }
- }
- // the last shard going through may add everything remaining.
- if (mInitCount == (mTotalShards - 1) &&
- mTokenModuleScheduled.size() != mTokenModules.size()) {
- mTokenModules.removeAll(mTokenModuleScheduled);
- if (mTotalShards != 1) {
- // Only print the warnings if we are sharding.
- CLog.e("Could not find any token for %s. Adding to last shard.", mTokenModules);
- }
- modules.addAll(mTokenModules);
- }
- mInitCount++;
- }
- Collections.sort(modules, new ExecutionOrderComparator());
- int uniqueCount = UniqueModuleCountUtil.countUniqueModules(modules);
- CLog.logAndDisplay(LogLevel.INFO, "%s running %s test sub-modules, expected to complete "
- + "in %s.", serial, uniqueCount, TimeUtil.formatElapsedTime(estimatedTime));
- CLog.d("module list for this shard: %s", modules);
- LinkedList<IModuleDef> tests = new LinkedList<>();
- tests.addAll(modules);
- return tests;
- }
-
- /**
- * Helper to linearly split the list into shards with balanced runtimeHint.
- * Exposed for testing.
- */
- protected List<IModuleDef> getShard(List<IModuleDef> fullList, int shardIndex, int totalShard) {
- List<List<IModuleDef>> res = LinearPartition.split(fullList, totalShard);
- if (res.isEmpty()) {
- return null;
- }
- if (shardIndex >= res.size()) {
- // If we could not shard up to expectation
- return null;
- }
- return res.get(shardIndex);
- }
-
- /**
- * @return the {@link List} of modules whose name contains the given pattern.
- */
- public static List<String> getModuleNamesMatching(File directory, String pattern) {
- String[] names = directory.list(new NameFilter(pattern));
- List<String> modules = new ArrayList<String>(names.length);
- for (String name : names) {
- int index = name.indexOf(CONFIG_EXT);
- if (index > 0) {
- String module = name.substring(0, index);
- if (module.equals(pattern)) {
- // Pattern represents a single module, just return a single-item list
- modules = new ArrayList<>(1);
- modules.add(module);
- return modules;
- }
- modules.add(module);
- }
- }
- return modules;
- }
-
- private static void putArgs(List<String> args,
- Map<String, Map<String, List<String>>> argsMap) {
- for (String arg : args) {
- String[] parts = arg.split(":");
- String target = parts[0];
- String name = parts[1];
- String value;
- if (parts.length == 4) {
- // key and value given, keep the pair delimited by ':' and stored as value
- value = String.format("%s:%s", parts[2], parts[3]);
- } else {
- value = parts[2];
- }
- Map<String, List<String>> map = argsMap.get(target);
- if (map == null) {
- map = new HashMap<>();
- argsMap.put(target, map);
- }
- List<String> valueList = map.get(name);
- if (valueList == null) {
- valueList = new ArrayList<>();
- map.put(name, valueList);
- }
- valueList.add(value);
- }
- }
-
- /**
- * Sort by name and use runtimeHint for separation, shortest test first.
- */
- private static class ExecutionOrderComparator implements Comparator<IModuleDef> {
- @Override
- public int compare(IModuleDef def1, IModuleDef def2) {
- int value1 = 0;
- int value2 = 0;
- if (ENDING_MODULES.containsKey(def1.getName())) {
- value1 = ENDING_MODULES.get(def1.getName());
- }
- if (ENDING_MODULES.containsKey(def2.getName())) {
- value2 = ENDING_MODULES.get(def2.getName());
- }
- if (value1 == 0 && value2 == 0) {
- int time = (int) Math.signum(def1.getRuntimeHint() - def2.getRuntimeHint());
- if (time == 0) {
- return def1.getName().compareTo(def2.getName());
- }
- return time;
- }
- return (int) Math.signum(value1 - value2);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void tearDown() {
- mNonTokenModules.clear();
- mTokenModules.clear();
- mIncludeFilters.clear();
- mExcludeFilters.clear();
- mTestArgs.clear();
- mModuleArgs.clear();
- }
-
- /**
- * @return the mConfigFactory
- */
- protected IConfigurationFactory getConfigFactory() {
- return mConfigFactory;
- }
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/CompatibilityTestSuite.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/CompatibilityTestSuite.java
index 802980a..4737959 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/CompatibilityTestSuite.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/CompatibilityTestSuite.java
@@ -44,11 +44,9 @@
import java.util.Map;
import java.util.Set;
-/**
- * A Test for running Compatibility Test Suite with new suite system.
- */
+/** A Test for running Compatibility Test Suite with new suite system. */
@OptionClass(alias = "compatibility")
-public class CompatibilityTestSuite extends BaseTestSuite {
+public final class CompatibilityTestSuite extends BaseTestSuite {
public static final String SUBPLAN_OPTION = "subplan";
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/DynamicConfigFileReader.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/DynamicConfigFileReader.java
index 00b9de1..e95a74a 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/DynamicConfigFileReader.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/DynamicConfigFileReader.java
@@ -18,8 +18,9 @@
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.util.DynamicConfig;
import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.error.HarnessRuntimeException;
import com.android.tradefed.log.LogUtil.CLog;
-
+import com.android.tradefed.result.error.InfraErrorIdentifier;
import org.xmlpull.v1.XmlPullParserException;
import java.io.File;
@@ -93,8 +94,14 @@
CompatibilityBuildHelper helper = new CompatibilityBuildHelper(info);
File dynamicConfig = helper.getDynamicConfigFiles().get(moduleName);
if (dynamicConfig == null) {
- CLog.w("Config file %s, not found in the map of dynamic configs.", moduleName);
- return null;
+ String message =
+ String.format(
+ "Dynamic config file %s, not found in the map of configured dynamic"
+ + " configs.",
+ moduleName);
+ CLog.w(message);
+ throw new HarnessRuntimeException(
+ message, InfraErrorIdentifier.CONFIGURED_ARTIFACT_NOT_FOUND);
}
return getValuesFromConfig(dynamicConfig, key);
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/LinearPartition.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/LinearPartition.java
deleted file mode 100644
index a1755bf..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/LinearPartition.java
+++ /dev/null
@@ -1,115 +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.compatibility.common.tradefed.util;
-
-import com.android.compatibility.common.tradefed.testtype.IModuleDef;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Helper for the shard splitting. Split linearly a list into N sublist with
- * approximately the same weight.
- * TODO: Can be generalized for any weighted objects.
- */
-public class LinearPartition {
-
- /**
- * Split a list of {@link IModuleDef} into k sub list based on the runtime hint.
- *
- * @param seq the full list of {@link IModuleDef} to be splitted
- * @param k the number of sub list we need.
- * @return the List of sublist.
- */
- public static List<List<IModuleDef>> split(List<IModuleDef> seq, int k) {
- ArrayList<List<IModuleDef>> result = new ArrayList<>();
-
- if (k <= 0) {
- ArrayList<IModuleDef> partition = new ArrayList<>();
- partition.addAll(seq);
- result.add(partition);
- return result;
- }
-
- int n = seq.size() - 1;
-
- if (k > n) {
- for (IModuleDef value : seq) {
- ArrayList<IModuleDef> partition = new ArrayList<>();
- partition.add(value);
- result.add(partition);
- }
- return result;
- }
-
- int[][] table = buildPartitionTable(seq, k);
- k = k - 2;
-
- while (k >= 0) {
- ArrayList<IModuleDef> partition = new ArrayList<>();
-
- for (int i = table[n - 1][k] + 1; i < n + 1; i++) {
- partition.add(seq.get(i));
- }
-
- result.add(0, partition);
- n = table[n - 1][k];
- k = k - 1;
- }
-
- ArrayList<IModuleDef> partition = new ArrayList<>();
-
- for (int i = 0; i < n + 1; i++) {
- partition.add(seq.get(i));
- }
-
- result.add(0, partition);
-
- return result;
- }
-
- /**
- * Internal helper to build the partition table of the linear distribution used for splitting.
- */
- private static int[][] buildPartitionTable(List<IModuleDef> seq, int k) {
- int n = seq.size();
- float[][] table = new float[n][k];
- int[][] solution = new int[n - 1][k - 1];
-
- for (int i = 0; i < n; i++) {
- table[i][0] = seq.get(i).getRuntimeHint() + ((i > 0) ? table[i - 1][0] : 0);
- }
-
- for (int j = 0; j < k; j++) {
- table[0][j] = seq.get(0).getRuntimeHint();
- }
-
- for (int i = 1; i < n; i++) {
- for (int j = 1; j < k; j++) {
- table[i][j] = Integer.MAX_VALUE;
- for (int x = 0; x < i; x++) {
- float cost = Math.max(table[x][j - 1], table[i][0] - table[x][0]);
- if (table[i][j] > cost) {
- table[i][j] = cost;
- solution[i - 1][j - 1] = x;
- }
- }
- }
- }
-
- return solution;
- }
-}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/RetryFilterHelper.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/RetryFilterHelper.java
index f20072a..907ad84 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/RetryFilterHelper.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/RetryFilterHelper.java
@@ -19,7 +19,6 @@
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.tradefed.result.SubPlanHelper;
import com.android.compatibility.common.tradefed.testtype.ISubPlan;
-import com.android.compatibility.common.tradefed.testtype.ModuleRepo;
import com.android.compatibility.common.util.IInvocationResult;
import com.android.compatibility.common.util.LightInvocationResult;
import com.android.compatibility.common.util.ResultHandler;
@@ -33,7 +32,10 @@
import com.google.common.annotations.VisibleForTesting;
+import java.io.File;
import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -269,8 +271,7 @@
}
if (mModuleName != null) {
try {
- List<String> modules = ModuleRepo.getModuleNamesMatching(
- mBuild.getTestsDir(), mModuleName);
+ List<String> modules = getModuleNamesMatching(mBuild.getTestsDir(), mModuleName);
if (modules.size() == 0) {
throw new IllegalArgumentException(
String.format("No modules found matching %s", mModuleName));
@@ -325,4 +326,40 @@
mRetryExcludes = null;
// keep references to buildInfo and session ID
}
+
+ /** @return the {@link List} of modules whose name contains the given pattern. */
+ public static List<String> getModuleNamesMatching(File directory, String pattern) {
+ String[] names = directory.list(new NameFilter(pattern));
+ List<String> modules = new ArrayList<String>(names.length);
+ for (String name : names) {
+ int index = name.indexOf(".config");
+ if (index > 0) {
+ String module = name.substring(0, index);
+ if (module.equals(pattern)) {
+ // Pattern represents a single module, just return a single-item list
+ modules = new ArrayList<>(1);
+ modules.add(module);
+ return modules;
+ }
+ modules.add(module);
+ }
+ }
+ return modules;
+ }
+
+ /** A {@link FilenameFilter} to find all modules in a directory who match the given pattern. */
+ public static class NameFilter implements FilenameFilter {
+
+ private String mPattern;
+
+ public NameFilter(String pattern) {
+ mPattern = pattern;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.contains(mPattern) && name.endsWith(".config");
+ }
+ }
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/UniqueModuleCountUtil.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/UniqueModuleCountUtil.java
deleted file mode 100644
index e801ab3..0000000
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/UniqueModuleCountUtil.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.tradefed.util;
-
-import com.android.compatibility.common.tradefed.testtype.IModuleDef;
-
-import java.util.HashSet;
-import java.util.List;
-
-/**
- * Utility to count the number of unique module from list of {@link IModuleDef}.
- */
-public class UniqueModuleCountUtil {
-
- /**
- * Count the number of unique modules within the list using module id. If two IModuleDef have
- * the same id, they are part of the same module.
- *
- * @param listModules list of {@link IModuleDef} to count from
- * @return the count of unique module.
- */
- public static int countUniqueModules(List<IModuleDef> listModules) {
- HashSet<String> uniqueNames = new HashSet<>();
- for (IModuleDef subModule : listModules) {
- uniqueNames.add(subModule.getId());
- }
- return uniqueNames.size();
- }
-}
diff --git a/common/host-side/tradefed/tests/Android.bp b/common/host-side/tradefed/tests/Android.bp
index 57a8fb9..eff09a1 100644
--- a/common/host-side/tradefed/tests/Android.bp
+++ b/common/host-side/tradefed/tests/Android.bp
@@ -15,26 +15,22 @@
java_test_host {
name: "compatibility-tradefed-tests",
defaults: ["tradefed_errorprone_defaults"],
+ // Restrict visibility to only those targets that need to access it.
+ visibility: ["//visibility:private"],
+// test_options: {
+// unit_test: true,
+// },
srcs: ["src/**/*.java"],
java_resource_dirs: ["res"],
- libs: [
+ static_libs: [
"tradefed",
- "compatibility-mock-tradefed",
- "junit-host",
+ "junit",
"compatibility-host-util",
- "easymock",
- "objenesis-host",
- "mockito-host",
+ "cts-tradefed-harness",
+ "easymock",
+ "objenesis-host",
+ "mockito-host",
],
}
-
-
-tradefed_binary_host {
- name: "compatibility-mock-tradefed",
- short_name: "TESTS",
- full_name: "Compatibility Tests",
- version: "1",
- static_libs: ["cts-tradefed-harness"],
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java
deleted file mode 100644
index df0c6c4..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java
+++ /dev/null
@@ -1,130 +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.compatibility.common.tradefed;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelperTest;
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildProviderTest;
-import com.android.compatibility.common.tradefed.command.CompatibilityConsoleTest;
-import com.android.compatibility.common.tradefed.config.ConfigurationFactoryTest;
-import com.android.compatibility.common.tradefed.presubmit.ApkPackageNameCheck;
-import com.android.compatibility.common.tradefed.presubmit.CtsConfigLoadingTest;
-import com.android.compatibility.common.tradefed.presubmit.DupFileTest;
-import com.android.compatibility.common.tradefed.presubmit.IntegrationTest;
-import com.android.compatibility.common.tradefed.presubmit.PresubmitSetupValidation;
-import com.android.compatibility.common.tradefed.presubmit.ValidateTestsAbi;
-import com.android.compatibility.common.tradefed.result.ChecksumReporterTest;
-import com.android.compatibility.common.tradefed.result.ConsoleReporterTest;
-import com.android.compatibility.common.tradefed.result.MetadataReporterTest;
-import com.android.compatibility.common.tradefed.result.ResultReporterBuildInfoTest;
-import com.android.compatibility.common.tradefed.result.ResultReporterTest;
-import com.android.compatibility.common.tradefed.result.SubPlanHelperTest;
-import com.android.compatibility.common.tradefed.result.suite.CertificationChecksumHelperTest;
-import com.android.compatibility.common.tradefed.result.suite.CertificationSuiteResultReporterTest;
-import com.android.compatibility.common.tradefed.result.suite.PreviousResultLoaderTest;
-import com.android.compatibility.common.tradefed.result.suite.PreviousSessionFileCopierTest;
-import com.android.compatibility.common.tradefed.targetprep.BusinessLogicPreparerTest;
-import com.android.compatibility.common.tradefed.targetprep.DeviceInfoCollectorTest;
-import com.android.compatibility.common.tradefed.targetprep.DeviceInteractionHelperInstallerTest;
-import com.android.compatibility.common.tradefed.targetprep.DynamicConfigPusherTest;
-import com.android.compatibility.common.tradefed.targetprep.MediaPreparerTest;
-import com.android.compatibility.common.tradefed.targetprep.PropertyCheckTest;
-import com.android.compatibility.common.tradefed.targetprep.SettingsPreparerTest;
-import com.android.compatibility.common.tradefed.targetprep.VtsDeviceInfoCollectorTest;
-import com.android.compatibility.common.tradefed.testtype.CompatibilityTestTest;
-import com.android.compatibility.common.tradefed.testtype.JarHostTestTest;
-import com.android.compatibility.common.tradefed.testtype.ModuleDefTest;
-import com.android.compatibility.common.tradefed.testtype.ModuleRepoTest;
-import com.android.compatibility.common.tradefed.testtype.SubPlanTest;
-import com.android.compatibility.common.tradefed.testtype.retry.RetryFactoryTestTest;
-import com.android.compatibility.common.tradefed.util.CollectorUtilTest;
-import com.android.compatibility.common.tradefed.util.DynamicConfigFileReaderTest;
-import com.android.compatibility.common.tradefed.util.OptionHelperTest;
-import com.android.compatibility.common.tradefed.util.RetryFilterHelperTest;
-import com.android.compatibility.common.tradefed.util.UniqueModuleCountUtilTest;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * A test suite for all compatibility tradefed unit tests.
- *
- * <p>All tests listed here should be self-contained, and do not require any external dependencies.
- */
-@RunWith(Suite.class)
-@SuiteClasses({
- // build
- CompatibilityBuildHelperTest.class,
- CompatibilityBuildProviderTest.class,
-
- // command
- CompatibilityConsoleTest.class,
-
- // config
- ConfigurationFactoryTest.class,
-
- // presubmit
- ApkPackageNameCheck.class,
- CtsConfigLoadingTest.class,
- DupFileTest.class,
- IntegrationTest.class,
- PresubmitSetupValidation.class,
- ValidateTestsAbi.class,
-
- // result
- ChecksumReporterTest.class,
- ConsoleReporterTest.class,
- MetadataReporterTest.class,
- ResultReporterBuildInfoTest.class,
- ResultReporterTest.class,
- SubPlanHelperTest.class,
-
- // result.suite
- CertificationChecksumHelperTest.class,
- CertificationSuiteResultReporterTest.class,
- PreviousResultLoaderTest.class,
- PreviousSessionFileCopierTest.class,
-
- // targetprep
- BusinessLogicPreparerTest.class,
- DeviceInfoCollectorTest.class,
- DeviceInteractionHelperInstallerTest.class,
- DynamicConfigPusherTest.class,
- MediaPreparerTest.class,
- PropertyCheckTest.class,
- SettingsPreparerTest.class,
- VtsDeviceInfoCollectorTest.class,
-
- // testtype
- CompatibilityTestTest.class,
- JarHostTestTest.class,
- ModuleDefTest.class,
- ModuleRepoTest.class,
- SubPlanTest.class,
-
- // testtype.retry
- RetryFactoryTestTest.class,
-
- // util
- CollectorUtilTest.class,
- DynamicConfigFileReaderTest.class,
- OptionHelperTest.class,
- RetryFilterHelperTest.class,
- UniqueModuleCountUtilTest.class,
-})
-public class UnitTests {
- // empty on purpose
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/config/ConfigurationFactoryTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/config/ConfigurationFactoryTest.java
index 3a59387..92e2898 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/config/ConfigurationFactoryTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/config/ConfigurationFactoryTest.java
@@ -34,17 +34,13 @@
mConfigFactory = (ConfigurationFactory) ConfigurationFactory.getInstance();
}
- /**
- * Sanity test to ensure all config names on classpath are loadable.
- */
+ /** Initial test to ensure all config names on classpath are loadable. */
public void testLoadAllConfigs() throws ConfigurationException {
// we dry-run the templates otherwise it will always fail.
mConfigFactory.loadAllConfigs(false);
}
- /**
- * Sanity test to ensure all configs on classpath can be fully loaded and parsed.
- */
+ /** Initial test to ensure all configs on classpath can be fully loaded and parsed. */
public void testLoadAndPrintAllConfigs() throws ConfigurationException {
// Printing the help involves more checks since it tries to resolve the config objects.
mConfigFactory.loadAndPrintAllConfigs();
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ApkPackageNameCheck.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ApkPackageNameCheck.java
deleted file mode 100644
index b50c906..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ApkPackageNameCheck.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.tradefed.presubmit;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.android.compatibility.common.tradefed.targetprep.FilePusher;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.config.ConfigurationFactory;
-import com.android.tradefed.config.IConfiguration;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.targetprep.PushFilePreparer;
-import com.android.tradefed.targetprep.TestAppInstallSetup;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.InstrumentationTest;
-import com.android.tradefed.util.AaptParser;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Class to validate tests Apks in testcases/
- */
-@RunWith(JUnit4.class)
-public class ApkPackageNameCheck {
-
- private static final Set<String> EXCEPTION_LIST = new HashSet<>();
- static {
- // TODO: Remove exception when their package have been fixed.
- EXCEPTION_LIST.add("android.app.cts");
- EXCEPTION_LIST.add("android.systemui.cts");
- }
-
- /**
- * We ensure that no apk with same package names may be installed. Otherwise it may results in
- * conflicts.
- */
- @Test
- public void testApkPackageNames() throws Exception {
- String ctsRoot = System.getProperty("CTS_ROOT");
- File testcases = new File(ctsRoot, "/android-cts/testcases/");
- if (!testcases.exists()) {
- fail(String.format("%s does not exists", testcases));
- return;
- }
- File[] listConfig = testcases.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- if (name.endsWith(".config")) {
- return true;
- }
- return false;
- }
- });
- assertTrue(listConfig.length > 0);
- // We check all apk installed by all modules
- Map<String, String> packageNames = new HashMap<>();
-
- for (File config : listConfig) {
- IConfiguration c = ConfigurationFactory.getInstance()
- .createConfigurationFromArgs(new String[] {config.getAbsolutePath()});
- // For each config, we check all the apk it's going to install
- List<File> apkNames = new ArrayList<>();
- List<String> packageListNames = new ArrayList<>();
- for (ITargetPreparer prep : c.getTargetPreparers()) {
- if (prep instanceof TestAppInstallSetup) {
- apkNames.addAll(((TestAppInstallSetup) prep).getTestsFileName());
- }
- // Ensure the files requested to be pushed exist.
- if (prep instanceof FilePusher && ((FilePusher) prep).shouldAppendBitness()) {
- for (File f : ((PushFilePreparer) prep).getPushSpecs(null).values()) {
- String path = f.getPath();
- if (!new File(testcases, path + "32").exists()
- || !new File(testcases, path + "64").exists()) {
- // TODO: Enforce should abort on failure is True in CTS
- if (((FilePusher) prep).shouldAbortOnFailure()) {
- fail(
- String.format(
- "File %s[32/64] wasn't found in testcases/ while "
- + "it's expected to be pushed as part of "
- + "%s",
- path, config.getName()));
- }
- }
- }
- } else if (prep instanceof PushFilePreparer) {
- for (File f : ((PushFilePreparer) prep).getPushSpecs(null).values()) {
- String path = f.getPath();
- if (!new File(testcases, path).exists()) {
- // TODO: Enforce should abort on failure is True in CTS
- if (((PushFilePreparer) prep).shouldAbortOnFailure()) {
- fail(
- String.format(
- "File %s wasn't found in testcases/ while it's "
- + "expected to be pushed as part of %s",
- path, config.getName()));
- }
- }
- }
- }
- }
-
- for (File apk : apkNames) {
- String apkName = apk.getName();
- File apkFile = new File(testcases, apkName);
- if (!apkFile.exists()) {
- fail(String.format("Module %s is trying to install %s which does not "
- + "exists in testcases/", config.getName(), apkFile));
- }
- AaptParser res = AaptParser.parse(apkFile);
- assertNotNull(res);
- String packageName = res.getPackageName();
- String put = packageNames.put(packageName, apkName);
- packageListNames.add(packageName);
- // The package already exists and it's a different apk
- if (put != null && !apkName.equals(put) && !EXCEPTION_LIST.contains(packageName)) {
- fail(String.format("Module %s: Package name '%s' from apk '%s' was already "
- + "added by previous apk '%s'.",
- config.getName(), packageName, apkName, put));
- }
- }
-
- // Catch a test trying to run something it doesn't install.
- List<IRemoteTest> tests = c.getTests();
- for (IRemoteTest test : tests) {
- if (test instanceof InstrumentationTest) {
- InstrumentationTest instrumentationTest = (InstrumentationTest) test;
- if (instrumentationTest.getPackageName() != null) {
- if (!packageListNames.contains(instrumentationTest.getPackageName())) {
- throw new ConfigurationException(
- String.format("Module %s requests to run '%s' but it's not "
- + "part of any apks.",
- config.getName(), instrumentationTest.getPackageName()));
- }
- }
- }
- }
- }
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java
deleted file mode 100644
index 0c7ac5a..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.tradefed.presubmit;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.compatibility.common.tradefed.targetprep.ApkInstaller;
-import com.android.compatibility.common.tradefed.targetprep.PreconditionPreparer;
-import com.android.compatibility.common.tradefed.testtype.JarHostTest;
-import com.android.tradefed.build.FolderBuildInfo;
-import com.android.tradefed.config.ConfigurationDescriptor;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.config.ConfigurationFactory;
-import com.android.tradefed.config.IConfiguration;
-import com.android.tradefed.invoker.ExecutionFiles.FilesKey;
-import com.android.tradefed.invoker.TestInformation;
-import com.android.tradefed.invoker.shard.token.TokenProperty;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.testtype.AndroidJUnitTest;
-import com.android.tradefed.testtype.HostTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.ITestFilterReceiver;
-import com.android.tradefed.testtype.suite.ITestSuite;
-import com.android.tradefed.testtype.suite.params.ModuleParameters;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Test that configuration in CTS can load and have expected properties.
- */
-@RunWith(JUnit4.class)
-public class CtsConfigLoadingTest {
-
- private static final String METADATA_COMPONENT = "component";
- private static final Set<String> KNOWN_COMPONENTS =
- new HashSet<>(
- Arrays.asList(
- // modifications to the list below must be reviewed
- "abuse",
- "art",
- "auth",
- "auto",
- "autofill",
- "backup",
- "bionic",
- "bluetooth",
- "camera",
- "contentcapture",
- "deviceinfo",
- "deqp",
- "devtools",
- "framework",
- "graphics",
- "hdmi",
- "inputmethod",
- "libcore",
- "location",
- "media",
- "metrics",
- "misc",
- "mocking",
- "networking",
- "neuralnetworks",
- "print",
- "renderscript",
- "security",
- "statsd",
- "systems",
- "sysui",
- "telecom",
- "tv",
- "uitoolkit",
- "vr",
- "webview",
- "wifi"));
- private static final Set<String> KNOWN_MISC_MODULES =
- new HashSet<>(
- Arrays.asList(
- // Modifications to the list below must be approved by someone in
- // test/suite_harness/OWNERS.
- "CtsSliceTestCases.config",
- "CtsSampleDeviceTestCases.config",
- "CtsUsbTests.config",
- "CtsGpuToolsHostTestCases.config",
- "CtsEdiHostTestCases.config",
- "CtsClassLoaderFactoryPathClassLoaderTestCases.config",
- "CtsSampleHostTestCases.config",
- "CtsHardwareTestCases.config",
- "CtsMonkeyTestCases.config",
- "CtsAndroidAppTestCases.config",
- "CtsClassLoaderFactoryInMemoryDexClassLoaderTestCases.config",
- "CtsAppComponentFactoryTestCases.config",
- "CtsSeccompHostTestCases.config"));
-
- /**
- * List of the officially supported runners in CTS, they meet all the interfaces criteria as
- * well as support sharding very well. Any new addition should go through a review.
- */
- private static final Set<String> SUPPORTED_CTS_TEST_TYPE = new HashSet<>(Arrays.asList(
- // Cts runners
- "com.android.compatibility.common.tradefed.testtype.JarHostTest",
- "com.android.compatibility.testtype.DalvikTest",
- "com.android.compatibility.testtype.LibcoreTest",
- "com.drawelements.deqp.runner.DeqpTestRunner",
- // Tradefed runners
- "com.android.tradefed.testtype.AndroidJUnitTest",
- "com.android.tradefed.testtype.HostTest",
- "com.android.tradefed.testtype.GTest"
- ));
-
- /**
- * In Most cases we impose the usage of the AndroidJUnitRunner because it supports all the
- * features required (filtering, sharding, etc.). We do not typically expect people to need a
- * different runner.
- */
- private static final Set<String> ALLOWED_INSTRUMENTATION_RUNNER_NAME = new HashSet<>();
- static {
- ALLOWED_INSTRUMENTATION_RUNNER_NAME.add("android.support.test.runner.AndroidJUnitRunner");
- ALLOWED_INSTRUMENTATION_RUNNER_NAME.add("androidx.test.runner.AndroidJUnitRunner");
- }
- private static final Set<String> RUNNER_EXCEPTION = new HashSet<>();
- static {
- // Used for a bunch of system-api cts tests
- RUNNER_EXCEPTION.add("repackaged.android.test.InstrumentationTestRunner");
- // Used by a UiRendering scenario where an activity is persisted between tests
- RUNNER_EXCEPTION.add("android.uirendering.cts.runner.UiRenderingRunner");
- }
-
- /**
- * Families of module parameterization that MUST be specified explicitly in the module
- * AndroidTest.xml.
- */
- private static final Set<String> MANDATORY_PARAMETERS_FAMILY = new HashSet<>();
-
- static {
- MANDATORY_PARAMETERS_FAMILY.add(ModuleParameters.INSTANT_APP_FAMILY);
- MANDATORY_PARAMETERS_FAMILY.add(ModuleParameters.MULTI_ABI_FAMILY);
- MANDATORY_PARAMETERS_FAMILY.add(ModuleParameters.SECONDARY_USER_FAMILY);
- }
-
- /**
- * Whitelist to start enforcing metadata on modules. No additional entry will be allowed! This
- * is meant to burn down the remaining modules definition.
- */
- private static final Set<String> WHITELIST_MODULE_PARAMETERS = new HashSet<>();
-
- static {
- WHITELIST_MODULE_PARAMETERS.add("CtsAccessibilityServiceTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsActivityManagerBackgroundActivityTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsAppOpsTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsCarrierApiTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsContentCaptureServiceTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsDeqpTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsHiddenApiKillswitchDebugClassTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsHiddenApiKillswitchWhitelistTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsHiddenApiKillswitchWildcardTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsLocationTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsLocation2TestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsMediaTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsMediaV2TestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsOpenGlPerfTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsOsTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsPermission2TestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsPermissionTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsProviderUiTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsRsBlasTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsSkQPTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsWrapNoWrapTestCases.config");
- WHITELIST_MODULE_PARAMETERS.add("CtsWrapWrapDebugMallocDebugTestCases.config");
- }
-
- /**
- * Test that configuration shipped in Tradefed can be parsed.
- * -> Exclude deprecated ApkInstaller.
- * -> Check if host-side tests are non empty.
- */
- @Test
- public void testConfigurationLoad() throws Exception {
- String ctsRoot = System.getProperty("CTS_ROOT");
- File testcases = new File(ctsRoot, "/android-cts/testcases/");
- if (!testcases.exists()) {
- fail(String.format("%s does not exists", testcases));
- return;
- }
- File[] listConfig = testcases.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- if (name.endsWith(".config")) {
- return true;
- }
- return false;
- }
- });
- assertTrue(listConfig.length > 0);
- // Create a FolderBuildInfo to similate the CompatibilityBuildProvider
- FolderBuildInfo stubFolder = new FolderBuildInfo("-1", "-1");
- stubFolder.setRootDir(new File(ctsRoot));
- stubFolder.addBuildAttribute(CompatibilityBuildHelper.SUITE_NAME, "CTS");
- stubFolder.addBuildAttribute("ROOT_DIR", ctsRoot);
- TestInformation stubTestInfo = TestInformation.newBuilder().build();
- stubTestInfo.executionFiles().put(FilesKey.TESTS_DIRECTORY, new File(ctsRoot));
-
- List<String> missingMandatoryParameters = new ArrayList<>();
- // We expect to be able to load every single config in testcases/
- for (File config : listConfig) {
- IConfiguration c = ConfigurationFactory.getInstance()
- .createConfigurationFromArgs(new String[] {config.getAbsolutePath()});
- // Ensure the deprecated ApkInstaller is not used anymore.
- for (ITargetPreparer prep : c.getTargetPreparers()) {
- if (prep.getClass().isAssignableFrom(ApkInstaller.class)) {
- throw new ConfigurationException(
- String.format("%s: Use com.android.tradefed.targetprep.suite."
- + "SuiteApkInstaller instead of com.android.compatibility."
- + "common.tradefed.targetprep.ApkInstaller, options will be "
- + "the same.", config));
- }
- if (prep.getClass().isAssignableFrom(PreconditionPreparer.class)) {
- throw new ConfigurationException(
- String.format(
- "%s: includes a PreconditionPreparer (%s) which is not allowed"
- + " in modules.",
- config.getName(), prep.getClass()));
- }
- }
- // We can ensure that Host side tests are not empty.
- for (IRemoteTest test : c.getTests()) {
- // Check that all the tests runners are well supported.
- if (!SUPPORTED_CTS_TEST_TYPE.contains(test.getClass().getCanonicalName())) {
- throw new ConfigurationException(
- String.format(
- "testtype %s is not officially supported by CTS. "
- + "The supported ones are: %s",
- test.getClass().getCanonicalName(), SUPPORTED_CTS_TEST_TYPE));
- }
- if (test instanceof HostTest) {
- HostTest hostTest = (HostTest) test;
- // We inject a made up folder so that it can find the tests.
- hostTest.setBuild(stubFolder);
- hostTest.setTestInformation(stubTestInfo);
- int testCount = hostTest.countTestCases();
- if (testCount == 0) {
- throw new ConfigurationException(
- String.format("%s: %s reports 0 test cases.",
- config.getName(), test));
- }
- }
- // Tests are expected to implement that interface.
- if (!(test instanceof ITestFilterReceiver)) {
- throw new IllegalArgumentException(String.format(
- "Test in module %s must implement ITestFilterReceiver.",
- config.getName()));
- }
- // Ensure that the device runner is the AJUR one if explicitly specified.
- if (test instanceof AndroidJUnitTest) {
- AndroidJUnitTest instru = (AndroidJUnitTest) test;
- if (instru.getRunnerName() != null &&
- !ALLOWED_INSTRUMENTATION_RUNNER_NAME.contains(instru.getRunnerName())) {
- // Some runner are exempt
- if (!RUNNER_EXCEPTION.contains(instru.getRunnerName())) {
- throw new ConfigurationException(
- String.format("%s: uses '%s' instead of on of '%s' that are "
- + "expected", config.getName(), instru.getRunnerName(),
- ALLOWED_INSTRUMENTATION_RUNNER_NAME));
- }
- }
- }
- }
- ConfigurationDescriptor cd = c.getConfigurationDescription();
- Assert.assertNotNull(config + ": configuration descriptor is null", cd);
- List<String> component = cd.getMetaData(METADATA_COMPONENT);
- Assert.assertNotNull(String.format("Missing module metadata field \"component\", "
- + "please add the following line to your AndroidTest.xml:\n"
- + "<option name=\"config-descriptor:metadata\" key=\"component\" "
- + "value=\"...\" />\nwhere \"value\" must be one of: %s\n"
- + "config: %s", KNOWN_COMPONENTS, config),
- component);
- Assert.assertEquals(String.format("Module config contains more than one \"component\" "
- + "metadata field: %s\nconfig: %s", component, config),
- 1, component.size());
- String cmp = component.get(0);
- Assert.assertTrue(String.format("Module config contains unknown \"component\" metadata "
- + "field \"%s\", supported ones are: %s\nconfig: %s",
- cmp, KNOWN_COMPONENTS, config), KNOWN_COMPONENTS.contains(cmp));
-
- if ("misc".equals(cmp)) {
- String configFileName = config.getName();
- Assert.assertTrue(
- String.format(
- "Adding new module %s to \"misc\" component is restricted, "
- + "please pick a component that your module fits in",
- configFileName),
- KNOWN_MISC_MODULES.contains(configFileName));
- }
-
- // Check that specified parameters are expected
- boolean res =
- checkModuleParameters(
- config.getName(), cd.getMetaData(ITestSuite.PARAMETER_KEY));
- if (!res) {
- missingMandatoryParameters.add(config.getName());
- }
- // Check that specified tokens are expected
- checkTokens(config.getName(), cd.getMetaData(ITestSuite.TOKEN_KEY));
-
- // Ensure each CTS module is tagged with <option name="test-suite-tag" value="cts" />
- Assert.assertTrue(String.format(
- "Module config %s does not contains "
- + "'<option name=\"test-suite-tag\" value=\"cts\" />'", config.getName()),
- cd.getSuiteTags().contains("cts"));
-
- // Check not-shardable: JarHostTest cannot create empty shards so it should never need
- // to be not-shardable.
- if (cd.isNotShardable()) {
- for (IRemoteTest test : c.getTests()) {
- if (test.getClass().isAssignableFrom(JarHostTest.class)) {
- throw new ConfigurationException(
- String.format("config: %s. JarHostTest does not need the "
- + "not-shardable option.", config.getName()));
- }
- }
- }
- // Ensure options have been set
- c.validateOptions();
- }
-
- // Exempt the whitelist
- missingMandatoryParameters.removeAll(WHITELIST_MODULE_PARAMETERS);
- // Ensure the mandatory fields are filled
- if (!missingMandatoryParameters.isEmpty()) {
- String msg =
- String.format(
- "The following %s modules are missing some of the mandatory "
- + "parameters [instant_app, not_instant_app, "
- + "multi_abi, not_multi_abi, "
- + "secondary_user, not_secondary_user]: '%s'",
- missingMandatoryParameters.size(), missingMandatoryParameters);
- throw new ConfigurationException(msg);
- }
- }
-
- /** Test that all parameter metadata can be resolved. */
- private boolean checkModuleParameters(String configName, List<String> parameters)
- throws ConfigurationException {
- if (parameters == null) {
- return false;
- }
- Map<String, Boolean> families = createFamilyCheckMap();
- for (String param : parameters) {
- try {
- ModuleParameters p = ModuleParameters.valueOf(param.toUpperCase());
- if (families.containsKey(p.getFamily())) {
- families.put(p.getFamily(), true);
- }
- } catch (IllegalArgumentException e) {
- throw new ConfigurationException(
- String.format("Config: %s includes an unknown parameter '%s'.",
- configName, param));
- }
- }
- if (families.containsValue(false)) {
- return false;
- }
- return true;
- }
-
- /** Test that all tokens can be resolved. */
- private void checkTokens(String configName, List<String> tokens) throws ConfigurationException {
- if (tokens == null) {
- return;
- }
- for (String token : tokens) {
- try {
- TokenProperty.valueOf(token.toUpperCase());
- } catch (IllegalArgumentException e) {
- throw new ConfigurationException(
- String.format(
- "Config: %s includes an unknown token '%s'.", configName, token));
- }
- }
- }
-
- private Map<String, Boolean> createFamilyCheckMap() {
- Map<String, Boolean> families = new HashMap<>();
- for (String family : MANDATORY_PARAMETERS_FAMILY) {
- families.put(family, false);
- }
- return families;
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/DupFileTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/DupFileTest.java
deleted file mode 100644
index cf73285..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/DupFileTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2018 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.compatibility.common.tradefed.presubmit;
-
-import static org.junit.Assert.fail;
-
-import com.android.tradefed.config.ConfigurationException;
-
-import com.google.common.collect.ImmutableSet;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-/**
- * Test to check for duplicate files in different jars and prevent the same dependencies of being
- * included several time (which might result in version conflicts).
- */
-@RunWith(JUnit4.class)
-public class DupFileTest {
-
- // We ignore directories part of the common java and google packages.
- private static final String[] IGNORE_DIRS =
- new String[] {
- "android/",
- "javax/annotation/",
- "com/google/protobuf/",
- "kotlin/",
- "perfetto/protos/"
- };
- // Temporarily exclude some Tradefed jar while we work on unbundling them.
- private static final Set<String> IGNORE_JARS =
- ImmutableSet.of("tradefed-no-fwk.jar", "tradefed-test-framework.jar");
-
- /** test if there are duplicate files in different jars. */
- @Test
- public void testDupFilesExist() throws Exception {
- // Get list of jars.
- List<File> jars = getListOfBuiltJars();
-
- // Create map of files to jars.
- Map<String, List<String>> filesToJars = getMapOfFilesAndJars(jars);
-
- // Check if there are any files with the same name in diff jars.
- int dupedFiles = 0;
- StringBuilder dupedFilesSummary = new StringBuilder();
- for (Map.Entry<String, List<String>> entry : filesToJars.entrySet()) {
- String file = entry.getKey();
- List<String> jarFiles = entry.getValue();
-
- if (jarFiles.size() != 1) {
- dupedFiles++;
- dupedFilesSummary.append(file + ": " + jarFiles.toString() + "\n");
- }
- }
-
- if (dupedFiles != 0) {
- fail(
- String.format(
- "%d files are duplicated in different jars:\n%s",
- dupedFiles, dupedFilesSummary.toString()));
- }
- }
-
- /** Create map of file to jars */
- private Map<String, List<String>> getMapOfFilesAndJars(List<File> jars) throws IOException {
- Map<String, List<String>> map = new LinkedHashMap<String, List<String>>();
- JarFile jarFile;
- List<String> jarFileList;
- // Map all the files from all the jars.
- for (File jar : jars) {
- if (IGNORE_JARS.contains(jar.getName())) {
- continue;
- }
- jarFile = new JarFile(jar);
- jarFileList = getListOfFiles(jarFile);
- jarFile.close();
-
- // Add in the jar file to the map.
- for (String file : jarFileList) {
- if (!map.containsKey(file)) {
- map.put(file, new LinkedList<String>());
- }
-
- map.get(file).add(jar.getName());
- }
- }
- return map;
- }
-
- /** Get the list of jars specified in the path. */
- private List<File> getListOfBuiltJars() throws ConfigurationException {
- String classpathStr = System.getProperty("java.class.path");
- if (classpathStr == null) {
- throw new ConfigurationException(
- "Could not find the classpath property: java.class.path");
- }
- List<File> listOfJars = new ArrayList<File>();
- for (String jar : classpathStr.split(":")) {
- File jarFile = new File(jar);
- if (jarFile.exists()) {
- listOfJars.add(jarFile);
- }
- }
- return listOfJars;
- }
-
- /** Return the list of files in the jar. */
- private List<String> getListOfFiles(JarFile jar) {
- List<String> files = new ArrayList<String>();
- Enumeration<JarEntry> e = jar.entries();
- while (e.hasMoreElements()) {
- JarEntry entry = e.nextElement();
- String filename = entry.getName();
- if (checkThisFile(filename)) {
- files.add(filename);
- }
- }
- return files;
- }
-
- /** Check if we should add this file to list of files. We only want to check for classes. */
- private Boolean checkThisFile(String filename) {
- if (!filename.endsWith(".class")) {
- return false;
- }
-
- for (String skipDir : IGNORE_DIRS) {
- if (filename.startsWith(skipDir)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/IntegrationTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/IntegrationTest.java
deleted file mode 100644
index 63e6fab..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/IntegrationTest.java
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.tradefed.presubmit;
-
-import static org.junit.Assert.assertEquals;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.compatibility.common.tradefed.result.ResultReporter;
-import com.android.compatibility.common.tradefed.testtype.CompatibilityTest;
-import com.android.compatibility.common.tradefed.testtype.IModuleDef;
-import com.android.compatibility.common.util.IInvocationResult;
-import com.android.compatibility.common.util.TestStatus;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.ConfigurationFactory;
-import com.android.tradefed.config.OptionSetter;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.invoker.IInvocationContext;
-import com.android.tradefed.invoker.InvocationContext;
-import com.android.tradefed.invoker.ShardListener;
-import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.ResultForwarder;
-import com.android.tradefed.result.TestDescription;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IInvocationContextReceiver;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.FileUtil;
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.io.File;
-import java.io.IOException;
-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;
-
-/**
- * Integration tests between {@link CompatibilityTest} and {@link ResultReporter} to ensure proper
- * flow of run and results.
- */
-@RunWith(JUnit4.class)
-public class IntegrationTest {
-
- private static final String CONFIG =
- "<configuration description=\"Auto Generated File\">\n" +
- "<option name=\"config-descriptor:metadata\" key=\"component\" value=\"%s\" />\n" +
- "<test class=\"com.android.compatibility.common.tradefed.testtype.%s\">\n" +
- " <option name=\"report-test\" value=\"%s\" />\n" +
- " <option name=\"run-complete\" value=\"%s\" />\n" +
- " <option name=\"test-fail\" value=\"%s\" />\n" +
- " <option name=\"internal-retry\" value=\"%s\" />\n" +
- "</test>\n" +
- "</configuration>";
- private static final String FILENAME = "%s.config";
- private static final String TEST_STUB = "TestStub"; // Test stub
- private static final String SIMPLE_TEST_STUB = "SimpleTestStub"; // Simple test stub
- private static final String TEST_STUB_SHARDABLE = "TestStubShardable";
- private static final String COMMAND_LINE = "run cts";
-
- private CompatibilityTest mTest;
- private ResultReporter mReporter;
- private ITestDevice mMockDevice;
- private IBuildInfo mMockBuildInfo;
- private IInvocationContext mContext;
-
- private File mRootDir;
- private File mAndroidFolder;
- private File mTestDir;
- private Map<String, String> mAttributes;
-
- @Before
- public void setUp() throws IOException {
- mAttributes = new HashMap<>();
- mTest = new CompatibilityTest() {
- @Override
- protected Set<String> getAbisForBuildTargetArch() {
- Set<String> abis = new HashSet<>();
- abis.add("arm64-v8a");
- abis.add("armeabi-v7a");
- return abis;
- }
- };
- mReporter = new ResultReporter();
- mMockDevice = EasyMock.createMock(ITestDevice.class);
- mMockBuildInfo = EasyMock.createMock(IBuildInfo.class);
- mTest.setBuild(mMockBuildInfo);
- mTest.setDevice(mMockDevice);
- mRootDir = FileUtil.createTempDir("fake-cts-root-dir");
- mAndroidFolder = FileUtil.createTempDir("android-", mRootDir);
- mTestDir = new File(mAndroidFolder, "testcases");
- mTestDir.mkdirs();
- String suiteName = mAndroidFolder.getName().split("-")[1];
- // Create fake build attributes
- mAttributes.put(CompatibilityBuildHelper.ROOT_DIR, mRootDir.getAbsolutePath());
- mAttributes.put(CompatibilityBuildHelper.SUITE_NAME, suiteName);
- mAttributes.put(CompatibilityBuildHelper.START_TIME_MS, "0");
- mAttributes.put(CompatibilityBuildHelper.SUITE_VERSION, "10");
- mAttributes.put(CompatibilityBuildHelper.SUITE_PLAN, "cts");
- mAttributes.put(CompatibilityBuildHelper.SUITE_BUILD, "good-build");
- mAttributes.put(CompatibilityBuildHelper.COMMAND_LINE_ARGS, COMMAND_LINE);
-
- // these attributes seems necessary for re-run, not for run
- mAttributes.put("cts:build_fingerprint", "fingerprint");
- mAttributes.put("cts:build_product", "product");
- mAttributes.put("cts:build_id", "bid");
-
- EasyMock.expect(mMockBuildInfo.getBuildAttributes()).andStubReturn(mAttributes);
-
- EasyMock.expect(mMockDevice.getSerialNumber()).andStubReturn("SERIAL");
- EasyMock.expect(mMockBuildInfo.getDeviceSerial()).andStubReturn("SERIAL");
-
- EasyMock.expect(mMockBuildInfo.getFiles()).andStubReturn(Collections.emptyList());
-
- mContext = new InvocationContext();
- mContext.addAllocatedDevice("default", mMockDevice);
- mContext.addDeviceBuildInfo("default", mMockBuildInfo);
- mTest.setInvocationContext(mContext);
- }
-
- @After
- public void tearDown() {
- FileUtil.recursiveDelete(mRootDir);
- }
-
- /**
- * Create a CTS configuration with a fake tests to exercise all cases.
- *
- * @param testsDir The testcases/ dir where to put the module
- * @param name the name of the module.
- * @param moduleClass the fake test class to use.
- * @param reportTest True if the test report some tests
- * @param runComplete True if the test run is complete
- * @param doesOneTestFail True if one of the test is going to fail
- * @param internalRetry True if the test will retry the module itself once
- */
- private void createConfig(File testsDir, String name, String moduleClass, boolean reportTest,
- boolean runComplete, boolean doesOneTestFail, boolean internalRetry)
- throws IOException {
- createConfig(testsDir, name, moduleClass, reportTest, runComplete, doesOneTestFail,
- internalRetry, "foo");
-
- }
-
- /**
- * Create a CTS configuration with a fake tests to exercise all cases.
- *
- * @param testsDir The testcases/ dir where to put the module
- * @param name the name of the module.
- * @param moduleClass the fake test class to use.
- * @param reportTest True if the test report some tests
- * @param runComplete True if the test run is complete
- * @param doesOneTestFail True if one of the test is going to fail
- * @param internalRetry True if the test will retry the module itself once
- * @param component the platform component name that the module can be categorized under
- */
- private void createConfig(File testsDir, String name, String moduleClass, boolean reportTest,
- boolean runComplete, boolean doesOneTestFail, boolean internalRetry, String component)
- throws IOException {
- File config = new File(testsDir, String.format(FILENAME, name));
- FileUtil.deleteFile(config);
- if (!config.createNewFile()) {
- throw new IOException(String.format("Failed to create '%s'", config.getAbsolutePath()));
- }
-
- FileUtil.writeToFile(String.format(CONFIG, component, moduleClass, reportTest, runComplete,
- doesOneTestFail, internalRetry), config);
- }
-
- /**
- * Simple tests running in one module that should be marked complete.
- */
- @Test
- public void testSingleModuleRun() throws Exception {
- final String moduleName = "module_run";
- final String mAbi = "arm64-v8a";
- createConfig(mTestDir, moduleName, TEST_STUB, true, true, true, false);
- EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
-
- mMockBuildInfo.addBuildAttribute(EasyMock.eq(CompatibilityBuildHelper.MODULE_IDS),
- EasyMock.eq(AbiUtils.createId(mAbi, moduleName)));
- EasyMock.expectLastCall();
-
- EasyMock.replay(mMockDevice, mMockBuildInfo);
- mReporter.invocationStarted(mContext);
- mTest.run(mReporter);
- mReporter.invocationEnded(500);
- EasyMock.verify(mMockDevice, mMockBuildInfo);
- IInvocationResult result = mReporter.getResult();
- assertEquals(2, result.countResults(TestStatus.PASS));
- assertEquals(1, result.countResults(TestStatus.FAIL));
- assertEquals(1, result.getModules().size());
- assertEquals(1, result.getModuleCompleteCount());
- }
-
- /**
- * Verify that result reporters test run ended callback can receive component name as configured
- * in module config metadata field.
- */
- @Test
- public void testSingleModuleRun_checkMetadata() throws Exception {
- final String moduleName = "AwsomeModule";
- final String mAbi = "arm64-v8a";
- final String component = "CriticalComponent";
- final List<String> receivedComponentsTestEnded = new ArrayList<>();
- final List<String> receivedModuleNameTestEnded = new ArrayList<>();
- final List<String> receivedAbiTestEnded = new ArrayList<>();
- final List<String> receivedComponentsTestRunEnded = new ArrayList<>();
- final List<String> receivedModuleNameTestRunEnded = new ArrayList<>();
- final List<String> receivedAbiTestRunEnded = new ArrayList<>();
- createConfig(mTestDir, moduleName, SIMPLE_TEST_STUB, true, true, true, false, component);
- EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
-
- mMockBuildInfo.addBuildAttribute(EasyMock.eq(CompatibilityBuildHelper.MODULE_IDS),
- EasyMock.eq(AbiUtils.createId(mAbi, moduleName)));
- EasyMock.expectLastCall();
-
- EasyMock.replay(mMockDevice, mMockBuildInfo);
- ITestInvocationListener myListener = new ITestInvocationListener() {
- private IInvocationContext myContext;
- @Override
- public void invocationStarted(IInvocationContext context) {
- myContext = context;
- }
- @Override
- public void testRunEnded(long elapsedTimeMillis, HashMap<String, Metric> runMetrics) {
- receivedComponentsTestRunEnded.addAll(myContext.getModuleInvocationContext()
- .getConfigurationDescriptor().getMetaData("component"));
- receivedModuleNameTestRunEnded.addAll(myContext.getModuleInvocationContext()
- .getAttributes().get(IModuleDef.MODULE_NAME));
- receivedAbiTestRunEnded.addAll(myContext.getModuleInvocationContext()
- .getAttributes().get(IModuleDef.MODULE_ABI));
- }
- @Override
- public void testEnded(TestDescription test, long endTime,
- HashMap<String, Metric> testMetrics) {
- receivedComponentsTestEnded.addAll(myContext.getModuleInvocationContext()
- .getConfigurationDescriptor().getMetaData("component"));
- receivedModuleNameTestEnded.addAll(myContext.getModuleInvocationContext()
- .getAttributes().get(IModuleDef.MODULE_NAME));
- receivedAbiTestEnded.addAll(myContext.getModuleInvocationContext()
- .getAttributes().get(IModuleDef.MODULE_ABI));
- }
- };
- myListener.invocationStarted(mContext);
- mTest.run(myListener);
- myListener.invocationEnded(500);
- EasyMock.verify(mMockDevice, mMockBuildInfo);
- // verify metadata was retrieved during testRunEnded callbacks
- assertEquals("[testRunEnded] wrong number of metadata collected",
- 1, receivedComponentsTestRunEnded.size());
- assertEquals("[testRunEnded] wrong component metadata field received",
- component, receivedComponentsTestRunEnded.get(0));
- assertEquals("[testRunEnded] wrong number of module name collected",
- 1, receivedModuleNameTestRunEnded.size());
- assertEquals(moduleName, receivedModuleNameTestRunEnded.get(0));
- assertEquals("[testEnded] wrong number of module abi collected",
- 1, receivedAbiTestRunEnded.size());
- assertEquals(mAbi, receivedAbiTestRunEnded.get(0));
- // verify metadata was retrieved during testEnded callbacks
- assertEquals("[testEnded] wrong number of metadata collected",
- 1, receivedComponentsTestEnded.size());
- assertEquals("[testEnded] wrong component metadata field received",
- component, receivedComponentsTestEnded.get(0));
- assertEquals("[testEnded] wrong number of module name collected",
- 1, receivedModuleNameTestEnded.size());
- assertEquals(moduleName, receivedModuleNameTestEnded.get(0));
- assertEquals("[testEnded] wrong number of module abi collected",
- 1, receivedAbiTestEnded.size());
- assertEquals(mAbi, receivedAbiTestEnded.get(0));
- }
-
- /**
- * Simple tests running in one module that run some tests but not all of them.
- */
- @Test
- public void testSingleModuleRun_incomplete() throws Exception {
- final String moduleName = "module_run_incomplete";
- final String mAbi = "arm64-v8a";
- createConfig(mTestDir, moduleName, TEST_STUB, true, false, true, false);
- EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
-
- mMockBuildInfo.addBuildAttribute(EasyMock.eq(CompatibilityBuildHelper.MODULE_IDS),
- EasyMock.eq(AbiUtils.createId(mAbi, moduleName)));
- EasyMock.expectLastCall();
-
- EasyMock.replay(mMockDevice, mMockBuildInfo);
- mReporter.invocationStarted(mContext);
- mTest.run(mReporter);
- mReporter.invocationEnded(500);
- EasyMock.verify(mMockDevice, mMockBuildInfo);
- IInvocationResult result = mReporter.getResult();
- assertEquals(1, result.countResults(TestStatus.PASS));
- assertEquals(1, result.countResults(TestStatus.FAIL));
- // Module should not be seen as complete.
- assertEquals(1, result.getModules().size());
- assertEquals(0, result.getModuleCompleteCount());
- }
-
- /**
- * Simple tests running in one module that should be marked complete since it runs all its
- * tests after an internal retry (like InstrumentationTest).
- * FIXME: Fix the expectation of this test
- */
- @Test
- public void testSingleModuleRun_completeAfterInternalRetry() throws Exception {
- final String moduleName = "module_completeAfterRetry";
- final String mAbi = "arm64-v8a";
- createConfig(mTestDir, moduleName, TEST_STUB, true, true, true, true);
- EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
-
- mMockBuildInfo.addBuildAttribute(EasyMock.eq(CompatibilityBuildHelper.MODULE_IDS),
- EasyMock.eq(AbiUtils.createId(mAbi, moduleName)));
- EasyMock.expectLastCall();
-
- EasyMock.replay(mMockDevice, mMockBuildInfo);
- mReporter.invocationStarted(mContext);
- mTest.run(mReporter);
- mReporter.invocationEnded(500);
- EasyMock.verify(mMockDevice, mMockBuildInfo);
- IInvocationResult result = mReporter.getResult();
- // FIXME: All tests should be marked as executed and not aggregating the count.
- assertEquals(2, result.countResults(TestStatus.PASS));
- assertEquals(1, result.countResults(TestStatus.FAIL));
- // FIXME: Module should be complete since all its test have run.
- assertEquals(1, result.getModules().size());
- assertEquals(0, result.getModuleCompleteCount());
- }
-
- /**
- * Simple tests running in one module that run some tests but not all of them, then we
- * attempt to run it again and they still didn't run.
- * FIXME: This test expectation needs to be fixed
- */
- @Test
- public void testSingleModuleRun_incomplete_rerun_incomplete() throws Exception {
- final String moduleName = "module_incomplete_rerun";
- final String mAbi = "arm64-v8a";
- createConfig(mTestDir, moduleName, TEST_STUB, true, false, true, false);
- EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
-
- mMockBuildInfo.addBuildAttribute(EasyMock.eq(CompatibilityBuildHelper.MODULE_IDS),
- EasyMock.eq(AbiUtils.createId(mAbi, moduleName)));
- EasyMock.expectLastCall();
-
- // extra calls for retry
- EasyMock.expect(mMockDevice.getProperty("ro.build.fingerprint")).andReturn("fingerprint");
- EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
- mMockBuildInfo.addBuildAttribute(EasyMock.eq(CompatibilityBuildHelper.MODULE_IDS),
- EasyMock.eq(AbiUtils.createId(mAbi, moduleName)));
- EasyMock.expectLastCall();
- mMockBuildInfo.addBuildAttribute(EasyMock.eq("retry_command_line_args"),
- EasyMock.eq(COMMAND_LINE));
- EasyMock.expectLastCall();
-
- EasyMock.replay(mMockDevice, mMockBuildInfo);
- mReporter.invocationStarted(mContext);
- mTest.run(mReporter);
- mReporter.invocationEnded(500);
-
- IInvocationResult result = mReporter.getResult();
- assertEquals(1, result.countResults(TestStatus.PASS));
- assertEquals(1, result.countResults(TestStatus.FAIL));
- // Module should not be seen as complete.
- assertEquals(0, result.getModuleCompleteCount());
-
- // We re-run it
- mReporter = new ResultReporter();
- mTest = new CompatibilityTest() {
- @Override
- protected Set<String> getAbisForBuildTargetArch() {
- Set<String> abis = new HashSet<>();
- abis.add("arm64-v8a");
- return abis;
- }
- };
- mTest.setDevice(mMockDevice);
- mTest.setBuild(mMockBuildInfo);
- mTest.setInvocationContext(mContext);
- OptionSetter setter = new OptionSetter(mTest, mReporter);
- setter.setOptionValue("retry", "0");
-
- mReporter.invocationStarted(mContext);
- mTest.run(mReporter);
- mReporter.invocationEnded(500);
- EasyMock.verify(mMockDevice, mMockBuildInfo);
-
- // Check retry results
- result = mReporter.getResult();
- // FIXME: We should only have 1 not_executed in the retry too. They should not aggregate
- // from one run to another.
- assertEquals(1, result.countResults(TestStatus.PASS));
- assertEquals(1, result.countResults(TestStatus.FAIL));
- // Module should not be seen as complete.
- assertEquals(1, result.getModules().size());
- assertEquals(0, result.getModuleCompleteCount());
- }
-
- /**
- * Simple tests running in one module that run some tests but not all of them, we then attempt
- * to retry run them and this time the not_executed is executed.
- */
- @Test
- public void testSingleModuleRun_incomplete_rerun_complete() throws Exception {
- final String moduleName = "module_incom_rerun_complete";
- final String mAbi = "arm64-v8a";
- createConfig(mTestDir, moduleName, TEST_STUB, true, false, true, false);
- EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
-
- mMockBuildInfo.addBuildAttribute(EasyMock.eq(CompatibilityBuildHelper.MODULE_IDS),
- EasyMock.eq(AbiUtils.createId(mAbi, moduleName)));
- EasyMock.expectLastCall();
-
- // extra calls for retry
- EasyMock.expect(mMockDevice.getProperty("ro.build.fingerprint")).andReturn("fingerprint");
- EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
- mMockBuildInfo.addBuildAttribute(EasyMock.eq(CompatibilityBuildHelper.MODULE_IDS),
- EasyMock.eq(AbiUtils.createId(mAbi, moduleName)));
- EasyMock.expectLastCall();
- mMockBuildInfo.addBuildAttribute(EasyMock.eq("retry_command_line_args"),
- EasyMock.eq(COMMAND_LINE));
- EasyMock.expectLastCall();
-
- EasyMock.replay(mMockDevice, mMockBuildInfo);
- mReporter.invocationStarted(mContext);
- mTest.run(mReporter);
- mReporter.invocationEnded(500);
-
- IInvocationResult result = mReporter.getResult();
- assertEquals(1, result.countResults(TestStatus.PASS));
- assertEquals(1, result.countResults(TestStatus.FAIL));
- // Module should not be seen as complete.
- assertEquals(0, result.getModuleCompleteCount());
-
- // We replace the config by one that runs all tests without failures.
- createConfig(mTestDir, moduleName, TEST_STUB, true, true, false, false);
- // Usually configs do not change during the same session so we clear the map to have
- // the new version of the config.
- ((ConfigurationFactory)ConfigurationFactory.getInstance()).clearMapConfig();
-
- // We re-run it
- mReporter = new ResultReporter();
- mTest = new CompatibilityTest() {
- @Override
- protected Set<String> getAbisForBuildTargetArch() {
- Set<String> abis = new HashSet<>();
- abis.add("arm64-v8a");
- return abis;
- }
- };
- mTest.setDevice(mMockDevice);
- mTest.setBuild(mMockBuildInfo);
- mTest.setInvocationContext(mContext);
- OptionSetter setter = new OptionSetter(mTest, mReporter);
- setter.setOptionValue("retry", "0");
-
- mReporter.invocationStarted(mContext);
- mTest.run(mReporter);
- mReporter.invocationEnded(500);
- EasyMock.verify(mMockDevice, mMockBuildInfo);
-
- // Check retry results
- result = mReporter.getResult();
- assertEquals(3, result.countResults(TestStatus.PASS));
- assertEquals(0, result.countResults(TestStatus.FAIL));
- // Module should be marked as complete after retry.
- assertEquals(1, result.getModules().size());
- assertEquals(1, result.getModuleCompleteCount());
- }
-
- // ***** Case for sharding interaction *****
-
- /**
- * Helper to create a shard listener with the original reporter as master.
- */
- private ITestInvocationListener getShardListener(ResultReporter masterReporter) {
- List<ITestInvocationListener> shardListeners = new ArrayList<ITestInvocationListener>();
- ShardListener origConfigListener = new ShardListener(masterReporter);
- ResultReporter reporterClone = (ResultReporter) masterReporter.clone();
- shardListeners.add(reporterClone);
- shardListeners.add(origConfigListener);
- ResultForwarder shard = new ResultForwarder(shardListeners);
- return shard;
- }
-
- /**
- * Helper Thread to run the IShardableTest.
- */
- private class ShardThread extends Thread {
- private IRemoteTest mShardTest;
- private ResultReporter mMasterReporter;
- private IBuildInfo mBuild;
- private ITestDevice mDevice;
- private IInvocationContext mShardContext;
-
- public ShardThread(IRemoteTest test, ResultReporter masterReporter, IBuildInfo build,
- ITestDevice device, IInvocationContext context) {
- mShardTest = test;
- mMasterReporter = masterReporter;
- mBuild = build;
- mDevice = device;
- mShardContext = context;
- }
-
- @Override
- public void run() {
- ITestInvocationListener listener = getShardListener(mMasterReporter);
- ((IBuildReceiver)mShardTest).setBuild(mBuild);
- ((IDeviceTest)mShardTest).setDevice(mDevice);
- ((IInvocationContextReceiver)mShardTest).setInvocationContext(mContext);
- listener.invocationStarted(mShardContext);
- try {
- mShardTest.run(listener);
- } catch (DeviceNotAvailableException e) {
- throw new RuntimeException(e);
- } finally {
- listener.invocationEnded(500);
- }
- }
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/PresubmitSetupValidation.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/PresubmitSetupValidation.java
deleted file mode 100644
index 4eb48fc..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/PresubmitSetupValidation.java
+++ /dev/null
@@ -1,57 +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.compatibility.common.tradefed.presubmit;
-
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.config.ConfigurationFactory;
-import com.android.tradefed.config.IConfigurationFactory;
-import com.android.tradefed.log.LogUtil.CLog;
-
-import junit.framework.TestCase;
-
-/**
- * Tests that validate the CTS presubmit setup to ensure no CL will break the presubmit setup
- * itself.
- */
-public class PresubmitSetupValidation extends TestCase {
- private static final String PRESUBMIT_CTS_UNIT_TESTS = "cts-unit-tests";
-
- /**
- * Test that the base cts unit tests configuration is still working, and has a reporter
- * template placeholder.
- */
- public void testCtsPresubmit_unit_tests() {
- IConfigurationFactory factory = ConfigurationFactory.getInstance();
- String[] presubmitCommand = {PRESUBMIT_CTS_UNIT_TESTS, "--template:map", "reporters=empty"};
- try {
- factory.createConfigurationFromArgs(presubmitCommand);
- } catch (ConfigurationException e) {
- CLog.e(e);
- fail(String.format("ConfigException '%s': One of your change is breaking the presubmit "
- + "CTS unit tests configuration.", e.getMessage()));
- }
- }
-
- /**
- * Test to ensure that Zip dependency on the Apache Commons Compress coming from TradeFed is
- * properly setup. This dependency is required for some utilities of TradeFed to work.
- */
- public void testDependencyCommonsCompress() throws Exception {
- ClassLoader loader = ClassLoader.getSystemClassLoader();
- // This will throw an exception if dependency isn't met.
- loader.loadClass("org.apache.commons.compress.archivers.zip.ZipFile");
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ValidateTestsAbi.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ValidateTestsAbi.java
deleted file mode 100644
index 6d19417..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ValidateTestsAbi.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.tradefed.presubmit;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.android.tradefed.testtype.suite.TestSuiteInfo;
-import com.android.tradefed.util.AaptParser;
-import com.android.tradefed.util.AbiUtils;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-/**
- * Tests to validate that the build is containing usable test artifact.
- */
-@RunWith(JUnit4.class)
-public class ValidateTestsAbi {
-
- private static final Set<String> MODULE_EXCEPTIONS = new HashSet<>();
- static {
- /**
- * This particular module is shipping all it's dependencies in all abis with prebuilt stuff.
- * Excluding it for now to have the test setup.
- */
- MODULE_EXCEPTIONS.add("CtsSplitApp");
-
- /**
- * This module tests for security vulnerabilities when installing attacker-devised APKs.
- */
- MODULE_EXCEPTIONS.add("CtsCorruptApkTests");
-
- /**
- * This module tests for installations of packages that have only 32-bit native libraries.
- */
- MODULE_EXCEPTIONS.add("CtsExtractNativeLibsAppTrue32");
-
- /**
- * This module tests for installations of packages that have only 64-bit native libraries.
- */
- MODULE_EXCEPTIONS.add("CtsExtractNativeLibsAppTrue64");
- }
-
- private static final Set<String> BINARY_EXCEPTIONS = new HashSet<>();
- static {
- /**
- * This binary is a host side helper, so we do not need to check it.
- */
- BINARY_EXCEPTIONS.add("sepolicy-analyze");
- }
-
- /**
- * Test that all apks have the same supported abis.
- * Sometimes, if a module is missing LOCAL_MULTILIB := both, we will end up with only one of
- * the two abis required and the second one will fail.
- */
- @Test
- public void testApksAbis() {
- String ctsRoot = System.getProperty("CTS_ROOT");
- File testcases = new File(ctsRoot, "/android-cts/testcases/");
- if (!testcases.exists()) {
- fail(String.format("%s does not exists", testcases));
- return;
- }
- File[] listApks = testcases.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- for (String module : MODULE_EXCEPTIONS) {
- if (name.startsWith(module)) {
- return false;
- }
- }
-
- return name.endsWith(".apk");
- }
- });
- assertTrue(listApks.length > 0);
- int maxAbi = 0;
- Map<String, Integer> apkToAbi = new HashMap<>();
-
- for (File testApk : listApks) {
- AaptParser result = AaptParser.parse(testApk);
- // Retry as we have seen flake with aapt sometimes.
- if (result == null) {
- for (int i = 0; i < 2; i++) {
- result = AaptParser.parse(testApk);
- if (result != null) {
- break;
- }
- }
- // If still couldn't parse the apk
- if (result == null) {
- fail(String.format("Fail to run 'aapt dump badging %s'",
- testApk.getAbsolutePath()));
- }
- }
- // We only check the apk that have native code
- if (!result.getNativeCode().isEmpty()) {
- List<String> supportedAbiApk = result.getNativeCode();
- Set<String> buildTarget = AbiUtils.getAbisForArch(
- TestSuiteInfo.getInstance().getTargetArchs().get(0));
- // first check, all the abis are supported
- for (String abi : supportedAbiApk) {
- if (!buildTarget.contains(abi)) {
- fail(String.format("apk %s %s does not support our abis [%s]",
- testApk.getName(), supportedAbiApk, buildTarget));
- }
- }
- apkToAbi.put(testApk.getName(), supportedAbiApk.size());
- maxAbi = Math.max(maxAbi, supportedAbiApk.size());
- }
- }
-
- // We do a second pass to make sure nobody is short on abi
- for (Entry<String, Integer> apk : apkToAbi.entrySet()) {
- if (apk.getValue() < maxAbi) {
- fail(String.format("apk %s only has %s abi when it should have %s", apk.getKey(),
- apk.getValue(), maxAbi));
- }
- }
- }
-
- /**
- * Test that when CTS has multiple abis, we have binary for each ABI. In this case the abi will
- * be the same with different bitness (only case supported by build system).
- * <p/>
- * If there is only one bitness, then we check that it's the right one.
- */
- @Test
- public void testBinariesAbis() {
- String ctsRoot = System.getProperty("CTS_ROOT");
- File testcases = new File(ctsRoot, "/android-cts/testcases/");
- if (!testcases.exists()) {
- fail(String.format("%s does not exist", testcases));
- return;
- }
- String[] listBinaries = testcases.list(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- if (name.contains(".")) {
- return false;
- }
- if (BINARY_EXCEPTIONS.contains(name)) {
- return false;
- }
- File file = new File(dir, name);
- if (file.isDirectory()) {
- return false;
- }
- if (!file.canExecute()) {
- return false;
- }
- return true;
- }
- });
- assertTrue(listBinaries.length > 0);
- List<String> orderedList = Arrays.asList(listBinaries);
- // we sort to have binary starting with same name, next to each other. The last two
- // characters of their name with be the bitness (32 or 64).
- Collections.sort(orderedList);
- Set<String> buildTarget = AbiUtils.getAbisForArch(
- TestSuiteInfo.getInstance().getTargetArchs().get(0));
- // We expect one binary per abi of CTS, they should be appended with 32 or 64
- for (int i = 0; i < orderedList.size(); i=i + buildTarget.size()) {
- List<String> subSet = orderedList.subList(i, i + buildTarget.size());
- if (subSet.size() > 1) {
- String base = subSet.get(0).substring(0, subSet.get(0).length() - 2);
- for (int j = 0; j < subSet.size(); j++) {
- assertEquals(base, subSet.get(j).substring(0, subSet.get(j).length() - 2));
- }
- } else {
- String bitness = AbiUtils.getBitness(buildTarget.iterator().next());
- assertTrue(subSet.get(i).endsWith(bitness));
- }
- }
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ChecksumReporterTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ChecksumReporterTest.java
deleted file mode 100644
index 23fcb9a..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ChecksumReporterTest.java
+++ /dev/null
@@ -1,198 +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.compatibility.common.tradefed.result;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider;
-import com.android.compatibility.common.util.ChecksumReporter;
-import com.android.compatibility.common.util.ChecksumReporter.ChecksumValidationException;
-import com.android.compatibility.common.util.ICaseResult;
-import com.android.compatibility.common.util.IInvocationResult;
-import com.android.compatibility.common.util.IModuleResult;
-import com.android.compatibility.common.util.ITestResult;
-import com.android.compatibility.common.util.ReportLog;
-import com.android.compatibility.common.util.TestStatus;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.OptionSetter;
-import com.android.tradefed.invoker.IInvocationContext;
-import com.android.tradefed.invoker.InvocationContext;
-import com.android.tradefed.util.FileUtil;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-/**
- * Unit tests for {@link ChecksumReporter}
- */
-public class ChecksumReporterTest extends TestCase {
-
- private static final String ROOT_PROPERTY = "TESTS_ROOT";
- private static final String ROOT_DIR_NAME = "root";
- private static final String SUITE_NAME = "TESTS";
- private static final String BUILD_NUMBER = "2";
- private static final String SUITE_PLAN = "cts";
- private static final String BASE_DIR_NAME = "android-tests";
- private static final String TESTCASES = "testcases";
-
- private ChecksumReporter mReporter;
- private File mRoot = null;
- private IBuildInfo mBuildInfo;
- private ReportLog mReportLog = null;
- private IInvocationResult mInvocationResult;
- private IModuleResult mModuleResult;
- private ITestResult mFailedTest;
-
- @Override
- public void setUp() throws Exception {
- mReporter = new ChecksumReporter(100, .001, (short)1);
- mRoot = FileUtil.createTempDir(ROOT_DIR_NAME);
- File baseDir = new File(mRoot, BASE_DIR_NAME);
- baseDir.mkdirs();
- File testDir = new File(baseDir, TESTCASES);
- testDir.mkdirs();
- System.setProperty(ROOT_PROPERTY, mRoot.getAbsolutePath());
-
- ResultReporter resultReporter = new ResultReporter();
- CompatibilityBuildProvider provider = new CompatibilityBuildProvider() {
- @Override
- protected String getSuiteInfoName() {
- return SUITE_NAME;
- }
- @Override
- protected String getSuiteInfoBuildNumber() {
- return BUILD_NUMBER;
- }
- @Override
- protected String getSuiteInfoVersion() {
- return BUILD_NUMBER;
- }
- };
- OptionSetter setter = new OptionSetter(provider);
- setter.setOptionValue("plan", SUITE_PLAN);
- setter.setOptionValue("dynamic-config-url", "");
- mBuildInfo = provider.getBuild();
- IInvocationContext context = new InvocationContext();
- context.addDeviceBuildInfo("fakeDevice", mBuildInfo);
-
- resultReporter.invocationStarted(context);
- mInvocationResult = resultReporter.getResult();
- mModuleResult = mInvocationResult.getOrCreateModule("Module-1");
- mModuleResult.setDone(true);
- ICaseResult caseResult = mModuleResult.getOrCreateResult("Case-1");
- ITestResult test1 = caseResult.getOrCreateResult("Test1");
- test1.passed(mReportLog);
- mFailedTest = caseResult.getOrCreateResult("Test2");
- mFailedTest.failed("stack-trace - error happened");
-
- IModuleResult moduleResult2 = mInvocationResult.getOrCreateModule("Module-2");
- ICaseResult caseResult2 = moduleResult2.getOrCreateResult("Case-2");
- mModuleResult.setDone(false);
- ITestResult test3 = caseResult2.getOrCreateResult("Test3");
- test3.passed(mReportLog);
-
- }
-
- @Override
- public void tearDown() throws Exception {
- mReporter = null;
- FileUtil.recursiveDelete(mRoot);
- }
-
- public void testStoreAndRetrieveTestResults() {
- mReporter.addInvocation(mInvocationResult);
- VerifyInvocationResults(mInvocationResult, mReporter);
- }
-
- /***
- * By definition this test is flaky since the checksum has a false positive probability of .1%
- */
- public void testInvalidChecksums() {
- mReporter.addInvocation(mInvocationResult);
- IModuleResult module = mInvocationResult.getModules().get(1);
- module.setDone(!module.isDone());
- String fingerprint = mInvocationResult.getBuildFingerprint();
- assertFalse("Checksum should contain module: " + module.getName(),
- mReporter.containsModuleResult(module, fingerprint));
-
- mFailedTest.setResultStatus(TestStatus.PASS);
- assertFalse("Checksum should not contain test: " + mFailedTest.getName(),
- mReporter.containsTestResult(mFailedTest, mModuleResult, fingerprint));
- assertFalse("Module checksum should verify number of tests",
- mReporter.containsModuleResult(mModuleResult, fingerprint));
- }
-
- public void testFileSerialization() throws IOException, ChecksumValidationException {
- mReporter.addInvocation(mInvocationResult);
-
- File file1 = new File(mRoot, "file1.txt");
- try (FileWriter fileWriter = new FileWriter(file1, false)) {
- fileWriter.append("This is a test file");
- }
-
- mReporter.addDirectory(mRoot);
- mReporter.saveToFile(mRoot);
-
- ChecksumReporter storedChecksum = ChecksumReporter.load(mRoot);
- VerifyInvocationResults(mInvocationResult, storedChecksum);
- assertTrue("Serializing checksum maintains file hash",
- storedChecksum.containsFile(file1, mRoot.getName()));
- }
-
- public void testFileCRCOperations() throws IOException {
- File subDirectory = new File(mRoot, "child");
- subDirectory.mkdir();
- File file1 = new File(mRoot, "file1.txt");
- try (FileWriter fileWriter = new FileWriter(file1, false)) {
- fileWriter.append("This is a test file");
- }
-
- File file2 = new File(subDirectory, "file2.txt");
- try (FileWriter fileWriter = new FileWriter(file2, false)) {
- fileWriter.append("This is another test file with a different crc");
- }
-
- mReporter.addDirectory(mRoot);
- String folderName = mRoot.getName();
- assertTrue(mReporter.containsFile(file1, folderName));
- assertTrue(mReporter.containsFile(file2, folderName + "/child"));
- assertFalse("Should not contain non-existent file",
- mReporter.containsFile(new File(mRoot, "fake.txt"), folderName));
-
- File file3 = new File(mRoot, "file3.txt");
- try (FileWriter fileWriter = new FileWriter(file3, false)) {
- fileWriter.append("This is a test file added after crc calculated");
- }
- assertFalse("Should not contain file created after crc calculated",
- mReporter.containsFile(file3, mRoot + "/"));
-
- }
-
- private void VerifyInvocationResults(IInvocationResult invocation, ChecksumReporter reporter) {
- for (IModuleResult module : invocation.getModules()) {
- String buildFingerprint = invocation.getBuildFingerprint();
- assertTrue("Checksum should contain module: " + module.getName(),
- reporter.containsModuleResult(module, buildFingerprint));
- for (ICaseResult caseResult : module.getResults()) {
- for (ITestResult result : caseResult.getResults()) {
- assertTrue("Checksum should contain test: " + result.getName(),
- reporter.containsTestResult(result, module, buildFingerprint));
- }
- }
- }
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterBuildInfoTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterBuildInfoTest.java
deleted file mode 100644
index 6e62c36..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterBuildInfoTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.tradefed.result;
-
-
-import com.android.compatibility.common.util.IInvocationResult;
-import com.android.compatibility.common.util.InvocationResult;
-import junit.framework.TestCase;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Unit tests for {@link ResultReporter}, focused on ability to override build info.
- */
-public class ResultReporterBuildInfoTest extends TestCase {
-
- public void testOverrideBuildProperties() {
- ResultReporterBuildInfoTester tester = new ResultReporterBuildInfoTester();
- String manufacture = "custom_manufacture";
- String brand = "google";
- String product = "gProduct";
- String device = "gDevice";
- String version = "gVersion";
- String buildId = "123";
- String model = "gModel";
- String fingerprint = brand + "/" + product + "/" + device + ":" +
- version + "/" + buildId + "/userdebug-keys";
-
- IInvocationResult result = tester.testBuildInfoOverride(fingerprint, manufacture, model);
- Map<String, String> invocationInfo = result.getInvocationInfo();
- assertEquals(invocationInfo.get(ResultReporter.BUILD_ID), buildId);
- assertEquals(invocationInfo.get(ResultReporter.BUILD_BRAND), brand);
- assertEquals(invocationInfo.get(ResultReporter.BUILD_DEVICE), device);
- assertEquals(invocationInfo.get(ResultReporter.BUILD_PRODUCT), product);
- assertEquals(invocationInfo.get(ResultReporter.BUILD_VERSION_RELEASE), version);
- assertEquals(invocationInfo.get(ResultReporter.BUILD_FINGERPRINT), fingerprint);
- assertEquals(invocationInfo.get(ResultReporter.BUILD_MANUFACTURER), manufacture);
- assertEquals(invocationInfo.get(ResultReporter.BUILD_MODEL), model);
- }
-
- public static class ResultReporterBuildInfoTester extends ResultReporter {
-
- public ResultReporterBuildInfoTester() {
- mResult = new InvocationResult();
- }
-
- public IInvocationResult testBuildInfoOverride(String buildFingerprintOverride,
- String manufactureOverride, String modelOverride) {
- addDeviceBuildInfoToResult(
- buildFingerprintOverride, manufactureOverride, modelOverride);
- return mResult;
- }
-
- @Override
- protected Map<String, String> mapBuildInfo() {
- Map<String, String> buildProperties = new HashMap<>();
- buildProperties.put(BUILD_ID, BUILD_ID);
- buildProperties.put(BUILD_BRAND, BUILD_BRAND);
- buildProperties.put(BUILD_DEVICE, BUILD_DEVICE);
- buildProperties.put(BUILD_PRODUCT, BUILD_PRODUCT);
- buildProperties.put(BUILD_VERSION_RELEASE, BUILD_VERSION_RELEASE);
- buildProperties.put(BUILD_FINGERPRINT, BUILD_FINGERPRINT);
- buildProperties.put(BUILD_MANUFACTURER, BUILD_MANUFACTURER);
- buildProperties.put(BUILD_MODEL, BUILD_MODEL);
- return buildProperties;
- }
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterTest.java
deleted file mode 100644
index 805a2ad..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterTest.java
+++ /dev/null
@@ -1,622 +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.compatibility.common.tradefed.result;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider;
-import com.android.compatibility.common.util.DeviceInfo;
-import com.android.compatibility.common.util.ICaseResult;
-import com.android.compatibility.common.util.IInvocationResult;
-import com.android.compatibility.common.util.IModuleResult;
-import com.android.compatibility.common.util.ITestResult;
-import com.android.compatibility.common.util.TestStatus;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.OptionSetter;
-import com.android.tradefed.invoker.IInvocationContext;
-import com.android.tradefed.invoker.InvocationContext;
-import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
-import com.android.tradefed.result.ByteArrayInputStreamSource;
-import com.android.tradefed.result.InputStreamSource;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.TestDescription;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.FileUtil;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- * Unit tests for {@link ResultReporter}
- */
-public class ResultReporterTest extends TestCase {
-
- private static final String ROOT_PROPERTY = "TESTS_ROOT";
- private static final String SUITE_NAME = "TESTS";
- private static final String BUILD_NUMBER = "2";
- private static final String SUITE_PLAN = "cts";
- private static final String DYNAMIC_CONFIG_URL = "";
- private static final String ROOT_DIR_NAME = "root";
- private static final String BASE_DIR_NAME = "android-tests";
- private static final String TESTCASES = "testcases";
- private static final String NAME = "ModuleName";
- private static final String ABI = "mips64";
- private static final String ID = AbiUtils.createId(ABI, NAME);
- private static final String CLASS = "android.test.FoorBar";
- private static final String METHOD_1 = "testBlah1";
- private static final String METHOD_2 = "testBlah2";
- private static final String METHOD_3 = "testBlah3";
- private static final String TEST_1 = String.format("%s#%s", CLASS, METHOD_1);
- private static final String TEST_2 = String.format("%s#%s", CLASS, METHOD_2);
- private static final String TEST_3 = String.format("%s#%s", CLASS, METHOD_3);
- private static final String STACK_TRACE = "Something small is not alright\n " +
- "at four.big.insects.Marley.sing(Marley.java:10)";
- private static final String RESULT_DIR = "result123";
- private static final String[] FORMATTING_FILES = {
- "compatibility_result.css",
- "compatibility_result.xsl",
- "logo.png"};
-
- private ResultReporter mReporter;
- private IBuildInfo mBuildInfo;
- private IInvocationContext mContext;
- private CompatibilityBuildHelper mBuildHelper;
-
- private File mRoot = null;
- private File mBase = null;
- private File mTests = null;
-
- @Override
- public void setUp() throws Exception {
- mReporter = new ResultReporter();
- mRoot = FileUtil.createTempDir(ROOT_DIR_NAME);
- mBase = new File(mRoot, BASE_DIR_NAME);
- mBase.mkdirs();
- mTests = new File(mBase, TESTCASES);
- mTests.mkdirs();
- System.setProperty(ROOT_PROPERTY, mRoot.getAbsolutePath());
- CompatibilityBuildProvider provider = new CompatibilityBuildProvider() {
- @Override
- protected String getSuiteInfoName() {
- return SUITE_NAME;
- }
- @Override
- protected String getSuiteInfoBuildNumber() {
- return BUILD_NUMBER;
- }
- @Override
- protected String getSuiteInfoVersion() {
- return BUILD_NUMBER;
- }
- };
- OptionSetter setter = new OptionSetter(provider);
- setter.setOptionValue("plan", SUITE_PLAN);
- setter.setOptionValue("dynamic-config-url", DYNAMIC_CONFIG_URL);
- mBuildInfo = provider.getBuild();
- mBuildHelper = new CompatibilityBuildHelper(mBuildInfo);
- mContext = new InvocationContext();
- mContext.addDeviceBuildInfo("fakeDevice", mBuildInfo);
- }
-
- @Override
- public void tearDown() throws Exception {
- mReporter = null;
- FileUtil.recursiveDelete(mRoot);
- }
-
- public void testSetup() throws Exception {
- mReporter.invocationStarted(mContext);
- // Should have created a directory for the logs
- File[] children = mBuildHelper.getLogsDir().listFiles();
- assertTrue("Didn't create logs dir", children.length == 1 && children[0].isDirectory());
- // Should have created a directory for the results
- children = mBuildHelper.getResultsDir().listFiles();
- assertTrue("Didn't create results dir", children.length == 1 && children[0].isDirectory());
- mReporter.invocationEnded(10);
- // Should have created a zip file
- children = mBuildHelper.getResultsDir().listFiles(new FileFilter() {
- @Override
- public boolean accept(File pathname) {
- return pathname.getName().endsWith(".zip");
- }
- });
- assertTrue("Didn't create results zip",
- children.length == 1 && children[0].isFile() && children[0].length() > 0);
- }
-
- public void testResultReporting() throws Exception {
- mReporter.invocationStarted(mContext);
- mReporter.testRunStarted(ID, 2);
- TestDescription test1 = new TestDescription(CLASS, METHOD_1);
- mReporter.testStarted(test1);
- mReporter.testEnded(test1, new HashMap<String, Metric>());
- TestDescription test2 = new TestDescription(CLASS, METHOD_2);
- mReporter.testStarted(test2);
- mReporter.testFailed(test2, STACK_TRACE);
- TestDescription test3 = new TestDescription(CLASS, METHOD_3);
- mReporter.testStarted(test3);
- mReporter.testFailed(test3, STACK_TRACE);
- mReporter.testEnded(test3, new HashMap<String, Metric>());
- mReporter.testRunEnded(10, new HashMap<String, Metric>());
- mReporter.invocationEnded(10);
- IInvocationResult result = mReporter.getResult();
- assertEquals("Expected 1 pass", 1, result.countResults(TestStatus.PASS));
- assertEquals("Expected 2 failures", 2, result.countResults(TestStatus.FAIL));
- List<IModuleResult> modules = result.getModules();
- assertEquals("Expected 1 module", 1, modules.size());
- IModuleResult module = modules.get(0);
- assertTrue(module.isDone());
- assertEquals("Incorrect ID", ID, module.getId());
- List<ICaseResult> caseResults = module.getResults();
- assertEquals("Expected 1 test case", 1, caseResults.size());
- ICaseResult caseResult = caseResults.get(0);
- List<ITestResult> testResults = caseResult.getResults();
- assertEquals("Expected 3 tests", 3, testResults.size());
- ITestResult result1 = caseResult.getResult(METHOD_1);
- assertNotNull(String.format("Expected result for %s", TEST_1), result1);
- assertEquals(String.format("Expected pass for %s", TEST_1), TestStatus.PASS,
- result1.getResultStatus());
- ITestResult result2 = caseResult.getResult(METHOD_2);
- assertNotNull(String.format("Expected result for %s", TEST_2), result2);
- assertEquals(String.format("Expected fail for %s", TEST_2), TestStatus.FAIL,
- result2.getResultStatus());
- ITestResult result3 = caseResult.getResult(METHOD_3);
- assertNotNull(String.format("Expected result for %s", TEST_3), result3);
- assertEquals(String.format("Expected fail for %s", TEST_3), TestStatus.FAIL,
- result3.getResultStatus());
- }
-
- private void makeTestRun(String[] methods, boolean[] passes) {
- mReporter.testRunStarted(ID, methods.length);
-
- for (int i = 0; i < methods.length; i++) {
- TestDescription test = new TestDescription(CLASS, methods[i]);
- mReporter.testStarted(test);
- if (!passes[i]) {
- mReporter.testFailed(test, STACK_TRACE);
- }
- mReporter.testEnded(test, new HashMap<String, Metric>());
- }
-
- mReporter.testRunEnded(10, new HashMap<String, Metric>());
- }
-
- public void testRepeatedExecutions() throws Exception {
- String[] methods = new String[] {METHOD_1, METHOD_2, METHOD_3};
-
- mReporter.invocationStarted(mContext);
-
- makeTestRun(methods, new boolean[] {true, false, true});
- makeTestRun(methods, new boolean[] {true, false, false});
- makeTestRun(methods, new boolean[] {true, true, true});
-
- mReporter.invocationEnded(10);
-
- // Verification
-
- IInvocationResult result = mReporter.getResult();
- assertEquals("Expected 1 pass", 1, result.countResults(TestStatus.PASS));
- assertEquals("Expected 2 failures", 2, result.countResults(TestStatus.FAIL));
- List<IModuleResult> modules = result.getModules();
- assertEquals("Expected 1 module", 1, modules.size());
- IModuleResult module = modules.get(0);
- assertEquals("Incorrect ID", ID, module.getId());
- List<ICaseResult> caseResults = module.getResults();
- assertEquals("Expected 1 test case", 1, caseResults.size());
- ICaseResult caseResult = caseResults.get(0);
- List<ITestResult> testResults = caseResult.getResults();
- assertEquals("Expected 3 tests", 3, testResults.size());
-
- // Test 1 details
- ITestResult result1 = caseResult.getResult(METHOD_1);
- assertNotNull(String.format("Expected result for %s", TEST_1), result1);
- assertEquals(String.format("Expected pass for %s", TEST_1), TestStatus.PASS,
- result1.getResultStatus());
-
- // Test 2 details
- ITestResult result2 = caseResult.getResult(METHOD_2);
- assertNotNull(String.format("Expected result for %s", TEST_2), result2);
- assertEquals(String.format("Expected fail for %s", TEST_2), TestStatus.FAIL,
- result2.getResultStatus());
- // TODO: Define requirement. Should this result have multiple stack traces?
- assertEquals(result2.getStackTrace(), STACK_TRACE);
-
- // Test 3 details
- ITestResult result3 = caseResult.getResult(METHOD_3);
- assertNotNull(String.format("Expected result for %s", TEST_3), result3);
- assertEquals(String.format("Expected fail for %s", TEST_3), TestStatus.FAIL,
- result3.getResultStatus());
- assertEquals(result3.getStackTrace(), STACK_TRACE);
- }
-
- public void testRetry() throws Exception {
- mReporter.invocationStarted(mContext);
-
- // Set up IInvocationResult with existing results from previous session
- mReporter.testRunStarted(ID, 2);
- IInvocationResult invocationResult = mReporter.getResult();
- IModuleResult moduleResult = invocationResult.getOrCreateModule(ID);
- ICaseResult caseResult = moduleResult.getOrCreateResult(CLASS);
- ITestResult testResult1 = caseResult.getOrCreateResult(METHOD_1);
- testResult1.setResultStatus(TestStatus.PASS);
- testResult1.setRetry(true);
- ITestResult testResult2 = caseResult.getOrCreateResult(METHOD_2);
- testResult2.setResultStatus(TestStatus.FAIL);
- testResult2.setStackTrace(STACK_TRACE);
- testResult2.setRetry(true);
-
- // Flip results for the current session
- TestDescription test1 = new TestDescription(CLASS, METHOD_1);
- mReporter.testStarted(test1);
- mReporter.testFailed(test1, STACK_TRACE);
- mReporter.testEnded(test1, new HashMap<String, Metric>());
- TestDescription test2 = new TestDescription(CLASS, METHOD_2);
- mReporter.testStarted(test2);
- mReporter.testEnded(test2, new HashMap<String, Metric>());
-
- mReporter.testRunEnded(10, new HashMap<String, Metric>());
- mReporter.invocationEnded(10);
-
- // Verification that results have been overwritten.
- IInvocationResult result = mReporter.getResult();
- assertEquals("Expected 1 pass", 1, result.countResults(TestStatus.PASS));
- assertEquals("Expected 1 failure", 1, result.countResults(TestStatus.FAIL));
- List<IModuleResult> modules = result.getModules();
- assertEquals("Expected 1 module", 1, modules.size());
- IModuleResult module = modules.get(0);
- List<ICaseResult> cases = module.getResults();
- assertEquals("Expected 1 test case", 1, cases.size());
- ICaseResult case1 = cases.get(0);
- List<ITestResult> testResults = case1.getResults();
- assertEquals("Expected 2 tests", 2, testResults.size());
-
- // Test 1 details
- ITestResult finalTestResult1 = case1.getResult(METHOD_1);
- assertNotNull(String.format("Expected result for %s", TEST_1), finalTestResult1);
- assertEquals(String.format("Expected fail for %s", TEST_1), TestStatus.FAIL,
- finalTestResult1.getResultStatus());
- assertEquals(finalTestResult1.getStackTrace(), STACK_TRACE);
-
- // Test 2 details
- ITestResult finalTestResult2 = case1.getResult(METHOD_2);
- assertNotNull(String.format("Expected result for %s", TEST_2), finalTestResult2);
- assertEquals(String.format("Expected pass for %s", TEST_2), TestStatus.PASS,
- finalTestResult2.getResultStatus());
- }
-
- public void testRetryCanSetDone() throws Exception {
- mReporter.invocationStarted(mContext);
- // Set mCanMarkDone directly (otherwise we must build result directory, write XML, and
- // perform actual retry)
- mReporter.mCanMarkDone = true;
- // Set up IInvocationResult with existing results from previous session
- IInvocationResult invocationResult = mReporter.getResult();
- IModuleResult moduleResult = invocationResult.getOrCreateModule(ID);
- moduleResult.initializeDone(false);
- ICaseResult caseResult = moduleResult.getOrCreateResult(CLASS);
- ITestResult testResult1 = caseResult.getOrCreateResult(METHOD_1);
- testResult1.setResultStatus(TestStatus.PASS);
- testResult1.setRetry(true);
- ITestResult testResult2 = caseResult.getOrCreateResult(METHOD_2);
- testResult2.setResultStatus(TestStatus.FAIL);
- testResult2.setStackTrace(STACK_TRACE);
- testResult2.setRetry(true);
-
- // Assume no additional filtering is applied to retry, and all tests for the module have
- // been collected. Thus, module "done" value should switch.
- mReporter.testRunStarted(ID, 1);
-
- TestDescription test2 = new TestDescription(CLASS, METHOD_2);
- mReporter.testStarted(test2);
- mReporter.testEnded(test2, new HashMap<String, Metric>());
-
- mReporter.testRunEnded(10, new HashMap<String, Metric>());
- mReporter.invocationEnded(10);
-
- // Verification that results have been overwritten.
- IInvocationResult result = mReporter.getResult();
- assertEquals("Expected 2 pass", 2, result.countResults(TestStatus.PASS));
- assertEquals("Expected 0 failures", 0, result.countResults(TestStatus.FAIL));
- List<IModuleResult> modules = result.getModules();
- assertEquals("Expected 1 module", 1, modules.size());
- IModuleResult module = modules.get(0);
- assertTrue("Module should be marked done", module.isDone());
- }
-
- public void testRetryCannotSetDone() throws Exception {
- mReporter.invocationStarted(mContext);
- // Set mCanMarkDone directly (otherwise we must build result directory, write XML, and
- // perform actual retry)
- mReporter.mCanMarkDone = false;
- // Set up IInvocationResult with existing results from previous session
- IInvocationResult invocationResult = mReporter.getResult();
- IModuleResult moduleResult = invocationResult.getOrCreateModule(ID);
- moduleResult.setDone(false);
- ICaseResult caseResult = moduleResult.getOrCreateResult(CLASS);
- ITestResult testResult1 = caseResult.getOrCreateResult(METHOD_1);
- testResult1.setResultStatus(TestStatus.PASS);
- testResult1.setRetry(true);
- ITestResult testResult2 = caseResult.getOrCreateResult(METHOD_2);
- testResult2.setResultStatus(TestStatus.FAIL);
- testResult2.setStackTrace(STACK_TRACE);
- testResult2.setRetry(true);
-
- // Since using retry-type failed option, we only run previously failed test
- // and don't run any non-executed tests, so module "done" value should not switch.
- mReporter.testRunStarted(ID, 1);
-
- TestDescription test2 = new TestDescription(CLASS, METHOD_2);
- mReporter.testStarted(test2);
- mReporter.testEnded(test2, new HashMap<String, Metric>());
-
- mReporter.testRunEnded(10, new HashMap<String, Metric>());
- mReporter.invocationEnded(10);
-
- // Verification that results have been overwritten.
- IInvocationResult result = mReporter.getResult();
- assertEquals("Expected 2 pass", 2, result.countResults(TestStatus.PASS));
- assertEquals("Expected 0 failures", 0, result.countResults(TestStatus.FAIL));
- List<IModuleResult> modules = result.getModules();
- assertEquals("Expected 1 module", 1, modules.size());
- IModuleResult module = modules.get(0);
- assertFalse("Module should not be marked done", module.isDone());
- }
-
- public void testResultReporting_moduleNotDone() throws Exception {
- mReporter.invocationStarted(mContext);
- mReporter.testRunStarted(ID, 2);
- TestDescription test1 = new TestDescription(CLASS, METHOD_1);
- mReporter.testStarted(test1);
- mReporter.testEnded(test1, new HashMap<String, Metric>());
- mReporter.testRunFailed("error");
- mReporter.testRunEnded(10, new HashMap<String, Metric>());
- mReporter.invocationEnded(10);
- IInvocationResult result = mReporter.getResult();
- assertEquals("Expected 1 pass", 1, result.countResults(TestStatus.PASS));
- assertEquals("Expected 0 failures", 0, result.countResults(TestStatus.FAIL));
- List<IModuleResult> modules = result.getModules();
- assertEquals("Expected 1 module", 1, modules.size());
- IModuleResult module = modules.get(0);
-
- // Ensure module is reported as not done
- assertFalse(module.isDone());
- assertEquals("Incorrect ID", ID, module.getId());
- List<ICaseResult> caseResults = module.getResults();
- assertEquals("Expected 1 test case", 1, caseResults.size());
- ICaseResult caseResult = caseResults.get(0);
- List<ITestResult> testResults = caseResult.getResults();
- assertEquals("Expected 1 tests", 1, testResults.size());
- ITestResult result1 = caseResult.getResult(METHOD_1);
- assertNotNull(String.format("Expected result for %s", TEST_1), result1);
- assertEquals(String.format("Expected pass for %s", TEST_1), TestStatus.PASS,
- result1.getResultStatus());
- }
-
- public void testResultReporting_moduleNotDone_noTests() throws Exception {
- mReporter.invocationStarted(mContext);
- mReporter.testRunStarted(ID, 0);
- mReporter.testRunFailed("error"); // test run failure should prevent marking module "done"
- mReporter.testRunEnded(10, new HashMap<String, String>());
- mReporter.invocationEnded(10);
- IInvocationResult result = mReporter.getResult();
- assertEquals("Expected 0 pass", 0, result.countResults(TestStatus.PASS));
- assertEquals("Expected 0 failures", 0, result.countResults(TestStatus.FAIL));
- List<IModuleResult> modules = result.getModules();
- assertEquals("Expected 1 module", 1, modules.size());
- IModuleResult module = modules.get(0);
- assertEquals("Incorrect ID", ID, module.getId());
- // Ensure module is reported as not done
- assertFalse(module.isDone());
- }
-
- public void testResultReporting_moduleDone_noTests() throws Exception {
- mReporter.invocationStarted(mContext);
- mReporter.testRunStarted(ID, 0);
- // Lack of test run failure should allow module to be marked "done"
- mReporter.testRunEnded(10, new HashMap<String, String>());
- mReporter.invocationEnded(10);
- IInvocationResult result = mReporter.getResult();
- assertEquals("Expected 0 pass", 0, result.countResults(TestStatus.PASS));
- assertEquals("Expected 0 failures", 0, result.countResults(TestStatus.FAIL));
- List<IModuleResult> modules = result.getModules();
- assertEquals("Expected 1 module", 1, modules.size());
- IModuleResult module = modules.get(0);
- assertEquals("Incorrect ID", ID, module.getId());
- // Ensure module is reported as done
- assertTrue(module.isDone());
- }
-
- public void testCopyFormattingFiles() throws Exception {
- File resultDir = new File(mBuildHelper.getResultsDir(), RESULT_DIR);
- resultDir.mkdirs();
- ResultReporter.copyFormattingFiles(resultDir, SUITE_NAME);
- for (String filename : FORMATTING_FILES) {
- File file = new File(resultDir, filename);
- assertTrue(String.format("%s (%s) was not created", filename, file.getAbsolutePath()),
- file.exists() && file.isFile() && file.length() > 0);
- }
- }
-
- /**
- * Ensure that when {@link ResultReporter#testLog(String, LogDataType, InputStreamSource)} is
- * called, a single invocation result folder is created and populated.
- */
- public void testTestLog() throws Exception {
- InputStreamSource fakeData = new ByteArrayInputStreamSource("test".getBytes());
- mReporter.invocationStarted(mContext);
- mReporter.testLog("test1", LogDataType.LOGCAT, fakeData);
- // date folder
- assertEquals(1, mBuildHelper.getLogsDir().list().length);
- // inv_ folder
- assertEquals(1, mBuildHelper.getLogsDir().listFiles()[0].list().length);
- // actual logs
- assertEquals(1, mBuildHelper.getLogsDir().listFiles()[0].listFiles()[0].list().length);
- mReporter.testLog("test2", LogDataType.LOGCAT, fakeData);
- // date folder
- assertEquals(1, mBuildHelper.getLogsDir().list().length);
- // inv_ folder
- assertEquals(1, mBuildHelper.getLogsDir().listFiles()[0].list().length);
- // actual logs
- assertEquals(2, mBuildHelper.getLogsDir().listFiles()[0].listFiles()[0].list().length);
- }
-
- /**
- * Ensure that when {@link ResultReporter#testLog(String, LogDataType, InputStreamSource)} is
- * called for host-side device info, a device info file is created in the result
- */
- public void testTestLogWithDeviceInfo() throws Exception {
- InputStreamSource fakeData = new ByteArrayInputStreamSource("test".getBytes());
- String deviceInfoName = String.format("Test%s", DeviceInfo.FILE_SUFFIX);
- mReporter.invocationStarted(mContext);
- mReporter.testLog(deviceInfoName, LogDataType.TEXT, fakeData);
- File deviceInfoFolder = new File(mBuildHelper.getResultDir(), DeviceInfo.RESULT_DIR_NAME);
- // assert device info folder was created
- assertTrue(deviceInfoFolder.exists());
- File[] deviceInfoFiles = deviceInfoFolder.listFiles();
- // assert that one file was written to the folder
- assertEquals(1, deviceInfoFiles.length);
- File deviceInfoFile = deviceInfoFiles[0];
- // assert device info file has been named correctly
- assertEquals(deviceInfoName, deviceInfoFile.getName());
- // assert contents of the file
- assertEquals("test", FileUtil.readStringFromFile(deviceInfoFile));
- }
-
- /** Ensure that the module is not marked done if any of the shard fails. */
- public void testResultReporter_sharded() throws Exception {
- ResultReporter shard1 = new ResultReporter(mReporter);
- ResultReporter shard2 = new ResultReporter(mReporter);
-
- mReporter.invocationStarted(mContext);
- shard1.invocationStarted(mContext);
- shard2.invocationStarted(mContext);
-
- // First shard is good
- shard1.testRunStarted(ID, 1);
- TestDescription test1 = new TestDescription(CLASS, METHOD_1);
- shard1.testStarted(test1);
- shard1.testEnded(test1, new HashMap<String, Metric>());
- shard1.testRunEnded(10, new HashMap<String, Metric>());
- shard1.invocationEnded(10);
- // Second shard failed
- shard2.testRunStarted(ID, 2);
- TestDescription test2 = new TestDescription(CLASS, METHOD_2);
- shard2.testStarted(test2);
- shard2.testEnded(test2, new HashMap<String, Metric>());
- shard2.testRunFailed("error");
- shard2.testRunEnded(10, new HashMap<String, Metric>());
- shard2.invocationEnded(10);
-
- IInvocationResult result = mReporter.getResult();
- assertEquals("Expected 2 pass", 2, result.countResults(TestStatus.PASS));
- assertEquals("Expected 0 failures", 0, result.countResults(TestStatus.FAIL));
- List<IModuleResult> modules = result.getModules();
- assertEquals("Expected 1 module", 1, modules.size());
- IModuleResult module = modules.get(0);
-
- // Ensure module is seen as not done and failed
- assertFalse(module.isDone());
- assertTrue(module.isFailed());
-
- assertEquals("Incorrect ID", ID, module.getId());
- List<ICaseResult> caseResults = module.getResults();
- assertEquals("Expected 1 test run", 1, caseResults.size());
- ICaseResult caseResult = caseResults.get(0);
- List<ITestResult> testResults = caseResult.getResults();
- assertEquals("Expected 2 test cases", 2, testResults.size());
- ITestResult result1 = caseResult.getResult(METHOD_1);
- assertNotNull(String.format("Expected result for %s", TEST_1), result1);
- assertEquals(
- String.format("Expected pass for %s", TEST_1),
- TestStatus.PASS,
- result1.getResultStatus());
- }
-
- /** Ensure that the run history of the current run is added to previous run history. */
- public void testRetryWithRunHistory() throws Exception {
- mReporter.invocationStarted(mContext);
-
- // Set up IInvocationResult with existing results from previous session
- mReporter.testRunStarted(ID, 2);
- IInvocationResult invocationResult = mReporter.getResult();
- IModuleResult moduleResult = invocationResult.getOrCreateModule(ID);
- ICaseResult caseResult = moduleResult.getOrCreateResult(CLASS);
- ITestResult testResult1 = caseResult.getOrCreateResult(METHOD_1);
- testResult1.setResultStatus(TestStatus.PASS);
- testResult1.setRetry(true);
- ITestResult testResult2 = caseResult.getOrCreateResult(METHOD_2);
- testResult2.setResultStatus(TestStatus.FAIL);
- testResult2.setStackTrace(STACK_TRACE);
- testResult2.setRetry(true);
- // Set up IInvocationResult with the run history of previous runs.
- invocationResult.addInvocationInfo(
- "run_history", "[{\"startTime\":1,\"endTime\":2},{\"startTime\":3,\"endTime\":4}]");
-
- // Flip results for the current session
- TestDescription test1 = new TestDescription(CLASS, METHOD_1);
- mReporter.testStarted(test1);
- mReporter.testFailed(test1, STACK_TRACE);
- mReporter.testEnded(test1, new HashMap<String, Metric>());
- TestDescription test2 = new TestDescription(CLASS, METHOD_2);
- mReporter.testStarted(test2);
- mReporter.testEnded(test2, new HashMap<String, Metric>());
-
- mReporter.testRunEnded(10, new HashMap<String, Metric>());
- mReporter.invocationEnded(10);
-
- // Verification that results have been overwritten.
- IInvocationResult result = mReporter.getResult();
- assertEquals("Expected 1 pass", 1, result.countResults(TestStatus.PASS));
- assertEquals("Expected 1 failure", 1, result.countResults(TestStatus.FAIL));
- List<IModuleResult> modules = result.getModules();
- assertEquals("Expected 1 module", 1, modules.size());
- IModuleResult module = modules.get(0);
- List<ICaseResult> cases = module.getResults();
- assertEquals("Expected 1 test case", 1, cases.size());
- ICaseResult case1 = cases.get(0);
- List<ITestResult> testResults = case1.getResults();
- assertEquals("Expected 2 tests", 2, testResults.size());
-
- long startTime = mReporter.getResult().getStartTime();
- String expectedRunHistory =
- String.format(
- "[{\"startTime\":1,\"endTime\":2},"
- + "{\"startTime\":3,\"endTime\":4},{\"startTime\":%d,\"endTime\":%d}]",
- startTime, startTime + 10);
- assertEquals(expectedRunHistory, invocationResult.getInvocationInfo().get("run_history"));
-
- // Test 1 details
- ITestResult finalTestResult1 = case1.getResult(METHOD_1);
- assertNotNull(String.format("Expected result for %s", TEST_1), finalTestResult1);
- assertEquals(
- String.format("Expected fail for %s", TEST_1),
- TestStatus.FAIL,
- finalTestResult1.getResultStatus());
- assertEquals(finalTestResult1.getStackTrace(), STACK_TRACE);
-
- // Test 2 details
- ITestResult finalTestResult2 = case1.getResult(METHOD_2);
- assertNotNull(String.format("Expected result for %s", TEST_2), finalTestResult2);
- assertEquals(
- String.format("Expected pass for %s", TEST_2),
- TestStatus.PASS,
- finalTestResult2.getResultStatus());
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusherTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusherTest.java
index 517ca34..9ca00eb 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusherTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusherTest.java
@@ -247,15 +247,25 @@
@Test
public void testSetUp() throws Exception {
final File[] localConfig = new File[1];
- mPreparer = new DynamicConfigPusher() {
- @Override
- File mergeConfigFiles(
- File localConfigFile, String apfeConfigInJson, String moduleName,
- ITestDevice device) throws TargetSetupError {
- localConfig[0] = localConfigFile;
- return super.mergeConfigFiles(localConfigFile,apfeConfigInJson,moduleName,device);
- }
- };
+ mPreparer =
+ new DynamicConfigPusher() {
+ @Override
+ File mergeConfigFiles(
+ File localConfigFile,
+ String apfeConfigInJson,
+ String moduleName,
+ ITestDevice device)
+ throws TargetSetupError {
+ localConfig[0] = localConfigFile;
+ return super.mergeConfigFiles(
+ localConfigFile, apfeConfigInJson, moduleName, device);
+ }
+
+ @Override
+ String resolveUrl(String suiteName) throws TargetSetupError {
+ return null;
+ }
+ };
OptionSetter setter = new OptionSetter(mPreparer);
setter.setOptionValue("config-filename", "moduleName");
setter.setOptionValue("extract-from-resource", "true");
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTestTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTestTest.java
deleted file mode 100644
index b04a4e3..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTestTest.java
+++ /dev/null
@@ -1,324 +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.compatibility.common.tradefed.testtype;
-
-import com.android.tradefed.config.OptionSetter;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.ITestLogger;
-import com.android.tradefed.result.ByteArrayInputStreamSource;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.InputStreamSource;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.suite.checker.ISystemStatusChecker;
-import com.android.tradefed.suite.checker.StatusCheckerResult;
-import com.android.tradefed.suite.checker.StatusCheckerResult.CheckStatus;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.util.AbiUtils;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Test class for {@link CompatibilityTest}
- */
-public class CompatibilityTestTest extends TestCase {
-
- private static final String FAKE_HOST_ARCH = "arm";
- private CompatibilityTest mTest;
- private ITestDevice mMockDevice;
- private ITestLogger mMockLogger;
- private ITestInvocationListener mMockListener;
-
- @Override
- public void setUp() throws Exception {
- mTest = new CompatibilityTest() {
- @Override
- protected Set<String> getAbisForBuildTargetArch() {
- return AbiUtils.getAbisForArch(FAKE_HOST_ARCH);
- }
- };
- mMockDevice = EasyMock.createMock(ITestDevice.class);
- mTest.setDevice(mMockDevice);
- mMockLogger = EasyMock.createMock(ITestLogger.class);
- mMockListener = EasyMock.createMock(ITestInvocationListener.class);
- }
-
- /**
- * Test that {@link CompatibilityTest#getAbis()} is returning a proper intersection of CTS
- * supported architectures and Device supported architectures.
- */
- public void testGetAbis() throws DeviceNotAvailableException {
- EasyMock.expect(mMockDevice.getProperty(EasyMock.eq("ro.product.cpu.abilist")))
- .andReturn("arm64-v8a,armeabi-v7a,armeabi");
- Set<String> expectedAbis = new HashSet<>();
- expectedAbis.add("arm64-v8a");
- expectedAbis.add("armeabi-v7a");
- EasyMock.replay(mMockDevice);
- Set<IAbi> res = mTest.getAbis();
- assertEquals(2, res.size());
- for (IAbi abi : res) {
- assertTrue(expectedAbis.contains(abi.getName()));
- }
- EasyMock.verify(mMockDevice);
- }
-
- /**
- * Test that {@link CompatibilityTest#getAbis()} is throwing an exception when none of the
- * CTS build supported abi match the device abi.
- */
- public void testGetAbis_notSupported() throws DeviceNotAvailableException {
- EasyMock.expect(mMockDevice.getProperty(EasyMock.eq("ro.product.cpu.abilist")))
- .andReturn("armeabi");
- EasyMock.replay(mMockDevice);
- try {
- mTest.getAbis();
- fail("Should have thrown an exception");
- } catch (IllegalArgumentException e) {
- assertEquals("None of the abi supported by this CTS build ('[armeabi-v7a, arm64-v8a]')"
- + " are supported by the device ('[armeabi]').", e.getMessage());
- }
- EasyMock.verify(mMockDevice);
- }
-
- /**
- * Test that {@link CompatibilityTest#getAbis()} is returning only the device primary abi.
- */
- public void testGetAbis_primaryAbiOnly() throws Exception {
- OptionSetter setter = new OptionSetter(mTest);
- setter.setOptionValue(CompatibilityTest.PRIMARY_ABI_RUN, "true");
- EasyMock.expect(mMockDevice.getProperty(EasyMock.eq("ro.product.cpu.abi")))
- .andReturn("arm64-v8a");
- Set<String> expectedAbis = new HashSet<>();
- expectedAbis.add("arm64-v8a");
- EasyMock.replay(mMockDevice);
- Set<IAbi> res = mTest.getAbis();
- assertEquals(1, res.size());
- for (IAbi abi : res) {
- assertTrue(expectedAbis.contains(abi.getName()));
- }
- EasyMock.verify(mMockDevice);
- }
-
- /**
- * Test that {@link CompatibilityTest#getAbis()} is throwing an exception if the primary
- * abi is not supported.
- */
- public void testGetAbis_primaryAbiOnly_NotSupported() throws Exception {
- OptionSetter setter = new OptionSetter(mTest);
- setter.setOptionValue(CompatibilityTest.PRIMARY_ABI_RUN, "true");
- EasyMock.expect(mMockDevice.getProperty(EasyMock.eq("ro.product.cpu.abi")))
- .andReturn("armeabi");
- EasyMock.replay(mMockDevice);
- try {
- mTest.getAbis();
- fail("Should have thrown an exception");
- } catch (IllegalArgumentException e) {
- assertEquals("Your CTS hasn't been built with abi 'armeabi' support, "
- + "this CTS currently supports '[armeabi-v7a, arm64-v8a]'.", e.getMessage());
- }
- EasyMock.verify(mMockDevice);
- }
-
- /**
- * Test that {@link CompatibilityTest#getAbis()} is returning the list of abi supported by
- * Compatibility and the device, and not the particular CTS build.
- */
- public void testGetAbis_skipCtsArchCheck() throws Exception {
- OptionSetter setter = new OptionSetter(mTest);
- setter.setOptionValue(CompatibilityTest.SKIP_HOST_ARCH_CHECK, "true");
- EasyMock.expect(mMockDevice.getProperty(EasyMock.eq("ro.product.cpu.abilist")))
- .andReturn("x86_64,x86,armeabi");
- Set<String> expectedAbis = new HashSet<>();
- expectedAbis.add("x86_64");
- expectedAbis.add("x86");
- EasyMock.replay(mMockDevice);
- Set<IAbi> res = mTest.getAbis();
- assertEquals(2, res.size());
- for (IAbi abi : res) {
- assertTrue(expectedAbis.contains(abi.getName()));
- }
- EasyMock.verify(mMockDevice);
- }
-
- /**
- * Test {@link CompatibilityTest#getAbis()} when we skip the Cts side architecture check and
- * want to run x86 abi.
- */
- public void testGetAbis_skipCtsArchCheck_abiSpecified() throws Exception {
- OptionSetter setter = new OptionSetter(mTest);
- setter.setOptionValue(CompatibilityTest.SKIP_HOST_ARCH_CHECK, "true");
- setter.setOptionValue(CompatibilityTest.ABI_OPTION, "x86");
- Set<String> expectedAbis = new HashSet<>();
- expectedAbis.add("x86");
- EasyMock.replay(mMockDevice);
- Set<IAbi> res = mTest.getAbis();
- assertEquals(1, res.size());
- for (IAbi abi : res) {
- assertTrue(expectedAbis.contains(abi.getName()));
- }
- EasyMock.verify(mMockDevice);
- }
-
- /**
- * Test {@link CompatibilityTest#split()} when a shard number is specified.
- */
- public void testSplit() throws Exception {
- OptionSetter setter = new OptionSetter(mTest);
- setter.setOptionValue("shards", "4");
- assertEquals(4, mTest.split().size());
- }
-
- /**
- * Test {@link CompatibilityTest#split()} when no shard number is specified.
- */
- public void testSplit_notShardable() throws Exception {
- assertNull(mTest.split());
- }
-
- /**
- * Test {@link CompatibilityTest#runPreModuleCheck(String, List, ITestDevice, ITestLogger)}
- * is successful when no system checker fails.
- */
- public void testRunPreModuleCheck() throws Exception {
- List<ISystemStatusChecker> systemCheckers = new ArrayList<>();
- // add 2 inop status checkers.
- systemCheckers.add(new ISystemStatusChecker() {});
- systemCheckers.add(new ISystemStatusChecker() {});
- EasyMock.replay(mMockDevice, mMockLogger);
- mTest.runPreModuleCheck("FAKE_MODULE", systemCheckers, mMockDevice, mMockLogger);
- EasyMock.verify(mMockDevice, mMockLogger);
- }
-
- /**
- * Test {@link CompatibilityTest#runPreModuleCheck(String, List, ITestDevice, ITestLogger)}
- * is failing and log the failure.
- */
- public void testRunPreModuleCheck_failure() throws Exception {
- List<ISystemStatusChecker> systemCheckers = new ArrayList<>();
- // add 2 inop status checkers.
- systemCheckers.add(new ISystemStatusChecker() {});
- systemCheckers.add(new ISystemStatusChecker() {
- @Override
- public StatusCheckerResult preExecutionCheck(ITestDevice device) {
- // fails
- return new StatusCheckerResult(CheckStatus.FAILED);
- }
- });
- InputStreamSource res = new ByteArrayInputStreamSource("fake bugreport".getBytes());
- EasyMock.expect(mMockDevice.getBugreport()).andReturn(res);
- mMockLogger.testLog(EasyMock.eq("bugreport-checker-pre-module-FAKE_MODULE"),
- EasyMock.eq(LogDataType.BUGREPORT),
- EasyMock.same(res));
- EasyMock.replay(mMockDevice, mMockLogger);
- mTest.runPreModuleCheck("FAKE_MODULE", systemCheckers, mMockDevice, mMockLogger);
- EasyMock.verify(mMockDevice, mMockLogger);
- }
-
- /**
- * Test {@link CompatibilityTest#runPostModuleCheck(String, List, ITestDevice, ITestLogger)}
- * is successful when no system checker fails.
- */
- public void testRunPostModuleCheck() throws Exception {
- List<ISystemStatusChecker> systemCheckers = new ArrayList<>();
- // add 2 inop status checkers.
- systemCheckers.add(new ISystemStatusChecker() {});
- systemCheckers.add(new ISystemStatusChecker() {});
- EasyMock.replay(mMockDevice, mMockLogger);
- mTest.runPostModuleCheck("FAKE_MODULE", systemCheckers, mMockDevice, mMockLogger);
- EasyMock.verify(mMockDevice, mMockLogger);
- }
-
- /**
- * Test {@link CompatibilityTest#runPreModuleCheck(String, List, ITestDevice, ITestLogger)}
- * is failing and log the failure.
- */
- public void testRunPostModuleCheck_failure() throws Exception {
- List<ISystemStatusChecker> systemCheckers = new ArrayList<>();
- // add 2 inop status checkers.
- systemCheckers.add(new ISystemStatusChecker() {});
- systemCheckers.add(new ISystemStatusChecker() {
- @Override
- public StatusCheckerResult postExecutionCheck(ITestDevice device) {
- // fails
- return new StatusCheckerResult(CheckStatus.FAILED);
- }
- });
- InputStreamSource res = new ByteArrayInputStreamSource("fake bugreport".getBytes());
- EasyMock.expect(mMockDevice.getBugreport()).andReturn(res);
- mMockLogger.testLog(EasyMock.eq("bugreport-checker-post-module-FAKE_MODULE"),
- EasyMock.eq(LogDataType.BUGREPORT),
- EasyMock.same(res));
- EasyMock.replay(mMockDevice, mMockLogger);
- mTest.runPostModuleCheck("FAKE_MODULE", systemCheckers, mMockDevice, mMockLogger);
- EasyMock.verify(mMockDevice, mMockLogger);
- }
-
- /**
- * Test {@link CompatibilityTest#run(ITestInvocationListener)} returns with no further
- * execution when there is no module to run.
- */
- public void testRun_noModules() throws Exception {
- mTest = new CompatibilityTest(1, new ModuleRepo() {
- @Override
- public boolean isInitialized() {
- return true;
- }
- @Override
- public LinkedList<IModuleDef> getModules(String serial, int shardIndex) {
- return new LinkedList<IModuleDef>();
- }
- }, 0);
- mTest.setDevice(mMockDevice);
- EasyMock.expect(mMockDevice.getSerialNumber()).andReturn("FAKE_SERIAL").times(2);
- EasyMock.replay(mMockDevice, mMockListener);
- mTest.run(mMockListener);
- EasyMock.verify(mMockDevice, mMockListener);
- }
-
- /**
- * Test {@link CompatibilityTest#checkSystemStatusBlackAndWhiteList()} correctly throws
- * if a system status is invalid.
- */
- public void testCheckSystemStatus_throw() throws Exception {
- OptionSetter setter = new OptionSetter(mTest);
- setter.setOptionValue("system-status-check-whitelist", "com.does.not.exit");
- try {
- mTest.checkSystemStatusBlackAndWhiteList();
- fail("should have thrown an exception");
- } catch (RuntimeException expected) {
- // expected.
- }
- }
-
- /**
- * Test {@link CompatibilityTest#checkSystemStatusBlackAndWhiteList()} does not throw
- * if a system status is valid.
- */
- public void testCheckSystemStatus_pass() throws Exception {
- OptionSetter setter = new OptionSetter(mTest);
- setter.setOptionValue("skip-system-status-check",
- "com.android.tradefed.suite.checker.KeyguardStatusChecker");
- mTest.checkSystemStatusBlackAndWhiteList();
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/JarHostTestTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/JarHostTestTest.java
deleted file mode 100644
index 66cef91..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/JarHostTestTest.java
+++ /dev/null
@@ -1,245 +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.compatibility.common.tradefed.testtype;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.android.tradefed.build.DeviceBuildInfo;
-import com.android.tradefed.config.OptionSetter;
-import com.android.tradefed.invoker.ExecutionFiles.FilesKey;
-import com.android.tradefed.invoker.TestInformation;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.TestDescription;
-import com.android.tradefed.testtype.DeviceJUnit4ClassRunner.TestMetrics;
-import com.android.tradefed.testtype.HostTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.util.FileUtil;
-import com.android.tradefed.util.proto.TfMetricProtoUtil;
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Unit tests for {@link JarHostTest}.
- */
-@RunWith(JUnit4.class)
-public class JarHostTestTest {
-
- private static final String TEST_JAR1 = "/testtype/testJar1.jar";
- private JarHostTest mTest;
- private DeviceBuildInfo mStubBuildInfo;
- private TestInformation mTestInfo;
- private File mTestDir = null;
- private ITestInvocationListener mListener;
-
- /**
- * More testable version of {@link JarHostTest}
- */
- public static class JarHostTestable extends JarHostTest {
-
- public static File mTestDir;
- public JarHostTestable() {}
-
- public JarHostTestable(File testDir) {
- mTestDir = testDir;
- }
- }
-
- @Before
- public void setUp() throws Exception {
- mTest = new JarHostTest();
- mTestDir = FileUtil.createTempDir("jarhostest");
- mListener = EasyMock.createMock(ITestInvocationListener.class);
- OptionSetter setter = new OptionSetter(mTest);
- setter.setOptionValue("enable-pretty-logs", "false");
- mStubBuildInfo = new DeviceBuildInfo();
- mStubBuildInfo.setTestsDir(mTestDir, "v1");
- mTestInfo = TestInformation.newBuilder().build();
- mTestInfo.executionFiles().put(FilesKey.TESTS_DIRECTORY, mTestDir);
- }
-
- @After
- public void tearDown() throws Exception {
- FileUtil.recursiveDelete(mTestDir);
- }
-
- /**
- * Helper to read a file from the res/testtype directory and return it.
- *
- * @param filename the name of the file in the res/testtype directory
- * @param parentDir dir where to put the jar. Null if in default tmp directory.
- * @return the extracted jar file.
- */
- protected File getJarResource(String filename, File parentDir) throws IOException {
- InputStream jarFileStream = getClass().getResourceAsStream(filename);
- File jarFile = FileUtil.createTempFile("test", ".jar", parentDir);
- FileUtil.writeToFile(jarFileStream, jarFile);
- return jarFile;
- }
-
- /**
- * Test class, we have to annotate with full org.junit.Test to avoid name collision in import.
- */
- @RunWith(JUnit4.class)
- public static class Junit4TestClass {
- public Junit4TestClass() {}
- @org.junit.Test
- public void testPass1() {}
- }
-
- /**
- * Test class, we have to annotate with full org.junit.Test to avoid name collision in import.
- */
- @RunWith(JUnit4.class)
- public static class Junit4TestClass2 {
- public Junit4TestClass2() {}
- @Rule public TestMetrics metrics = new TestMetrics();
-
- @org.junit.Test
- public void testPass2() {
- metrics.addTestMetric("key", "value");
- }
- }
-
- /**
- * Test that {@link JarHostTest#split()} inherited from {@link HostTest} is still good.
- */
- @Test
- public void testSplit_withoutJar() throws Exception {
- OptionSetter setter = new OptionSetter(mTest);
- setter.setOptionValue("class", "com.android.compatibility.common.tradefed.testtype."
- + "JarHostTestTest$Junit4TestClass");
- setter.setOptionValue("class", "com.android.compatibility.common.tradefed.testtype."
- + "JarHostTestTest$Junit4TestClass2");
- // sharCount is ignored; will split by number of classes
- List<IRemoteTest> res = (List<IRemoteTest>) mTest.split(1, mTestInfo);
- assertEquals(2, res.size());
- assertTrue(res.get(0) instanceof JarHostTest);
- assertTrue(res.get(1) instanceof JarHostTest);
- }
-
- /**
- * Test that {@link JarHostTest#split()} can split classes coming from a jar.
- */
- @Test
- public void testSplit_withJar() throws Exception {
- File testJar = getJarResource(TEST_JAR1, mTestDir);
- mTest = new JarHostTestable(mTestDir);
- mTest.setBuild(mStubBuildInfo);
- OptionSetter setter = new OptionSetter(mTest);
- setter.setOptionValue("enable-pretty-logs", "false");
- setter.setOptionValue("jar", testJar.getName());
- // sharCount is ignored; will split by number of classes
- List<IRemoteTest> res = (List<IRemoteTest>) mTest.split(1, mTestInfo);
- assertEquals(2, res.size());
- assertTrue(res.get(0) instanceof JarHostTest);
- assertEquals("[android.ui.cts.TaskSwitchingTest]",
- ((JarHostTest)res.get(0)).getClassNames().toString());
- assertTrue(res.get(1) instanceof JarHostTest);
- assertEquals("[android.ui.cts.InstallTimeTest]",
- ((JarHostTest)res.get(1)).getClassNames().toString());
- }
-
- /**
- * Testable version of {@link JarHostTest} that allows adding jar to classpath for testing
- * purpose.
- */
- public static class JarHostTestLoader extends JarHostTestable {
-
- private static File mTestJar;
-
- public JarHostTestLoader() {}
-
- public JarHostTestLoader(File testDir, File jar) {
- super(testDir);
- mTestJar = jar;
- }
-
- @Override
- protected ClassLoader getClassLoader() {
- ClassLoader child = super.getClassLoader();
- try {
- child = new URLClassLoader(Arrays.asList(mTestJar.toURI().toURL())
- .toArray(new URL[]{}), super.getClassLoader());
- } catch (MalformedURLException e) {
- CLog.e(e);
- }
- return child;
- }
- }
-
- /**
- * If a jar file is not found, the countTest will fail but we still want to report a
- * testRunStart and End pair for results.
- */
- @Test
- public void testCountTestFails() throws Exception {
- OptionSetter setter = new OptionSetter(mTest);
- setter.setOptionValue("jar", "thisjardoesnotexistatall.jar");
- mListener.testRunStarted(EasyMock.anyObject(), EasyMock.eq(0));
- mListener.testRunEnded(EasyMock.anyLong(), EasyMock.<HashMap<String, Metric>>anyObject());
- EasyMock.replay(mListener);
- try {
- mTest.run(mTestInfo, mListener);
- fail("Should have thrown an exception.");
- } catch(RuntimeException expected) {
- // expected
- }
- EasyMock.verify(mListener);
- }
-
- /**
- * Test that metrics from tests in JarHost are reported and accounted for.
- */
- @Test
- public void testJarHostMetrics() throws Exception {
- OptionSetter setter = new OptionSetter(mTest);
- setter.setOptionValue("class", "com.android.compatibility.common.tradefed.testtype."
- + "JarHostTestTest$Junit4TestClass2");
- mListener.testRunStarted(EasyMock.anyObject(), EasyMock.eq(1));
- TestDescription tid = new TestDescription("com.android.compatibility.common.tradefed."
- + "testtype.JarHostTestTest$Junit4TestClass2", "testPass2");
- mListener.testStarted(EasyMock.eq(tid), EasyMock.anyLong());
- Map<String, String> metrics = new HashMap<>();
- metrics.put("key", "value");
- mListener.testEnded(EasyMock.eq(tid), EasyMock.anyLong(),
- EasyMock.eq(TfMetricProtoUtil.upgradeConvert(metrics)));
- mListener.testRunEnded(EasyMock.anyLong(), EasyMock.<HashMap<String, Metric>>anyObject());
- EasyMock.replay(mListener);
- mTest.run(mTestInfo, mListener);
- EasyMock.verify(mListener);
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleDefTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleDefTest.java
deleted file mode 100644
index d3cbaa2..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleDefTest.java
+++ /dev/null
@@ -1,146 +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.compatibility.common.tradefed.testtype;
-
-import com.android.tradefed.config.ConfigurationDescriptor;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.testtype.Abi;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IAbiReceiver;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.IRuntimeHintProvider;
-import com.android.tradefed.testtype.ITestCollector;
-import com.android.tradefed.testtype.ITestFilterReceiver;
-import com.android.tradefed.util.AbiUtils;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class ModuleDefTest extends TestCase {
-
- private static final String NAME = "ModuleName";
- private static final String ABI = "mips64";
- private static final String ID = AbiUtils.createId(ABI, NAME);
-
- public void testAccessors() throws Exception {
- IAbi abi = new Abi(ABI, "");
- MockRemoteTest mockTest = new MockRemoteTest();
- IModuleDef def = new ModuleDef(NAME, abi, mockTest, new ArrayList<ITargetPreparer>(),
- new ConfigurationDescriptor());
- assertEquals("Incorrect ID", ID, def.getId());
- assertEquals("Incorrect ABI", ABI, def.getAbi().getName());
- assertEquals("Incorrect Name", NAME, def.getName());
- }
-
- public void testModuleFinisher() throws Exception {
- IAbi abi = new Abi(ABI, "");
- MockRemoteTest mockTest = new MockRemoteTest();
- IModuleDef def = new ModuleDef(NAME, abi, mockTest,
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor());
- ITestInvocationListener mockListener = EasyMock.createMock(ITestInvocationListener.class);
- // listener should receive testRunStarted/testRunEnded events even for no-op run() method
- mockListener.testRunStarted(ID, 0);
- EasyMock.expectLastCall().once();
- mockListener.testRunEnded(0, new HashMap<String, Metric>());
- EasyMock.expectLastCall().once();
- EasyMock.replay(mockListener);
- def.run(mockListener);
- EasyMock.verify(mockListener);
- }
-
- private class MockRemoteTest implements IRemoteTest, ITestFilterReceiver, IAbiReceiver,
- IRuntimeHintProvider, ITestCollector {
-
- private final List<String> mIncludeFilters = new ArrayList<>();
- private final List<String> mExcludeFilters = new ArrayList<>();
-
- @Override
- public void addIncludeFilter(String filter) {
- mIncludeFilters.add(filter);
- }
-
- @Override
- public void addAllIncludeFilters(Set<String> filters) {
- mIncludeFilters.addAll(filters);
- }
-
- @Override
- public void clearIncludeFilters() {
- mIncludeFilters.clear();
- }
-
- @Override
- public Set<String> getIncludeFilters() {
- return new HashSet<>(mIncludeFilters);
- }
-
- @Override
- public void addExcludeFilter(String filter) {
- mExcludeFilters.add(filter);
- }
-
- @Override
- public void addAllExcludeFilters(Set<String> filters) {
- mExcludeFilters.addAll(filters);
- }
-
- @Override
- public void clearExcludeFilters() {
- mExcludeFilters.clear();
- }
-
- @Override
- public Set<String> getExcludeFilters() {
- return new HashSet<>(mExcludeFilters);
- }
-
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- // Do nothing
- }
-
- @Override
- public void setAbi(IAbi abi) {
- // Do nothing
- }
-
- @Override
- public IAbi getAbi() {
- return null;
- }
-
- @Override
- public long getRuntimeHint() {
- return 1L;
- }
-
- @Override
- public void setCollectTestsOnly(boolean shouldCollectTest) {
- // Do nothing
- }
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleRepoTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleRepoTest.java
deleted file mode 100644
index 9e9c540..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleRepoTest.java
+++ /dev/null
@@ -1,806 +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.compatibility.common.tradefed.testtype;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.compatibility.common.tradefed.testtype.ModuleRepo.ConfigFilter;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Configuration;
-import com.android.tradefed.config.ConfigurationDescriptor;
-import com.android.tradefed.config.IConfiguration;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.testtype.Abi;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IAbiReceiver;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.IRuntimeHintProvider;
-import com.android.tradefed.testtype.ITestCollector;
-import com.android.tradefed.testtype.ITestFilterReceiver;
-import com.android.tradefed.util.AbiUtils;
-import com.android.tradefed.util.FileUtil;
-import com.android.tradefed.util.MultiMap;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Unit Tests for {@link ModuleRepo}
- */
-public class ModuleRepoTest extends TestCase {
-
- private static final String TOKEN =
- "<target_preparer class=\"com.android.compatibility.common.tradefed.targetprep.TokenRequirement\">\n"
- + "<option name=\"token\" value=\"%s\" />\n"
- + "</target_preparer>\n";
- private static final String CONFIG =
- "<configuration description=\"Auto Generated File\">\n" +
- "%s" +
- "<test class=\"com.android.compatibility.common.tradefed.testtype.%s\">\n" +
- "<option name=\"module\" value=\"%s\" />" +
- "</test>\n" +
- "</configuration>";
- private static final String FOOBAR_TOKEN = "foobar";
- private static final String SERIAL1 = "abc";
- private static final String SERIAL2 = "def";
- private static final String SERIAL3 = "ghi";
- private static final Set<String> SERIALS = new HashSet<>();
- private static final Set<IAbi> ABIS = new LinkedHashSet<>();
- private static final List<String> DEVICE_TOKENS = new ArrayList<>();
- private static final List<String> TEST_ARGS= new ArrayList<>();
- private static final List<String> MODULE_ARGS = new ArrayList<>();
- private static final Set<String> INCLUDES = new HashSet<>();
- private static final Set<String> EXCLUDES = new HashSet<>();
- private static final MultiMap<String, String> METADATA_INCLUDES = new MultiMap<>();
- private static final MultiMap<String, String> METADATA_EXCLUDES = new MultiMap<>();
- private static final Set<String> FILES = new HashSet<>();
- private static final String FILENAME = "%s.config";
- private static final String ROOT_DIR_ATTR = "ROOT_DIR";
- private static final String SUITE_NAME_ATTR = "SUITE_NAME";
- private static final String START_TIME_MS_ATTR = "START_TIME_MS";
- private static final String ABI_32 = "armeabi-v7a";
- private static final String ABI_64 = "arm64-v8a";
- private static final String MODULE_NAME_A = "FooModuleA";
- private static final String MODULE_NAME_B = "FooModuleB";
- private static final String MODULE_NAME_C = "FooModuleC";
- private static final String NON_EXISTS_MODULE_NAME = "NonExistModule";
- private static final String ID_A_32 = AbiUtils.createId(ABI_32, MODULE_NAME_A);
- private static final String ID_A_64 = AbiUtils.createId(ABI_64, MODULE_NAME_A);
- private static final String ID_B_32 = AbiUtils.createId(ABI_32, MODULE_NAME_B);
- private static final String ID_B_64 = AbiUtils.createId(ABI_64, MODULE_NAME_B);
- private static final String ID_C_32 = AbiUtils.createId(ABI_32, MODULE_NAME_C);
- private static final String ID_C_64 = AbiUtils.createId(ABI_64, MODULE_NAME_C);
- private static final String TEST_ARG = TestStub.class.getName() + ":foo:bar";
- private static final String MODULE_ARG = "%s:blah:foobar";
- private static final String TEST_STUB = "TestStub"; // Trivial test stub
- private static final String SHARDABLE_TEST_STUB = "ShardableTestStub"; // Shardable and IBuildReceiver
- private static final String [] EXPECTED_MODULE_IDS = new String[] {
- "arm64-v8a FooModuleB",
- "arm64-v8a FooModuleC",
- "armeabi-v7a FooModuleA",
- "arm64-v8a FooModuleA",
- "armeabi-v7a FooModuleC",
- "armeabi-v7a FooModuleB"
- };
-
- static {
- SERIALS.add(SERIAL1);
- SERIALS.add(SERIAL2);
- SERIALS.add(SERIAL3);
- ABIS.add(new Abi(ABI_32, "32"));
- ABIS.add(new Abi(ABI_64, "64"));
- DEVICE_TOKENS.add(String.format("%s:%s", SERIAL3, FOOBAR_TOKEN));
- TEST_ARGS.add(TEST_ARG);
- MODULE_ARGS.add(String.format(MODULE_ARG, MODULE_NAME_A));
- MODULE_ARGS.add(String.format(MODULE_ARG, MODULE_NAME_B));
- MODULE_ARGS.add(String.format(MODULE_ARG, MODULE_NAME_C));
- FILES.add(String.format(FILENAME, MODULE_NAME_A));
- FILES.add(String.format(FILENAME, MODULE_NAME_B));
- FILES.add(String.format(FILENAME, MODULE_NAME_C));
- }
- private ModuleRepo mRepo;
- private File mTestsDir;
- private File mRootDir;
- private IBuildInfo mMockBuildInfo;
-
- @Override
- public void setUp() throws Exception {
- mTestsDir = setUpConfigs();
- mRepo = new ModuleRepo();
- mMockBuildInfo = EasyMock.createMock(IBuildInfo.class);
- // Flesh out the result directory structure so ModuleRepo can write to the test runs file
- mRootDir = FileUtil.createTempDir("root");
- File subRootDir = new File(mRootDir, String.format("android-suite"));
- File resultsDir = new File(subRootDir, "results");
- File resultDir = new File(resultsDir, CompatibilityBuildHelper.getDirSuffix(0));
- resultDir.mkdirs();
-
- Map<String, String> mockBuildInfoMap = new HashMap<String, String>();
- mockBuildInfoMap.put(ROOT_DIR_ATTR, mRootDir.getAbsolutePath());
- mockBuildInfoMap.put(SUITE_NAME_ATTR, "suite");
- mockBuildInfoMap.put(START_TIME_MS_ATTR, Long.toString(0));
- EasyMock.expect(mMockBuildInfo.getBuildAttributes()).andReturn(mockBuildInfoMap).anyTimes();
- EasyMock.replay(mMockBuildInfo);
- }
-
- private File setUpConfigs() throws IOException {
- File testsDir = FileUtil.createTempDir("testcases");
- createConfig(testsDir, MODULE_NAME_A, null);
- createConfig(testsDir, MODULE_NAME_B, null);
- createConfig(testsDir, MODULE_NAME_C, FOOBAR_TOKEN);
- return testsDir;
- }
-
- private void createConfig(File testsDir, String name, String token) throws IOException {
- createConfig(testsDir, name, token, TEST_STUB);
- }
-
- private void createConfig(File testsDir, String name, String token, String moduleClass)
- throws IOException {
- File config = new File(testsDir, String.format(FILENAME, name));
- if (!config.createNewFile()) {
- throw new IOException(String.format("Failed to create '%s'", config.getAbsolutePath()));
- }
- String preparer = "";
- if (token != null) {
- preparer = String.format(TOKEN, token);
- }
- FileUtil.writeToFile(String.format(CONFIG, preparer, moduleClass, name), config);
- }
-
- @Override
- public void tearDown() throws Exception {
- FileUtil.recursiveDelete(mTestsDir);
- tearDownConfigs(mTestsDir);
- tearDownConfigs(mRootDir);
- }
-
- private void tearDownConfigs(File testsDir) {
- FileUtil.recursiveDelete(testsDir);
- }
-
- public void testInitialization() throws Exception {
- mRepo.initialize(3, null, mTestsDir, ABIS, DEVICE_TOKENS, TEST_ARGS, MODULE_ARGS, INCLUDES,
- EXCLUDES, METADATA_INCLUDES, METADATA_EXCLUDES, mMockBuildInfo);
- assertTrue("Should be initialized", mRepo.isInitialized());
- assertEquals("Wrong number of shards", 3, mRepo.getNumberOfShards());
- Map<String, Set<String>> deviceTokens = mRepo.getDeviceTokens();
- assertEquals("Wrong number of devices with tokens", 1, deviceTokens.size());
- Set<String> tokens = deviceTokens.get(SERIAL3);
- assertEquals("Wrong number of tokens", 1, tokens.size());
- assertTrue("Unexpected device token", tokens.contains(FOOBAR_TOKEN));
- assertEquals("Wrong number of modules", 4, mRepo.getNonTokenModules().size());
- List<IModuleDef> tokenModules = mRepo.getTokenModules();
- assertEquals("Wrong number of modules with tokens", 2, tokenModules.size());
- }
-
- public void testGetModules() throws Exception {
- mRepo.initialize(1, null, mTestsDir, ABIS, DEVICE_TOKENS, TEST_ARGS, MODULE_ARGS, INCLUDES,
- EXCLUDES, METADATA_INCLUDES, METADATA_EXCLUDES, mMockBuildInfo);
- assertTrue("Should be initialized", mRepo.isInitialized());
- assertEquals("Wrong number of tokens", 2, mRepo.getTokenModules().size());
- assertEquals("Wrong number of tokens", 4, mRepo.getNonTokenModules().size());
- }
-
- /**
- * Test sharding with 2 shards of the 4 non token modules.
- */
- public void testGetModulesSharded() throws Exception {
- mRepo.initialize(2, null, mTestsDir, ABIS, new ArrayList<String>(), TEST_ARGS, MODULE_ARGS,
- INCLUDES, EXCLUDES, METADATA_INCLUDES, METADATA_EXCLUDES, mMockBuildInfo);
- assertTrue("Should be initialized", mRepo.isInitialized());
- assertEquals("Wrong number of tokens", 2, mRepo.getTokenModules().size());
- assertEquals("Wrong number of tokens", 4, mRepo.getNonTokenModules().size());
- List<IModuleDef> shard1 = mRepo.getModules(SERIAL1, 0);
- assertEquals(2, shard1.size());
- assertEquals("armeabi-v7a FooModuleA", shard1.get(0).getId());
- assertEquals("arm64-v8a FooModuleA", shard1.get(1).getId());
- List<IModuleDef> shard2 = mRepo.getModules(SERIAL2, 1);
- // last shard gets the token modules too
- assertEquals(4, shard2.size());
- assertEquals("armeabi-v7a FooModuleB", shard2.get(0).getId());
- assertEquals("arm64-v8a FooModuleB", shard2.get(1).getId());
- }
-
- /**
- * Test running with only token modules.
- */
- public void testGetModules_onlyTokenModules() throws Exception {
- Set<String> includes = new HashSet<>();
- includes.add(MODULE_NAME_C);
- mRepo.initialize(1, null, mTestsDir, ABIS, new ArrayList<String>(), TEST_ARGS, MODULE_ARGS,
- includes, EXCLUDES, METADATA_INCLUDES, METADATA_EXCLUDES, mMockBuildInfo);
- assertTrue("Should be initialized", mRepo.isInitialized());
- assertEquals("Wrong number of tokens", 2, mRepo.getTokenModules().size());
- assertEquals("Wrong number of tokens", 0, mRepo.getNonTokenModules().size());
- List<IModuleDef> modules = mRepo.getModules(SERIAL1, 0);
- assertNotNull(modules);
- assertEquals(2, modules.size());
- }
-
- /**
- * Test running with only token modules, with sharded local run, we specify a token module
- * for each device, tests should go in the right place.
- */
- public void testGetModules_TokenModules_multiDevices() throws Exception {
- createConfig(mTestsDir, "FooModuleD", "foobar2");
- Set<String> includes = new HashSet<>();
- includes.add(MODULE_NAME_C);
- includes.add("FooModuleD");
- List<String> tokens = new ArrayList<>();
- tokens.add(String.format("%s:%s", SERIAL1, FOOBAR_TOKEN));
- tokens.add(String.format("%s:%s", SERIAL2, "foobar2"));
- mRepo.initialize(2, null, mTestsDir, ABIS, tokens, TEST_ARGS, MODULE_ARGS,
- includes, EXCLUDES, METADATA_INCLUDES, METADATA_EXCLUDES, mMockBuildInfo);
- assertTrue("Should be initialized", mRepo.isInitialized());
- assertEquals("Wrong number of tokens", 4, mRepo.getTokenModules().size());
- assertEquals("Wrong number of tokens", 0, mRepo.getNonTokenModules().size());
- List<IModuleDef> modules1 = mRepo.getModules(SERIAL1, 0);
- assertNotNull(modules1);
- assertEquals(2, modules1.size());
- // Only module C tokens with serial 1.
- assertTrue(modules1.get(0).getId().contains(MODULE_NAME_C));
- assertTrue(modules1.get(1).getId().contains(MODULE_NAME_C));
- List<IModuleDef> modules2 = mRepo.getModules(SERIAL2, 1);
- assertNotNull(modules2);
- assertEquals(2, modules2.size());
- assertTrue(modules2.get(0).getId().contains("FooModuleD"));
- assertTrue(modules2.get(1).getId().contains("FooModuleD"));
- }
-
- /**
- * Test sharding with 4 shards of the 6 non token modules + 2 token modules.
- */
- public void testGetModulesSharded_uneven() throws Exception {
- createConfig(mTestsDir, "FooModuleD", null);
- mRepo.initialize(4, null, mTestsDir, ABIS, new ArrayList<String>(), TEST_ARGS, MODULE_ARGS,
- INCLUDES, EXCLUDES, METADATA_INCLUDES, METADATA_EXCLUDES, mMockBuildInfo);
- assertTrue("Should be initialized", mRepo.isInitialized());
- assertEquals("Wrong number of tokens", 2, mRepo.getTokenModules().size());
- assertEquals("Wrong number of tokens", 6, mRepo.getNonTokenModules().size());
-
- List<IModuleDef> shard1 = mRepo.getModules(SERIAL1, 0);
- assertEquals(1, shard1.size());
- assertEquals("armeabi-v7a FooModuleA", shard1.get(0).getId());
-
- List<IModuleDef> shard2 = mRepo.getModules(SERIAL2, 1);
- assertEquals(1, shard2.size());
- assertEquals("arm64-v8a FooModuleA", shard2.get(0).getId());
-
- List<IModuleDef> shard3 = mRepo.getModules(SERIAL3, 2);
- assertEquals(2, shard3.size());
- assertEquals("armeabi-v7a FooModuleB", shard3.get(0).getId());
- assertEquals("arm64-v8a FooModuleB", shard3.get(1).getId());
-
- List<IModuleDef> shard4 = mRepo.getModules(SERIAL2, 3);
- assertEquals(4, shard4.size());
- assertEquals("armeabi-v7a FooModuleC", shard4.get(0).getId());
- assertEquals("arm64-v8a FooModuleC", shard4.get(1).getId());
- assertEquals("armeabi-v7a FooModuleD", shard4.get(2).getId());
- assertEquals("arm64-v8a FooModuleD", shard4.get(3).getId());
- }
-
- public void testConfigFilter() throws Exception {
- File[] configFiles = mTestsDir.listFiles(new ConfigFilter());
- assertEquals("Wrong number of config files found.", 3, configFiles.length);
- for (File file : configFiles) {
- assertTrue(String.format("Unrecognised file: %s", file.getAbsolutePath()),
- FILES.contains(file.getName()));
- }
- }
-
- public void testFiltering() throws Exception {
- Set<String> includeFilters = new HashSet<>();
- includeFilters.add(MODULE_NAME_A);
- Set<String> excludeFilters = new HashSet<>();
- excludeFilters.add(ID_A_32);
- excludeFilters.add(MODULE_NAME_B);
- mRepo.initialize(1, null, mTestsDir, ABIS, DEVICE_TOKENS, TEST_ARGS, MODULE_ARGS,
- includeFilters, excludeFilters, METADATA_INCLUDES, METADATA_EXCLUDES,
- mMockBuildInfo);
- List<IModuleDef> modules = mRepo.getModules(SERIAL1, 0);
- assertEquals("Incorrect number of modules", 1, modules.size());
- IModuleDef module = modules.get(0);
- assertEquals("Incorrect ID", ID_A_64, module.getId());
- checkArgs(module);
- }
-
- /** Test that excluded module shouldn't be loaded. */
- public void testInitialization_ExcludeModule_SkipLoadingConfig() throws Exception {
- Set<String> excludeFilters = new HashSet<String>();
- excludeFilters.add(NON_EXISTS_MODULE_NAME);
- mRepo.initialize(
- 1,
- null,
- mTestsDir,
- ABIS,
- DEVICE_TOKENS,
- TEST_ARGS,
- MODULE_ARGS,
- Collections.emptySet(),
- excludeFilters,
- METADATA_INCLUDES,
- METADATA_EXCLUDES,
- mMockBuildInfo);
- }
-
- /**
- * Test that {@link ModuleRepo#getModules(String, int)} handles well all module being filtered.
- */
- public void testFiltering_empty() throws Exception {
- Set<String> includeFilters = new HashSet<>();
- Set<String> excludeFilters = new HashSet<>();
- excludeFilters.add(MODULE_NAME_A);
- excludeFilters.add(MODULE_NAME_B);
- excludeFilters.add(MODULE_NAME_C);
- mRepo.initialize(1, null, mTestsDir, ABIS, DEVICE_TOKENS, TEST_ARGS, MODULE_ARGS,
- includeFilters, excludeFilters,
- METADATA_INCLUDES, METADATA_EXCLUDES, mMockBuildInfo);
- List<IModuleDef> modules = mRepo.getModules(SERIAL1, 0);
- assertEquals("Incorrect number of modules", 0, modules.size());
- }
-
- public void testParsing() throws Exception {
- mRepo.initialize(1, null, mTestsDir, ABIS, DEVICE_TOKENS, TEST_ARGS, MODULE_ARGS, INCLUDES,
- EXCLUDES, METADATA_INCLUDES, METADATA_EXCLUDES, mMockBuildInfo);
- List<IModuleDef> modules = mRepo.getModules(SERIAL3, 0);
- Set<String> idSet = new HashSet<>();
- for (IModuleDef module : modules) {
- idSet.add(module.getId());
- }
- assertEquals("Incorrect number of IDs", 6, idSet.size());
- assertTrue("Missing ID_A_32", idSet.contains(ID_A_32));
- assertTrue("Missing ID_A_64", idSet.contains(ID_A_64));
- assertTrue("Missing ID_B_32", idSet.contains(ID_B_32));
- assertTrue("Missing ID_B_64", idSet.contains(ID_B_64));
- assertTrue("Missing ID_C_32", idSet.contains(ID_C_32));
- assertTrue("Missing ID_C_64", idSet.contains(ID_C_64));
- for (IModuleDef module : modules) {
- checkArgs(module);
- }
- }
-
- private void checkArgs(IModuleDef module) {
- IRemoteTest test = module.getTest();
- assertTrue("Incorrect test type", test instanceof TestStub);
- TestStub stub = (TestStub) test;
- assertEquals("Incorrect test arg", "bar", stub.mFoo);
- assertEquals("Incorrect module arg", "foobar", stub.mBlah);
- }
-
- public void testGetModuleIds() {
- mRepo.initialize(3, null, mTestsDir, ABIS, DEVICE_TOKENS, TEST_ARGS, MODULE_ARGS, INCLUDES,
- EXCLUDES, METADATA_INCLUDES, METADATA_EXCLUDES, mMockBuildInfo);
- assertTrue("Should be initialized", mRepo.isInitialized());
-
- assertArrayEquals(EXPECTED_MODULE_IDS, mRepo.getModuleIds());
- }
-
- private void assertArrayEquals(Object[] expected, Object[] actual) {
- assertEquals(Arrays.asList(expected), Arrays.asList(actual));
- }
-
- /**
- * Test class to provide runtimeHint.
- */
- private class TestRuntime implements IRemoteTest, IRuntimeHintProvider, IAbiReceiver,
- ITestCollector, ITestFilterReceiver {
- public long runtimeHint = 0l;
- @Override
- public long getRuntimeHint() {
- return runtimeHint;
- }
- // ignore all the other calls
- @Override
- public void run(ITestInvocationListener arg0) throws DeviceNotAvailableException {}
- @Override
- public void addAllExcludeFilters(Set<String> arg0) {}
- @Override
- public void addAllIncludeFilters(Set<String> arg0) {}
- @Override
- public void addExcludeFilter(String arg0) {}
- @Override
- public void addIncludeFilter(String arg0) {}
- @Override
- public void setCollectTestsOnly(boolean arg0) {}
- @Override
- public void setAbi(IAbi arg0) {}
- @Override
- public IAbi getAbi() {return null;}
- @Override
- public Set<String> getIncludeFilters() {
- return null;
- }
- @Override
- public Set<String> getExcludeFilters() {
- return null;
- }
- @Override
- public void clearIncludeFilters() {}
- @Override
- public void clearExcludeFilters() {}
- }
-
- /**
- * Balance the load of runtime of the modules for the same runtimehint everywhere.
- */
- public void testGetshard_allSameRuntime() throws Exception {
- List<IModuleDef> testList = new ArrayList<>();
- TestRuntime test1 = new TestRuntime();
- test1.runtimeHint = 100l;
- IModuleDef mod1 = new ModuleDef("test1", new Abi("arm", "32"), test1,
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor());
- testList.add(mod1);
- TestRuntime test2 = new TestRuntime();
- test2.runtimeHint = 100l;
- IModuleDef mod2 = new ModuleDef("test2", new Abi("arm", "32"), test2,
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor());
- testList.add(mod2);
- TestRuntime test3 = new TestRuntime();
- test3.runtimeHint = 100l;
- IModuleDef mod3 = new ModuleDef("test3", new Abi("arm", "32"), test3,
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor());
- testList.add(mod3);
- TestRuntime test4 = new TestRuntime();
- test4.runtimeHint = 100l;
- IModuleDef mod4 = new ModuleDef("test4", new Abi("arm", "32"), test4,
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor());
- testList.add(mod4);
- // if we don't shard everything is in one shard.
- List<IModuleDef> res = mRepo.getShard(testList, 0, 1);
- assertEquals(4, res.size());
- res = mRepo.getShard(testList, 0, 2);
- assertEquals(2, res.size());
- assertEquals(mod1, res.get(0));
- assertEquals(mod2, res.get(1));
- res = mRepo.getShard(testList, 1, 2);
- assertEquals(2, res.size());
- assertEquals(mod3, res.get(0));
- assertEquals(mod4, res.get(1));
- }
-
- /**
- * When reaching splitting time, we need to ensure that even after best effort, if we cannot
- * split into the requested number of shardIndex, we simply return null to report an empty
- * shard.
- */
- public void testGetShard_cannotSplitMore() {
- List<IModuleDef> testList = new ArrayList<>();
- TestRuntime test1 = new TestRuntime();
- test1.runtimeHint = 100l;
- IModuleDef mod1 = new ModuleDef("test1", new Abi("arm", "32"), test1,
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor());
- testList.add(mod1);
- List<IModuleDef> res = mRepo.getShard(testList, 1, 2);
- assertNull(res);
- }
-
- /**
- * When there are no metadata based filters specified, config should be included
- * @throws Exception
- */
- public void testMetadataFilter_emptyFilters() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- assertTrue("config not included when metadata filters are empty",
- mRepo.filterByConfigMetadata(config, METADATA_INCLUDES, METADATA_EXCLUDES));
- }
-
- /**
- * When inclusion filter is specified, config matching the filter is included
- * @throws Exception
- */
- public void testMetadataFilter_matchInclude() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo");
- desc.setMetaData(metadata);
- MultiMap<String, String> includeFilter = new MultiMap<>();
- includeFilter.put("component", "foo");
- assertTrue("config not included with matching inclusion filter",
- mRepo.filterByConfigMetadata(config, includeFilter, METADATA_EXCLUDES));
- }
-
- /**
- * When inclusion filter is specified, config not matching the filter is excluded
- * @throws Exception
- */
- public void testMetadataFilter_noMatchInclude_mismatchValue() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo");
- desc.setMetaData(metadata);
- MultiMap<String, String> includeFilter = new MultiMap<>();
- includeFilter.put("component", "bar");
- assertFalse("config not excluded with mismatching inclusion filter",
- mRepo.filterByConfigMetadata(config, includeFilter, METADATA_EXCLUDES));
- }
-
- /**
- * When inclusion filter is specified, config not matching the filter is excluded
- * @throws Exception
- */
- public void testMetadataFilter_noMatchInclude_mismatchKey() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo");
- desc.setMetaData(metadata);
- MultiMap<String, String> includeFilter = new MultiMap<>();
- includeFilter.put("group", "bar");
- assertFalse("config not excluded with mismatching inclusion filter",
- mRepo.filterByConfigMetadata(config, includeFilter, METADATA_EXCLUDES));
- }
-
- /**
- * When exclusion filter is specified, config matching the filter is excluded
- * @throws Exception
- */
- public void testMetadataFilter_matchExclude() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo");
- desc.setMetaData(metadata);
- MultiMap<String, String> excludeFilter = new MultiMap<>();
- excludeFilter.put("component", "foo");
- assertFalse("config not excluded with matching exclusion filter",
- mRepo.filterByConfigMetadata(config, METADATA_INCLUDES, excludeFilter));
- }
-
- /**
- * When exclusion filter is specified, config not matching the filter is included
- * @throws Exception
- */
- public void testMetadataFilter_noMatchExclude_mismatchKey() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo");
- desc.setMetaData(metadata);
- MultiMap<String, String> excludeFilter = new MultiMap<>();
- excludeFilter.put("component", "bar");
- assertTrue("config not included with mismatching exclusion filter",
- mRepo.filterByConfigMetadata(config, METADATA_INCLUDES, excludeFilter));
- }
-
- /**
- * When exclusion filter is specified, config not matching the filter is included
- * @throws Exception
- */
- public void testMetadataFilter_noMatchExclude_mismatchValue() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo");
- desc.setMetaData(metadata);
- MultiMap<String, String> excludeFilter = new MultiMap<>();
- excludeFilter.put("group", "bar");
- assertTrue("config not included with mismatching exclusion filter",
- mRepo.filterByConfigMetadata(config, METADATA_INCLUDES, excludeFilter));
- }
-
- /**
- * When inclusion filter is specified, config with one of the metadata field matching the filter
- * is included
- * @throws Exception
- */
- public void testMetadataFilter_matchInclude_multipleMetadataField() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo");
- metadata.put("component", "bar");
- desc.setMetaData(metadata);
- MultiMap<String, String> includeFilter = new MultiMap<>();
- includeFilter.put("component", "foo");
- assertTrue("config not included with matching inclusion filter",
- mRepo.filterByConfigMetadata(config, includeFilter, METADATA_EXCLUDES));
- }
-
- /**
- * When exclusion filter is specified, config with one of the metadata field matching the filter
- * is excluded
- * @throws Exception
- */
- public void testMetadataFilter_matchExclude_multipleMetadataField() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo");
- metadata.put("component", "bar");
- desc.setMetaData(metadata);
- MultiMap<String, String> excludeFilter = new MultiMap<>();
- excludeFilter.put("component", "foo");
- assertFalse("config not excluded with matching exclusion filter",
- mRepo.filterByConfigMetadata(config, METADATA_INCLUDES, excludeFilter));
- }
-
- /**
- * When inclusion filters are specified, config with metadata field matching one of the filter
- * is included
- * @throws Exception
- */
- public void testMetadataFilter_matchInclude_multipleFilters() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo");
- desc.setMetaData(metadata);
- MultiMap<String, String> includeFilter = new MultiMap<>();
- includeFilter.put("component", "foo");
- includeFilter.put("component", "bar");
- assertTrue("config not included with matching inclusion filter",
- mRepo.filterByConfigMetadata(config, includeFilter, METADATA_EXCLUDES));
- }
-
- /**
- * When exclusion filters are specified, config with metadata field matching one of the filter
- * is excluded
- * @throws Exception
- */
- public void testMetadataFilter_matchExclude_multipleFilters() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo");
- desc.setMetaData(metadata);
- MultiMap<String, String> excludeFilter = new MultiMap<>();
- excludeFilter.put("component", "foo");
- excludeFilter.put("component", "bar");
- assertFalse("config not excluded with matching exclusion filter",
- mRepo.filterByConfigMetadata(config, METADATA_INCLUDES, excludeFilter));
- }
-
- /**
- * When inclusion filters are specified, config with metadata field matching one of the filter
- * is included
- * @throws Exception
- */
- public void testMetadataFilter_matchInclude_multipleMetadataAndFilters() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo1");
- metadata.put("group", "bar1");
- desc.setMetaData(metadata);
- MultiMap<String, String> includeFilter = new MultiMap<>();
- includeFilter.put("component", "foo1");
- includeFilter.put("group", "bar2");
- assertTrue("config not included with matching inclusion filter",
- mRepo.filterByConfigMetadata(config, includeFilter, METADATA_EXCLUDES));
- }
-
- /**
- * When exclusion filters are specified, config with metadata field matching one of the filter
- * is excluded
- * @throws Exception
- */
- public void testMetadataFilter_matchExclude_multipleMetadataAndFilters() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo1");
- metadata.put("group", "bar1");
- desc.setMetaData(metadata);
- MultiMap<String, String> excludeFilter = new MultiMap<>();
- excludeFilter.put("component", "foo1");
- excludeFilter.put("group", "bar2");
- assertFalse("config not excluded with matching exclusion filter",
- mRepo.filterByConfigMetadata(config, METADATA_INCLUDES, excludeFilter));
- }
-
- /**
- * When inclusion and exclusion filters are both specified, config can pass through the filters
- * as expected.
- * @throws Exception
- */
- public void testMetadataFilter_includeAndExclude() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo");
- metadata.put("group", "bar1");
- desc.setMetaData(metadata);
- MultiMap<String, String> includeFilter = new MultiMap<>();
- includeFilter.put("component", "foo");
- MultiMap<String, String> excludeFilter = new MultiMap<>();
- excludeFilter.put("group", "bar2");
- assertTrue("config not included with matching inclusion and mismatching exclusion filters",
- mRepo.filterByConfigMetadata(config, includeFilter, excludeFilter));
- }
-
- /**
- * When inclusion and exclusion filters are both specified, config be excluded as specified
- * @throws Exception
- */
- public void testMetadataFilter_includeThenExclude() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- ConfigurationDescriptor desc = config.getConfigurationDescription();
- MultiMap<String, String> metadata = new MultiMap<>();
- metadata.put("component", "foo");
- metadata.put("group", "bar");
- desc.setMetaData(metadata);
- MultiMap<String, String> includeFilter = new MultiMap<>();
- includeFilter.put("component", "foo");
- MultiMap<String, String> excludeFilter = new MultiMap<>();
- excludeFilter.put("group", "bar");
- assertFalse("config not excluded with matching inclusion and exclusion filters",
- mRepo.filterByConfigMetadata(config, includeFilter, excludeFilter));
- }
-
- public static class TestInject implements IRemoteTest {
- @Option(name = "simple-string")
- public String test = null;
- @Option(name = "list-string")
- public List<String> testList = new ArrayList<>();
- @Option(name = "map-string")
- public Map<String, String> testMap = new HashMap<>();
-
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- }
- }
-
- /**
- * Test that the different format for module-arg and test-arg can properly be passed to the
- * configuration.
- */
- public void testInjectConfig() throws Exception {
- IConfiguration config = new Configuration("foo", "bar");
- TestInject checker = new TestInject();
- config.setTest(checker);
- Map<String, List<String>> optionMap = new HashMap<String, List<String>>();
- List<String> option1 = new ArrayList<>();
- option1.add("value1");
- optionMap.put("simple-string", option1);
-
- List<String> option2 = new ArrayList<>();
- option2.add("value2");
- option2.add("value3");
- option2.add("set-option:moreoption");
- optionMap.put("list-string", option2);
-
- List<String> option3 = new ArrayList<>();
- option3.add("set-option:=moreoption");
- optionMap.put("map-string", option3);
-
- mRepo.injectOptionsToConfig(optionMap, config);
-
- assertEquals("value1", checker.test);
- assertEquals(option2, checker.testList);
- Map<String, String> resMap = new HashMap<>();
- resMap.put("set-option", "moreoption");
- assertEquals(resMap, checker.testMap);
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ShardableTestStub.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ShardableTestStub.java
deleted file mode 100644
index 293d0d2..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ShardableTestStub.java
+++ /dev/null
@@ -1,132 +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.compatibility.common.tradefed.testtype;
-
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IAbiReceiver;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.IRuntimeHintProvider;
-import com.android.tradefed.testtype.IShardableTest;
-import com.android.tradefed.testtype.ITestCollector;
-import com.android.tradefed.testtype.ITestFilterReceiver;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Set;
-
-public class ShardableTestStub implements IRemoteTest, IShardableTest, IBuildReceiver,
- IAbiReceiver, IRuntimeHintProvider, ITestCollector, ITestFilterReceiver {
-
- @Option(name = "module")
- String mModule;
- @Option(name = "foo")
- String mFoo;
- @Option(name = "blah")
- String mBlah;
-
- public IBuildInfo mBuildInfo = null;
-
- Collection<IRemoteTest> mShards;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setBuild(IBuildInfo buildInfo) {
- mBuildInfo = buildInfo;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- // Do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<IRemoteTest> split() {
- mShards = new ArrayList<>();
- for (int i = 0; i < 3; i++) {
- mShards.add(new ShardableTestStub());
- }
- return mShards;
- }
-
- @Override
- public void setAbi(IAbi abi) {
- // Do nothing
- }
-
- @Override
- public IAbi getAbi() {
- return null;
- }
-
- @Override
- public long getRuntimeHint() {
- return 1L;
- }
-
- @Override
- public void setCollectTestsOnly(boolean shouldCollectTest) {
- // Do nothing
- }
-
- @Override
- public void addIncludeFilter(String filter) {
-
- }
-
- @Override
- public void addAllIncludeFilters(Set<String> filters) {
-
- }
-
- @Override
- public void addExcludeFilter(String filter) {
-
- }
-
- @Override
- public void addAllExcludeFilters(Set<String> filters) {
-
- }
-
- @Override
- public Set<String> getIncludeFilters() {
- return null;
- }
-
- @Override
- public Set<String> getExcludeFilters() {
- return null;
- }
-
- @Override
- public void clearIncludeFilters() {}
-
- @Override
- public void clearExcludeFilters() {}
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/SimpleTestStub.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/SimpleTestStub.java
deleted file mode 100644
index effea21..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/SimpleTestStub.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.tradefed.testtype;
-
-import com.android.tradefed.config.Option;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.TestDescription;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IAbiReceiver;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.IRuntimeHintProvider;
-import com.android.tradefed.testtype.ITestCollector;
-import com.android.tradefed.testtype.ITestFilterReceiver;
-
-import java.util.HashMap;
-import java.util.Set;
-
-/**
- * A test Stub that can be used to fake some runs.
- */
-public class SimpleTestStub implements IRemoteTest, IAbiReceiver, IRuntimeHintProvider,
- ITestCollector, ITestFilterReceiver {
-
- // options below are unused
- @Option(name = "report-test")
- protected boolean mReportTest = false;
- @Option(name = "run-complete")
- protected boolean mIsComplete = true;
- @Option(name = "test-fail")
- protected boolean mDoesOneTestFail = true;
- @Option(name = "internal-retry")
- protected boolean mRetry = false;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- // We report 1 passing tes
- listener.testRunStarted("module-run", 1);
- TestDescription tid = new TestDescription("TestStub", "test1");
- listener.testStarted(tid);
- listener.testEnded(tid, new HashMap<String, Metric>());
- listener.testRunEnded(0, new HashMap<String, Metric>());
- }
-
- @Override
- public void setAbi(IAbi abi) {
- // Do nothing
- }
-
- @Override
- public long getRuntimeHint() {
- return 1L;
- }
-
- @Override
- public void setCollectTestsOnly(boolean shouldCollectTest) {
- // Do nothing
- }
-
- @Override
- public void addIncludeFilter(String filter) {
-
- }
-
- @Override
- public void addAllIncludeFilters(Set<String> filters) {
-
- }
-
- @Override
- public void addExcludeFilter(String filter) {
-
- }
-
- @Override
- public void addAllExcludeFilters(Set<String> filters) {
-
- }
-
- @Override
- public Set<String> getIncludeFilters() {
- return null;
- }
-
- @Override
- public Set<String> getExcludeFilters() {
- return null;
- }
-
- @Override
- public void clearIncludeFilters() {}
-
- @Override
- public void clearExcludeFilters() {}
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/TestStub.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/TestStub.java
deleted file mode 100644
index f04a1be..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/TestStub.java
+++ /dev/null
@@ -1,185 +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.compatibility.common.tradefed.testtype;
-
-import com.android.tradefed.config.Option;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.TestDescription;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IAbiReceiver;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.IRuntimeHintProvider;
-import com.android.tradefed.testtype.ITestCollector;
-import com.android.tradefed.testtype.ITestFilterReceiver;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
-
-/**
- * A test Stub that can be used to fake some runs.
- */
-public class TestStub implements IRemoteTest, IAbiReceiver, IRuntimeHintProvider, ITestCollector,
- ITestFilterReceiver {
-
- @Option(name = "module")
- private String mModule;
- @Option(name = "foo")
- protected String mFoo;
- @Option(name = "blah")
- protected String mBlah;
- @Option(name = "report-test")
- protected boolean mReportTest = false;
- @Option(name = "run-complete")
- protected boolean mIsComplete = true;
- @Option(name = "test-fail")
- protected boolean mDoesOneTestFail = true;
- @Option(name = "internal-retry")
- protected boolean mRetry = false;
-
- protected List<TestDescription> mShardedTestToRun;
- protected Integer mShardIndex = null;
-
- /**
- * Tests attempt.
- */
- private void testAttempt(ITestInvocationListener listener) {
- // We report 3 tests: 2 pass, 1 failed
- listener.testRunStarted("module-run", 3);
- TestDescription tid = new TestDescription("TestStub", "test1");
- listener.testStarted(tid);
- listener.testEnded(tid, new HashMap<String, Metric>());
-
- if (mIsComplete) {
- // possibly skip this one to create some not_executed case.
- TestDescription tid2 = new TestDescription("TestStub", "test2");
- listener.testStarted(tid2);
- listener.testEnded(tid2, new HashMap<String, Metric>());
- }
-
- TestDescription tid3 = new TestDescription("TestStub", "test3");
- listener.testStarted(tid3);
- if (mDoesOneTestFail) {
- listener.testFailed(tid3, "ouch this is bad.");
- }
- listener.testEnded(tid3, new HashMap<String, Metric>());
-
- listener.testRunEnded(0, new HashMap<String, Metric>());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- if (mReportTest) {
- if (mShardedTestToRun == null) {
- if (!mRetry) {
- testAttempt(listener);
- } else {
- // We fake an internal retry by calling testRunStart/Ended again.
- listener.testRunStarted("module-run", 3);
- listener.testRunEnded(0, new HashMap<String, Metric>());
- testAttempt(listener);
- }
- } else {
- // Run the shard
- if (mDoesOneTestFail) {
- listener.testRunStarted("module-run", mShardedTestToRun.size() + 1);
- } else {
- listener.testRunStarted("module-run", mShardedTestToRun.size());
- }
-
- if (mIsComplete) {
- for (TestDescription tid : mShardedTestToRun) {
- listener.testStarted(tid);
- listener.testEnded(tid, new HashMap<String, Metric>());
- }
- } else {
- TestDescription tid = mShardedTestToRun.get(0);
- listener.testStarted(tid);
- listener.testEnded(tid, new HashMap<String, Metric>());
- }
-
- if (mDoesOneTestFail) {
- TestDescription tid = new TestDescription("TestStub", "failed" + mShardIndex);
- listener.testStarted(tid);
- listener.testFailed(tid, "shard failed this one.");
- listener.testEnded(tid, new HashMap<String, Metric>());
- }
- listener.testRunEnded(0, new HashMap<String, Metric>());
- }
- }
- }
-
- @Override
- public void setAbi(IAbi abi) {
- // Do nothing
- }
-
- @Override
- public IAbi getAbi() {
- return null;
- }
-
- @Override
- public long getRuntimeHint() {
- return 1L;
- }
-
- @Override
- public void setCollectTestsOnly(boolean shouldCollectTest) {
- // Do nothing
- }
-
- @Override
- public void addIncludeFilter(String filter) {
-
- }
-
- @Override
- public void addAllIncludeFilters(Set<String> filters) {
-
- }
-
- @Override
- public void addExcludeFilter(String filter) {
-
- }
-
- @Override
- public void addAllExcludeFilters(Set<String> filters) {
-
- }
-
- @Override
- public Set<String> getIncludeFilters() {
- return null;
- }
-
- @Override
- public Set<String> getExcludeFilters() {
- return null;
- }
-
- @Override
- public void clearIncludeFilters() {}
-
- @Override
- public void clearExcludeFilters() {}
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/retry/RetryFactoryTestTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/retry/RetryFactoryTestTest.java
deleted file mode 100644
index f7bbb4b..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/retry/RetryFactoryTestTest.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.tradefed.testtype.retry;
-
-import static org.junit.Assert.assertEquals;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.compatibility.common.tradefed.testtype.suite.CompatibilityTestSuite;
-import com.android.compatibility.common.tradefed.util.RetryFilterHelper;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.build.IDeviceBuildInfo;
-import com.android.tradefed.config.Configuration;
-import com.android.tradefed.config.ConfigurationDef;
-import com.android.tradefed.config.IConfiguration;
-import com.android.tradefed.config.OptionClass;
-import com.android.tradefed.config.OptionSetter;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.invoker.IInvocationContext;
-import com.android.tradefed.invoker.InvocationContext;
-import com.android.tradefed.invoker.TestInformation;
-import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.suite.checker.ISystemStatusChecker;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.StubTest;
-
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-/**
- * Unit tests for {@link RetryFactoryTest}.
- */
-@RunWith(JUnit4.class)
-public class RetryFactoryTestTest {
-
- private RetryFactoryTest mFactory;
- private ITestInvocationListener mMockListener;
- private RetryFilterHelper mSpyFilter;
-
- private List<ISystemStatusChecker> mCheckers;
- private IBuildInfo mMockInfo;
- private ITestDevice mMockDevice;
- private IConfiguration mMockMainConfiguration;
- private IInvocationContext mMockContext;
- private TestInformation mTestInfo;
-
- /**
- * A {@link CompatibilityTestSuite} that does not run anything.
- */
- @OptionClass(alias = "compatibility")
- public static class VoidCompatibilityTest extends CompatibilityTestSuite {
- @Override
- public LinkedHashMap<String, IConfiguration> loadTests() {
- return new LinkedHashMap<>();
- }
-
- @Override
- public Collection<IRemoteTest> split(int shardCountHint) {
- List<IRemoteTest> tests = new ArrayList<>();
- for (int i = 0; i < shardCountHint; i++) {
- tests.add(new StubTest());
- }
- return tests;
- }
- }
-
- @OptionClass(alias = "compatibility")
- public static class TestCompatibilityTestSuite extends CompatibilityTestSuite {
- @Override
- public LinkedHashMap<String, IConfiguration> loadTests() {
- LinkedHashMap<String, IConfiguration> tests = new LinkedHashMap<>();
- IConfiguration config = new Configuration("test", "test");
- config.setTest(new StubTest());
- tests.put("module1", config);
- return tests;
- }
- }
-
- @Before
- public void setUp() {
- mMockMainConfiguration = new Configuration("mockMain", "mockMain");
- mCheckers = new ArrayList<>();
- mMockInfo = EasyMock.createMock(IDeviceBuildInfo.class);
- EasyMock.expect(mMockInfo.getRemoteFiles()).andStubReturn(null);
- mMockDevice = EasyMock.createMock(ITestDevice.class);
- mMockContext = new InvocationContext();
- mMockContext.addAllocatedDevice(ConfigurationDef.DEFAULT_DEVICE_NAME, mMockDevice);
- mMockContext.addDeviceBuildInfo(ConfigurationDef.DEFAULT_DEVICE_NAME, mMockInfo);
- mTestInfo = TestInformation.newBuilder().setInvocationContext(mMockContext).build();
-
- mSpyFilter = new RetryFilterHelper() {
- @Override
- public void validateBuildFingerprint(ITestDevice device)
- throws DeviceNotAvailableException {
- // do nothing
- }
- @Override
- public void setCommandLineOptionsFor(Object obj) {
- // do nothing
- }
- @Override
- public void setBuildInfoRetryCommand(IBuildInfo info) {
- // do nothing
- }
- @Override
- public void populateFiltersBySubPlan() {
- // do nothing
- }
- };
- mFactory = new RetryFactoryTest() {
- @Override
- protected RetryFilterHelper createFilterHelper(CompatibilityBuildHelper buildHelper) {
- return mSpyFilter;
- }
- @Override
- CompatibilityTestSuite createTest() {
- return new VoidCompatibilityTest();
- }
- };
- mMockListener = EasyMock.createMock(ITestInvocationListener.class);
- }
-
- /**
- * Tests that the CompatibilityTest created can receive all the options without throwing.
- */
- @Test
- public void testRetry_receiveOption() throws Exception {
- OptionSetter setter = new OptionSetter(mFactory);
- setter.setOptionValue("retry", "10599");
- setter.setOptionValue("test-arg", "abcd");
- EasyMock.replay(mMockListener);
- mFactory.run(mTestInfo, mMockListener);
- EasyMock.verify(mMockListener);
- }
-
- /**
- * Assert that the {@link RetryFactoryTest#split(int)} calls the
- * {@link CompatibilityTestSuite#split(int)} after applying all the filters.
- */
- @Test
- public void testRetry_split() throws Exception {
- EasyMock.replay(mMockListener);
- Collection<IRemoteTest> res = mFactory.split(2);
- assertEquals(2, res.size());
- EasyMock.verify(mMockListener);
- }
-
- /**
- * This test is meant to validate more end-to-end that the retry can create the runner, and
- * running it works properly for the main use case.
- */
- @Test
- public void testValidation() throws Exception {
- mFactory = new RetryFactoryTest() {
- @Override
- protected RetryFilterHelper createFilterHelper(CompatibilityBuildHelper buildHelper) {
- return mSpyFilter;
- }
- @Override
- CompatibilityTestSuite createTest() {
- return new TestCompatibilityTestSuite();
- }
- };
- mFactory.setBuild(mMockInfo);
- mFactory.setDevice(mMockDevice);
- mFactory.setSystemStatusChecker(mCheckers);
- mFactory.setConfiguration(mMockMainConfiguration);
- mFactory.setInvocationContext(mMockContext);
-
- mMockListener.testModuleStarted(EasyMock.anyObject());
- mMockListener.testRunStarted(
- EasyMock.eq("module1"), EasyMock.eq(0), EasyMock.eq(0), EasyMock.anyLong());
- mMockListener.testRunEnded(
- EasyMock.anyLong(), EasyMock.<HashMap<String, Metric>>anyObject());
- mMockListener.testModuleEnded();
-
- EasyMock.replay(mMockListener, mMockInfo, mMockDevice);
- mFactory.run(mTestInfo, mMockListener);
- EasyMock.verify(mMockListener, mMockInfo, mMockDevice);
- }
-}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/util/UniqueModuleCountUtilTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/util/UniqueModuleCountUtilTest.java
deleted file mode 100644
index 8e20133..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/util/UniqueModuleCountUtilTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.tradefed.util;
-
-import static org.junit.Assert.assertEquals;
-
-import com.android.compatibility.common.tradefed.testtype.IModuleDef;
-import com.android.compatibility.common.tradefed.testtype.ModuleDef;
-import com.android.compatibility.common.tradefed.testtype.TestStub;
-import com.android.tradefed.config.ConfigurationDescriptor;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.testtype.Abi;
-
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Unit tests for {@link UniqueModuleCountUtil}.
- */
-public class UniqueModuleCountUtilTest {
-
- @Test
- public void testCountEmptyList() {
- List<IModuleDef> emptyList = new ArrayList<>();
- assertEquals(0, UniqueModuleCountUtil.countUniqueModules(emptyList));
- }
-
- @Test
- public void testCount_2uniquesModules() {
- List<IModuleDef> list = new ArrayList<>();
- list.add(new ModuleDef("moduleA", new Abi("arm64", "64"), new TestStub(),
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor()));
- list.add(new ModuleDef("moduleA", new Abi("arm32", "32"), new TestStub(),
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor()));
- assertEquals(2, UniqueModuleCountUtil.countUniqueModules(list));
- }
-
- @Test
- public void testCount_2subModules() {
- List<IModuleDef> list = new ArrayList<>();
- list.add(new ModuleDef("moduleA", new Abi("arm32", "32"), new TestStub(),
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor()));
- list.add(new ModuleDef("moduleA", new Abi("arm32", "32"), new TestStub(),
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor()));
- assertEquals(1, UniqueModuleCountUtil.countUniqueModules(list));
- }
-
- @Test
- public void testCount_mix() {
- List<IModuleDef> list = new ArrayList<>();
- list.add(new ModuleDef("moduleA", new Abi("arm64", "64"), new TestStub(),
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor()));
- list.add(new ModuleDef("moduleA", new Abi("arm32", "32"), new TestStub(),
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor()));
- list.add(new ModuleDef("moduleC", new Abi("arm32", "32"), new TestStub(),
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor()));
- list.add(new ModuleDef("moduleB", new Abi("arm64", "64"), new TestStub(),
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor()));
- list.add(new ModuleDef("moduleB", new Abi("arm32", "32"), new TestStub(),
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor()));
- list.add(new ModuleDef("moduleC", new Abi("arm64", "64"), new TestStub(),
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor()));
- list.add(new ModuleDef("moduleA", new Abi("arm32", "32"), new TestStub(),
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor()));
- list.add(new ModuleDef("moduleC", new Abi("arm32", "32"), new TestStub(),
- new ArrayList<ITargetPreparer>(), new ConfigurationDescriptor()));
- assertEquals(6, UniqueModuleCountUtil.countUniqueModules(list));
- }
-}
diff --git a/common/host-side/util/.classpath b/common/host-side/util/.classpath
index 5f9e867..aaf1635 100644
--- a/common/host-side/util/.classpath
+++ b/common/host-side/util/.classpath
@@ -13,11 +13,11 @@
<classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
<classpathentry combineaccessrules="false" kind="src" path="/tradefederation"/>
<classpathentry kind="var" path="TRADEFED_ROOT/out/soong/.intermediates/prebuilts/misc/common/json/json-prebuilt/linux_glibc_common/combined/json-prebuilt.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/cts-common-util"/>
<classpathentry kind="var" path="TRADEFED_ROOT/out/soong/.intermediates/external/mockito/mockito-byte-buddy-agent/linux_glibc_common/combined/mockito-byte-buddy-agent.jar"/>
<classpathentry kind="var" path="TRADEFED_ROOT/out/soong/.intermediates/external/mockito/mockito-byte-buddy/linux_glibc_common/combined/mockito-byte-buddy.jar"/>
<classpathentry kind="var" path="TRADEFED_ROOT/out/soong/.intermediates/cts/libs/json/json/linux_glibc_common/javac/json.jar"/>
<classpathentry kind="var" path="TRADEFED_ROOT/out/soong/.intermediates/external/guice/guice/linux_glibc_common/combined/guice.jar"/>
<classpathentry kind="var" path="TRADEFED_ROOT/out/soong/.intermediates/external/protobuf/libprotobuf-java-full/linux_glibc_common/javac/classes"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/cts-common-util"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/CpuFeatures.java b/common/host-side/util/src/com/android/compatibility/common/util/CpuFeatures.java
index 896381a..1d67ee8 100644
--- a/common/host-side/util/src/com/android/compatibility/common/util/CpuFeatures.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/CpuFeatures.java
@@ -55,8 +55,40 @@
* Return true if architecture is x86.
*/
public static boolean isX86(ITestDevice device) throws DeviceNotAvailableException {
+ // Possible names: i386, i486, i686, x86_64.
+ return uname(device, UNAME_OPTION_MACHINE_TYPE).contains("86");
+ }
- return uname(device, UNAME_OPTION_MACHINE_TYPE).contains("x86");
+ /* Return true if architecture is x86_64. */
+ public static boolean isX86_64(ITestDevice device) throws DeviceNotAvailableException {
+
+ return uname(device, UNAME_OPTION_MACHINE_TYPE).contains("x86_64");
+ }
+
+ /* Return true if architecture is 32-bit x86. */
+ public static boolean isX86_32(ITestDevice device) throws DeviceNotAvailableException {
+
+ return isX86(device) && !isX86_64(device);
+ }
+
+ /* Return true if ABI is native. */
+ public static boolean isNativeAbi(ITestDevice device, String abi)
+ throws DeviceNotAvailableException {
+ if (isArm32(device) && abi.equals("armeabi-v7a")) {
+ return true;
+ }
+ // Both armeabi-v7a and arm64-v8a are native.
+ if (isArm64(device) && abi.contains("arm")) {
+ return true;
+ }
+ if (isX86_32(device) && abi.equals("x86")) {
+ return true;
+ }
+ // Both x86 and x86_64 are native.
+ if (isX86_64(device) && abi.contains("x86")) {
+ return true;
+ }
+ return false;
}
/**
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/ShellCommandUtil.java b/common/host-side/util/src/com/android/compatibility/common/util/ShellCommandUtil.java
deleted file mode 100644
index a62a9f5..0000000
--- a/common/host-side/util/src/com/android/compatibility/common/util/ShellCommandUtil.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.util;
-
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-
-/**
- * Device-side compatibility utility class for executing ADB shell commands.
- */
-public class ShellCommandUtil {
-
- public static void execute(ITestDevice device, String command)
- throws DeviceNotAvailableException {
- device.executeShellCommand(command);
- }
-}
diff --git a/common/host-side/util/tests/Android.bp b/common/host-side/util/tests/Android.bp
index ad9725b..acfba99 100644
--- a/common/host-side/util/tests/Android.bp
+++ b/common/host-side/util/tests/Android.bp
@@ -16,15 +16,19 @@
name: "compatibility-host-util-tests",
defaults: ["cts_error_prone_rules"],
+ // Restrict visibility to only those targets that need to access it.
+ visibility: ["//visibility:private"],
+
+// test_options: {
+// unit_test: true,
+// },
+
srcs: ["src/**/*.java"],
static_libs: [
"objenesis-host",
"mockito-host",
- ],
-
- libs: [
- "compatibility-host-util",
+ "compatibility-host-util",
"easymock",
"junit",
"json-prebuilt",
diff --git a/common/host-side/util/tests/src/com/android/compatibility/common/util/HostUnitTests.java b/common/host-side/util/tests/src/com/android/compatibility/common/util/HostUnitTests.java
deleted file mode 100644
index 2fb0868..0000000
--- a/common/host-side/util/tests/src/com/android/compatibility/common/util/HostUnitTests.java
+++ /dev/null
@@ -1,36 +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.compatibility.common.util;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-/**
- * A test suite for all host util unit tests.
- *
- * <p>All tests listed here should be self-contained, and do not require any external dependencies.
- */
-@RunWith(Suite.class)
-@SuiteClasses({
- BusinessLogicHostExecutorTest.class,
- DynamicConfigHandlerTest.class,
- ModuleResultTest.class,
- TestFilterTest.class,
- PollingCheckTest.class,
-})
-public class HostUnitTests {
- // empty on purpose
-}
diff --git a/common/util/.classpath b/common/util/.classpath
index e655896..9499a3b 100644
--- a/common/util/.classpath
+++ b/common/util/.classpath
@@ -9,8 +9,8 @@
<classpathentry kind="src" path="tests/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="var" path="TRADEFED_ROOT/out/soong/.intermediates/prebuilts/misc/common/json/json-prebuilt/linux_glibc_common/combined/json-prebuilt.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/tradefederation"/>
<classpathentry kind="var" path="TRADEFED_ROOT/prebuilts/misc/common/kxml2/kxml2-2.3.0.jar"/>
- <classpathentry kind="var" path="TRADEFED_ROOT/out/soong/.intermediates/external/guice/guice/linux_glibc_common/combined/guice.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/cts-common-util"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tradefederation"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/common/util/.project b/common/util/.project
index 6f53dd0..2ed97b9 100644
--- a/common/util/.project
+++ b/common/util/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>cts-common-util</name>
+ <name>cts-common-util-tests</name>
<comment></comment>
<projects>
</projects>
diff --git a/common/util/Android.bp b/common/util/Android.bp
index bc46cdb..6b7fe25 100644
--- a/common/util/Android.bp
+++ b/common/util/Android.bp
@@ -12,31 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-// Build the common utility library for use device-side
-java_library_static {
- name: "compatibility-common-util-devicesidelib",
- sdk_version: "current",
-
- srcs: ["src/**/*.java"],
-
- static_libs: [
- "guava",
- "junit",
- ],
-}
-
// Build the common utility library for use host-side
java_library_host {
name: "compatibility-common-util-hostsidelib",
+ // Restrict visibility to only those targets that need to access it.
+// visibility: [
+// "//test/suite_harness/common/host-side/util",
+// "//test/suite_harness/common/util/tests"
+// ],
defaults: ["cts_error_prone_rules"],
- srcs: ["src/**/*.java"],
-
- libs: [
- "junit",
- "guava",
- "json-prebuilt",
- "platform-test-annotations",
- "kxml2-2.3.0",
+ static_libs: [
+ "compatibility-common-util-lib"
],
}
diff --git a/common/util/src/com/android/compatibility/common/util/AbiUtils.java b/common/util/src/com/android/compatibility/common/util/AbiUtils.java
deleted file mode 100644
index c9c82b7..0000000
--- a/common/util/src/com/android/compatibility/common/util/AbiUtils.java
+++ /dev/null
@@ -1,61 +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.compatibility.common.util;
-
-/**
- * Utility class for handling device ABIs
- */
-public class AbiUtils {
-
- /**
- * Creates a unique id from the given ABI and name.
- * @param abi The ABI to use.
- * @param name The name to use.
- * @return a string which uniquely identifies a run.
- */
- public static String createId(String abi, String name) {
- return String.format("%s %s", abi, name);
- }
-
- /**
- * @return the abi portion of the test id.
- * e.g. armeabi-v7a android.mytest = armeabi-v7a
- */
- public static String parseAbi(String id) {
- return parseId(id)[0];
- }
-
- /**
- * Parses a unique id into the ABI and name.
- * @param id The id to parse.
- * @return a string array containing the ABI and name.
- */
- public static String[] parseId(String id) {
- if (id == null || !id.contains(" ")) {
- return new String[] {"", ""};
- }
- return id.split(" ");
- }
-
- /**
- * @return the test name portion of the test id.
- * e.g. armeabi-v7a android.mytest = android.mytest
- */
- public static String parseTestName(String id) {
- return parseId(id)[1];
- }
-
-}
diff --git a/common/util/src/com/android/compatibility/common/util/BackupUtils.java b/common/util/src/com/android/compatibility/common/util/BackupUtils.java
deleted file mode 100644
index c636427..0000000
--- a/common/util/src/com/android/compatibility/common/util/BackupUtils.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * Copyright (C) 2018 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.compatibility.common.util;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.google.common.annotations.VisibleForTesting;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.util.Scanner;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Utility class for backup and restore.
- */
-public abstract class BackupUtils {
- private static final String LOCAL_TRANSPORT_NAME =
- "com.android.localtransport/.LocalTransport";
- private static final String LOCAL_TRANSPORT_NAME_PRE_Q =
- "android/com.android.internal.backup.LocalTransport";
- private static final String LOCAL_TRANSPORT_PACKAGE = "com.android.localtransport";
- public static final String LOCAL_TRANSPORT_TOKEN = "1";
-
- private static final int BACKUP_PROVISIONING_TIMEOUT_SECONDS = 30;
- private static final int BACKUP_PROVISIONING_POLL_INTERVAL_SECONDS = 1;
- private static final long BACKUP_SERVICE_INIT_TIMEOUT_SECS = TimeUnit.MINUTES.toSeconds(2);
-
- private static final Pattern BACKUP_MANAGER_CURRENTLY_ENABLE_STATUS_PATTERN =
- Pattern.compile("^Backup Manager currently (enabled|disabled)$");
- private static final String MATCH_LINE_BACKUP_MANAGER_IS_NOT_PENDING_INIT =
- "(?s)" + "^Backup Manager is .* not pending init.*"; // DOTALL
-
- private static final String BACKUP_DUMPSYS_CURRENT_TOKEN_FIELD = "Current:";
-
- /**
- * Kicks off adb shell {@param command} and return an {@link InputStream} with the command
- * output stream.
- */
- protected abstract InputStream executeShellCommand(String command) throws IOException;
-
- public void executeShellCommandSync(String command) throws IOException {
- StreamUtil.drainAndClose(new InputStreamReader(executeShellCommand(command)));
- }
-
- public String getShellCommandOutput(String command) throws IOException {
- return StreamUtil.readInputStream(executeShellCommand(command));
- }
-
- /** Executes shell command "bmgr backupnow <package>" and assert success. */
- public void backupNowAndAssertSuccess(String packageName) throws IOException {
- assertBackupIsSuccessful(packageName, backupNow(packageName));
- }
-
- /** Executes "bmgr --user <id> backupnow <package>" and assert success. */
- public void backupNowAndAssertSuccessForUser(String packageName, int userId)
- throws IOException {
- assertBackupIsSuccessful(packageName, backupNowForUser(packageName, userId));
- }
-
- public void backupNowAndAssertBackupNotAllowed(String packageName) throws IOException {
- assertBackupNotAllowed(packageName, getBackupNowOutput(packageName));
- }
-
- /** Executes shell command "bmgr backupnow <package>" and waits for completion. */
- public void backupNowSync(String packageName) throws IOException {
- StreamUtil.drainAndClose(new InputStreamReader(backupNow(packageName)));
- }
-
- public String getBackupNowOutput(String packageName) throws IOException {
- return StreamUtil.readInputStream(backupNow(packageName));
- }
-
- /** Executes shell command "bmgr restore <token> <package>" and assert success. */
- public void restoreAndAssertSuccess(String token, String packageName) throws IOException {
- assertRestoreIsSuccessful(restore(token, packageName));
- }
-
- /** Executes shell command "bmgr --user <id> restore <token> <package>" and assert success. */
- public void restoreAndAssertSuccessForUser(String token, String packageName, int userId)
- throws IOException {
- assertRestoreIsSuccessful(restoreForUser(token, packageName, userId));
- }
-
- public void restoreSync(String token, String packageName) throws IOException {
- StreamUtil.drainAndClose(new InputStreamReader(restore(token, packageName)));
- }
-
- public String getRestoreOutput(String token, String packageName) throws IOException {
- return StreamUtil.readInputStream(restore(token, packageName));
- }
-
- public boolean isLocalTransportSelected() throws IOException {
- return getShellCommandOutput("bmgr list transports")
- .contains("* " + getLocalTransportName());
- }
-
- /**
- * Executes shell command "bmgr --user <id> list transports" to check the currently selected
- * transport and returns {@code true} if the local transport is the selected one.
- */
- public boolean isLocalTransportSelectedForUser(int userId) throws IOException {
- return getShellCommandOutput(String.format("bmgr --user %d list transports", userId))
- .contains("* " + getLocalTransportName());
- }
-
- public boolean isBackupEnabled() throws IOException {
- return getShellCommandOutput("bmgr enabled").contains("currently enabled");
- }
-
- /**
- * Executes shell command "bmgr --user <id> enabled" and returns if backup is enabled for the
- * user {@code userId}.
- */
- public boolean isBackupEnabledForUser(int userId) throws IOException {
- return getShellCommandOutput(String.format("bmgr --user %d enabled", userId))
- .contains("currently enabled");
- }
-
- public void wakeAndUnlockDevice() throws IOException {
- executeShellCommandSync("input keyevent KEYCODE_WAKEUP");
- executeShellCommandSync("wm dismiss-keyguard");
- }
-
- /**
- * Returns {@link #LOCAL_TRANSPORT_NAME} if it's available on the device, or
- * {@link #LOCAL_TRANSPORT_NAME_PRE_Q} otherwise.
- */
- public String getLocalTransportName() throws IOException {
- return getShellCommandOutput("pm list packages").contains(LOCAL_TRANSPORT_PACKAGE)
- ? LOCAL_TRANSPORT_NAME : LOCAL_TRANSPORT_NAME_PRE_Q;
- }
-
- /** Executes "bmgr backupnow <package>" and returns an {@link InputStream} for its output. */
- private InputStream backupNow(String packageName) throws IOException {
- return executeShellCommand("bmgr backupnow " + packageName);
- }
-
- /**
- * Executes "bmgr --user <id> backupnow <package>" and returns an {@link InputStream} for its
- * output.
- */
- private InputStream backupNowForUser(String packageName, int userId) throws IOException {
- return executeShellCommand(
- String.format("bmgr --user %d backupnow %s", userId, packageName));
- }
-
- /**
- * Parses the output of "bmgr backupnow" command and checks that {@code packageName} wasn't
- * allowed to backup.
- *
- * Expected format: "Package <packageName> with result: Backup is not allowed"
- *
- * TODO: Read input stream instead of string.
- */
- private void assertBackupNotAllowed(String packageName, String backupNowOutput) {
- Scanner in = new Scanner(backupNowOutput);
- boolean found = false;
- while (in.hasNextLine()) {
- String line = in.nextLine();
-
- if (line.contains(packageName)) {
- String result = line.split(":")[1].trim();
- if ("Backup is not allowed".equals(result)) {
- found = true;
- }
- }
- }
- in.close();
- assertTrue("Didn't find \'Backup not allowed\' in the output", found);
- }
-
- /**
- * Parses the output of "bmgr backupnow" command checking that the package {@code packageName}
- * was backed up successfully. Closes the input stream.
- *
- * Expected format: "Package <package> with result: Success"
- */
- private void assertBackupIsSuccessful(String packageName, InputStream backupNowOutput)
- throws IOException {
- BufferedReader reader =
- new BufferedReader(new InputStreamReader(backupNowOutput, StandardCharsets.UTF_8));
- try {
- String line;
- while ((line = reader.readLine()) != null) {
- if (line.contains(packageName)) {
- String result = line.split(":")[1].trim().toLowerCase();
- if ("success".equals(result)) {
- return;
- }
- }
- }
- fail("Couldn't find package in output or backup wasn't successful");
- } finally {
- StreamUtil.drainAndClose(reader);
- }
- }
-
- /**
- * Executes "bmgr restore <token> <packageName>" and returns an {@link InputStream} for its
- * output.
- */
- private InputStream restore(String token, String packageName) throws IOException {
- return executeShellCommand(String.format("bmgr restore %s %s", token, packageName));
- }
-
- /**
- * Executes "bmgr --user <id> restore <token> <packageName>" and returns an {@link InputStream}
- * for its output.
- */
- private InputStream restoreForUser(String token, String packageName, int userId)
- throws IOException {
- return executeShellCommand(
- String.format("bmgr --user %d restore %s %s", userId, token, packageName));
- }
-
- /**
- * Parses the output of "bmgr restore" command and checks that the package under test
- * was restored successfully. Closes the input stream.
- *
- * Expected format: "restoreFinished: 0"
- */
- private void assertRestoreIsSuccessful(InputStream restoreOutput) throws IOException {
- BufferedReader reader =
- new BufferedReader(new InputStreamReader(restoreOutput, StandardCharsets.UTF_8));
- try {
- String line;
- while ((line = reader.readLine()) != null) {
- if (line.contains("restoreFinished: 0")) {
- return;
- }
- }
- fail("Restore not successful");
- } finally {
- StreamUtil.drainAndClose(reader);
- }
- }
-
- /**
- * Execute shell command and return output from this command.
- */
- public String executeShellCommandAndReturnOutput(String command) throws IOException {
- InputStream in = executeShellCommand(command);
- BufferedReader br = new BufferedReader(
- new InputStreamReader(in, StandardCharsets.UTF_8));
- String str;
- StringBuilder out = new StringBuilder();
- while ((str = br.readLine()) != null) {
- out.append(str).append("\n");
- }
- return out.toString();
- }
-
- // Copied over from BackupQuotaTest
- public boolean enableBackup(boolean enable) throws Exception {
- boolean previouslyEnabled;
- String output = getLineString(executeShellCommand("bmgr enabled"));
- Matcher matcher = BACKUP_MANAGER_CURRENTLY_ENABLE_STATUS_PATTERN.matcher(output.trim());
- if (matcher.find()) {
- previouslyEnabled = "enabled".equals(matcher.group(1));
- } else {
- throw new RuntimeException("non-parsable output setting bmgr enabled: " + output);
- }
-
- executeShellCommand("bmgr enable " + enable);
- return previouslyEnabled;
- }
-
- /**
- * Execute shell command "bmgr --user <id> enable <enable> and return previous enabled state.
- */
- public boolean enableBackupForUser(boolean enable, int userId) throws IOException {
- boolean previouslyEnabled = isBackupEnabledForUser(userId);
- executeShellCommand(String.format("bmgr --user %d enable %b", userId, enable));
- return previouslyEnabled;
- }
-
- /** Execute shell command "bmgr --user <id> activate <activate>." */
- public boolean activateBackupForUser(boolean activate, int userId) throws IOException {
- boolean previouslyActivated = isBackupActivatedForUser(userId);
- executeShellCommandSync(String.format("bmgr --user %d activate %b", userId, activate));
- return previouslyActivated;
- }
-
- /**
- * Executes shell command "bmgr --user <id> activated" and returns if backup is activated for
- * the user {@code userId}.
- */
- public boolean isBackupActivatedForUser(int userId) throws IOException {
- return getShellCommandOutput(String.format("bmgr --user %d activated", userId))
- .contains("currently activated");
- }
-
- private String getLineString(InputStream inputStream) throws IOException {
- BufferedReader reader =
- new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
- String str;
- try {
- str = reader.readLine();
- } finally {
- StreamUtil.drainAndClose(reader);
- }
- return str;
- }
-
- public void waitForBackupInitialization() throws IOException {
- long tryUntilNanos = System.nanoTime()
- + TimeUnit.SECONDS.toNanos(BACKUP_PROVISIONING_TIMEOUT_SECONDS);
- while (System.nanoTime() < tryUntilNanos) {
- String output = getLineString(executeShellCommand("dumpsys backup"));
- if (output.matches(MATCH_LINE_BACKUP_MANAGER_IS_NOT_PENDING_INIT)) {
- return;
- }
- try {
- Thread.sleep(TimeUnit.SECONDS.toMillis(BACKUP_PROVISIONING_POLL_INTERVAL_SECONDS));
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- break;
- }
- }
- throw new IOException("Timed out waiting for backup initialization");
- }
-
- public void waitUntilBackupServiceIsRunning(int userId)
- throws IOException, InterruptedException {
- waitUntilBackupServiceIsRunning(userId, BACKUP_SERVICE_INIT_TIMEOUT_SECS);
- }
-
- @VisibleForTesting
- void waitUntilBackupServiceIsRunning(int userId, long timeout)
- throws IOException, InterruptedException {
- CommonTestUtils.waitUntil(
- "Backup Manager init timed out",
- timeout,
- () -> {
- String output = getLineString(executeShellCommand("dumpsys backup users"));
- return output.matches(
- "Backup Manager is running for users:.* " + userId + "( .*)?");
- });
- }
-
- /**
- * Executes shell command "bmgr --user <id> list transports" and returns {@code true} if the
- * user has the {@code transport} available.
- */
- public boolean userHasBackupTransport(String transport, int userId) throws IOException {
- String output =
- getLineString(
- executeShellCommand(
- String.format("bmgr --user %d list transports", userId)));
- for (String t : output.split("\n")) {
- // Parse out the '*' character used to denote the selected transport.
- t = t.replace("*", "").trim();
- if (transport.equals(t)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Executes shell command "bmgr --user <id> transport <transport>" and returns the old
- * transport.
- */
- public String setBackupTransportForUser(String transport, int userId) throws IOException {
- String output =
- executeShellCommandAndReturnOutput(
- String.format("bmgr --user %d transport %s", userId, transport));
- Pattern pattern = Pattern.compile("\\(formerly (.*)\\)$");
- Matcher matcher = pattern.matcher(output);
- if (matcher.find()) {
- return matcher.group(1);
- } else {
- throw new RuntimeException("Non-parsable output setting bmgr transport: " + output);
- }
- }
-}
-
diff --git a/common/util/src/com/android/compatibility/common/util/BusinessLogic.java b/common/util/src/com/android/compatibility/common/util/BusinessLogic.java
deleted file mode 100644
index f20f43e..0000000
--- a/common/util/src/com/android/compatibility/common/util/BusinessLogic.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.util;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.junit.AssumptionViolatedException;
-
-/**
- * Helper and constants accessible to host and device components that enable Business Logic
- * configuration
- */
-public class BusinessLogic {
-
- // Device location to which business logic data is pushed
- public static final String DEVICE_FILE = "/sdcard/bl";
-
- /* A map from testcase name to the business logic rules for the test case */
- protected Map<String, List<BusinessLogicRulesList>> mRules;
- /* Feature flag determining if device specific tests are executed. */
- public boolean mConditionalTestsEnabled;
- private AuthenticationStatusEnum mAuthenticationStatus = AuthenticationStatusEnum.UNKNOWN;
-
- // A Date denoting the time of request from the business logic service
- protected Date mTimestamp;
-
- // A list of regexes triggering log redaction
- protected List<String> mRedactionRegexes = new ArrayList<>();
-
- /**
- * Determines whether business logic exists for a given test name
- * @param testName the name of the test case, prefixed by fully qualified class name, then '#'.
- * For example, "com.android.foo.FooTest#testFoo"
- * @return whether business logic exists for this test for this suite
- */
- public boolean hasLogicFor(String testName) {
- List<BusinessLogicRulesList> rulesLists = mRules.get(testName);
- return rulesLists != null && !rulesLists.isEmpty();
- }
-
- /**
- * Return whether multiple rule lists exist in the BusinessLogic for this test name.
- */
- private boolean hasLogicsFor(String testName) {
- List<BusinessLogicRulesList> rulesLists = mRules.get(testName);
- return rulesLists != null && rulesLists.size() > 1;
- }
-
- /**
- * Apply business logic for the given test.
- * @param testName the name of the test case, prefixed by fully qualified class name, then '#'.
- * For example, "com.android.foo.FooTest#testFoo"
- * @param executor a {@link BusinessLogicExecutor}
- */
- public void applyLogicFor(String testName, BusinessLogicExecutor executor) {
- if (!hasLogicFor(testName)) {
- return;
- }
- if (hasLogicsFor(testName)) {
- applyLogicsFor(testName, executor); // handle this special case separately
- return;
- }
- // expecting exactly one rules list at this point
- BusinessLogicRulesList rulesList = mRules.get(testName).get(0);
- rulesList.invokeRules(executor);
- }
-
- /**
- * Handle special case in which multiple rule lists exist for the test name provided.
- * Execute each rule list in a sandbox and store an exception for each rule list that
- * triggers failure or skipping for the test.
- * If all rule lists trigger skipping, rethrow AssumptionViolatedException to report a 'skip'
- * for the test as a whole.
- * If one or more rule lists trigger failure, rethrow RuntimeException with a list containing
- * each failure.
- */
- private void applyLogicsFor(String testName, BusinessLogicExecutor executor) {
- Map<String, RuntimeException> failedMap = new HashMap<>();
- Map<String, RuntimeException> skippedMap = new HashMap<>();
- List<BusinessLogicRulesList> rulesLists = mRules.get(testName);
- for (int index = 0; index < rulesLists.size(); index++) {
- BusinessLogicRulesList rulesList = rulesLists.get(index);
- String description = cleanDescription(rulesList.getDescription(), index);
- try {
- rulesList.invokeRules(executor);
- } catch (RuntimeException re) {
- if (AssumptionViolatedException.class.isInstance(re)) {
- skippedMap.put(description, re);
- executor.logInfo("Test %s (%s) skipped for reason: %s", testName, description,
- re.getMessage());
- } else {
- failedMap.put(description, re);
- }
- }
- }
- if (skippedMap.size() == rulesLists.size()) {
- throwAggregatedException(skippedMap, false);
- } else if (failedMap.size() > 0) {
- throwAggregatedException(failedMap, true);
- } // else this test should be reported as a pure pass
- }
-
- /**
- * Helper to aggregate the messages of many {@link RuntimeException}s, and optionally their
- * stack traces, before throwing an exception.
- * @param exceptions a map from description strings to exceptions. The descriptive keySet is
- * used to differentiate which BusinessLogicRulesList caused which exception
- * @param failed whether to trigger failure. When false, throws assumption failure instead, and
- * excludes stack traces from the exception message.
- */
- private static void throwAggregatedException(Map<String, RuntimeException> exceptions,
- boolean failed) {
- Set<String> keySet = exceptions.keySet();
- String[] descriptions = keySet.toArray(new String[keySet.size()]);
- StringBuilder msg = new StringBuilder("");
- msg.append(String.format("Test %s for cases: ", (failed) ? "failed" : "skipped"));
- msg.append(Arrays.toString(descriptions));
- msg.append("\nReasons include:");
- for (String description : descriptions) {
- RuntimeException re = exceptions.get(description);
- msg.append(String.format("\nMessage [%s]: %s", description, re.getMessage()));
- if (failed) {
- StringWriter sw = new StringWriter();
- re.printStackTrace(new PrintWriter(sw));
- msg.append(String.format("\nStack Trace: %s", sw.toString()));
- }
- }
- if (failed) {
- throw new RuntimeException(msg.toString());
- } else {
- throw new AssumptionViolatedException(msg.toString());
- }
- }
-
- /**
- * Helper method to generate a meaningful description in case the provided description is null
- * or empty. In this case, returns a string representation of the index provided.
- */
- private String cleanDescription(String description, int index) {
- return (description == null || description.length() == 0)
- ? Integer.toString(index)
- : description;
- }
-
- public void setAuthenticationStatus(String authenticationStatus) {
- try {
- mAuthenticationStatus = Enum.valueOf(AuthenticationStatusEnum.class,
- authenticationStatus);
- } catch (IllegalArgumentException e) {
- // Invalid value, set to unknown
- mAuthenticationStatus = AuthenticationStatusEnum.UNKNOWN;
- }
- }
-
- public boolean isAuthorized() {
- return AuthenticationStatusEnum.AUTHORIZED.equals(mAuthenticationStatus);
- }
-
- public Date getTimestamp() {
- return mTimestamp;
- }
-
- public List<String> getRedactionRegexes() {
- return new ArrayList<String>(mRedactionRegexes);
- }
-
- /**
- * Builds a user readable string tha explains the authentication status and the effect on tests
- * which require authentication to execute.
- */
- public String getAuthenticationStatusMessage() {
- switch (mAuthenticationStatus) {
- case AUTHORIZED:
- return "Authorized";
- case NOT_AUTHENTICATED:
- return "authorization failed, please ensure the service account key is "
- + "properly installed.";
- case NOT_AUTHORIZED:
- return "service account is not authorized to access information for this device. "
- + "Please verify device properties are set correctly and account "
- + "permissions are configured to the Business Logic Api.";
- case NO_DEVICE_INFO:
- return "unable to read device info files. Retry without --skip-device-info flag.";
- default:
- return "something went wrong, please try again.";
- }
- }
-
- /**
- * A list of BusinessLogicRules, wrapped with an optional description to differentiate rule
- * lists that apply to the same test.
- */
- protected static class BusinessLogicRulesList {
-
- /* Stored description and rules */
- protected List<BusinessLogicRule> mRulesList;
- protected String mDescription;
-
- public BusinessLogicRulesList(List<BusinessLogicRule> rulesList) {
- mRulesList = rulesList;
- }
-
- public BusinessLogicRulesList(List<BusinessLogicRule> rulesList, String description) {
- mRulesList = rulesList;
- mDescription = description;
- }
-
- public String getDescription() {
- return mDescription;
- }
-
- public List<BusinessLogicRule> getRules() {
- return mRulesList;
- }
-
- public void invokeRules(BusinessLogicExecutor executor) {
- for (BusinessLogicRule rule : mRulesList) {
- // Check conditions
- if (rule.invokeConditions(executor)) {
- rule.invokeActions(executor);
- }
- }
- }
- }
-
- /**
- * Nested class representing an Business Logic Rule. Stores a collection of conditions
- * and actions for later invokation.
- */
- protected static class BusinessLogicRule {
-
- /* Stored conditions and actions */
- protected List<BusinessLogicRuleCondition> mConditions;
- protected List<BusinessLogicRuleAction> mActions;
-
- public BusinessLogicRule(List<BusinessLogicRuleCondition> conditions,
- List<BusinessLogicRuleAction> actions) {
- mConditions = conditions;
- mActions = actions;
- }
-
- /**
- * Method that invokes all Business Logic conditions for this rule, and returns true
- * if all conditions evaluate to true.
- */
- public boolean invokeConditions(BusinessLogicExecutor executor) {
- for (BusinessLogicRuleCondition condition : mConditions) {
- if (!condition.invoke(executor)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Method that invokes all Business Logic actions for this rule
- */
- public void invokeActions(BusinessLogicExecutor executor) {
- for (BusinessLogicRuleAction action : mActions) {
- action.invoke(executor);
- }
- }
- }
-
- /**
- * Nested class representing an Business Logic Rule Condition. Stores the name of a method
- * to invoke, as well as String args to use during invokation.
- */
- protected static class BusinessLogicRuleCondition {
-
- /* Stored method name and String args */
- protected String mMethodName;
- protected List<String> mMethodArgs;
- /* Whether or not the boolean result of this condition should be reversed */
- protected boolean mNegated;
-
-
- public BusinessLogicRuleCondition(String methodName, List<String> methodArgs,
- boolean negated) {
- mMethodName = methodName;
- mMethodArgs = methodArgs;
- mNegated = negated;
- }
-
- /**
- * Invoke this Business Logic condition with an executor.
- */
- public boolean invoke(BusinessLogicExecutor executor) {
- // XOR the negated boolean with the return value of the method
- return (mNegated != executor.executeCondition(mMethodName,
- mMethodArgs.toArray(new String[mMethodArgs.size()])));
- }
- }
-
- /**
- * Nested class representing an Business Logic Rule Action. Stores the name of a method
- * to invoke, as well as String args to use during invokation.
- */
- protected static class BusinessLogicRuleAction {
-
- /* Stored method name and String args */
- protected String mMethodName;
- protected List<String> mMethodArgs;
-
- public BusinessLogicRuleAction(String methodName, List<String> methodArgs) {
- mMethodName = methodName;
- mMethodArgs = methodArgs;
- }
-
- /**
- * Invoke this Business Logic action with an executor.
- */
- public void invoke(BusinessLogicExecutor executor) {
- executor.executeAction(mMethodName,
- mMethodArgs.toArray(new String[mMethodArgs.size()]));
- }
- }
-
- /**
- * Nested enum of the possible authentication statuses.
- */
- protected enum AuthenticationStatusEnum {
- UNKNOWN,
- NOT_AUTHENTICATED,
- NOT_AUTHORIZED,
- AUTHORIZED,
- NO_DEVICE_INFO
- }
-
-}
diff --git a/common/util/src/com/android/compatibility/common/util/BusinessLogicExecutor.java b/common/util/src/com/android/compatibility/common/util/BusinessLogicExecutor.java
deleted file mode 100644
index 857ea15..0000000
--- a/common/util/src/com/android/compatibility/common/util/BusinessLogicExecutor.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.util;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.junit.AssumptionViolatedException;
-
-/**
- * Resolves methods provided by the BusinessLogicService and invokes them
- */
-public abstract class BusinessLogicExecutor {
-
- protected static final String LOG_TAG = "BusinessLogicExecutor";
-
- /** String representations of the String class and String[] class */
- protected static final String STRING_CLASS = "java.lang.String";
- protected static final String STRING_ARRAY_CLASS = "[Ljava.lang.String;";
-
- private static final String REDACTED_PLACEHOLDER = "[redacted]";
- /* List of regexes indicating a method arg should be redacted in the logs */
- protected List<String> mRedactionRegexes = new ArrayList<>();
-
- /**
- * Execute a business logic condition.
- * @param method the name of the method to invoke. Must include fully qualified name of the
- * enclosing class, followed by '.', followed by the name of the method
- * @param args the string arguments to supply to the method
- * @return the return value of the method invoked
- * @throws RuntimeException when failing to resolve or invoke the condition method
- */
- public boolean executeCondition(String method, String... args) {
- logDebug("Executing condition: %s", formatExecutionString(method, args));
- try {
- return (Boolean) invokeMethod(method, args);
- } catch (ClassNotFoundException | IllegalAccessException | InstantiationException |
- InvocationTargetException | NoSuchMethodException e) {
- throw new RuntimeException(String.format(
- "BusinessLogic: Failed to invoke condition method %s with args: %s", method,
- Arrays.toString(args)), e);
- }
- }
-
- /**
- * Execute a business logic action.
- * @param method the name of the method to invoke. Must include fully qualified name of the
- * enclosing class, followed by '.', followed by the name of the method
- * @param args the string arguments to supply to the method
- * @throws RuntimeException when failing to resolve or invoke the action method
- */
- public void executeAction(String method, String... args) {
- logDebug("Executing action: %s", formatExecutionString(method, args));
- try {
- invokeMethod(method, args);
- } catch (ClassNotFoundException | IllegalAccessException | InstantiationException |
- NoSuchMethodException e) {
- throw new RuntimeException(String.format(
- "BusinessLogic: Failed to invoke action method %s with args: %s", method,
- Arrays.toString(args)), e);
- } catch (InvocationTargetException e) {
- // This action throws an exception, so throw the original exception (e.g.
- // AssertionFailedError) for a more readable stacktrace.
- Throwable t = e.getCause();
- if (AssumptionViolatedException.class.isInstance(t)) {
- // This is an assumption failure (registered as a "pass") so don't wrap this
- // throwable in a RuntimeException
- throw (AssumptionViolatedException) t;
- } else {
- RuntimeException re = new RuntimeException(t.getMessage(), t.getCause());
- re.setStackTrace(t.getStackTrace());
- throw re;
- }
- }
- }
-
- /**
- * Format invokation information as "method(args[0], args[1], ...)".
- */
- protected abstract String formatExecutionString(String method, String... args);
-
- /** Substitute sensitive information with REDACTED_PLACEHOLDER if necessary. */
- protected String[] formatArgs(String[] args) {
- List<String> formattedArgs = new ArrayList<>();
- for (String arg : args) {
- formattedArgs.add(formatArg(arg));
- }
- return formattedArgs.toArray(new String[0]);
- }
-
- private String formatArg(String arg) {
- for (String regex : mRedactionRegexes) {
- Pattern pattern = Pattern.compile(regex);
- Matcher matcher = pattern.matcher(arg);
- if (matcher.find()) {
- return REDACTED_PLACEHOLDER;
- }
- }
- return arg;
- }
-
- /**
- * Execute a business logic method.
- * @param method the name of the method to invoke. Must include fully qualified name of the
- * enclosing class, followed by '.', followed by the name of the method
- * @param args the string arguments to supply to the method
- * @return the return value of the method invoked (type Boolean if method is a condition)
- * @throws RuntimeException when failing to resolve or invoke the method
- */
- protected Object invokeMethod(String method, String... args) throws ClassNotFoundException,
- IllegalAccessException, InstantiationException, InvocationTargetException,
- NoSuchMethodException {
- // Method names served by the BusinessLogic service should assume format
- // classname.methodName, but also handle format classname#methodName since test names use
- // this format
- int index = (method.indexOf('#') == -1) ? method.lastIndexOf('.') : method.indexOf('#');
- if (index == -1) {
- throw new RuntimeException(String.format("BusinessLogic: invalid method name "
- + "\"%s\". Method string must include fully qualified class name. "
- + "For example, \"com.android.packagename.ClassName.methodName\".", method));
- }
- String className = method.substring(0, index);
- Class cls = Class.forName(className);
- Object obj = cls.getDeclaredConstructor().newInstance();
- if (getTestObject() != null && cls.isAssignableFrom(getTestObject().getClass())) {
- // The given method is a member of the test class, use the known test class instance
- obj = getTestObject();
- }
- ResolvedMethod rm = getResolvedMethod(cls, method.substring(index + 1), args);
- return rm.invoke(obj);
- }
-
- /**
- * Log information with whichever logging mechanism is available to the instance. This varies
- * from host-side to device-side, so implementations are left to subclasses.
- * See {@link String.format(String, Object...)} for parameter information.
- */
- public abstract void logInfo(String format, Object... args);
-
- /**
- * Log debugging information to the host or device logs (depending on implementation).
- * See {@link String.format(String, Object...)} for parameter information.
- */
- public abstract void logDebug(String format, Object... args);
-
- /**
- * Get the test object. This method is left abstract, since non-abstract subclasses will set
- * the test object in the constructor.
- * @return the test case instance
- */
- protected abstract Object getTestObject();
-
- /**
- * Get the method and list of arguments corresponding to the class, method name, and proposed
- * argument values, in the form of a {@link ResolvedMethod} object. This object stores all
- * information required to successfully invoke the method. getResolvedMethod is left abstract,
- * since argument types differ between device-side (e.g. Context) and host-side
- * (e.g. ITestDevice) implementations of this class.
- * @param cls the Class to which the method belongs
- * @param methodName the name of the method to invoke
- * @param args the string arguments to use when invoking the method
- * @return a {@link ResolvedMethod}
- * @throws ClassNotFoundException
- */
- protected abstract ResolvedMethod getResolvedMethod(Class cls, String methodName,
- String... args) throws ClassNotFoundException;
-
- /**
- * Retrieve all methods within a class that match a given name
- * @param cls the class
- * @param name the method name
- * @return a list of method objects
- */
- protected List<Method> getMethodsWithName(Class cls, String name) {
- List<Method> methodList = new ArrayList<>();
- for (Method m : cls.getMethods()) {
- if (name.equals(m.getName())) {
- methodList.add(m);
- }
- }
- return methodList;
- }
-
- /**
- * Helper class for storing a method object, and a list of arguments to use when invoking the
- * method. The class is also equipped with an "invoke" method for convenience.
- */
- protected static class ResolvedMethod {
- private Method mMethod;
- List<Object> mArgs;
-
- public ResolvedMethod(Method method) {
- mMethod = method;
- mArgs = new ArrayList<>();
- }
-
- /** Add an argument to the argument list for this instance */
- public void addArg(Object arg) {
- mArgs.add(arg);
- }
-
- /** Invoke the stored method with the stored args on a given object */
- public Object invoke(Object instance) throws IllegalAccessException,
- InvocationTargetException {
- return mMethod.invoke(instance, mArgs.toArray());
- }
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/BusinessLogicFactory.java b/common/util/src/com/android/compatibility/common/util/BusinessLogicFactory.java
deleted file mode 100644
index b072413..0000000
--- a/common/util/src/com/android/compatibility/common/util/BusinessLogicFactory.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.util;
-
-import com.android.compatibility.common.util.BusinessLogic.BusinessLogicRule;
-import com.android.compatibility.common.util.BusinessLogic.BusinessLogicRuleAction;
-import com.android.compatibility.common.util.BusinessLogic.BusinessLogicRuleCondition;
-import com.android.compatibility.common.util.BusinessLogic.BusinessLogicRulesList;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Scanner;
-import java.util.TimeZone;
-
-/**
- * Factory for creating a {@link BusinessLogic}
- */
-public class BusinessLogicFactory {
-
- // Name of list object storing test-rules pairs
- private static final String BUSINESS_LOGIC_RULES_LISTS = "businessLogicRulesLists";
- // Name of test name string
- private static final String TEST_NAME = "testName";
- // Name of rules object (one 'rules' object to a single test)
- private static final String BUSINESS_LOGIC_RULES = "businessLogicRules";
- // Name of rule conditions array
- private static final String RULE_CONDITIONS = "ruleConditions";
- // Name of rule actions array
- private static final String RULE_ACTIONS = "ruleActions";
- // Description of a rule list object
- private static final String RULES_LIST_DESCRIPTION = "description";
- // Name of method name string
- private static final String METHOD_NAME = "methodName";
- // Name of method args array of strings
- private static final String METHOD_ARGS = "methodArgs";
- // Name of the field in the response object that stores that the auth status of the request.
- private static final String AUTHENTICATION_STATUS = "authenticationStatus";
- public static final String CONDITIONAL_TESTS_ENABLED = "conditionalTestsEnabled";
- // Name of the timestamp field
- private static final String TIMESTAMP = "timestamp";
- // Date and time pattern for raw timestamp string
- private static final String TIMESTAMP_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
- // Name of the redacted regexes field
- private static final String REDACTION_REGEXES = "redactionRegexes";
-
- /**
- * Create a BusinessLogic instance from a {@link FileInputStream} of business logic data,
- * formatted in JSON. This format is identical to that which is received from the Android
- * Partner business logic service.
- */
- public static BusinessLogic createFromFile(FileInputStream stream) {
- try {
- String businessLogicString = readStream(stream);
- return createBL(businessLogicString);
- } catch (IOException e) {
- throw new RuntimeException("Business Logic failed", e);
- }
- }
-
- /**
- * Create a BusinessLogic instance from a file of business logic data, formatted in JSON.
- * This format is identical to that which is received from the Android Partner business logic
- * service.
- */
- public static BusinessLogic createFromFile(File f) {
- try {
- String businessLogicString = readFile(f);
- return createBL(businessLogicString);
- } catch (IOException e) {
- throw new RuntimeException("Business Logic failed", e);
- }
- }
-
- private static BusinessLogic createBL(String businessLogicString) {
- // Populate the map from testname to business rules for this new BusinessLogic instance
- Map<String, List<BusinessLogicRulesList>> rulesMap = new HashMap<>();
- BusinessLogic bl = new BusinessLogic();
- try {
- JSONObject root = new JSONObject(businessLogicString);
- JSONArray jsonRulesLists = null;
- if (root.has(AUTHENTICATION_STATUS)){
- String authStatus = root.getString(AUTHENTICATION_STATUS);
- bl.setAuthenticationStatus(authStatus);
- }
- if (root.has(CONDITIONAL_TESTS_ENABLED)){
- boolean enabled = root.getBoolean(CONDITIONAL_TESTS_ENABLED);
- bl.mConditionalTestsEnabled = enabled;
- }
- if (root.has(TIMESTAMP)) {
- bl.mTimestamp = parseTimestamp(root.getString(TIMESTAMP));
- }
- if (root.has(REDACTION_REGEXES)) {
- bl.mRedactionRegexes = parseRedactionRegexes(root.getJSONArray(REDACTION_REGEXES));
- }
- try {
- jsonRulesLists = root.getJSONArray(BUSINESS_LOGIC_RULES_LISTS);
- } catch (JSONException e) {
- bl.mRules = rulesMap;
- return bl; // no rules defined for this suite, leave internal map empty
- }
- for (int i = 0; i < jsonRulesLists.length(); i++) {
- JSONObject jsonRulesList = jsonRulesLists.getJSONObject(i);
- String testName = jsonRulesList.getString(TEST_NAME);
- List<BusinessLogicRulesList> testRulesLists = rulesMap.get(testName);
- if (testRulesLists == null) {
- testRulesLists = new ArrayList<>();
- }
- testRulesLists.add(extractRulesList(jsonRulesList));
- rulesMap.put(testName, testRulesLists);
- }
- } catch (JSONException e) {
- throw new RuntimeException("Business Logic failed", e);
- }
- // Return business logic
- bl.mRules = rulesMap;
- return bl;
- }
-
- private static List<String> parseRedactionRegexes(JSONArray redactionRegexesJSONArray)
- throws JSONException {
- List<String> redactionRegexes = new ArrayList<>();
- for (int i = 0; i < redactionRegexesJSONArray.length(); i++) {
- redactionRegexes.add(redactionRegexesJSONArray.getString(i));
- }
- return redactionRegexes;
- }
-
- /* Extract a BusinessLogicRulesList from the representative JSON object */
- private static BusinessLogicRulesList extractRulesList(JSONObject rulesListJSONObject)
- throws JSONException {
- // First, parse the description for this rule list object, if one exists
- String description = null;
- try {
- description = rulesListJSONObject.getString(RULES_LIST_DESCRIPTION);
- } catch (JSONException e) { /* no description set, leave null */}
-
- // Next, get the list of rules
- List<BusinessLogicRule> rules = new ArrayList<>();
- JSONArray rulesJSONArray = null;
- try {
- rulesJSONArray = rulesListJSONObject.getJSONArray(BUSINESS_LOGIC_RULES);
- } catch (JSONException e) {
- // no rules defined for this test case, return new, rule-less BusinessLogicRulesList
- return new BusinessLogicRulesList(rules, description);
- }
- for (int j = 0; j < rulesJSONArray.length(); j++) {
- JSONObject ruleJSONObject = rulesJSONArray.getJSONObject(j);
- // Build conditions list
- List<BusinessLogicRuleCondition> ruleConditions =
- extractRuleConditionList(ruleJSONObject);
- // Build actions list
- List<BusinessLogicRuleAction> ruleActions =
- extractRuleActionList(ruleJSONObject);
- rules.add(new BusinessLogicRule(ruleConditions, ruleActions));
- }
- return new BusinessLogicRulesList(rules, description);
- }
-
- /* Extract all BusinessLogicRuleConditions from a JSON business logic rule */
- private static List<BusinessLogicRuleCondition> extractRuleConditionList(
- JSONObject ruleJSONObject) throws JSONException {
- List<BusinessLogicRuleCondition> ruleConditions = new ArrayList<>();
- // Rules do not require a condition, return empty list if no condition is found
- JSONArray ruleConditionsJSONArray = null;
- try {
- ruleConditionsJSONArray = ruleJSONObject.getJSONArray(RULE_CONDITIONS);
- } catch (JSONException e) {
- return ruleConditions; // no conditions for this rule, apply in all cases
- }
- for (int i = 0; i < ruleConditionsJSONArray.length(); i++) {
- JSONObject ruleConditionJSONObject = ruleConditionsJSONArray.getJSONObject(i);
- String methodName = ruleConditionJSONObject.getString(METHOD_NAME);
- boolean negated = false;
- if (methodName.startsWith("!")) {
- methodName = methodName.substring(1); // remove negation from method name string
- negated = true; // change "negated" property to true
- }
- List<String> methodArgs = new ArrayList<>();
- JSONArray methodArgsJSONArray = null;
- try {
- methodArgsJSONArray = ruleConditionJSONObject.getJSONArray(METHOD_ARGS);
- } catch (JSONException e) {
- // No method args for this rule condition, add rule condition with empty args list
- ruleConditions.add(new BusinessLogicRuleCondition(methodName, methodArgs, negated));
- continue;
- }
- for (int j = 0; j < methodArgsJSONArray.length(); j++) {
- methodArgs.add(methodArgsJSONArray.getString(j));
- }
- ruleConditions.add(new BusinessLogicRuleCondition(methodName, methodArgs, negated));
- }
- return ruleConditions;
- }
-
- /* Extract all BusinessLogicRuleActions from a JSON business logic rule */
- private static List<BusinessLogicRuleAction> extractRuleActionList(JSONObject ruleJSONObject)
- throws JSONException {
- List<BusinessLogicRuleAction> ruleActions = new ArrayList<>();
- // All rules require at least one action, line below throws JSONException if not
- JSONArray ruleActionsJSONArray = ruleJSONObject.getJSONArray(RULE_ACTIONS);
- for (int i = 0; i < ruleActionsJSONArray.length(); i++) {
- JSONObject ruleActionJSONObject = ruleActionsJSONArray.getJSONObject(i);
- String methodName = ruleActionJSONObject.getString(METHOD_NAME);
- List<String> methodArgs = new ArrayList<>();
- JSONArray methodArgsJSONArray = null;
- try {
- methodArgsJSONArray = ruleActionJSONObject.getJSONArray(METHOD_ARGS);
- } catch (JSONException e) {
- // No method args for this rule action, add rule action with empty args list
- ruleActions.add(new BusinessLogicRuleAction(methodName, methodArgs));
- continue;
- }
- for (int j = 0; j < methodArgsJSONArray.length(); j++) {
- methodArgs.add(methodArgsJSONArray.getString(j));
- }
- ruleActions.add(new BusinessLogicRuleAction(methodName, methodArgs));
- }
- return ruleActions;
- }
-
- /* Pare a timestamp string with format TIMESTAMP_PATTERN to a date object */
- private static Date parseTimestamp(String timestamp) {
- SimpleDateFormat format = new SimpleDateFormat(TIMESTAMP_PATTERN);
- format.setTimeZone(TimeZone.getTimeZone("UTC"));
- try {
- return format.parse(timestamp);
- } catch (ParseException e) {
- return null;
- }
- }
-
- /* Extract string from file */
- private static String readFile(File f) throws IOException {
- StringBuilder sb = new StringBuilder((int) f.length());
- String lineSeparator = System.getProperty("line.separator");
- try (Scanner scanner = new Scanner(f)) {
- while(scanner.hasNextLine()) {
- sb.append(scanner.nextLine() + lineSeparator);
- }
- return sb.toString();
- }
- }
-
- /** Extract string from stream */
- private static String readStream(FileInputStream stream) throws IOException {
- int irChar = -1;
- StringBuilder builder = new StringBuilder();
- try (Reader ir = new BufferedReader(new InputStreamReader(stream))) {
- while ((irChar = ir.read()) != -1) {
- builder.append((char) irChar);
- }
- }
- return builder.toString();
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/CaseResult.java b/common/util/src/com/android/compatibility/common/util/CaseResult.java
deleted file mode 100644
index a7c3318..0000000
--- a/common/util/src/com/android/compatibility/common/util/CaseResult.java
+++ /dev/null
@@ -1,131 +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.compatibility.common.util;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Data structure for a Compatibility test case result.
- */
-public class CaseResult implements ICaseResult {
-
- private String mName;
-
- private Map<String, ITestResult> mResults = new HashMap<>();
-
- /**
- * Creates a {@link CaseResult} for the given name, eg <package-name>.<class-name>
- */
- public CaseResult(String name) {
- mName = name;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getName() {
- return mName;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ITestResult getOrCreateResult(String testName) {
- ITestResult result = mResults.get(testName);
- if (result == null) {
- result = new TestResult(this, testName);
- mResults.put(testName, result);
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ITestResult getResult(String testName) {
- return mResults.get(testName);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<ITestResult> getResults(TestStatus status) {
- List<ITestResult> results = new ArrayList<>();
- for (ITestResult result : mResults.values()) {
- if (result.getResultStatus() == status) {
- results.add(result);
- }
- }
- return results;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<ITestResult> getResults() {
- ArrayList<ITestResult> results = new ArrayList<>(mResults.values());
- Collections.sort(results);
- return results;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int countResults(TestStatus status) {
- int total = 0;
- for (ITestResult result : mResults.values()) {
- if (result.getResultStatus() == status) {
- total++;
- }
- }
- return total;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int compareTo(ICaseResult another) {
- return getName().compareTo(another.getName());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void mergeFrom(ICaseResult otherCaseResult) {
- if (!otherCaseResult.getName().equals(getName())) {
- throw new IllegalArgumentException(String.format(
- "Cannot merge case result with mismatched name. Expected %s, Found %s",
- otherCaseResult.getName(), getName()));
- }
-
- for (ITestResult otherTestResult : otherCaseResult.getResults()) {
- mResults.put(otherTestResult.getName(), otherTestResult);
- }
- }
-
-}
diff --git a/common/util/src/com/android/compatibility/common/util/CddTest.java b/common/util/src/com/android/compatibility/common/util/CddTest.java
deleted file mode 100644
index 34ee663..0000000
--- a/common/util/src/com/android/compatibility/common/util/CddTest.java
+++ /dev/null
@@ -1,31 +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.compatibility.common.util;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marks the type of test with purpose of asserting CDD requirements.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD, ElementType.TYPE})
-public @interface CddTest {
- String requirement();
-}
diff --git a/common/util/src/com/android/compatibility/common/util/ChecksumReporter.java b/common/util/src/com/android/compatibility/common/util/ChecksumReporter.java
deleted file mode 100644
index ce39f38..0000000
--- a/common/util/src/com/android/compatibility/common/util/ChecksumReporter.java
+++ /dev/null
@@ -1,393 +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.compatibility.common.util;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Joiner;
-import com.google.common.base.Strings;
-import com.google.common.hash.BloomFilter;
-import com.google.common.hash.Funnels;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.security.DigestException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Arrays;
-import java.util.HashMap;
-
-/***
- * Calculate and store checksum values for files and test results
- */
-public final class ChecksumReporter implements Serializable {
-
- public static final String NAME = "checksum.data";
- public static final String PREV_NAME = "checksum.previous.data";
-
- private static final double DEFAULT_FPP = 0.05;
- private static final String SEPARATOR = "/";
- private static final String ID_SEPARATOR = "@";
- private static final String NAME_SEPARATOR = ".";
-
- private static final short CURRENT_VERSION = 1;
- // Serialized format Id (ie magic number) used to identify serialized data.
- static final short SERIALIZED_FORMAT_CODE = 650;
-
- private final BloomFilter<CharSequence> mResultChecksum;
- private final HashMap<String, byte[]> mFileChecksum;
- private final short mVersion;
-
- /***
- * Calculate checksum of test results and files in result directory and write to disk
- * @param dir test results directory
- * @param result test results
- * @return true if successful, false if unable to calculate or store the checksum
- */
- public static boolean tryCreateChecksum(File dir, IInvocationResult result) {
- try {
- int totalCount = countTestResults(result);
- ChecksumReporter checksumReporter =
- new ChecksumReporter(totalCount, DEFAULT_FPP, CURRENT_VERSION);
- checksumReporter.addInvocation(result);
- checksumReporter.addDirectory(dir);
- checksumReporter.saveToFile(dir);
- } catch (Exception e) {
- return false;
- }
- return true;
- }
-
- /***
- * Create Checksum Reporter from data saved on disk
- * @param directory
- * @return
- * @throws ChecksumValidationException
- */
- public static ChecksumReporter load(File directory) throws ChecksumValidationException {
- ChecksumReporter reporter = new ChecksumReporter(directory);
- if (reporter.getCapacity() > 1.1) {
- throw new ChecksumValidationException("Capacity exceeded.");
- }
- return reporter;
- }
-
- /***
- * Deserialize checksum from file
- * @param directory the parent directory containing the checksum file
- * @throws ChecksumValidationException
- */
- public ChecksumReporter(File directory) throws ChecksumValidationException {
- File file = new File(directory, ChecksumReporter.NAME);
- try (FileInputStream fileStream = new FileInputStream(file);
- InputStream outputStream = new BufferedInputStream(fileStream);
- ObjectInput objectInput = new ObjectInputStream(outputStream)) {
- short magicNumber = objectInput.readShort();
- switch (magicNumber) {
- case SERIALIZED_FORMAT_CODE:
- mVersion = objectInput.readShort();
- mResultChecksum = (BloomFilter<CharSequence>) objectInput.readObject();
- mFileChecksum = (HashMap<String, byte[]>) objectInput.readObject();
- break;
- default:
- throw new ChecksumValidationException("Unknown format of serialized data.");
- }
- } catch (Exception e) {
- throw new ChecksumValidationException("Unable to load checksum from file", e);
- }
- if (mVersion > CURRENT_VERSION) {
- throw new ChecksumValidationException(
- "File contains a newer version of ChecksumReporter");
- }
- }
-
- /***
- * Create new instance of ChecksumReporter
- * @param testCount the number of test results that will be stored
- * @param fpp the false positive percentage for result lookup misses
- */
- public ChecksumReporter(int testCount, double fpp, short version) {
- mResultChecksum = BloomFilter.create(Funnels.unencodedCharsFunnel(),
- testCount, fpp);
- mFileChecksum = new HashMap<>();
- mVersion = version;
- }
-
- /***
- * Add each test result from each module and test case
- */
- public void addInvocation(IInvocationResult invocationResult) {
- for (IModuleResult module : invocationResult.getModules()) {
- String buildFingerprint = invocationResult.getBuildFingerprint();
- addModuleResult(module, buildFingerprint);
- for (ICaseResult caseResult : module.getResults()) {
- for (ITestResult testResult : caseResult.getResults()) {
- addTestResult(testResult, module, buildFingerprint);
- }
- }
- }
- }
-
- /***
- * Calculate CRC of file and store the result
- * @param file crc calculated on this file
- * @param path part of the key to identify the files crc
- */
- public void addFile(File file, String path) {
- byte[] crc;
- try {
- crc = calculateFileChecksum(file);
- } catch (ChecksumValidationException e) {
- crc = new byte[0];
- }
- String key = path + SEPARATOR + file.getName();
- mFileChecksum.put(key, crc);
- }
-
- @VisibleForTesting
- public boolean containsFile(File file, String path) {
- String key = path + SEPARATOR + file.getName();
- if (mFileChecksum.containsKey(key))
- {
- try {
- byte[] crc = calculateFileChecksum(file);
- return Arrays.equals(mFileChecksum.get(key), crc);
- } catch (ChecksumValidationException e) {
- return false;
- }
- }
- return false;
- }
-
- /***
- * Adds all child files recursively through all sub directories
- * @param directory target that is deeply searched for files
- */
- public void addDirectory(File directory) {
- addDirectory(directory, directory.getName());
- }
-
- /***
- * @param path the relative path to the current directory from the base directory
- */
- private void addDirectory(File directory, String path) {
- for(String childName : directory.list()) {
- File child = new File(directory, childName);
- if (child.isDirectory()) {
- addDirectory(child, path + SEPARATOR + child.getName());
- } else {
- addFile(child, path);
- }
- }
- }
-
- /***
- * Calculate checksum of test result and store the value
- * @param testResult the target of the checksum
- * @param moduleResult the module that contains the test result
- * @param buildFingerprint the fingerprint the test execution is running against
- */
- public void addTestResult(
- ITestResult testResult, IModuleResult moduleResult, String buildFingerprint) {
-
- String signature = generateTestResultSignature(testResult, moduleResult, buildFingerprint);
- mResultChecksum.put(signature);
- }
-
- @VisibleForTesting
- public boolean containsTestResult(
- ITestResult testResult, IModuleResult moduleResult, String buildFingerprint) {
-
- String signature = generateTestResultSignature(testResult, moduleResult, buildFingerprint);
- return mResultChecksum.mightContain(signature);
- }
-
- /***
- * Calculate checksm of module result and store value
- * @param moduleResult the target of the checksum
- * @param buildFingerprint the fingerprint the test execution is running against
- */
- public void addModuleResult(IModuleResult moduleResult, String buildFingerprint) {
- mResultChecksum.put(
- generateModuleResultSignature(moduleResult, buildFingerprint));
- mResultChecksum.put(
- generateModuleSummarySignature(moduleResult, buildFingerprint));
- }
-
- @VisibleForTesting
- public Boolean containsModuleResult(IModuleResult moduleResult, String buildFingerprint) {
- return mResultChecksum.mightContain(
- generateModuleResultSignature(moduleResult, buildFingerprint));
- }
-
- /***
- * Write the checksum data to disk.
- * Overwrites existing file
- * @param directory
- * @throws IOException
- */
- public void saveToFile(File directory) throws IOException {
- File file = new File(directory, NAME);
-
- try (FileOutputStream fileStream = new FileOutputStream(file, false);
- OutputStream outputStream = new BufferedOutputStream(fileStream);
- ObjectOutput objectOutput = new ObjectOutputStream(outputStream)) {
- objectOutput.writeShort(SERIALIZED_FORMAT_CODE);
- objectOutput.writeShort(mVersion);
- objectOutput.writeObject(mResultChecksum);
- objectOutput.writeObject(mFileChecksum);
- }
- }
-
- @VisibleForTesting
- double getCapacity() {
- // If default FPP changes:
- // increment the CURRENT_VERSION and set the denominator based on this.mVersion
- return mResultChecksum.expectedFpp() / DEFAULT_FPP;
- }
-
- static String generateTestResultSignature(ITestResult testResult, IModuleResult module,
- String buildFingerprint) {
- StringBuilder sb = new StringBuilder();
- String stacktrace = testResult.getStackTrace();
-
- stacktrace = stacktrace == null ? "" : stacktrace.trim();
- // Line endings for stacktraces are somewhat unpredictable and there is no need to
- // actually read the result they are all removed for consistency.
- stacktrace = stacktrace.replaceAll("\\r?\\n|\\r", "");
- sb.append(buildFingerprint).append(SEPARATOR)
- .append(module.getId()).append(SEPARATOR)
- .append(testResult.getFullName()).append(SEPARATOR)
- .append(testResult.getResultStatus().getValue()).append(SEPARATOR)
- .append(stacktrace).append(SEPARATOR);
- return sb.toString();
- }
-
- static String generateTestResultSignature(
- String packageName, String suiteName, String caseName, String testName, String abi,
- String status,
- String stacktrace,
- String buildFingerprint) {
-
- String testId = buildTestId(suiteName, caseName, testName, abi);
- StringBuilder sb = new StringBuilder();
-
- stacktrace = stacktrace == null ? "" : stacktrace.trim();
- // Line endings for stacktraces are somewhat unpredictable and there is no need to
- // actually read the result they are all removed for consistency.
- stacktrace = stacktrace.replaceAll("\\r?\\n|\\r", "");
- sb.append(buildFingerprint)
- .append(SEPARATOR)
- .append(packageName)
- .append(SEPARATOR)
- .append(testId)
- .append(SEPARATOR)
- .append(status)
- .append(SEPARATOR)
- .append(stacktrace)
- .append(SEPARATOR);
- return sb.toString();
- }
-
- private static String buildTestId(
- String suiteName, String caseName, String testName, String abi) {
- String name = Joiner.on(NAME_SEPARATOR).skipNulls().join(
- Strings.emptyToNull(suiteName),
- Strings.emptyToNull(caseName),
- Strings.emptyToNull(testName));
- return Joiner.on(ID_SEPARATOR).skipNulls().join(
- Strings.emptyToNull(name),
- Strings.emptyToNull(abi));
- }
-
-
- private static String generateModuleResultSignature(IModuleResult module,
- String buildFingerprint) {
- StringBuilder sb = new StringBuilder();
- sb.append(buildFingerprint).append(SEPARATOR)
- .append(module.getId()).append(SEPARATOR)
- .append(module.isDone()).append(SEPARATOR)
- .append(module.countResults(TestStatus.FAIL));
- return sb.toString();
- }
-
- private static String generateModuleSummarySignature(IModuleResult module,
- String buildFingerprint) {
- StringBuilder sb = new StringBuilder();
- sb.append(buildFingerprint).append(SEPARATOR)
- .append(module.getId()).append(SEPARATOR)
- .append(module.countResults(TestStatus.FAIL));
- return sb.toString();
- }
-
- static byte[] calculateFileChecksum(File file) throws ChecksumValidationException {
-
- try (FileInputStream fis = new FileInputStream(file);
- InputStream inputStream = new BufferedInputStream(fis)) {
- MessageDigest hashSum = MessageDigest.getInstance("SHA-256");
- int cnt;
- int bufferSize = 8192;
- byte [] buffer = new byte[bufferSize];
- while ((cnt = inputStream.read(buffer)) != -1) {
- hashSum.update(buffer, 0, cnt);
- }
-
- byte[] partialHash = new byte[32];
- hashSum.digest(partialHash, 0, 32);
- return partialHash;
- } catch (NoSuchAlgorithmException e) {
- throw new ChecksumValidationException("Unable to hash file.", e);
- } catch (IOException e) {
- throw new ChecksumValidationException("Unable to hash file.", e);
- } catch (DigestException e) {
- throw new ChecksumValidationException("Unable to hash file.", e);
- }
- }
-
-
- private static int countTestResults(IInvocationResult invocation) {
- int count = 0;
- for (IModuleResult module : invocation.getModules()) {
- // Two entries per module (result & summary)
- count += 2;
- for (ICaseResult caseResult : module.getResults()) {
- count += caseResult.getResults().size();
- }
- }
- return count;
- }
-
- public static class ChecksumValidationException extends Exception {
- public ChecksumValidationException(String detailMessage) {
- super(detailMessage);
- }
-
- public ChecksumValidationException(String detailMessage, Throwable throwable) {
- super(detailMessage, throwable);
- }
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/CommonTestUtils.java b/common/util/src/com/android/compatibility/common/util/CommonTestUtils.java
deleted file mode 100644
index 75fa17a..0000000
--- a/common/util/src/com/android/compatibility/common/util/CommonTestUtils.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2019 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.compatibility.common.util;
-
-import static org.junit.Assert.fail;
-
-// TODO(b/131736394): Remove duplication with HostSideTestUtils.
-/** Utility class for tests. */
-public class CommonTestUtils {
- @FunctionalInterface
- public interface BooleanSupplierWithThrow<E extends Throwable> {
- boolean getAsBoolean() throws E;
- }
-
- /** Wait until {@code predicate} is satisfied, or fail, with a given timeout. */
- public static <E extends Throwable> void waitUntil(
- String message, long timeoutSeconds, BooleanSupplierWithThrow<E> predicate)
- throws E, InterruptedException {
- int sleep = 125;
- final long timeout = System.currentTimeMillis() + timeoutSeconds * 1000;
- while (System.currentTimeMillis() < timeout) {
- if (predicate.getAsBoolean()) {
- return;
- }
- Thread.sleep(sleep);
- }
- fail(message);
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/CrashUtils.java b/common/util/src/com/android/compatibility/common/util/CrashUtils.java
deleted file mode 100644
index 8d6e288..0000000
--- a/common/util/src/com/android/compatibility/common/util/CrashUtils.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Copyright (C) 2019 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.compatibility.common.util;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.math.BigInteger;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/** Contains helper functions and shared constants for crash parsing. */
-public class CrashUtils {
- // used to only detect actual addresses instead of nullptr and other unlikely values
- public static final BigInteger MIN_CRASH_ADDR = new BigInteger("8000", 16);
- // Matches the end of a crash
- public static final Pattern sEndofCrashPattern =
- Pattern.compile("DEBUG\\s+?:\\s+?backtrace:");
- public static final String DEVICE_PATH = "/data/local/tmp/CrashParserResults/";
- public static final String LOCK_FILENAME = "lockFile.loc";
- public static final String UPLOAD_REQUEST = "Please upload a result file to stagefright";
- public static final Pattern sUploadRequestPattern =
- Pattern.compile(UPLOAD_REQUEST);
- public static final String NEW_TEST_ALERT = "New test starting with name: ";
- public static final Pattern sNewTestPattern =
- Pattern.compile(NEW_TEST_ALERT + "(\\w+?)\\(.*?\\)");
- public static final String SIGNAL = "signal";
- public static final String ABORT_MESSAGE = "abortmessage";
- public static final String NAME = "name";
- public static final String PROCESS = "process";
- public static final String PID = "pid";
- public static final String TID = "tid";
- public static final String FAULT_ADDRESS = "faultaddress";
- // Matches the smallest blob that has the appropriate header and footer
- private static final Pattern sCrashBlobPattern =
- Pattern.compile("DEBUG\\s+?:( [*]{3})+?.*?DEBUG\\s+?:\\s+?backtrace:", Pattern.DOTALL);
- // Matches process id and name line and captures them
- private static final Pattern sPidtidNamePattern =
- Pattern.compile("pid: (\\d+?), tid: (\\d+?), name: ([^\\s]+?\\s+?)*?>>> (.*?) <<<");
- // Matches fault address and signal type line
- private static final Pattern sFaultLinePattern =
- Pattern.compile(
- "\\w+? \\d+? \\((.*?)\\), code -*?\\d+? \\(.*?\\), fault addr "
- + "(?:0x(\\p{XDigit}+)|-+)");
- // Matches the abort message line
- private static Pattern sAbortMessagePattern =
- Pattern.compile("(?i)Abort message: (.*)");
-
- public static final String SIGSEGV = "SIGSEGV";
- public static final String SIGBUS = "SIGBUS";
- public static final String SIGABRT = "SIGABRT";
-
- /**
- * returns the filename of the process.
- * e.g. "/system/bin/mediaserver" returns "mediaserver"
- */
- public static String getProcessFileName(JSONObject crash) throws JSONException {
- return new File(crash.getString(PROCESS)).getName();
- }
-
- /**
- * Determines if the given input has a {@link com.android.compatibility.common.util.Crash} that
- * should fail an sts test
- *
- * @param crashes list of crashes to check
- * @param config crash detection configuration object
- * @return if a crash is serious enough to fail an sts test
- */
- public static boolean securityCrashDetected(JSONArray crashes, Config config) {
- return matchSecurityCrashes(crashes, config).length() > 0;
- }
-
- public static BigInteger getBigInteger(JSONObject source, String name) throws JSONException {
- if (source.isNull(name)) {
- return null;
- }
- String intString = source.getString(name);
- BigInteger value = null;
- try {
- value = new BigInteger(intString, 16);
- } catch (NumberFormatException e) {}
- return value;
- }
-
- /**
- * Determines which given inputs have a {@link com.android.compatibility.common.util.Crash} that
- * should fail an sts test
- *
- * @param crashes list of crashes to check
- * @param config crash detection configuration object
- * @return the list of crashes serious enough to fail an sts test
- */
- public static JSONArray matchSecurityCrashes(JSONArray crashes, Config config) {
- JSONArray securityCrashes = new JSONArray();
- for (int i = 0; i < crashes.length(); i++) {
- try {
- JSONObject crash = crashes.getJSONObject(i);
-
- // match process patterns
- if (!matchesAny(getProcessFileName(crash), config.processPatterns)) {
- continue;
- }
-
- // match signal
- String crashSignal = crash.getString(SIGNAL);
- if (!config.signals.contains(crashSignal)) {
- continue;
- }
-
- if (crash.has(ABORT_MESSAGE)) {
- String crashAbortMessage = crash.getString(ABORT_MESSAGE);
- if (!config.abortMessageIncludes.isEmpty()) {
- if (!config.abortMessageIncludes.stream()
- .filter(p -> p.matcher(crashAbortMessage).find())
- .findFirst()
- .isPresent()) {
- continue;
- }
- }
- if (config.abortMessageExcludes.stream()
- .filter(p -> p.matcher(crashAbortMessage).find())
- .findFirst()
- .isPresent()) {
- continue;
- }
- }
-
- // if check specified, reject crash if address is unlikely to be security-related
- if (config.checkMinAddress) {
- BigInteger faultAddress = getBigInteger(crash, FAULT_ADDRESS);
- if (faultAddress != null
- && faultAddress.compareTo(config.minCrashAddress) < 0) {
- continue;
- }
- }
- securityCrashes.put(crash);
- } catch (JSONException e) {}
- }
- return securityCrashes;
- }
-
- /**
- * returns true if the input matches any of the patterns.
- */
- private static boolean matchesAny(String input, Collection<Pattern> patterns) {
- for (Pattern p : patterns) {
- if (p.matcher(input).matches()) {
- return true;
- }
- }
- return false;
- }
-
- /** Adds all crashes found in the input as JSONObjects to the given JSONArray */
- public static JSONArray addAllCrashes(String input, JSONArray crashes) {
- Matcher crashBlobFinder = sCrashBlobPattern.matcher(input);
- while (crashBlobFinder.find()) {
- String crashStr = crashBlobFinder.group(0);
- int tid = 0;
- int pid = 0;
- BigInteger faultAddress = null;
- String name = null;
- String process = null;
- String signal = null;
- String abortMessage = null;
-
- Matcher pidtidNameMatcher = sPidtidNamePattern.matcher(crashStr);
- if (pidtidNameMatcher.find()) {
- try {
- pid = Integer.parseInt(pidtidNameMatcher.group(1));
- } catch (NumberFormatException e) {}
- try {
- tid = Integer.parseInt(pidtidNameMatcher.group(2));
- } catch (NumberFormatException e) {}
- name = pidtidNameMatcher.group(3).trim();
- process = pidtidNameMatcher.group(4).trim();
- }
-
- Matcher faultLineMatcher = sFaultLinePattern.matcher(crashStr);
- if (faultLineMatcher.find()) {
- signal = faultLineMatcher.group(1);
- String faultAddrMatch = faultLineMatcher.group(2);
- if (faultAddrMatch != null) {
- try {
- faultAddress = new BigInteger(faultAddrMatch, 16);
- } catch (NumberFormatException e) {}
- }
- }
-
- Matcher abortMessageMatcher = sAbortMessagePattern.matcher(crashStr);
- if (abortMessageMatcher.find()) {
- abortMessage = abortMessageMatcher.group(1);
- }
-
- try {
- JSONObject crash = new JSONObject();
- crash.put(PID, pid);
- crash.put(TID, tid);
- crash.put(NAME, name);
- crash.put(PROCESS, process);
- crash.put(FAULT_ADDRESS,
- faultAddress == null ? null : faultAddress.toString(16));
- crash.put(SIGNAL, signal);
- crash.put(ABORT_MESSAGE, abortMessage);
- crashes.put(crash);
- } catch (JSONException e) {}
- }
- return crashes;
- }
-
- public static class Config {
- private boolean checkMinAddress;
- private BigInteger minCrashAddress;
- private List<String> signals;
- private List<Pattern> processPatterns;
- private List<Pattern> abortMessageIncludes;
- private List<Pattern> abortMessageExcludes;
-
- public Config() {
- checkMinAddress = true;
- minCrashAddress = MIN_CRASH_ADDR;
- setSignals(SIGSEGV, SIGBUS);
- abortMessageIncludes = new ArrayList<>();
- setAbortMessageExcludes("CHECK_");
- processPatterns = new ArrayList();
- }
-
- public Config setMinAddress(BigInteger minCrashAddress) {
- this.minCrashAddress = minCrashAddress;
- return this;
- }
-
- public Config checkMinAddress(boolean checkMinAddress) {
- this.checkMinAddress = checkMinAddress;
- return this;
- }
-
- public Config setSignals(String... signals) {
- this.signals = new ArrayList(Arrays.asList(signals));
- return this;
- }
-
- public Config appendSignals(String... signals) {
- Collections.addAll(this.signals, signals);
- return this;
- }
-
- public Config setAbortMessageIncludes(String... abortMessages) {
- this.abortMessageIncludes = new ArrayList<>(toPatterns(abortMessages));
- return this;
- }
-
- public Config setAbortMessageIncludes(Pattern... abortMessages) {
- this.abortMessageIncludes = new ArrayList<>(Arrays.asList(abortMessages));
- return this;
- }
-
- public Config appendAbortMessageIncludes(String... abortMessages) {
- this.abortMessageIncludes.addAll(toPatterns(abortMessages));
- return this;
- }
-
- public Config appendAbortMessageIncludes(Pattern... abortMessages) {
- Collections.addAll(this.abortMessageIncludes, abortMessages);
- return this;
- }
-
- public Config setAbortMessageExcludes(String... abortMessages) {
- this.abortMessageExcludes = new ArrayList<>(toPatterns(abortMessages));
- return this;
- }
-
- public Config setAbortMessageExcludes(Pattern... abortMessages) {
- this.abortMessageExcludes = new ArrayList<>(Arrays.asList(abortMessages));
- return this;
- }
-
- public Config appendAbortMessageExcludes(String... abortMessages) {
- this.abortMessageExcludes.addAll(toPatterns(abortMessages));
- return this;
- }
-
- public Config appendAbortMessageExcludes(Pattern... abortMessages) {
- Collections.addAll(this.abortMessageExcludes, abortMessages);
- return this;
- }
-
-
- public Config setProcessPatterns(String... processPatternStrings) {
- this.processPatterns = new ArrayList<>(toPatterns(processPatternStrings));
- return this;
- }
-
- public Config setProcessPatterns(Pattern... processPatterns) {
- this.processPatterns = new ArrayList(Arrays.asList(processPatterns));
- return this;
- }
-
- public List<Pattern> getProcessPatterns() {
- return Collections.unmodifiableList(processPatterns);
- }
-
- public Config appendProcessPatterns(String... processPatternStrings) {
- this.processPatterns.addAll(toPatterns(processPatternStrings));
- return this;
- }
-
- public Config appendProcessPatterns(Pattern... processPatterns) {
- Collections.addAll(this.processPatterns, processPatterns);
- return this;
- }
- }
-
- private static List<Pattern> toPatterns(String... patternStrings) {
- return Stream.of(patternStrings).map(Pattern::compile).collect(Collectors.toList());
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/CtsDownstreamingTest.java b/common/util/src/com/android/compatibility/common/util/CtsDownstreamingTest.java
deleted file mode 100644
index 5dce31c..0000000
--- a/common/util/src/com/android/compatibility/common/util/CtsDownstreamingTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2019 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.compatibility.common.util;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation marking a test case as a CTS downstreaming test.
- * <p>
- * Test classes and test cases marked with this annotation will be excluded
- * from CTS runs, and included in GTS releases.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD, ElementType.TYPE})
-public @interface CtsDownstreamingTest {
-}
diff --git a/common/util/src/com/android/compatibility/common/util/DevicePropertyInfo.java b/common/util/src/com/android/compatibility/common/util/DevicePropertyInfo.java
deleted file mode 100644
index 7435839..0000000
--- a/common/util/src/com/android/compatibility/common/util/DevicePropertyInfo.java
+++ /dev/null
@@ -1,140 +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.compatibility.common.util;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Utility class for collecting device information. This is used to enforce
- * consistent property collection host-side and device-side for CTS reports.
- *
- * Note that properties across sources can differ, e.g. {@code android.os.Build}
- * properties sometimes deviate from the read-only properties that they're based
- * on.
- */
-public final class DevicePropertyInfo {
-
- private final String mAbi;
- private final String mAbi2;
- private final String mAbis;
- private final String mAbis32;
- private final String mAbis64;
- private final String mBoard;
- private final String mBrand;
- private final String mDevice;
- private final String mFingerprint;
- private final String mId;
- private final String mManufacturer;
- private final String mModel;
- private final String mProduct;
- private final String mReferenceFingerprint;
- private final String mVendorFingerprint;
- private final String mSerial;
- private final String mTags;
- private final String mType;
- private final String mVersionBaseOs;
- private final String mVersionRelease;
- private final String mVersionSdk;
- private final String mVersionSecurityPatch;
- private final String mVersionIncremental;
-
- public DevicePropertyInfo(
- String abi,
- String abi2,
- String abis,
- String abis32,
- String abis64,
- String board,
- String brand,
- String device,
- String fingerprint,
- String vendorFingerprint,
- String id,
- String manufacturer,
- String model,
- String product,
- String referenceFingerprint,
- String serial,
- String tags,
- String type,
- String versionBaseOs,
- String versionRelease,
- String versionSdk,
- String versionSecurityPatch,
- String versionIncremental) {
- mAbi = abi;
- mAbi2 = abi2;
- mAbis = abis;
- mAbis32 = abis32;
- mAbis64 = abis64;
- mBoard = board;
- mBrand = brand;
- mDevice = device;
- mFingerprint = fingerprint;
- mVendorFingerprint = vendorFingerprint;
- mId = id;
- mManufacturer = manufacturer;
- mModel = model;
- mProduct = product;
- mReferenceFingerprint = referenceFingerprint;
- mSerial = serial;
- mTags = tags;
- mType = type;
- mVersionBaseOs = versionBaseOs;
- mVersionRelease = versionRelease;
- mVersionSdk = versionSdk;
- mVersionSecurityPatch = versionSecurityPatch;
- mVersionIncremental = versionIncremental;
- }
-
- /**
- * Return a {@code Map} with property keys prepended with a given prefix
- * string. This is intended to be used to generate entries for
- * {@code} Build tag attributes in CTS test results.
- */
- public Map<String, String> getPropertytMapWithPrefix(String prefix) {
- Map<String, String> propertyMap = new HashMap<>();
-
- propertyMap.put(prefix + "abi", mAbi);
- propertyMap.put(prefix + "abi2", mAbi2);
- propertyMap.put(prefix + "abis", mAbis);
- propertyMap.put(prefix + "abis_32", mAbis32);
- propertyMap.put(prefix + "abis_64", mAbis64);
- propertyMap.put(prefix + "board", mBoard);
- propertyMap.put(prefix + "brand", mBrand);
- propertyMap.put(prefix + "device", mDevice);
- propertyMap.put(prefix + "fingerprint", mFingerprint);
- propertyMap.put(prefix + "vendor_fingerprint", mVendorFingerprint);
- propertyMap.put(prefix + "id", mId);
- propertyMap.put(prefix + "manufacturer", mManufacturer);
- propertyMap.put(prefix + "model", mModel);
- propertyMap.put(prefix + "product", mProduct);
- propertyMap.put(prefix + "reference_fingerprint", mReferenceFingerprint);
- propertyMap.put(prefix + "serial", mSerial);
- propertyMap.put(prefix + "tags", mTags);
- propertyMap.put(prefix + "type", mType);
- propertyMap.put(prefix + "version_base_os", mVersionBaseOs);
- propertyMap.put(prefix + "version_release", mVersionRelease);
- propertyMap.put(prefix + "version_sdk", mVersionSdk);
- propertyMap.put(prefix + "version_security_patch", mVersionSecurityPatch);
- propertyMap.put(prefix + "version_incremental", mVersionIncremental);
-
- return propertyMap;
- }
-
-}
diff --git a/common/util/src/com/android/compatibility/common/util/DynamicConfig.java b/common/util/src/com/android/compatibility/common/util/DynamicConfig.java
deleted file mode 100644
index 797afea..0000000
--- a/common/util/src/com/android/compatibility/common/util/DynamicConfig.java
+++ /dev/null
@@ -1,150 +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.compatibility.common.util;
-
-import static org.junit.Assert.assertTrue;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Load dynamic config for test cases
- */
-public class DynamicConfig {
-
- //XML constant
- public static final String NS = null;
- public static final String CONFIG_TAG = "dynamicConfig";
- public static final String ENTRY_TAG = "entry";
- public static final String VALUE_TAG = "value";
- public static final String KEY_ATTR = "key";
-
- public static final String REMOTE_CONFIG_REQUIRED_KEY = "remote_config_required";
- public static final String REMOTE_CONFIG_RETRIEVED_KEY = "remote_config_retrieved";
- public static final String CONFIG_FOLDER_ON_DEVICE = "/sdcard/dynamic-config-files/";
-
- protected Map<String, List<String>> mDynamicConfigMap = new HashMap<String, List<String>>();
-
- public void initializeConfig(File file) throws XmlPullParserException, IOException {
- mDynamicConfigMap = createConfigMap(file);
- }
-
- /** Init using directly a {@link FileInputStream} from the config file. */
- public void initializeConfig(FileInputStream fileStream)
- throws XmlPullParserException, IOException {
- mDynamicConfigMap = createConfigMap(fileStream);
- }
-
- public String getValue(String key) {
- assertRemoteConfigRequirementMet();
- List<String> singleValue = mDynamicConfigMap.get(key);
- if (singleValue == null || singleValue.size() == 0 || singleValue.size() > 1) {
- // key must exist in the map, and map to a list containing exactly one string
- return null;
- }
- return singleValue.get(0);
- }
-
- public List<String> getValues(String key) {
- assertRemoteConfigRequirementMet();
- return mDynamicConfigMap.get(key);
- }
-
- public Set<String> keySet() {
- assertRemoteConfigRequirementMet();
- return mDynamicConfigMap.keySet();
- }
-
- public boolean remoteConfigRequired() {
- if (mDynamicConfigMap.containsKey(REMOTE_CONFIG_REQUIRED_KEY)) {
- String val = mDynamicConfigMap.get(REMOTE_CONFIG_REQUIRED_KEY).get(0);
- return Boolean.parseBoolean(val);
- }
- return true; // require remote configuration by default
- }
-
- public boolean remoteConfigRetrieved() {
- // assume config will always contain exactly one value, populated by DynamicConfigHandler
- String val = mDynamicConfigMap.get(REMOTE_CONFIG_RETRIEVED_KEY).get(0);
- return Boolean.parseBoolean(val);
- }
-
- public void assertRemoteConfigRequirementMet() {
- assertTrue("Remote connection to DynamicConfigService required for this test",
- !remoteConfigRequired() || remoteConfigRetrieved());
- }
-
- public static File getConfigFile(File configFolder, String moduleName)
- throws FileNotFoundException {
- File config = getConfigFileUnchecked(configFolder, moduleName);
- if (!config.exists()) {
- throw new FileNotFoundException(String.format("Cannot find %s.dynamic", moduleName));
- }
- return config;
- }
-
- public static File getConfigFileUnchecked(File configFolder, String moduleName) {
- return new File(configFolder, String.format("%s.dynamic", moduleName));
- }
-
- public static Map<String, List<String>> createConfigMap(File file)
- throws XmlPullParserException, IOException {
- try (FileInputStream stream = new FileInputStream(file)) {
- return createConfigMap(stream);
- }
- }
-
- public static Map<String, List<String>> createConfigMap(FileInputStream fileStream)
- throws XmlPullParserException, IOException {
-
- Map<String, List<String>> dynamicConfigMap = new HashMap<String, List<String>>();
- XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
- parser.setInput(new InputStreamReader(fileStream));
- parser.nextTag();
- parser.require(XmlPullParser.START_TAG, NS, CONFIG_TAG);
-
- while (parser.nextTag() == XmlPullParser.START_TAG) {
- parser.require(XmlPullParser.START_TAG, NS, ENTRY_TAG);
- String key = parser.getAttributeValue(NS, KEY_ATTR);
- List<String> valueList = new ArrayList<String>();
- while (parser.nextTag() == XmlPullParser.START_TAG) {
- parser.require(XmlPullParser.START_TAG, NS, VALUE_TAG);
- valueList.add(parser.nextText());
- parser.require(XmlPullParser.END_TAG, NS, VALUE_TAG);
- }
- parser.require(XmlPullParser.END_TAG, NS, ENTRY_TAG);
- if (key != null && !key.isEmpty()) {
- dynamicConfigMap.put(key, valueList);
- }
- }
-
- parser.require(XmlPullParser.END_TAG, NS, CONFIG_TAG);
- return dynamicConfigMap;
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/FileUtil.java b/common/util/src/com/android/compatibility/common/util/FileUtil.java
deleted file mode 100644
index b59912b..0000000
--- a/common/util/src/com/android/compatibility/common/util/FileUtil.java
+++ /dev/null
@@ -1,71 +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.compatibility.common.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * A helper class for file related operations
- */
-public class FileUtil {
-
- /**
- * Recursively delete given file or directory and all its contents.
- *
- * @param rootDir the directory or file to be deleted; can be null
- */
- public static void recursiveDelete(File rootDir) {
- if (rootDir != null) {
- if (rootDir.isDirectory()) {
- File[] childFiles = rootDir.listFiles();
- if (childFiles != null) {
- for (File child : childFiles) {
- recursiveDelete(child);
- }
- }
- }
- rootDir.delete();
- }
- }
-
- /**
- * A helper method for writing stream data to file
- *
- * @param input the unbuffered input stream
- * @param destFile the dest file to write to
- */
- public static void writeToFile(InputStream input, File destFile) throws IOException {
- InputStream origStream = null;
- OutputStream destStream = null;
- try {
- origStream = new BufferedInputStream(input);
- destStream = new BufferedOutputStream(new FileOutputStream(destFile));
- StreamUtil.copyStreams(origStream, destStream);
- } finally {
- origStream.close();
- destStream.flush();
- destStream.close();
- }
- }
-
-}
diff --git a/common/util/src/com/android/compatibility/common/util/GmsTest.java b/common/util/src/com/android/compatibility/common/util/GmsTest.java
deleted file mode 100644
index 0032000..0000000
--- a/common/util/src/com/android/compatibility/common/util/GmsTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2020 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.compatibility.common.util;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/** Marks the type of test with purpose of asserting GMS requirements. */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD, ElementType.TYPE})
-public @interface GmsTest {
- String requirement();
-}
diff --git a/common/util/src/com/android/compatibility/common/util/ICaseResult.java b/common/util/src/com/android/compatibility/common/util/ICaseResult.java
deleted file mode 100644
index 5904d69..0000000
--- a/common/util/src/com/android/compatibility/common/util/ICaseResult.java
+++ /dev/null
@@ -1,62 +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.compatibility.common.util;
-
-import java.util.List;
-
-/**
- * Data structure for a Compatibility test case result.
- */
-public interface ICaseResult extends Comparable<ICaseResult> {
-
- String getName();
-
- /**
- * Gets a {@link ITestResult} for the given test, creating it if it doesn't exist.
- *
- * @param testName the name of the test eg <method-name>
- * @return the {@link ITestResult} or <code>null</code>
- */
- ITestResult getOrCreateResult(String testName);
-
- /**
- * Gets the {@link ITestResult} for given test.
- *
- * @param testName the name of the test eg <method-name>
- * @return the {@link ITestResult} or <code>null</code>
- */
- ITestResult getResult(String testName);
-
- /**
- * Gets all results sorted by name.
- */
- List<ITestResult> getResults();
-
- /**
- * Gets all results which have the given status.
- */
- List<ITestResult> getResults(TestStatus status);
-
- /**
- * Counts the number of results which have the given status.
- */
- int countResults(TestStatus status);
-
- /**
- * Merge the case results from otherCaseResult into this caseResult.
- */
- void mergeFrom(ICaseResult otherCaseResult);
-}
diff --git a/common/util/src/com/android/compatibility/common/util/IInvocationResult.java b/common/util/src/com/android/compatibility/common/util/IInvocationResult.java
deleted file mode 100644
index 96eca2d..0000000
--- a/common/util/src/com/android/compatibility/common/util/IInvocationResult.java
+++ /dev/null
@@ -1,138 +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.compatibility.common.util;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Interface for a the result of a single Compatibility invocation.
- */
-public interface IInvocationResult {
-
- /**
- * @return the starting timestamp.
- */
- long getStartTime();
-
- /**
- * @param time the starting timestamp
- */
- void setStartTime(long time);
-
- /**
- * Count the number of results with given status.
- */
- int countResults(TestStatus result);
-
- /**
- * @return the number of tests that have not been executed in this moduleResult.
- */
- int getNotExecuted();
-
- /**
- * @param plan the plan associated with this result.
- */
- void setTestPlan(String plan);
-
- /**
- * @return the test plan associated with this result.
- */
- String getTestPlan();
-
- /**
- * Adds the given device serial to the result.
- */
- void addDeviceSerial(String serial);
-
- /**
- * @return the device serials associated with result.
- */
- Set<String> getDeviceSerials();
-
- /**
- * @return the {@link IModuleResult} for the given id, creating one if it doesn't exist
- */
- IModuleResult getOrCreateModule(String id);
-
- /**
- * @return the {@link IModuleResult}s sorted by id.
- */
- List<IModuleResult> getModules();
-
- /**
- * Merges a module result to the invocation result.
- */
- void mergeModuleResult(IModuleResult moduleResult);
-
- /**
- * Adds the given invocation info to the result.
- */
- void addInvocationInfo(String key, String value);
-
- /**
- * Gets the {@link Map} of invocation info collected.
- */
- Map<String, String> getInvocationInfo();
-
- /**
- * Set the string containing the command line arguments to the run command.
- */
- void setCommandLineArgs(String setCommandLineArgs);
-
- /**
- * Retrieve the command line arguments to the run command.
- */
- String getCommandLineArgs();
-
- /**
- * @param buildFingerprint the build fingerprint associated with this result.
- */
- void setBuildFingerprint(String buildFingerprint);
-
- /**
- * @return the device build fingerprint associated with result.
- */
- String getBuildFingerprint();
-
- /**
- * Return the number of completed test modules for this invocation.
- */
- int getModuleCompleteCount();
-
- /**
- * Return status of checksum from previous session
- */
- RetryChecksumStatus getRetryChecksumStatus();
-
- /**
- * Set status of checksum from previous session
- */
- void setRetryChecksumStatus(RetryChecksumStatus retryStatus);
-
- /**
- * Return the directory of the previous sessions results
- */
- File getRetryDirectory();
-
- /**
- * Set the directory of the previous sessions results
- */
- void setRetryDirectory(File resultDir);
-
-}
diff --git a/common/util/src/com/android/compatibility/common/util/IModuleResult.java b/common/util/src/com/android/compatibility/common/util/IModuleResult.java
deleted file mode 100644
index 73188e0..0000000
--- a/common/util/src/com/android/compatibility/common/util/IModuleResult.java
+++ /dev/null
@@ -1,157 +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.compatibility.common.util;
-
-import java.util.List;
-
-/**
- * Data structure for a Compatibility test module result.
- */
-public interface IModuleResult extends Comparable<IModuleResult> {
-
- String getId();
-
- String getName();
-
- String getAbi();
-
- void addRuntime(long elapsedTime);
-
- void resetRuntime();
-
- long getRuntime();
-
- /**
- * Get the estimate of not-executed tests for this module. This estimate is a maximum
- * not-executed count, assuming all test runs have been started.
- * @return estimate of not-executed tests
- */
- int getNotExecuted();
-
- /**
- * Set the estimate of not-executed tests for this module. This estimate is a maximum
- * not-executed count, assuming all test runs have been started.
- * @param estimate of not-executed tests
- */
- void setNotExecuted(int numTests);
-
- /**
- * Whether all expected tests have been executed and all expected test runs have been seen
- * and completed.
- *
- * @return the comprehensive completeness status of the module
- */
- boolean isDone();
-
- /**
- * Whether all expected tests have been executed for the test runs seen so far.
- *
- * @return the completeness status of the module so far
- */
- boolean isDoneSoFar();
-
- /**
- * Explicitly sets the "done" status for this module. To be used when constructing this
- * instance from an XML report. The done status for an {@link IModuleResult} can be changed
- * indiscriminately by method setDone(boolean) immediately after a call to initializeDone,
- * whereas the status may only be switched to false immediately after a call to setDone.
- *
- * @param done the initial completeness status of the module
- */
- void initializeDone(boolean done);
-
- /**
- * Sets the "done" status for this module. To be used after each test run for the module.
- * After setDone is used once, subsequent calls to setDone will AND the given value with the
- * existing done status value. Thus a module with "done" already set to false cannot be marked
- * done unless re-initialized (see initializeDone).
- *
- * @param done the completeness status of the module for a test run
- */
- void setDone(boolean done);
-
- /**
- * Sets the "in-progress" status for this module. Useful for tracking completion of the module
- * in the case that a test run begins but never ends.
- *
- * @param inProgress whether the module is currently in progress
- */
- void inProgress(boolean inProgress);
-
- /**
- * @return the number of expected test runs for this module in this invocation
- */
- int getExpectedTestRuns();
-
- /**
- * @param the number of expected test runs for this module in this invocation
- */
- void setExpectedTestRuns(int numRuns);
-
- /**
- * @return the number of test runs seen for this module in this invocation
- */
- int getTestRuns();
-
- /**
- * Adds to the count of test runs seen for this module in this invocation
- */
- void addTestRun();
-
- /**
- * Reset the count of test runs seen for this module in this invocation. Should be performed
- * after merging the module into another module, so that future merges do not double-count the
- * same test runs.
- */
- void resetTestRuns();
-
- /**
- * Gets a {@link ICaseResult} for the given testcase, creating it if it doesn't exist.
- *
- * @param caseName the name of the testcase eg <package-name><class-name>
- * @return the {@link ICaseResult} or <code>null</code>
- */
- ICaseResult getOrCreateResult(String caseName);
-
- /**
- * Gets the {@link ICaseResult} result for given testcase.
- *
- * @param caseName the name of the testcase eg <package-name><class-name>
- * @return the {@link ITestResult} or <code>null</code>
- */
- ICaseResult getResult(String caseName);
-
- /**
- * Gets all results sorted by name.
- */
- List<ICaseResult> getResults();
-
- /**
- * Counts the number of results which have the given status.
- */
- int countResults(TestStatus status);
-
- /** Sets the module as failed. */
- void setFailed();
-
- /** Returns whether or not the module has failed. */
- boolean isFailed();
-
- /**
- * Merge the module results from otherModuleResult into this moduleResult.
- */
- void mergeFrom(IModuleResult otherModuleResult);
-}
diff --git a/common/util/src/com/android/compatibility/common/util/ITestResult.java b/common/util/src/com/android/compatibility/common/util/ITestResult.java
deleted file mode 100644
index 33340e6..0000000
--- a/common/util/src/com/android/compatibility/common/util/ITestResult.java
+++ /dev/null
@@ -1,173 +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.compatibility.common.util;
-
-import java.util.List;
-
-/**
- * Represents a single test result.
- */
-public interface ITestResult extends Comparable<ITestResult> {
-
- /**
- * @return The name of this test result.
- */
- String getName();
-
- /**
- * @return The full name of this test result, ie
- * <package-name>.<class-name>#<method-name>
- */
- String getFullName();
-
- /**
- * @return The {@link TestStatus} of this result.
- */
- TestStatus getResultStatus();
-
- /**
- * Sets the {@link TestStatus} of the result and updates the end time of the test.
- *
- * @param status The {@link TestStatus} of this result.
- */
- void setResultStatus(TestStatus status);
-
- /**
- * @return The failure message to display
- */
- String getMessage();
-
- /**
- * @param message The message to display which describes the failure
- */
- void setMessage(String message);
-
- /**
- * @return The stack trace generated by the failure
- */
- String getStackTrace();
-
- /**
- * @param stackTrace the stack trace generated by the failure.
- */
- void setStackTrace(String stackTrace);
-
- /**
- * @return the metrics report.
- */
- ReportLog getReportLog();
-
- /**
- * @param report the metrics report.
- */
- void setReportLog(ReportLog report);
-
- /**
- * @return the path of the bug report generated of the failure.
- */
- String getBugReport();
-
- /**
- * @param path the path of the bug report generated of the failure.
- */
- void setBugReport(String path);
-
- /**
- * @return the path of the log file generated of the failure.
- */
- String getLog();
-
- /**
- * @param path the path of the log file generated of the failure.
- */
- void setLog(String path);
-
- /**
- * @return the path of the screenshot file generated of the failure.
- */
- String getScreenshot();
-
- /**
- * @param path the path of the screenshot file generated of the failure.
- */
- void setScreenshot(String path);
-
- /**
- * Report the test as a failure.
- *
- * @param trace the stacktrace of the failure.
- */
- void failed(String trace);
-
- /**
- * Report that the test has completed.
- *
- * @param report A report generated by the test, or null.
- */
- void passed(ReportLog report);
-
- /**
- * Report that the test was skipped.
- *
- * This means that the test is not considered appropriate for the
- * current device, and thus is never attempted. The test does not require execution,
- * and nothing more needs to be done.
- */
- void skipped();
-
- /**
- * Retrieves whether execution for this test result has been determined unnecessary.
- */
- boolean isSkipped();
-
- /**
- * Resets the result.
- */
- void reset();
-
- /**
- * Sets whether the test result status has been generated from a previous testing session.
- */
- void setRetry(boolean isRetry);
-
- /**
- * Retrieves whether the test result status has been generated from a previous testing session.
- */
- boolean isRetry();
-
- /**
- * Clear the existing result and default to 'failed'
- */
- void removeResult();
-
- /**
- * This method is to record per-case history for CTS Verifier. If this field is used for large
- * test suites like CTS, it may cause performance issues in APFE. Thus please do not use this
- * field in other test suites.
- *
- * @return The test result histories
- */
- List<TestResultHistory> getTestResultHistories();
-
- /**
- * Set test result histories of test item. This method is for per-case history in CTS Verifier.
- * If this field is used for large test suites like CTS, it may cause performance issues in
- * APFE. Thus please do not use this field in other test suites.
- *
- * @param resultHistories The test result histories.
- */
- void setTestResultHistories(List<TestResultHistory> resultHistories);
-}
diff --git a/common/util/src/com/android/compatibility/common/util/InfoStore.java b/common/util/src/com/android/compatibility/common/util/InfoStore.java
deleted file mode 100644
index f677c80..0000000
--- a/common/util/src/com/android/compatibility/common/util/InfoStore.java
+++ /dev/null
@@ -1,197 +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.compatibility.common.util;
-
-import java.io.IOException;
-import java.lang.AutoCloseable;
-import java.util.Arrays;
-import java.util.List;
-
-public abstract class InfoStore implements AutoCloseable {
-
- protected static final int MAX_STRING_LENGTH = 1000;
- protected static final int MAX_ARRAY_LENGTH = 1000;
- protected static final int MAX_LIST_LENGTH = 1000;
-
- /**
- * Opens the file for storage and creates the writer.
- */
- abstract void open() throws IOException;
-
- /**
- * Closes the writer.
- */
- @Override
- public abstract void close() throws Exception;
-
- /**
- * Start a new group of result.
- */
- abstract void startGroup() throws IOException;
-
- /**
- * Start a new group of result with specified name.
- */
- abstract void startGroup(String name) throws IOException;
-
- /**
- * Complete adding result to the last started group.
- */
- abstract void endGroup() throws IOException;
-
- /**
- * Start a new array of result.
- */
- abstract void startArray() throws IOException;
-
- /**
- * Start a new array of result with specified name.
- */
- abstract void startArray(String name) throws IOException;
-
- /**
- * Complete adding result to the last started array.
- */
- abstract void endArray() throws IOException;
-
- /**
- * Adds a int value to the InfoStore
- */
- abstract void addResult(String name, int value) throws IOException;
-
- /**
- * Adds a long value to the InfoStore
- */
- abstract void addResult(String name, long value) throws IOException;
-
- /**
- * Adds a float value to the InfoStore
- */
- abstract void addResult(String name, float value) throws IOException;
-
- /**
- * Adds a double value to the InfoStore
- */
- abstract void addResult(String name, double value) throws IOException;
-
- /**
- * Adds a boolean value to the InfoStore
- */
- abstract void addResult(String name, boolean value) throws IOException;
-
- /**
- * Adds a String value to the InfoStore
- */
- abstract void addResult(String name, String value) throws IOException;
-
- /**
- * Adds a int array to the InfoStore
- */
- abstract void addArrayResult(String name, int[] array) throws IOException;
-
- /**
- * Adds a long array to the InfoStore
- */
- abstract void addArrayResult(String name, long[] array) throws IOException;
-
- /**
- * Adds a float array to the InfoStore
- */
- abstract void addArrayResult(String name, float[] array) throws IOException;
-
- /**
- * Adds a double array to the InfoStore
- */
- abstract void addArrayResult(String name, double[] array) throws IOException;
-
- /**
- * Adds a boolean array to the InfoStore
- */
- abstract void addArrayResult(String name, boolean[] array) throws IOException;
-
- /**
- * Adds a List of String to the InfoStore
- */
- abstract void addListResult(String name, List<String> list) throws IOException;
-
- protected static int[] checkArray(int[] values) {
- if (values.length > MAX_ARRAY_LENGTH) {
- return Arrays.copyOf(values, MAX_ARRAY_LENGTH);
- } else {
- return values;
- }
- }
-
- protected static long[] checkArray(long[] values) {
- if (values.length > MAX_ARRAY_LENGTH) {
- return Arrays.copyOf(values, MAX_ARRAY_LENGTH);
- } else {
- return values;
- }
- }
-
- protected static float[] checkArray(float[] values) {
- if (values.length > MAX_ARRAY_LENGTH) {
- return Arrays.copyOf(values, MAX_ARRAY_LENGTH);
- } else {
- return values;
- }
- }
-
- protected static double[] checkArray(double[] values) {
- if (values.length > MAX_ARRAY_LENGTH) {
- return Arrays.copyOf(values, MAX_ARRAY_LENGTH);
- } else {
- return values;
- }
- }
-
- protected static boolean[] checkArray(boolean[] values) {
- if (values.length > MAX_ARRAY_LENGTH) {
- return Arrays.copyOf(values, MAX_ARRAY_LENGTH);
- } else {
- return values;
- }
- }
-
- protected static List<String> checkStringList(List<String> list) {
- if (list.size() > MAX_LIST_LENGTH) {
- return list.subList(0, MAX_LIST_LENGTH);
- }
- return list;
- }
-
- protected static String checkString(String value) {
- if (value == null || value.isEmpty()) {
- return "";
- }
- if (value.length() > MAX_STRING_LENGTH) {
- return value.substring(0, MAX_STRING_LENGTH);
- }
- return value;
- }
-
- protected static String checkName(String value) {
- if (value == null || value.isEmpty()) {
- throw new NullPointerException();
- }
- return value;
- }
-
- protected static boolean isDoubleNaNOrInfinite(Double value) {
- return Double.isNaN(value) || Double.isInfinite(value);
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/InvocationResult.java b/common/util/src/com/android/compatibility/common/util/InvocationResult.java
deleted file mode 100644
index f4f294e..0000000
--- a/common/util/src/com/android/compatibility/common/util/InvocationResult.java
+++ /dev/null
@@ -1,252 +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.compatibility.common.util;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Data structure for the detailed Compatibility test results.
- */
-public class InvocationResult implements IInvocationResult {
-
- /** Helper object for JSON conversion. */
- public static final class RunHistory {
- public long startTime;
- public long endTime;
- }
-
- private Collection<RunHistory> mRunHistories = new ArrayList<>();
-
- private long mTimestamp;
- private Map<String, IModuleResult> mModuleResults = new LinkedHashMap<>();
- private Map<String, String> mInvocationInfo = new HashMap<>();
- private Set<String> mSerials = new HashSet<>();
- private String mBuildFingerprint;
- private String mTestPlan;
- private String mCommandLineArgs;
- private RetryChecksumStatus mRetryChecksumStatus = RetryChecksumStatus.NotRetry;
- private File mRetryDirectory = null;
-
- /** @return a collection of the run history of previous runs. */
- public Collection<RunHistory> getRunHistories() {
- return mRunHistories;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<IModuleResult> getModules() {
- ArrayList<IModuleResult> modules = new ArrayList<>(mModuleResults.values());
- Collections.sort(modules);
- return modules;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int countResults(TestStatus result) {
- int total = 0;
- for (IModuleResult m : mModuleResults.values()) {
- total += m.countResults(result);
- }
- return total;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getNotExecuted() {
- int numTests = 0;
- for (IModuleResult module : mModuleResults.values()) {
- numTests += module.getNotExecuted();
- }
- return numTests;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IModuleResult getOrCreateModule(String id) {
- IModuleResult moduleResult = mModuleResults.get(id);
- if (moduleResult == null) {
- moduleResult = new ModuleResult(id);
- mModuleResults.put(id, moduleResult);
- }
- return moduleResult;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void mergeModuleResult(IModuleResult moduleResult) {
- // Merge the moduleResult with any existing module result
- IModuleResult existingModuleResult = getOrCreateModule(moduleResult.getId());
- existingModuleResult.mergeFrom(moduleResult);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addInvocationInfo(String key, String value) {
- mInvocationInfo.put(key, value);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Map<String, String> getInvocationInfo() {
- return mInvocationInfo;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setStartTime(long time) {
- mTimestamp = time;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long getStartTime() {
- return mTimestamp;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setTestPlan(String plan) {
- mTestPlan = plan;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getTestPlan() {
- return mTestPlan;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addDeviceSerial(String serial) {
- mSerials.add(serial);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set<String> getDeviceSerials() {
- return mSerials;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setCommandLineArgs(String commandLineArgs) {
- mCommandLineArgs = commandLineArgs;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getCommandLineArgs() {
- return mCommandLineArgs;
- }
-
- @Override
- public void setBuildFingerprint(String buildFingerprint) {
- mBuildFingerprint = buildFingerprint;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getBuildFingerprint() {
- return mBuildFingerprint;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getModuleCompleteCount() {
- int completeModules = 0;
- for (IModuleResult module : mModuleResults.values()) {
- if (module.isDone()) {
- completeModules++;
- }
- }
- return completeModules;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public RetryChecksumStatus getRetryChecksumStatus() {
- return mRetryChecksumStatus;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setRetryChecksumStatus(RetryChecksumStatus retryStatus) {
- mRetryChecksumStatus = retryStatus;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public File getRetryDirectory() {
- return mRetryDirectory;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setRetryDirectory(File resultDir) {
- mRetryDirectory = resultDir;
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/KeyValueArgsParser.java b/common/util/src/com/android/compatibility/common/util/KeyValueArgsParser.java
deleted file mode 100644
index 92a2b18..0000000
--- a/common/util/src/com/android/compatibility/common/util/KeyValueArgsParser.java
+++ /dev/null
@@ -1,49 +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.compatibility.common.util;
-
-import java.util.HashMap;
-
-/**
- * Parses an array of arguments into a HashMap.
- *
- * This class assumed the arguments are in the form "-<key> <value> ..."
- */
-public class KeyValueArgsParser {
-
- private KeyValueArgsParser() {}
-
- public static HashMap<String, String> parse(String[] args) {
- final HashMap<String, String> map = new HashMap<String, String>();
- String key = null;
- for (String s : args) {
- if (key == null) {
- if (!s.startsWith("-")) {
- throw new RuntimeException("Invalid Key: " + s);
- }
- key = s;
- } else {
- map.put(key, s);
- key = null;
- }
- }
- if (key != null) {
- throw new RuntimeException("Left over key");
- }
- return map;
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/LightInvocationResult.java b/common/util/src/com/android/compatibility/common/util/LightInvocationResult.java
deleted file mode 100644
index 3c7008e..0000000
--- a/common/util/src/com/android/compatibility/common/util/LightInvocationResult.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.util;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Data structure for storing finalized Compatibility test results with minimum memory.
- * This implementation stores only enough ModuleResult information to return empty modules
- * of the correct ids (names and abis) upon {@link IInvocationResult}'s getModules() method.
- */
-public class LightInvocationResult implements IInvocationResult {
-
- private long mTimestamp;
- private Map<String, String> mInvocationInfo;
- private Set<String> mSerials;
- private String mBuildFingerprint;
- private String mTestPlan;
- private String mCommandLineArgs;
- private int mNotExecuted;
- private int mModuleCompleteCount;
- private RetryChecksumStatus mRetryChecksumStatus;
- private File mRetryDirectory;
- private Set<String> mModuleIds;
- private Map<TestStatus, Integer> mResultCounts;
-
- /**
- * Constructor that takes a reference to an existing result (light or complete) and
- * initializes instance variables accordingly. This class must NOT save any reference to the
- * result param to remain lightweight.
- */
- public LightInvocationResult(IInvocationResult result) {
- mTimestamp = result.getStartTime();
- mInvocationInfo = new HashMap<String, String>(result.getInvocationInfo());
- mSerials = new HashSet<String>(result.getDeviceSerials());
- mBuildFingerprint = result.getBuildFingerprint();
- mTestPlan = result.getTestPlan();
- mCommandLineArgs = result.getCommandLineArgs();
- mNotExecuted = result.getNotExecuted();
- mModuleCompleteCount = result.getModuleCompleteCount();
- mRetryChecksumStatus = RetryChecksumStatus.NotRetry;
- mRetryDirectory = result.getRetryDirectory();
- mModuleIds = new HashSet<String>();
- for (IModuleResult module : result.getModules()) {
- mModuleIds.add(module.getId());
- }
- mResultCounts = new HashMap<TestStatus, Integer>();
- for (TestStatus status : TestStatus.values()) {
- mResultCounts.put(status, result.countResults(status));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<IModuleResult> getModules() {
- List<IModuleResult> modules = new ArrayList<IModuleResult>();
- for (String id : mModuleIds) {
- modules.add(new ModuleResult(id));
- }
- return modules; // return empty modules
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int countResults(TestStatus result) {
- return mResultCounts.get(result);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getNotExecuted() {
- return mNotExecuted;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IModuleResult getOrCreateModule(String id) {
- mModuleIds.add(id);
- return new ModuleResult(id);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void mergeModuleResult(IModuleResult moduleResult) {
- mModuleIds.add(moduleResult.getId());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addInvocationInfo(String key, String value) {
- mInvocationInfo.put(key, value);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Map<String, String> getInvocationInfo() {
- return mInvocationInfo;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setStartTime(long time) {
- mTimestamp = time;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long getStartTime() {
- return mTimestamp;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setTestPlan(String plan) {
- mTestPlan = plan;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getTestPlan() {
- return mTestPlan;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addDeviceSerial(String serial) {
- mSerials.add(serial);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set<String> getDeviceSerials() {
- return mSerials;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setCommandLineArgs(String commandLineArgs) {
- mCommandLineArgs = commandLineArgs;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getCommandLineArgs() {
- return mCommandLineArgs;
- }
-
- @Override
- public void setBuildFingerprint(String buildFingerprint) {
- mBuildFingerprint = buildFingerprint;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getBuildFingerprint() {
- return mBuildFingerprint;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getModuleCompleteCount() {
- return mModuleCompleteCount;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public RetryChecksumStatus getRetryChecksumStatus() {
- return mRetryChecksumStatus;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setRetryChecksumStatus(RetryChecksumStatus retryStatus) {
- mRetryChecksumStatus = retryStatus;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public File getRetryDirectory() {
- return mRetryDirectory;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setRetryDirectory(File resultDir) {
- mRetryDirectory = resultDir;
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/LogcatInspector.java b/common/util/src/com/android/compatibility/common/util/LogcatInspector.java
deleted file mode 100644
index 053db34..0000000
--- a/common/util/src/com/android/compatibility/common/util/LogcatInspector.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package com.android.compatibility.common.util;
-
-import static junit.framework.TestCase.fail;
-
-import com.google.common.base.Joiner;
-import com.google.common.io.Closeables;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Inherit this class and implement {@link #executeShellCommand(String)} to be able to assert that
- * logcat contains what you want.
- */
-public abstract class LogcatInspector {
- private static final int SMALL_LOGCAT_DELAY = 1000;
-
- /**
- * Should execute adb shell {@param command} and return an {@link InputStream} with the result.
- */
- protected abstract InputStream executeShellCommand(String command) throws IOException;
-
- /**
- * Logs an unique string using tag {@param tag} and wait until it appears to continue execution.
- *
- * @return a unique separator string.
- * @throws IOException if error while executing command.
- */
- public String mark(String tag) throws IOException {
- String uniqueString = ":::" + UUID.randomUUID().toString();
- executeShellCommand("log -t " + tag + " " + uniqueString);
- // This is to guarantee that we only return after the string has been logged, otherwise
- // in practice the case where calling Log.?(<message1>) right after clearAndMark() resulted
- // in <message1> appearing before the unique identifier. It's not guaranteed per the docs
- // that log command will have written when returning, so better be safe. 5s should be fine.
- assertLogcatContainsInOrder(tag + ":* *:S", 5, uniqueString);
- return uniqueString;
- }
-
- /**
- * Wait for up to {@param maxTimeoutInSeconds} for the given {@param logcatStrings} strings to
- * appear in logcat in the given order. By passing the separator returned by {@link
- * #mark(String)} as the first string you can ensure that only logs emitted after that
- * call to mark() are found. Repeated strings are not supported.
- *
- * @throws AssertionError if the strings are not found in the given time.
- * @throws IOException if error while reading.
- */
- public void assertLogcatContainsInOrder(
- String filterSpec, int maxTimeoutInSeconds, String... logcatStrings)
- throws AssertionError, IOException {
- try {
- int nextStringIndex =
- numberOfLogcatStringsFound(filterSpec, maxTimeoutInSeconds, logcatStrings);
- if (nextStringIndex < logcatStrings.length) {
- fail(
- "Couldn't find "
- + logcatStrings[nextStringIndex]
- + (nextStringIndex > 0
- ? " after " + logcatStrings[nextStringIndex - 1]
- : "")
- + " within "
- + maxTimeoutInSeconds
- + " seconds ");
- }
- } catch (InterruptedException e) {
- fail("Thread interrupted unexpectedly: " + e.getMessage());
- }
- }
-
- /**
- * Wait for up to {@param timeInSeconds}, if all the strings {@param logcatStrings} are found in
- * order then the assertion fails, otherwise it succeeds.
- *
- * @throws AssertionError if all the strings are found in order in the given time.
- * @throws IOException if error while reading.
- */
- public void assertLogcatDoesNotContainInOrder(int timeInSeconds, String... logcatStrings)
- throws IOException {
- try {
- int stringsFound = numberOfLogcatStringsFound("", timeInSeconds, logcatStrings);
- if (stringsFound == logcatStrings.length) {
- fail("Found " + Joiner.on(", ").join(logcatStrings) + " that weren't expected");
- }
- } catch (InterruptedException e) {
- fail("Thread interrupted unexpectedly: " + e.getMessage());
- }
- }
-
- private int numberOfLogcatStringsFound(
- String filterSpec, int timeInSeconds, String... logcatStrings)
- throws InterruptedException, IOException {
- long timeout = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(timeInSeconds);
- int stringIndex = 0;
- while (timeout >= System.currentTimeMillis()) {
- InputStream logcatStream = executeShellCommand("logcat -v brief -d " + filterSpec);
- BufferedReader logcat = new BufferedReader(new InputStreamReader(logcatStream));
- String line;
- while ((line = logcat.readLine()) != null) {
- if (line.contains(logcatStrings[stringIndex])) {
- stringIndex++;
- if (stringIndex >= logcatStrings.length) {
- StreamUtil.drainAndClose(logcat);
- return stringIndex;
- }
- }
- }
- Closeables.closeQuietly(logcat);
- // In case the key has not been found, wait for the log to update before
- // performing the next search.
- Thread.sleep(SMALL_LOGCAT_DELAY);
- }
- return stringIndex;
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/MeasureRun.java b/common/util/src/com/android/compatibility/common/util/MeasureRun.java
deleted file mode 100644
index 2b8905f..0000000
--- a/common/util/src/com/android/compatibility/common/util/MeasureRun.java
+++ /dev/null
@@ -1,31 +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.compatibility.common.util;
-
-/**
- * Interface for measuring time for each run.
- */
-public abstract class MeasureRun {
- /**
- * Called before each run. not included in time measurement.
- */
- public void prepare(int i) throws Exception {
- // default empty implementation
- }
-
- abstract public void run(int i) throws Exception;
-}
diff --git a/common/util/src/com/android/compatibility/common/util/MeasureTime.java b/common/util/src/com/android/compatibility/common/util/MeasureTime.java
deleted file mode 100644
index 102b96a..0000000
--- a/common/util/src/com/android/compatibility/common/util/MeasureTime.java
+++ /dev/null
@@ -1,44 +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.compatibility.common.util;
-
-/**
- * Provides a mechanism to measure the time taken to run a piece of code.
- *
- * The code will be run multiple times and the time taken by each run will returned.
- */
-public class MeasureTime {
- /**
- * measure time taken for each run for given count
- * @param count
- * @param run
- * @return array of time taken in each run in msec.
- * @throws Exception
- */
- public static double[] measure(int count, MeasureRun run) throws Exception {
- double[] result = new double[count];
-
- for (int i = 0; i < count; i++) {
- run.prepare(i);
- long start = System.currentTimeMillis();
- run.run(i);
- long end = System.currentTimeMillis();
- result[i] = end - start;
- }
- return result;
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/MetricsXmlSerializer.java b/common/util/src/com/android/compatibility/common/util/MetricsXmlSerializer.java
deleted file mode 100644
index ce8696b..0000000
--- a/common/util/src/com/android/compatibility/common/util/MetricsXmlSerializer.java
+++ /dev/null
@@ -1,50 +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.compatibility.common.util;
-
-import org.xmlpull.v1.XmlSerializer;
-
-import java.io.IOException;
-
-//TODO(stuartscott): Delete file for v2, ReportLog can serialize itself.
-/**
- * Serialize Metric data from {@link ReportLog} into compatibility report friendly XML
- */
-public final class MetricsXmlSerializer {
-
- private final XmlSerializer mXmlSerializer;
-
- public MetricsXmlSerializer(XmlSerializer xmlSerializer) {
- this.mXmlSerializer = xmlSerializer;
- }
-
- public void serialize(ReportLog reportLog) throws IOException {
- if (reportLog == null) {
- return;
- }
- ReportLog.Metric summary = reportLog.getSummary();
- // <Summary message="Average" scoreType="lower_better" unit="ms">195.2</Summary>
- if (summary != null) {
- mXmlSerializer.startTag(null, "Summary");
- mXmlSerializer.attribute(null, "message", summary.getMessage());
- mXmlSerializer.attribute(null, "scoreType", summary.getType().toReportString());
- mXmlSerializer.attribute(null, "unit", summary.getUnit().toReportString());
- mXmlSerializer.text(Double.toString(summary.getValues()[0]));
- mXmlSerializer.endTag(null, "Summary");
- }
- }
-}
\ No newline at end of file
diff --git a/common/util/src/com/android/compatibility/common/util/ModuleResult.java b/common/util/src/com/android/compatibility/common/util/ModuleResult.java
deleted file mode 100644
index abb22f8..0000000
--- a/common/util/src/com/android/compatibility/common/util/ModuleResult.java
+++ /dev/null
@@ -1,302 +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.compatibility.common.util;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Data structure for a Compatibility test module result.
- */
-public class ModuleResult implements IModuleResult {
-
- private String mId;
- private long mRuntime = 0;
-
- /* Variables related to completion of the module */
- private boolean mDone = false;
- private boolean mHaveSetDone = false;
- private boolean mInProgress = false;
- private int mExpectedTestRuns = 0;
- private int mActualTestRuns = 0;
- private int mNotExecuted = 0;
- private boolean mIsFailed = false;
-
- private Map<String, ICaseResult> mResults = new HashMap<>();
-
- /**
- * Creates a {@link ModuleResult} for the given id, created with
- * {@link AbiUtils#createId(String, String)}
- */
- public ModuleResult(String id) {
- mId = id;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isDone() {
- // If module is failed, it cannot be marked done.
- if (isFailed()) {
- return false;
- }
- return mDone && !mInProgress && (mActualTestRuns >= mExpectedTestRuns);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isDoneSoFar() {
- return mDone && !mInProgress;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void initializeDone(boolean done) {
- mDone = done;
- mHaveSetDone = false;
- if (mDone) {
- mNotExecuted = 0;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setDone(boolean done) {
- if (mHaveSetDone) {
- mDone &= done; // If we've already set done for this instance, AND the received value
- } else {
- mDone = done; // If done has only been initialized, overwrite the existing value
- }
- mHaveSetDone = true;
- if (mDone) {
- mNotExecuted = 0;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void inProgress(boolean inProgress) {
- mInProgress = inProgress;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getExpectedTestRuns() {
- return mExpectedTestRuns;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setExpectedTestRuns(int numRuns) {
- mExpectedTestRuns = numRuns;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getTestRuns() {
- return mActualTestRuns;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addTestRun() {
- mActualTestRuns++;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void resetTestRuns() {
- mActualTestRuns = 0;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getNotExecuted() {
- return mNotExecuted;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setNotExecuted(int numTests) {
- mNotExecuted = numTests;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getId() {
- return mId;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getName() {
- return AbiUtils.parseTestName(mId);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getAbi() {
- return AbiUtils.parseAbi(mId);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addRuntime(long elapsedTime) {
- mRuntime += elapsedTime;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void resetRuntime() {
- mRuntime = 0;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long getRuntime() {
- return mRuntime;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ICaseResult getOrCreateResult(String caseName) {
- ICaseResult result = mResults.get(caseName);
- if (result == null) {
- result = new CaseResult(caseName);
- mResults.put(caseName, result);
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ICaseResult getResult(String caseName) {
- return mResults.get(caseName);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<ICaseResult> getResults() {
- ArrayList<ICaseResult> results = new ArrayList<>(mResults.values());
- Collections.sort(results);
- return results;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int countResults(TestStatus status) {
- int total = 0;
- for (ICaseResult result : mResults.values()) {
- total += result.countResults(status);
- }
- return total;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int compareTo(IModuleResult another) {
- return getId().compareTo(another.getId());
- }
-
- @Override
- public void setFailed() {
- mIsFailed = true;
- }
-
- @Override
- public boolean isFailed() {
- return mIsFailed;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void mergeFrom(IModuleResult otherModuleResult) {
- if (!otherModuleResult.getId().equals(getId())) {
- throw new IllegalArgumentException(String.format(
- "Cannot merge module result with mismatched id. Expected %s, Found %s",
- otherModuleResult.getId(), getId()));
- }
-
- this.mRuntime += otherModuleResult.getRuntime();
- this.mNotExecuted += otherModuleResult.getNotExecuted();
- // Only touch variables related to 'done' status if this module is not already done
- if (!isDone()) {
- this.setDone(otherModuleResult.isDoneSoFar());
- this.mActualTestRuns += otherModuleResult.getTestRuns();
- // expected test runs are the same across shards, except for shards that do not run
- // this module at least once (for which the value is not yet set).
- this.mExpectedTestRuns += otherModuleResult.getExpectedTestRuns();
- }
- // If something failed, then the aggregation is failed
- if (!this.isFailed()) {
- this.mIsFailed = otherModuleResult.isFailed();
- }
- for (ICaseResult otherCaseResult : otherModuleResult.getResults()) {
- ICaseResult caseResult = getOrCreateResult(otherCaseResult.getName());
- caseResult.mergeFrom(otherCaseResult);
- }
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/MultipartForm.java b/common/util/src/com/android/compatibility/common/util/MultipartForm.java
deleted file mode 100644
index c311492..0000000
--- a/common/util/src/com/android/compatibility/common/util/MultipartForm.java
+++ /dev/null
@@ -1,165 +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.compatibility.common.util;
-
-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;
-
-/** Builds a multipart form and submits it. */
-class MultipartForm {
-
- private static final String FORM_DATA_BOUNDARY = "C75I55u3R3p0r73r";
-
- /* package */ final String mServerUrl;
- /* package */ final Map<String, String> mFormValues = new HashMap<String, String>();
- /* package */ String mName;
- /* package */ String mFileName;
- /* package */ byte[] mData;
-
- /**
- * Creates a new multi-part form with the given serverUrl.
- */
- public MultipartForm(String serverUrl) {
- mServerUrl = serverUrl;
- }
-
- /**
- * Adds a key value attribute to the form.
- *
- * @param name the name of the attribute.
- * @param value the attribute's value.
- * @return the {@link MultipartForm} for easy chaining.
- */
- public MultipartForm addFormValue(String name, String value) {
- mFormValues.put(name, value);
- return this;
- }
-
- /**
- * Adds the file as the payload of the form.
- *
- * @param name The name of attribute
- * @param fileName The file's name
- * @param data The file's data
- * @return the {@link MultipartForm} for easy chaining.
- */
- public MultipartForm addFormFile(String name, String fileName, byte[] data) {
- mName = name;
- mFileName = fileName;
- mData = data;
- return this;
- }
-
- /**
- * Submits the form to the server url.
- *
- * This will handle a redirection from the server.
- *
- * @return response code
- * @throws IOException
- */
- public int submit() throws IOException {
- return submitForm(mServerUrl);
- }
-
- /**
- * @param serverUrl to post the data to
- * @return response code
- * @throws IOException
- */
- private int 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();
-
- int response = connection.getResponseCode();
- if (response == 302) {
- return submitForm(connection.getHeaderField("Location"));
- }
- return response;
- } finally {
- if (connection != null) {
- connection.disconnect();
- }
- }
- }
-
- /* package */ 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/common/util/src/com/android/compatibility/common/util/ReadElf.java b/common/util/src/com/android/compatibility/common/util/ReadElf.java
deleted file mode 100644
index b681c1c..0000000
--- a/common/util/src/com/android/compatibility/common/util/ReadElf.java
+++ /dev/null
@@ -1,1341 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A poor man's implementation of the readelf command. This program is designed to parse ELF
- * (Executable and Linkable Format) files.
- */
-// ToDo: consolidate with com.android.compatibility.common.util
-public class ReadElf implements AutoCloseable {
- /** The magic values for the ELF identification. */
- private static final byte[] ELFMAG = {
- (byte) 0x7F, (byte) 'E', (byte) 'L', (byte) 'F',
- };
-
- private static final int EI_NIDENT = 16;
-
- private static final int EI_CLASS = 4;
- private static final int EI_DATA = 5;
-
- public static final int ET_DYN = 3;
- public static final int EM_386 = 3;
- public static final int EM_MIPS = 8;
- public static final int EM_ARM = 40;
- public static final int EM_X86_64 = 62;
- // http://en.wikipedia.org/wiki/Qualcomm_Hexagon
- public static final int EM_QDSP6 = 164;
- public static final int EM_AARCH64 = 183;
-
- public static final String ARCH_ARM = "arm";
- public static final String ARCH_X86 = "x86";
- public static final String ARCH_MIPS = "mips";
- public static final String ARCH_UNKNOWN = "unknown";
- private static final String RODATA = ".rodata";
-
- private static final int ELFCLASS32 = 1;
- private static final int ELFCLASS64 = 2;
-
- private static final int ELFDATA2LSB = 1;
- private static final int ELFDATA2MSB = 2;
-
- private static final int EV_CURRENT = 1;
-
- private static final long PT_LOAD = 1;
-
- // https://en.wikipedia.org/wiki/Executable_and_Linkable_Format
- private static final int SHT_PROGBITS = 1;
- private static final int SHT_SYMTAB = 2;
- private static final int SHT_STRTAB = 3;
- private static final int SHT_DYNAMIC = 6;
- private static final int SHT_DYNSYM = 11;
- private static final int SHT_GNU_VERDEF = 0x6ffffffd;
- private static final int SHT_GNU_VERNEED = 0x6ffffffe;
- private static final int SHT_GNU_VERSYM = 0x6fffffff;
-
- public static class Symbol {
- public static final int STB_LOCAL = 0;
- public static final int STB_GLOBAL = 1;
- public static final int STB_WEAK = 2;
- public static final int STB_LOPROC = 13;
- public static final int STB_HIPROC = 15;
-
- public static final int STT_NOTYPE = 0;
- public static final int STT_OBJECT = 1;
- public static final int STT_FUNC = 2;
- public static final int STT_SECTION = 3;
- public static final int STT_FILE = 4;
- public static final int STT_COMMON = 5;
- public static final int STT_TLS = 6;
-
- public static final int SHN_UNDEF = 0;
- public static final int SHN_ABS = 0xfff1;
-
- public final String name;
- public final int bind;
- public final int type;
- public final int shndx;
- public final long value;
- public final long size;
- public final int other;
-
- public VerNeed mVerNeed;
- public VerDef mVerDef;
-
- Symbol(String name, int st_info, int st_shndx, long st_value, long st_size, int st_other) {
- this.name = name;
- this.bind = (st_info >> 4) & 0x0F;
- this.type = st_info & 0x0F;
- this.shndx = st_shndx;
- this.value = st_value;
- this.size = st_size;
- this.other = st_other;
- }
-
- @Override
- public String toString() {
- return String.format(
- "%s, %s, %s, %s, %s, %s",
- name,
- toBind(),
- toType(),
- toShndx(),
- getExternalLibFileName(),
- getExternalLibName());
- }
-
- public String toBind() {
- switch (bind) {
- case STB_LOCAL:
- return "LOCAL";
- case STB_GLOBAL:
- return "GLOBAL";
- case STB_WEAK:
- return "WEAK";
- }
- return "STB_??? (" + bind + ")";
- }
-
- public String toType() {
- switch (type) {
- case STT_NOTYPE:
- return "NOTYPE";
- case STT_OBJECT:
- return "OBJECT";
- case STT_FUNC:
- return "FUNC";
- case STT_SECTION:
- return "SECTION";
- case STT_FILE:
- return "FILE";
- case STT_COMMON:
- return "COMMON";
- case STT_TLS:
- return "TLS";
- }
- return "STT_??? (" + type + ")";
- }
-
- public String toShndx() {
- switch (shndx) {
- case SHN_ABS:
- return "ABS";
- case SHN_UNDEF:
- return "UND";
- }
- return String.valueOf(shndx);
- }
-
- // if a symbol is not define locally
- public boolean isGlobalUnd() {
- return (bind != STB_LOCAL && shndx == SHN_UNDEF);
- }
-
- // if a symbol is extern
- public boolean isExtern() {
- return (bind != STB_LOCAL && shndx != SHN_UNDEF);
- }
-
- public String getExternalLibFileName() {
- if (mVerNeed != null) {
- return mVerNeed.vn_file_name;
- }
- return null;
- }
-
- public String getExternalLibName() {
- if (mVerNeed != null) {
- return mVerNeed.vn_vernaux[0].vna_lib_name;
- }
- return null;
- }
-
- public int getExternalLibVer() {
- if (mVerNeed != null) {
- return mVerNeed.vn_vernaux[0].vna_other;
- }
- return -1;
- }
-
- public String getVerDefLibName() {
- if (mVerDef != null) {
- return mVerDef.vd_verdaux[0].vda_lib_name;
- }
- return null;
- }
-
- public int getVerDefVersion() {
- if (mVerDef != null) {
- return mVerDef.vd_version;
- }
- return -1;
- }
- }
-
- public static class SecHeader {
- public final long sh_name;
- public final long sh_type;
- public final long sh_flags;
- public final long sh_addr;
- public final long sh_offset;
- public final long sh_size;
- public final long sh_link;
- public final long sh_info;
- public final long sh_addralign;
- public final long sh_entsize;
-
- SecHeader(
- long name,
- long type,
- long flags,
- long addr,
- long offset,
- long size,
- long link,
- long info,
- long addralign,
- long entsize) {
- this.sh_name = name;
- this.sh_type = type;
- this.sh_flags = flags;
- this.sh_addr = addr;
- this.sh_offset = offset;
- this.sh_size = size;
- this.sh_link = link;
- this.sh_info = info;
- this.sh_addralign = addralign;
- this.sh_entsize = entsize;
- }
-
- @Override
- public String toString() {
- return String.format(
- "%d, %d, %d, %d, %d, %d, %d, %d, %d, %d",
- this.sh_name,
- this.sh_type,
- this.sh_flags,
- this.sh_addr,
- this.sh_offset,
- this.sh_size,
- this.sh_link,
- this.sh_info,
- this.sh_addralign,
- this.sh_entsize);
- }
- }
-
- public static class VerNeed {
- public final int vn_version;
- public final int vn_cnt;
- public final long vn_file;
- public final long vn_aux;
- public final long vn_next;
- public String vn_file_name;
- public VerNAux[] vn_vernaux;
-
- VerNeed(String file_name, String lib_name, int ndx) {
- this.vn_file_name = file_name.toLowerCase();
- this.vn_vernaux = new VerNAux[1];
- this.vn_vernaux[0] = new VerNAux(lib_name, ndx);
-
- this.vn_version = 0;
- this.vn_cnt = 0;
- this.vn_file = 0;
- this.vn_aux = 0;
- this.vn_next = 0;
- }
-
- VerNeed(int ver, int cnt, long file, long aux, long next) {
- this.vn_version = ver;
- this.vn_cnt = cnt;
- this.vn_file = file;
- this.vn_aux = aux;
- this.vn_next = next;
- }
-
- @Override
- public String toString() {
- String vernauxStr = "";
- for (int i = 0; i < this.vn_cnt; i++) {
- vernauxStr += String.format(" %s\n", this.vn_vernaux[i].toString());
- }
- return String.format(
- "%s, %d, %d, %d, %d, %d \n%s",
- this.vn_file_name,
- this.vn_version,
- this.vn_cnt,
- this.vn_file,
- this.vn_aux,
- this.vn_next,
- vernauxStr);
- }
- }
-
- public static class VerNAux {
- public final long vna_hash;
- public final int vna_flags;
- public final int vna_other;
- public final long vna_name;
- public final long vna_next;
- public String vna_lib_name;
-
- VerNAux(String lib_name, int ndx) {
- this.vna_lib_name = lib_name;
-
- this.vna_hash = 0;
- this.vna_flags = 0;
- this.vna_other = ndx;
- this.vna_name = 0;
- this.vna_next = 0;
- }
-
- VerNAux(long hash, int flags, int other, long name, long next) {
- this.vna_hash = hash;
- this.vna_flags = flags;
- this.vna_other = other;
- this.vna_name = name;
- this.vna_next = next;
- }
-
- @Override
- public String toString() {
- return String.format(
- "%s, %d, %d, %d, %d, %d",
- this.vna_lib_name,
- this.vna_hash,
- this.vna_flags,
- this.vna_other,
- this.vna_name,
- this.vna_next);
- }
- }
-
- public static class VerDef {
- public final int vd_version;
- public final int vd_flags;
- public final int vd_ndx;
- public final int vd_cnt;
- public final long vd_hash;
- public final long vd_aux;
- public final long vd_next;
- public VerDAux[] vd_verdaux;
-
- VerDef(String lib_name) {
- this.vd_verdaux = new VerDAux[1];
- this.vd_verdaux[0] = new VerDAux(lib_name);
-
- this.vd_version = 0;
- this.vd_flags = 0;
- this.vd_ndx = 0;
- this.vd_cnt = 0;
- this.vd_hash = 0;
- this.vd_aux = 0;
- this.vd_next = 0;
- }
-
- VerDef(int ver, int flags, int ndx, int cnt, long hash, long aux, long next) {
- this.vd_version = ver;
- this.vd_flags = flags;
- this.vd_ndx = ndx;
- this.vd_cnt = cnt;
- this.vd_hash = hash;
- this.vd_aux = aux;
- this.vd_next = next;
- }
-
- @Override
- public String toString() {
- String vStr = "";
- for (int i = 0; i < this.vd_cnt; i++) {
- vStr += String.format(" %s\n", this.vd_verdaux[i].toString());
- }
- return String.format(
- "%s, %d, %d, %d, %d, %d \n%s",
- this.vd_verdaux[0].vda_lib_name,
- this.vd_version,
- this.vd_flags,
- this.vd_ndx,
- this.vd_cnt,
- this.vd_hash,
- vStr);
- }
- }
-
- public static class VerDAux {
- public final long vda_name;
- public final long vda_next;
- public String vda_lib_name;
-
- VerDAux(String lib_name) {
- this.vda_lib_name = lib_name.toLowerCase();
-
- this.vda_name = 0;
- this.vda_next = 0;
- }
-
- VerDAux(long name, long next) {
- this.vda_name = name;
- this.vda_next = next;
- }
-
- @Override
- public String toString() {
- return String.format("%s, %d, %d", this.vda_lib_name, this.vda_name, this.vda_next);
- }
- }
-
- // Dynamic Section Entry
- public static class DynamicEntry {
- private static final int DT_NEEDED = 1;
- public final long mTag;
- public final long mValue;
-
- DynamicEntry(long tag, long value) {
- mTag = tag;
- mValue = value;
- }
-
- public boolean isNeeded() {
- if (mTag == DT_NEEDED) {
- return true;
- } else {
- // System.err.println(String.format("Not Needed: %d, %d", mTag, mValue));
- return false;
- }
- }
-
- public long getValue() {
- return mValue;
- }
-
- @Override
- public String toString() {
- return String.format("%d, %d", this.mTag, this.mValue);
- }
- }
-
- private final String mPath;
- private final RandomAccessFile mFile;
- private final byte[] mBuffer = new byte[512];
- private int mEndian;
- private boolean mIsDynamic;
- private boolean mIsPIE;
- private int mType;
- private int mAddrSize;
- private int mMachine;
-
- /** Symbol Table offset */
- private long mSymTabOffset;
-
- /** Symbol Table size */
- private long mSymTabSize;
-
- /** Symbol entry count */
- private int mSymEntCnt;
-
- /** Dynamic Symbol Table offset */
- private long mDynSymOffset;
-
- /** Dynamic Symbol Table size */
- private long mDynSymSize;
-
- /** Dynamic entry count */
- private int mDynSymEntCnt;
-
- /** Section Header String Table offset */
- private long mShStrTabOffset;
-
- /** Section Header String Table size */
- private long mShStrTabSize;
-
- /** String Table offset */
- private long mStrTabOffset;
-
- /** String Table size */
- private long mStrTabSize;
-
- /** Dynamic String Table offset */
- private long mDynStrOffset;
-
- /** Dynamic String Table size */
- private long mDynStrSize;
-
- /** Dynamic Table offset */
- private long mDynamicTabOffset;
-
- /** Dynamic Table size */
- private long mDynamicTabSize;
-
- /** Version Symbols Table offset */
- private long mVerSymTabOffset;
-
- /** Version Symbols Table size */
- private long mVerSymTabSize;
-
- /** Version Needs Table offset */
- private long mVerNeedTabOffset;
-
- /** Version Definition Table size */
- private long mVerNeedTabSize;
-
- private int mVerNeedEntryCnt;
-
- /** Version Definition Table offset */
- private long mVerDefTabOffset;
-
- /** Version Needs Table size */
- private long mVerDefTabSize;
-
- private int mVerDefEntryCnt;
-
- /** Symbol Table symbol names */
- private Map<String, Symbol> mSymbols;
-
- /** Symbol Table symbol array */
- private Symbol[] mSymArr;
-
- /** Dynamic Symbol Table symbol names */
- private Map<String, Symbol> mDynamicSymbols;
-
- /** Dynamic Symbol Table symbol array */
- private Symbol[] mDynSymArr;
-
- /** Version Symbols Table */
- private int[] mVerSym;
-
- /** Version Needed Table */
- private VerNeed[] mVerNeedArr;
-
- /** Version Definition Table */
- private VerDef[] mVerDefArr;
-
- /** Dynamic Table */
- private List<DynamicEntry> mDynamicArr;
-
- /** Rodata offset */
- private boolean mHasRodata;
-
- /** Rodata offset */
- private long mRodataOffset;
-
- /** Rodata size */
- private int mRodataSize;
-
- /** Rodata String List */
- private List<String> mRoStrings;
-
- /** Rodata byte[] */
- private byte[] mRoData;
-
- public static ReadElf read(File file) throws IOException {
- return new ReadElf(file);
- }
-
- public static void main(String[] args) throws IOException {
- for (String arg : args) {
- ReadElf elf = ReadElf.read(new File(arg));
- elf.getDynamicSymbol("x");
- elf.getSymbol("x");
-
- Symbol[] symArr;
- System.out.println("===Symbol===");
- symArr = elf.getSymArr();
- for (int i = 0; i < symArr.length; i++) {
- System.out.println(String.format("%8x: %s", i, symArr[i].toString()));
- }
- System.out.println("===Dynamic Symbol===");
- symArr = elf.getDynSymArr();
- for (int i = 0; i < symArr.length; i++) {
- if (elf.mVerNeedEntryCnt > 0) {
- System.out.println(
- String.format(
- "%8x: %s, %s, %s - %d",
- i,
- symArr[i].toString(),
- symArr[i].getExternalLibName(),
- symArr[i].getExternalLibFileName(),
- symArr[i].getExternalLibVer()));
- } else {
- System.out.println(
- String.format(
- "%8x: %s, %s - %d",
- i,
- symArr[i].toString(),
- symArr[i].getVerDefLibName(),
- symArr[i].getVerDefVersion()));
- }
- }
-
- System.out.println("===Dynamic Dependencies===");
- for (String DynDepEntry : elf.getDynamicDependencies()) {
- System.out.println(DynDepEntry);
- }
-
- System.out.println("===Strings in Read Only(.rodata) section===");
- for (String roStr : elf.getRoStrings()) {
- System.out.println(roStr);
- }
-
- elf.close();
- }
- }
-
- public static boolean isElf(File file) {
- try {
- if (file.length() < EI_NIDENT) {
- throw new IllegalArgumentException(
- "Too small to be an ELF file: " + file.getCanonicalPath());
- }
-
- RandomAccessFile raFile = new RandomAccessFile(file, "r");
- byte[] buffer = new byte[512];
- raFile.seek(0);
- raFile.readFully(buffer, 0, EI_NIDENT);
- if (buffer[0] != ELFMAG[0]
- || buffer[1] != ELFMAG[1]
- || buffer[2] != ELFMAG[2]
- || buffer[3] != ELFMAG[3]) {
- throw new IllegalArgumentException("Invalid ELF file: " + file.getCanonicalPath());
- }
- raFile.close();
- ;
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- public int getBits() {
- if (mMachine == EM_386
- || mMachine == EM_MIPS
- || mMachine == EM_ARM
- || mMachine == EM_QDSP6) {
- return 32;
- } else if (mMachine == EM_AARCH64 || mMachine == EM_X86_64) {
- return 64;
- } else {
- return -1;
- }
- }
-
- public String getArchitecture() {
- if (mMachine == EM_ARM || mMachine == EM_AARCH64) {
- return ARCH_ARM;
- } else if (mMachine == EM_386 || mMachine == EM_X86_64) {
- return ARCH_X86;
- } else if (mMachine == EM_MIPS) {
- return ARCH_MIPS;
- } else {
- return ARCH_UNKNOWN;
- }
- }
-
- public Map<String, Symbol> getSymbols() throws IOException {
- if (mSymbols == null) {
- getSymbol("");
- }
- return mSymbols;
- }
-
- public Symbol[] getSymArr() throws IOException {
- if (mSymArr == null) {
- getSymbol("");
- }
- return mSymArr;
- }
-
- public Map<String, Symbol> getDynamicSymbols() throws IOException {
- if (mDynamicSymbols == null) {
- getDynamicSymbol("");
- }
- return mDynamicSymbols;
- }
-
- public Symbol[] getDynSymArr() throws IOException {
- if (mDynSymArr == null) {
- getDynamicSymbol("");
- }
- return mDynSymArr;
- }
-
- public boolean isDynamic() {
- return mIsDynamic;
- }
-
- public int getType() {
- return mType;
- }
-
- public boolean isPIE() {
- return mIsPIE;
- }
-
- private ReadElf(File file) throws IOException {
- mHasRodata = false;
- mRoData = null;
- mPath = file.getPath();
- mFile = new RandomAccessFile(file, "r");
-
- if (mFile.length() < EI_NIDENT) {
- throw new IllegalArgumentException("Too small to be an ELF file: " + file);
- }
-
- readHeader();
- }
-
- @Override
- public void close() {
- try {
- mFile.close();
- } catch (IOException ignored) {
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- try {
- close();
- } finally {
- super.finalize();
- }
- }
-
- private void readHeader() throws IOException {
- mFile.seek(0);
- mFile.readFully(mBuffer, 0, EI_NIDENT);
-
- if (mBuffer[0] != ELFMAG[0]
- || mBuffer[1] != ELFMAG[1]
- || mBuffer[2] != ELFMAG[2]
- || mBuffer[3] != ELFMAG[3]) {
- throw new IllegalArgumentException("Invalid ELF file: " + mPath);
- }
-
- int elfClass = mBuffer[EI_CLASS];
- if (elfClass == ELFCLASS32) {
- mAddrSize = 4;
- } else if (elfClass == ELFCLASS64) {
- mAddrSize = 8;
- } else {
- throw new IOException("Invalid ELF EI_CLASS: " + elfClass + ": " + mPath);
- }
-
- mEndian = mBuffer[EI_DATA];
- if (mEndian == ELFDATA2LSB) {
- } else if (mEndian == ELFDATA2MSB) {
- throw new IOException("Unsupported ELFDATA2MSB file: " + mPath);
- } else {
- throw new IOException("Invalid ELF EI_DATA: " + mEndian + ": " + mPath);
- }
-
- mType = readHalf();
-
- int e_machine = readHalf();
- if (e_machine != EM_386
- && e_machine != EM_X86_64
- && e_machine != EM_AARCH64
- && e_machine != EM_ARM
- && e_machine != EM_MIPS
- && e_machine != EM_QDSP6) {
- throw new IOException("Invalid ELF e_machine: " + e_machine + ": " + mPath);
- }
-
- // AbiTest relies on us rejecting any unsupported combinations.
- if ((e_machine == EM_386 && elfClass != ELFCLASS32)
- || (e_machine == EM_X86_64 && elfClass != ELFCLASS64)
- || (e_machine == EM_AARCH64 && elfClass != ELFCLASS64)
- || (e_machine == EM_ARM && elfClass != ELFCLASS32)
- || (e_machine == EM_QDSP6 && elfClass != ELFCLASS32)) {
- throw new IOException(
- "Invalid e_machine/EI_CLASS ELF combination: "
- + e_machine
- + "/"
- + elfClass
- + ": "
- + mPath);
- }
-
- mMachine = e_machine;
- long e_version = readWord();
- if (e_version != EV_CURRENT) {
- throw new IOException("Invalid e_version: " + e_version + ": " + mPath);
- }
-
- long e_entry = readAddr();
-
- long ph_off = readOff();
- long sh_off = readOff();
-
- long e_flags = readWord();
- int e_ehsize = readHalf();
- int e_phentsize = readHalf();
- int e_phnum = readHalf();
- int e_shentsize = readHalf();
- int e_shnum = readHalf();
- int e_shstrndx = readHalf();
-
- readSectionHeaders(sh_off, e_shnum, e_shentsize, e_shstrndx);
- readProgramHeaders(ph_off, e_phnum, e_phentsize);
- }
-
- private void readSectionHeaders(long sh_off, int e_shnum, int e_shentsize, int e_shstrndx)
- throws IOException {
- // Read the Section Header String Table offset first.
- {
- mFile.seek(sh_off + e_shstrndx * e_shentsize);
-
- long sh_name = readWord();
- long sh_type = readWord();
- long sh_flags = readX(mAddrSize);
- long sh_addr = readAddr();
- long sh_offset = readOff();
- long sh_size = readX(mAddrSize);
- // ...
-
- if (sh_type == SHT_STRTAB) {
- mShStrTabOffset = sh_offset;
- mShStrTabSize = sh_size;
- }
- }
-
- for (int i = 0; i < e_shnum; ++i) {
- // Don't bother to re-read the Section Header StrTab.
- if (i == e_shstrndx) {
- continue;
- }
-
- mFile.seek(sh_off + i * e_shentsize);
-
- long sh_name = readWord();
- long sh_type = readWord();
- long sh_flags = readX(mAddrSize);
- long sh_addr = readAddr();
- long sh_offset = readOff();
- long sh_size = readX(mAddrSize);
- long sh_link = readWord();
- long sh_info = readWord();
- long sh_addralign = readX(mAddrSize);
- ;
- long sh_entsize = readX(mAddrSize);
- ;
-
- if (sh_type == SHT_SYMTAB || sh_type == SHT_DYNSYM) {
- final String symTabName = readShStrTabEntry(sh_name);
- if (".symtab".equals(symTabName)) {
- mSymTabOffset = sh_offset;
- mSymTabSize = sh_size;
- mSymEntCnt = (int) (sh_size / sh_entsize);
- } else if (".dynsym".equals(symTabName)) {
- mDynSymOffset = sh_offset;
- mDynSymSize = sh_size;
- mDynSymEntCnt = (int) (sh_size / sh_entsize);
- }
- System.out.println(
- String.format(
- "%s, %d, %d, %d, %d, %d",
- symTabName, sh_offset, sh_size, sh_link, sh_info, sh_entsize));
- } else if (sh_type == SHT_STRTAB) {
- final String strTabName = readShStrTabEntry(sh_name);
- if (".strtab".equals(strTabName)) {
- mStrTabOffset = sh_offset;
- mStrTabSize = sh_size;
- System.out.println(
- String.format(
- "%s, %d, %d, %d, %d",
- strTabName, sh_offset, sh_size, sh_link, sh_info));
- } else if (".dynstr".equals(strTabName)) {
- mDynStrOffset = sh_offset;
- mDynStrSize = sh_size;
- System.out.println(
- String.format(
- "%s, %d, %d, %d, %d",
- strTabName, sh_offset, sh_size, sh_link, sh_info));
- }
- } else if (sh_type == SHT_DYNAMIC) {
- mIsDynamic = true;
- final String strTabName = readShStrTabEntry(sh_name);
- mDynamicTabOffset = sh_offset;
- mDynamicTabSize = sh_size;
- System.out.println(
- String.format(
- "%s, %d, %d, %d, %d",
- strTabName, sh_offset, sh_size, sh_link, sh_info));
- } else if (sh_type == SHT_GNU_VERSYM) {
- final String strTabName = readShStrTabEntry(sh_name);
- if (".gnu.version".equals(strTabName)) {
- mVerSymTabOffset = sh_offset;
- mVerSymTabSize = sh_size;
- }
- System.out.println(
- String.format(
- "%s, %d, %d, %d, %d",
- strTabName, sh_offset, sh_size, sh_link, sh_info));
- } else if (sh_type == SHT_GNU_VERNEED) {
- final String strTabName = readShStrTabEntry(sh_name);
- if (".gnu.version_r".equals(strTabName)) {
- mVerNeedTabOffset = sh_offset;
- mVerNeedTabSize = sh_size;
- mVerNeedEntryCnt = (int) sh_info;
- }
- System.out.println(
- String.format(
- "%s, %d, %d, %d, %d",
- strTabName, sh_offset, sh_size, sh_link, sh_info));
- } else if (sh_type == SHT_GNU_VERDEF) {
- final String strTabName = readShStrTabEntry(sh_name);
- if (".gnu.version_d".equals(strTabName)) {
- mVerDefTabOffset = sh_offset;
- mVerDefTabSize = sh_size;
- mVerDefEntryCnt = (int) sh_info;
- }
- System.out.println(
- String.format(
- "%s, %d, %d, %d, %d",
- strTabName, sh_offset, sh_size, sh_link, sh_info));
- } else if (sh_type == SHT_PROGBITS) {
- final String strTabName = readShStrTabEntry(sh_name);
- if (".rodata".equals(strTabName)) {
- mHasRodata = true;
- mRodataOffset = sh_offset;
- mRodataSize = (int) sh_size;
- }
- System.out.println(
- String.format(
- "%s, %d, %d, %d, %d",
- strTabName, sh_offset, sh_size, sh_link, sh_info));
- }
- }
- }
-
- private void readProgramHeaders(long ph_off, int e_phnum, int e_phentsize) throws IOException {
- for (int i = 0; i < e_phnum; ++i) {
- mFile.seek(ph_off + i * e_phentsize);
-
- long p_type = readWord();
- if (p_type == PT_LOAD) {
- if (mAddrSize == 8) {
- // Only in Elf64_phdr; in Elf32_phdr p_flags is at the end.
- long p_flags = readWord();
- }
- long p_offset = readOff();
- long p_vaddr = readAddr();
- // ...
-
- if (p_vaddr == 0) {
- mIsPIE = true;
- }
- }
- }
- }
-
- private HashMap<String, Symbol> readSymbolTable(
- Symbol[] symArr,
- boolean isDynSym,
- long symStrOffset,
- long symStrSize,
- long tableOffset,
- long tableSize)
- throws IOException {
- HashMap<String, Symbol> result = new HashMap<String, Symbol>();
- mFile.seek(tableOffset);
- int i = 0;
- while (mFile.getFilePointer() < tableOffset + tableSize) {
- long st_name = readWord();
- int st_info;
- int st_shndx;
- long st_value;
- long st_size;
- int st_other;
- if (mAddrSize == 8) {
- st_info = readByte();
- st_other = readByte();
- st_shndx = readHalf();
- st_value = readAddr();
- st_size = readX(mAddrSize);
- } else {
- st_value = readAddr();
- st_size = readWord();
- st_info = readByte();
- st_other = readByte();
- st_shndx = readHalf();
- }
-
- String symName;
- if (st_name == 0) {
- symName = "";
- } else {
- symName = readStrTabEntry(symStrOffset, symStrSize, st_name);
- }
-
- Symbol sym = new Symbol(symName, st_info, st_shndx, st_value, st_size, st_other);
- if (!symName.equals("")) {
- result.put(symName, sym);
- }
- if (isDynSym) {
- if (mVerNeedEntryCnt > 0) {
- if (sym.type == Symbol.STT_NOTYPE) {
- sym.mVerNeed = mVerNeedArr[0];
- } else {
- sym.mVerNeed = getVerNeed(mVerSym[i]);
- }
- } else if (mVerDefEntryCnt > 0) {
- sym.mVerDef = mVerDefArr[mVerSym[i]];
- }
- }
- symArr[i] = sym;
- i++;
- }
- System.out.println(
- String.format(
- "Info readSymbolTable: %s, isDynSym %b, symbol# %d",
- mPath, isDynSym, symArr.length));
- return result;
- }
-
- private String readShStrTabEntry(long strOffset) throws IOException {
- if (mShStrTabOffset == 0 || strOffset < 0 || strOffset >= mShStrTabSize) {
- return null;
- }
- return readString(mShStrTabOffset + strOffset);
- }
-
- private String readStrTabEntry(long tableOffset, long tableSize, long strOffset)
- throws IOException {
- if (tableOffset == 0 || strOffset < 0 || strOffset >= tableSize) {
- return null;
- }
- return readString(tableOffset + strOffset);
- }
-
- private String readDynStrTabEntry(long strOffset) throws IOException {
- if (mDynStrOffset == 0 || strOffset < 0 || strOffset >= mDynStrSize) {
- return null;
- }
- return readString(mDynStrOffset + strOffset);
- }
-
- private int[] getVerSym() throws IOException {
- if (mVerSym == null) {
- mFile.seek(mVerSymTabOffset);
- int cnt = (int) mVerSymTabSize / 2;
- mVerSym = new int[cnt];
- for (int i = 0; i < cnt; i++) {
- mVerSym[i] = readHalf();
- //System.out.println(String.format("%d, %d", i, mVerSym[i]));
- }
- }
- return mVerSym;
- }
-
- public VerNeed getVerNeed(int ndx) throws IOException {
- // vna_other Contains version index unique for the file which is used in the version symbol table.
- if (ndx < 2) {
- return this.mVerNeedArr[ndx];
- }
-
- for (int i = 2; i < this.mVerNeedEntryCnt + 2; i++) {
- for (int j = 0; j < this.mVerNeedArr[i].vn_cnt; j++) {
- if (this.mVerNeedArr[i].vn_vernaux[j].vna_other == ndx) {
- return this.mVerNeedArr[i];
- }
- }
- }
- System.out.println(String.format("no VerNeed found: %d", ndx));
- return null;
- }
-
- private VerNeed[] getVerNeedArr() throws IOException {
- if (mVerNeedArr == null) {
- mVerNeedArr = new VerNeed[mVerNeedEntryCnt + 2];
-
- // SHT_GNU_versym 0: local
- mVerNeedArr[0] = new VerNeed("*local*", "*local*", 0);
- // HT_GNU_versym 1: global
- mVerNeedArr[1] = new VerNeed("*global*", "*global*", 1);
-
- long idx = mVerNeedTabOffset;
- for (int i = 2; i < mVerNeedEntryCnt + 2; i++) {
- mFile.seek(idx);
- mVerNeedArr[i] =
- new VerNeed(readHalf(), readHalf(), readWord(), readWord(), readWord());
- mVerNeedArr[i].vn_file_name = readDynStrTabEntry(mVerNeedArr[i].vn_file).toLowerCase();
-
- mVerNeedArr[i].vn_vernaux = new VerNAux[mVerNeedArr[i].vn_cnt];
- long idxAux = idx + mVerNeedArr[i].vn_aux;
- for (int j = 0; j < mVerNeedArr[i].vn_cnt; j++) {
- mFile.seek(idxAux);
- mVerNeedArr[i].vn_vernaux[j] =
- new VerNAux(readWord(), readHalf(), readHalf(), readWord(), readWord());
- mVerNeedArr[i].vn_vernaux[j].vna_lib_name =
- readDynStrTabEntry(mVerNeedArr[i].vn_vernaux[j].vna_name);
- idxAux += mVerNeedArr[i].vn_vernaux[j].vna_next;
- }
- idx += mVerNeedArr[i].vn_next;
- System.out.println(mVerNeedArr[i]);
- }
- }
-
- return mVerNeedArr;
- }
-
- private VerDef[] getVerDef() throws IOException {
- if (mVerDefArr == null) {
- mVerDefArr = new VerDef[mVerDefEntryCnt + 2];
-
- // SHT_GNU_versym 0: local
- mVerDefArr[0] = new VerDef("*local*");
- // HT_GNU_versym 1: global
- mVerDefArr[1] = new VerDef("*global*");
-
- long idx = mVerDefTabOffset;
- for (int i = 2; i < mVerDefEntryCnt + 2; i++) {
- mFile.seek(idx);
- mVerDefArr[i] =
- new VerDef(
- readHalf(),
- readHalf(),
- readHalf(),
- readHalf(),
- readWord(),
- readWord(),
- readWord());
-
- mVerDefArr[i].vd_verdaux = new VerDAux[mVerDefArr[i].vd_cnt];
- long idxAux = idx + mVerDefArr[i].vd_aux;
- for (int j = 0; j < mVerDefArr[i].vd_cnt; j++) {
- mFile.seek(idxAux);
- mVerDefArr[i].vd_verdaux[j] = new VerDAux(readWord(), readWord());
- mVerDefArr[i].vd_verdaux[j].vda_lib_name =
- readDynStrTabEntry(mVerDefArr[i].vd_verdaux[j].vda_name).toLowerCase();
- idxAux += mVerDefArr[i].vd_verdaux[j].vda_next;
- }
- idx += mVerDefArr[i].vd_next;
- System.out.println(mVerDefArr[i]);
- }
- }
- return mVerDefArr;
- }
-
- private int readHalf() throws IOException {
- return (int) readX(2);
- }
-
- private long readWord() throws IOException {
- return readX(4);
- }
-
- private long readOff() throws IOException {
- return readX(mAddrSize);
- }
-
- private long readAddr() throws IOException {
- return readX(mAddrSize);
- }
-
- private long readX(int byteCount) throws IOException {
- mFile.readFully(mBuffer, 0, byteCount);
-
- int answer = 0;
- if (mEndian == ELFDATA2LSB) {
- for (int i = byteCount - 1; i >= 0; i--) {
- answer = (answer << 8) | (mBuffer[i] & 0xff);
- }
- } else {
- final int N = byteCount - 1;
- for (int i = 0; i <= N; ++i) {
- answer = (answer << 8) | (mBuffer[i] & 0xff);
- }
- }
-
- return answer;
- }
-
- private String readString(long offset) throws IOException {
- long originalOffset = mFile.getFilePointer();
- mFile.seek(offset);
- mFile.readFully(mBuffer, 0, (int) Math.min(mBuffer.length, mFile.length() - offset));
- mFile.seek(originalOffset);
-
- for (int i = 0; i < mBuffer.length; ++i) {
- if (mBuffer[i] == 0) {
- return new String(mBuffer, 0, i);
- }
- }
-
- return null;
- }
-
- private int readByte() throws IOException {
- return mFile.read() & 0xff;
- }
-
- public Symbol getSymbol(String name) {
- if (mSymbols == null) {
- try {
- mSymArr = new Symbol[mSymEntCnt];
- mSymbols =
- readSymbolTable(
- mSymArr,
- false,
- mStrTabOffset,
- mStrTabSize,
- mSymTabOffset,
- mSymTabSize);
- } catch (IOException e) {
- return null;
- }
- }
- return mSymbols.get(name);
- }
-
- public Symbol getDynamicSymbol(String name) throws IOException {
- if (mDynamicSymbols == null) {
- try {
- int[] verSmyArr = this.getVerSym();
- VerNeed[] verNeedArr = this.getVerNeedArr();
- VerDef[] verDefArr = this.getVerDef();
- mDynSymArr = new Symbol[mDynSymEntCnt];
- mDynamicSymbols =
- readSymbolTable(
- mDynSymArr,
- true,
- mDynStrOffset,
- mDynStrSize,
- mDynSymOffset,
- mDynSymSize);
- } catch (IOException e) {
- return null;
- }
- }
- return mDynamicSymbols.get(name);
- }
-
- // Get Dynamic Linking Dependency List
- public List<String> getDynamicDependencies() throws IOException {
- List<String> result = new ArrayList<>();
- for (DynamicEntry entry : getDynamicList()) {
- if (entry.isNeeded()) {
- result.add(readDynStr(entry.getValue()));
- }
- }
- return result;
- }
-
- private List<DynamicEntry> getDynamicList() throws IOException {
- if (mDynamicArr == null) {
- int entryNo = 0;
- mDynamicArr = new ArrayList<>();
- mFile.seek(mDynamicTabOffset);
- System.out.println(
- String.format(
- "mDynamicTabOffset 0x%x, mDynamicTabSize %d",
- mDynamicTabOffset, mDynamicTabSize));
- while (true) {
- long tag = readX(mAddrSize);
- long value = readX(mAddrSize);
- // System.out.println(String.format("%d: 0x%x, %d", entryNo, tag, value));
- mDynamicArr.add(new DynamicEntry(tag, value));
- if (tag == 0) {
- break;
- }
- entryNo++;
- }
- }
- return mDynamicArr;
- }
-
- private String readDynStr(long strOffset) throws IOException {
- int offset = (int) (strOffset & 0xFFFFFFFF);
- if (mDynStrOffset == 0 || offset < 0 || offset >= mDynStrSize) {
- System.err.println(
- String.format(
- "err mDynStrOffset: %d, mDynStrSize: %d, offset: %d",
- mDynStrOffset, mDynStrSize, offset));
- return String.format("%d", offset);
- }
- return readString(mDynStrOffset + offset);
- }
-
- /**
- * Gets a list of string from .rodata section
- *
- * @return a String list .rodata section
- */
- public List<String> getRoStrings() throws IOException {
- if (mRoStrings == null) {
- mRoStrings = new ArrayList<>();
- byte[] byteArr = getRoData();
- if (byteArr != null) {
- int strOffset = 0;
- for (int i = 0; i < mRodataSize; i++) {
- if (byteArr[i] == 0) {
- // skip null string
- if (i != strOffset) {
- String str = new String(byteArr, strOffset, i - strOffset);
- mRoStrings.add(str);
- }
- strOffset = i + 1;
- }
- }
- }
- }
- return mRoStrings;
- }
-
- /**
- * Gets .rodata section
- *
- * @return byte [] of .rodata or null if there is none
- */
- public byte[] getRoData() throws IOException {
- if (mHasRodata && mRoData == null) {
- mRoData = new byte[mRodataSize];
- mFile.seek(mRodataOffset);
- mFile.readFully(mRoData);
- }
-
- return mRoData;
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/ReportLog.java b/common/util/src/com/android/compatibility/common/util/ReportLog.java
deleted file mode 100644
index 08b1d76..0000000
--- a/common/util/src/com/android/compatibility/common/util/ReportLog.java
+++ /dev/null
@@ -1,374 +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.compatibility.common.util;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-import org.xmlpull.v1.XmlSerializer;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Utility class to add results to the report.
- */
-public class ReportLog implements Serializable {
-
- private static final String ENCODING = "UTF-8";
- private static final String TYPE = "org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer";
-
- // XML constants
- private static final String METRIC_TAG = "Metric";
- private static final String MESSAGE_ATTR = "message";
- private static final String SCORETYPE_ATTR = "score_type";
- private static final String SCOREUNIT_ATTR = "score_unit";
- private static final String SOURCE_ATTR = "source";
- private static final String SUMMARY_TAG = "Summary";
- private static final String VALUE_TAG = "Value";
- private static final String DEFAULT_NAME = "default";
-
- protected Metric mSummary;
- protected String mReportLogName;
- protected String mStreamName;
-
- public static class Metric implements Serializable {
- private static final int MAX_SOURCE_LENGTH = 200;
- private static final int MAX_MESSAGE_LENGTH = 200;
- private static final int MAX_NUM_VALUES = 1000;
- String mSource;
- String mMessage;
- double[] mValues;
- ResultType mType;
- ResultUnit mUnit;
-
- Metric(String source, String message, double value, ResultType type, ResultUnit unit) {
- this(source, message, new double[] { value }, type, unit);
- }
-
- /**
- * Creates a metric array to be included in the report. Each object has a message
- * describing its values and enums to interpret them. In addition, each result also includes
- * class, method and line number information about the test which added this result which is
- * collected by looking at the stack trace.
- *
- * @param message A string describing the values
- * @param values An array of the values
- * @param type Represents how to interpret the values (eg. A lower score is better)
- * @param unit Represents the unit in which the values are (eg. Milliseconds)
- */
- Metric(String source, String message, double[] values, ResultType type, ResultUnit unit) {
- int sourceLength = source.length();
- if (sourceLength > MAX_SOURCE_LENGTH) {
- // Substring to the end
- mSource = source.substring(sourceLength - MAX_SOURCE_LENGTH);
- } else {
- mSource = source;
- }
- int messageLength = message.length();
- if (messageLength > MAX_MESSAGE_LENGTH) {
- // Substring from the start
- mMessage = message.substring(0, MAX_MESSAGE_LENGTH);
- } else {
- mMessage = message;
- }
- int valuesLength = values.length;
- if (valuesLength > MAX_NUM_VALUES) {
- // Subarray from the start
- mValues = Arrays.copyOf(values, MAX_NUM_VALUES);
- } else {
- mValues = values;
- }
- mType = type;
- mUnit = unit;
- }
-
- public String getSource() {
- return mSource;
- }
-
- public String getMessage() {
- return mMessage;
- }
-
- public double[] getValues() {
- return mValues;
- }
-
- public ResultType getType() {
- return mType;
- }
-
- public ResultUnit getUnit() {
- return mUnit;
- }
-
- void serialize(XmlSerializer serializer)
- throws IllegalArgumentException, IllegalStateException, IOException {
- serializer.startTag(null, METRIC_TAG);
- serializer.attribute(null, SOURCE_ATTR, getSource());
- serializer.attribute(null, MESSAGE_ATTR, getMessage());
- serializer.attribute(null, SCORETYPE_ATTR, getType().toReportString());
- serializer.attribute(null, SCOREUNIT_ATTR, getUnit().toReportString());
- for (double d : getValues()) {
- serializer.startTag(null, VALUE_TAG);
- serializer.text(Double.toString(d));
- serializer.endTag(null, VALUE_TAG);
- }
- serializer.endTag(null, METRIC_TAG);
- }
-
- static Metric parse(XmlPullParser parser)
- throws XmlPullParserException, IOException {
- parser.require(XmlPullParser.START_TAG, null, METRIC_TAG);
- String source = parser.getAttributeValue(null, SOURCE_ATTR);
- String message = parser.getAttributeValue(null, MESSAGE_ATTR);
- ResultType type = ResultType.parseReportString(
- parser.getAttributeValue(null, SCORETYPE_ATTR));
- ResultUnit unit = ResultUnit.parseReportString(
- parser.getAttributeValue(null, SCOREUNIT_ATTR));
- List<String> valuesList = new ArrayList<>();
- while (parser.nextTag() == XmlPullParser.START_TAG) {
- parser.require(XmlPullParser.START_TAG, null, VALUE_TAG);
- valuesList.add(parser.nextText());
- parser.require(XmlPullParser.END_TAG, null, VALUE_TAG);
- }
- int length = valuesList.size();
- double[] values = new double[length];
- for (int i = 0; i < length; i++) {
- values[i] = Double.parseDouble(valuesList.get(i));
- }
- parser.require(XmlPullParser.END_TAG, null, METRIC_TAG);
- return new Metric(source, message, values, type, unit);
- }
- }
-
- public ReportLog() {
- mReportLogName = DEFAULT_NAME;
- }
-
- public ReportLog(String reportLogName, String streamName) {
- mReportLogName = reportLogName;
- mStreamName = streamName;
- }
-
- /**
- * Adds a double array of metrics to the report.
- */
- public void addValues(String message, double[] values, ResultType type, ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds a double array of metrics to the report.
- */
- public void addValues(String source, String message, double[] values, ResultType type,
- ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds a double metric to the report.
- */
- public void addValue(String message, double value, ResultType type, ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds a double metric to the report.
- */
- public void addValue(String source, String message, double value, ResultType type,
- ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds an int metric to the report.
- */
- public void addValue(String message, int value, ResultType type, ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds a long metric to the report.
- */
- public void addValue(String message, long value, ResultType type, ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds a float metric to the report.
- */
- public void addValue(String message, float value, ResultType type, ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds a boolean metric to the report.
- */
- public void addValue(String message, boolean value, ResultType type, ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds a String metric to the report.
- */
- public void addValue(String message, String value, ResultType type, ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds an int array of metrics to the report.
- */
- public void addValues(String message, int[] values, ResultType type, ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds a long array of metrics to the report.
- */
- public void addValues(String message, long[] values, ResultType type, ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds a float array of metrics to the report.
- */
- public void addValues(String message, float[] values, ResultType type, ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds a boolean array of metrics to the report.
- */
- public void addValues(String message, boolean[] values, ResultType type, ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * Adds a String List of metrics to the report.
- */
- public void addValues(String message, List<String> values, ResultType type, ResultUnit unit) {
- // Do nothing. Subclasses may implement using InfoStore to write metrics to files.
- }
-
- /**
- * @param elem
- */
- /* package */ void setSummary(Metric elem) {
- mSummary = elem;
- }
-
- /**
- * Sets the double metric summary of the report.
- *
- * NOTE: messages over {@value Metric#MAX_MESSAGE_LENGTH} chars will be trimmed.
- */
- public void setSummary(String message, double value, ResultType type, ResultUnit unit) {
- setSummary(new Metric(Stacktrace.getTestCallerClassMethodNameLineNumber(), message, value,
- type, unit));
- }
-
- public Metric getSummary() {
- return mSummary;
- }
-
- /**
- * Serializes a given {@link ReportLog} to a String.
- * @throws XmlPullParserException
- * @throws IOException
- * @throws IllegalStateException
- * @throws IllegalArgumentException
- */
- public static String serialize(ReportLog reportlog) throws XmlPullParserException,
- IllegalArgumentException, IllegalStateException, IOException {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XmlSerializer serializer = XmlPullParserFactory.newInstance(TYPE, null).newSerializer();
- serializer.setOutput(byteArrayOutputStream, ENCODING);
- serializer.startDocument(ENCODING, true);
- serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
- serialize(serializer, reportlog);
- serializer.endDocument();
- return byteArrayOutputStream.toString(ENCODING);
- }
-
- /**
- * Serializes a given {@link ReportLog} to XML.
- * @param serializer
- * @param reportLog
- * @throws IOException
- */
- public static void serialize(XmlSerializer serializer, ReportLog reportLog)
- throws IOException {
- if (reportLog == null) {
- throw new IllegalArgumentException("Metrics reports was null");
- }
- Metric summary = reportLog.getSummary();
- // Summary is optional. Details are not included in result report.
- if (summary != null) {
- serializer.startTag(null, SUMMARY_TAG);
- summary.serialize(serializer);
- serializer.endTag(null, SUMMARY_TAG);
- }
- }
-
- /**
- * Parses a {@link ReportLog} from the given string.
- * @throws XmlPullParserException
- * @throws IOException
- */
- public static ReportLog parse(String result) throws XmlPullParserException, IOException {
- if (result == null){
- throw new IllegalArgumentException("Metrics string was null");
- }
- if (result.trim().isEmpty()) {
- // Empty report.
- return new ReportLog();
- }
- XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
- XmlPullParser parser = factory.newPullParser();
- parser.setInput(new ByteArrayInputStream(result.getBytes(ENCODING)), ENCODING);
- try {
- parser.nextTag();
- } catch (XmlPullParserException e) {
- // Empty Report.
- return new ReportLog();
- }
- return parse(parser);
- }
-
- /**
- * Parses a {@link ReportLog} from the given XML parser.
- * @param parser
- * @throws IOException
- * @throws XmlPullParserException
- */
- public static ReportLog parse(XmlPullParser parser) throws XmlPullParserException, IOException {
- parser.require(XmlPullParser.START_TAG, null, SUMMARY_TAG);
- parser.nextTag();
- ReportLog report = new ReportLog();
- report.setSummary(Metric.parse(parser));
- parser.nextTag();
- parser.require(XmlPullParser.END_TAG, null, SUMMARY_TAG);
- return report;
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/ResultHandler.java b/common/util/src/com/android/compatibility/common/util/ResultHandler.java
deleted file mode 100644
index ffe16b4..0000000
--- a/common/util/src/com/android/compatibility/common/util/ResultHandler.java
+++ /dev/null
@@ -1,709 +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.compatibility.common.util;
-
-import com.android.compatibility.common.util.ChecksumReporter.ChecksumValidationException;
-
-import com.google.common.base.Strings;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-import org.xmlpull.v1.XmlSerializer;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-/**
- * Handles conversion of results to/from files.
- */
-public class ResultHandler {
-
- private static final String ENCODING = "UTF-8";
- private static final String TYPE = "org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer";
- private static final String NS = null;
- private static final String RESULT_FILE_VERSION = "5.0";
- public static final String TEST_RESULT_FILE_NAME = "test_result.xml";
- public static final String FAILURE_REPORT_NAME = "test_result_failures.html";
- private static final String FAILURE_XSL_FILE_NAME = "compatibility_failures.xsl";
-
- public static final String[] RESULT_RESOURCES = {
- "compatibility_result.css",
- "compatibility_result.xsd",
- "compatibility_result.xsl",
- "logo.png"
- };
-
- // XML constants
- private static final String ABI_ATTR = "abi";
- private static final String BUGREPORT_TAG = "BugReport";
- private static final String BUILD_FINGERPRINT = "build_fingerprint";
- private static final String BUILD_FINGERPRINT_UNALTERED = "build_fingerprint_unaltered";
- private static final String BUILD_ID = "build_id";
- private static final String BUILD_PRODUCT = "build_product";
- private static final String BUILD_TAG = "Build";
- private static final String CASE_TAG = "TestCase";
- private static final String COMMAND_LINE_ARGS = "command_line_args";
- private static final String DEVICES_ATTR = "devices";
- private static final String DONE_ATTR = "done";
- private static final String END_DISPLAY_TIME_ATTR = "end_display";
- private static final String END_TIME_ATTR = "end";
- private static final String FAILED_ATTR = "failed";
- private static final String FAILURE_TAG = "Failure";
- private static final String HOST_NAME_ATTR = "host_name";
- private static final String JAVA_VENDOR_ATTR = "java_vendor";
- private static final String JAVA_VERSION_ATTR = "java_version";
- private static final String LOGCAT_TAG = "Logcat";
- private static final String LOG_URL_ATTR = "log_url";
- private static final String MESSAGE_ATTR = "message";
- private static final String MODULE_TAG = "Module";
- private static final String MODULES_DONE_ATTR = "modules_done";
- private static final String MODULES_TOTAL_ATTR = "modules_total";
- private static final String MODULES_NOT_DONE_REASON = "Reason";
- private static final String NAME_ATTR = "name";
- private static final String OS_ARCH_ATTR = "os_arch";
- private static final String OS_NAME_ATTR = "os_name";
- private static final String OS_VERSION_ATTR = "os_version";
- private static final String PASS_ATTR = "pass";
- private static final String REPORT_VERSION_ATTR = "report_version";
- private static final String REFERENCE_URL_ATTR = "reference_url";
- private static final String RESULT_ATTR = "result";
- private static final String RESULT_TAG = "Result";
- private static final String RUNTIME_ATTR = "runtime";
- private static final String RUN_HISTORY_ATTR = "run_history";
- private static final String RUN_HISTORY_TAG = "RunHistory";
- private static final String RUN_TAG = "Run";
- private static final String SCREENSHOT_TAG = "Screenshot";
- private static final String SKIPPED_ATTR = "skipped";
- private static final String STACK_TAG = "StackTrace";
- private static final String START_DISPLAY_TIME_ATTR = "start_display";
- private static final String START_TIME_ATTR = "start";
- private static final String SUITE_NAME_ATTR = "suite_name";
- private static final String SUITE_PLAN_ATTR = "suite_plan";
- private static final String SUITE_VERSION_ATTR = "suite_version";
- private static final String SUITE_BUILD_ATTR = "suite_build_number";
- private static final String SUMMARY_TAG = "Summary";
- private static final String METRIC_TAG = "Metric";
- private static final String TEST_TAG = "Test";
-
- private static final String LATEST_RESULT_DIR = "latest";
-
- /**
- * Returns IInvocationResults that can be queried for general reporting information, but that
- * do not store underlying module data. Useful for summarizing invocation history.
- * @param resultsDir
- */
- public static List<IInvocationResult> getLightResults(File resultsDir) {
- List<IInvocationResult> results = new ArrayList<>();
- List<File> files = getResultDirectories(resultsDir);
- for (File resultDir : files) {
- if (LATEST_RESULT_DIR.equals(resultDir.getName())) {
- continue;
- }
- IInvocationResult result = getResultFromDir(resultDir, false);
- if (result != null) {
- results.add(new LightInvocationResult(result));
- result = null; // ensure all references are removed to free memory
- }
- }
- // Sort the table entries on each entry's timestamp.
- Collections.sort(results, (result1, result2) -> Long.compare(
- result1.getStartTime(),
- result2.getStartTime()));
- return results;
- }
-
- /**
- * @param resultDir
- * @return an IInvocationResult for this result, or null upon error
- */
- public static IInvocationResult getResultFromDir(File resultDir) {
- return getResultFromDir(resultDir, false);
- }
-
- /**
- * @param resultDir
- * @param useChecksum
- * @return an IInvocationResult for this result, or null upon error
- */
- public static IInvocationResult getResultFromDir(File resultDir, Boolean useChecksum) {
- File resultFile = null;
- try {
- resultFile = new File(resultDir, TEST_RESULT_FILE_NAME);
- if (!resultFile.exists()) {
- return null;
- }
- Boolean invocationUseChecksum = useChecksum;
- IInvocationResult invocation = new InvocationResult();
- invocation.setRetryDirectory(resultDir);
- ChecksumReporter checksumReporter = null;
- if (invocationUseChecksum) {
- try {
- checksumReporter = ChecksumReporter.load(resultDir);
- invocation.setRetryChecksumStatus(RetryChecksumStatus.RetryWithChecksum);
- } catch (ChecksumValidationException e) {
- // Unable to read checksum form previous execution
- invocation.setRetryChecksumStatus(RetryChecksumStatus.RetryWithoutChecksum);
- invocationUseChecksum = false;
- }
- }
- XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
- XmlPullParser parser = factory.newPullParser();
- parser.setInput(new FileReader(resultFile));
-
- parser.nextTag();
- parser.require(XmlPullParser.START_TAG, NS, RESULT_TAG);
- invocation.setStartTime(Long.valueOf(
- parser.getAttributeValue(NS, START_TIME_ATTR)));
- invocation.setTestPlan(parser.getAttributeValue(NS, SUITE_PLAN_ATTR));
- invocation.setCommandLineArgs(parser.getAttributeValue(NS, COMMAND_LINE_ARGS));
- String deviceList = parser.getAttributeValue(NS, DEVICES_ATTR);
- for (String device : deviceList.split(",")) {
- invocation.addDeviceSerial(device);
- }
-
- parser.nextTag();
- parser.require(XmlPullParser.START_TAG, NS, BUILD_TAG);
- invocation.addInvocationInfo(BUILD_ID, parser.getAttributeValue(NS, BUILD_ID));
- invocation.addInvocationInfo(BUILD_PRODUCT, parser.getAttributeValue(NS,
- BUILD_PRODUCT));
- String runHistoryValue = parser.getAttributeValue(NS, RUN_HISTORY_ATTR);
- if (runHistoryValue != null) {
- invocation.addInvocationInfo(RUN_HISTORY_ATTR, runHistoryValue);
- }
-
- // The build fingerprint needs to reflect the true fingerprint of the device under test,
- // ignoring potential overrides made by test suites (namely STS) for APFE build
- // association.
- String reportFingerprint = parser.getAttributeValue(NS, BUILD_FINGERPRINT);
- String unalteredFingerprint = parser.getAttributeValue(NS, BUILD_FINGERPRINT_UNALTERED);
- Boolean fingerprintWasAltered = !Strings.isNullOrEmpty(unalteredFingerprint);
- invocation.setBuildFingerprint(fingerprintWasAltered ? unalteredFingerprint :
- reportFingerprint );
-
- // TODO(stuartscott): may want to reload these incase the retry was done with
- // --skip-device-info flag
- parser.nextTag();
- parser.require(XmlPullParser.END_TAG, NS, BUILD_TAG);
-
- // Parse RunHistory tag.
- parser.nextTag();
- boolean hasRunHistoryTag = true;
- try {
- parser.require(XmlPullParser.START_TAG, NS, RUN_HISTORY_TAG);
- } catch (XmlPullParserException e) {
- hasRunHistoryTag = false;
- }
- if (hasRunHistoryTag) {
- parseRunHistory(parser);
- }
-
- parser.require(XmlPullParser.START_TAG, NS, SUMMARY_TAG);
- parser.nextTag();
- parser.require(XmlPullParser.END_TAG, NS, SUMMARY_TAG);
- while (parser.nextTag() == XmlPullParser.START_TAG) {
- parser.require(XmlPullParser.START_TAG, NS, MODULE_TAG);
- String name = parser.getAttributeValue(NS, NAME_ATTR);
- String abi = parser.getAttributeValue(NS, ABI_ATTR);
- String moduleId = AbiUtils.createId(abi, name);
- boolean done = Boolean.parseBoolean(parser.getAttributeValue(NS, DONE_ATTR));
- IModuleResult module = invocation.getOrCreateModule(moduleId);
- module.initializeDone(done);
- long runtime = Long.parseLong(parser.getAttributeValue(NS, RUNTIME_ATTR));
- module.addRuntime(runtime);
- while (parser.nextTag() == XmlPullParser.START_TAG) {
- // If a reason for not done exists, handle it.
- if (parser.getName().equals(MODULES_NOT_DONE_REASON)) {
- parser.require(XmlPullParser.START_TAG, NS, MODULES_NOT_DONE_REASON);
- parser.nextTag();
- parser.require(XmlPullParser.END_TAG, NS, MODULES_NOT_DONE_REASON);
- continue;
- }
- parser.require(XmlPullParser.START_TAG, NS, CASE_TAG);
- String caseName = parser.getAttributeValue(NS, NAME_ATTR);
- ICaseResult testCase = module.getOrCreateResult(caseName);
- while (parser.nextTag() == XmlPullParser.START_TAG) {
- parser.require(XmlPullParser.START_TAG, NS, TEST_TAG);
- String testName = parser.getAttributeValue(NS, NAME_ATTR);
- ITestResult test = testCase.getOrCreateResult(testName);
- String result = parser.getAttributeValue(NS, RESULT_ATTR);
- String skipped = parser.getAttributeValue(NS, SKIPPED_ATTR);
- if (skipped != null && Boolean.parseBoolean(skipped)) {
- // mark test passed and skipped
- test.skipped();
- } else {
- // only apply result status directly if test was not skipped
- test.setResultStatus(TestStatus.getStatus(result));
- }
- test.setRetry(true);
- while (parser.nextTag() == XmlPullParser.START_TAG) {
- if (parser.getName().equals(FAILURE_TAG)) {
- test.setMessage(parser.getAttributeValue(NS, MESSAGE_ATTR));
- if (parser.nextTag() == XmlPullParser.START_TAG) {
- parser.require(XmlPullParser.START_TAG, NS, STACK_TAG);
- test.setStackTrace(parser.nextText());
- parser.require(XmlPullParser.END_TAG, NS, STACK_TAG);
- parser.nextTag();
- }
- parser.require(XmlPullParser.END_TAG, NS, FAILURE_TAG);
- } else if (parser.getName().equals(BUGREPORT_TAG)) {
- test.setBugReport(parser.nextText());
- parser.require(XmlPullParser.END_TAG, NS, BUGREPORT_TAG);
- } else if (parser.getName().equals(LOGCAT_TAG)) {
- test.setLog(parser.nextText());
- parser.require(XmlPullParser.END_TAG, NS, LOGCAT_TAG);
- } else if (parser.getName().equals(SCREENSHOT_TAG)) {
- test.setScreenshot(parser.nextText());
- parser.require(XmlPullParser.END_TAG, NS, SCREENSHOT_TAG);
- } else if (SUMMARY_TAG.equals(parser.getName())) {
- test.setReportLog(ReportLog.parse(parser));
- } else if (METRIC_TAG.equals(parser.getName())) {
- // Ignore the new format in the old parser.
- parser.nextText();
- parser.require(XmlPullParser.END_TAG, NS, METRIC_TAG);
- } else if (RUN_HISTORY_TAG.equals(parser.getName())) {
- // Ignore the test result history since it only exists in
- // CTS Verifier, which will not use parsing feature.
- skipCurrentTag(parser);
- } else {
- parser.nextTag();
- }
- }
- parser.require(XmlPullParser.END_TAG, NS, TEST_TAG);
- // If the fingerprint was altered, then checksum against the fingerprint
- // originally reported
- Boolean checksumMismatch = invocationUseChecksum &&
- !checksumReporter.containsTestResult(test, module, reportFingerprint)
- && (fingerprintWasAltered ? !checksumReporter.containsTestResult(
- test, module, unalteredFingerprint) : true);
- if (checksumMismatch) {
- test.removeResult();
- }
- }
- parser.require(XmlPullParser.END_TAG, NS, CASE_TAG);
- }
- parser.require(XmlPullParser.END_TAG, NS, MODULE_TAG);
- // If the fingerprint was altered, then checksum against the fingerprint
- // originally reported
- Boolean checksumMismatch = invocationUseChecksum &&
- !checksumReporter.containsModuleResult(module, reportFingerprint) &&
- (fingerprintWasAltered ? !checksumReporter.containsModuleResult(
- module, unalteredFingerprint) : true);
- if (checksumMismatch) {
- module.initializeDone(false);
- }
- }
- parser.require(XmlPullParser.END_TAG, NS, RESULT_TAG);
- return invocation;
- } catch (XmlPullParserException | IOException e) {
- System.out.println(
- String.format("Exception when trying to load %s",
- resultFile.getAbsolutePath()));
- e.printStackTrace();
- return null;
- }
- }
-
- /** Parse and replay all run history information. */
- private static void parseRunHistory(XmlPullParser parser)
- throws IOException, XmlPullParserException {
- while (parser.nextTag() == XmlPullParser.START_TAG) {
- parser.require(XmlPullParser.START_TAG, NS, RUN_TAG);
- parser.nextTag();
- parser.require(XmlPullParser.END_TAG, NS, RUN_TAG);
- }
- parser.require(XmlPullParser.END_TAG, NS, RUN_HISTORY_TAG);
- parser.nextTag();
- }
-
- /** Skip the current XML tags. */
- private static void skipCurrentTag(XmlPullParser parser)
- throws XmlPullParserException, IOException {
- int depth = 1;
- while (depth != 0) {
- switch (parser.next()) {
- case XmlPullParser.END_TAG:
- depth--;
- break;
- case XmlPullParser.START_TAG:
- depth++;
- break;
- }
- }
- }
-
- /**
- * @param result
- * @param resultDir
- * @param startTime
- * @param referenceUrl A nullable string that can contain a URL to a related data
- * @param logUrl A nullable string that can contain a URL to related log files
- * @param commandLineArgs A string containing the arguments to the run command
- * @param resultAttributes Extra key-value pairs to be added as attributes and corresponding
- * values into the result XML file
- * @return The result file created.
- * @throws IOException
- * @throws XmlPullParserException
- */
- public static File writeResults(
- String suiteName,
- String suiteVersion,
- String suitePlan,
- String suiteBuild,
- IInvocationResult result,
- File resultDir,
- long startTime,
- long endTime,
- String referenceUrl,
- String logUrl,
- String commandLineArgs,
- Map<String, String> resultAttributes)
- throws IOException, XmlPullParserException {
- int passed = result.countResults(TestStatus.PASS);
- int failed = result.countResults(TestStatus.FAIL);
- File resultFile = new File(resultDir, TEST_RESULT_FILE_NAME);
- OutputStream stream = new FileOutputStream(resultFile);
- XmlSerializer serializer = XmlPullParserFactory.newInstance(TYPE, null).newSerializer();
- serializer.setOutput(stream, ENCODING);
- serializer.startDocument(ENCODING, false);
- serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
- serializer.processingInstruction(
- "xml-stylesheet type=\"text/xsl\" href=\"compatibility_result.xsl\"");
- serializer.startTag(NS, RESULT_TAG);
- serializer.attribute(NS, START_TIME_ATTR, String.valueOf(startTime));
- serializer.attribute(NS, END_TIME_ATTR, String.valueOf(endTime));
- serializer.attribute(NS, START_DISPLAY_TIME_ATTR, toReadableDateString(startTime));
- serializer.attribute(NS, END_DISPLAY_TIME_ATTR, toReadableDateString(endTime));
-
- serializer.attribute(NS, SUITE_NAME_ATTR, suiteName);
- serializer.attribute(NS, SUITE_VERSION_ATTR, suiteVersion);
- serializer.attribute(NS, SUITE_PLAN_ATTR, suitePlan);
- serializer.attribute(NS, SUITE_BUILD_ATTR, suiteBuild);
- serializer.attribute(NS, REPORT_VERSION_ATTR, RESULT_FILE_VERSION);
- serializer.attribute(NS, COMMAND_LINE_ARGS, nullToEmpty(commandLineArgs));
-
- if (resultAttributes != null) {
- for (Entry<String, String> entry : resultAttributes.entrySet()) {
- serializer.attribute(NS, entry.getKey(), entry.getValue());
- }
- }
-
- if (referenceUrl != null) {
- serializer.attribute(NS, REFERENCE_URL_ATTR, referenceUrl);
- }
-
- if (logUrl != null) {
- serializer.attribute(NS, LOG_URL_ATTR, logUrl);
- }
-
- // Device Info
- Set<String> devices = result.getDeviceSerials();
- StringBuilder deviceList = new StringBuilder();
- boolean first = true;
- for (String device : devices) {
- if (first) {
- first = false;
- } else {
- deviceList.append(",");
- }
- deviceList.append(device);
- }
- serializer.attribute(NS, DEVICES_ATTR, deviceList.toString());
-
- // Host Info
- String hostName = "";
- try {
- hostName = InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException ignored) {}
- serializer.attribute(NS, HOST_NAME_ATTR, hostName);
- serializer.attribute(NS, OS_NAME_ATTR, System.getProperty("os.name"));
- serializer.attribute(NS, OS_VERSION_ATTR, System.getProperty("os.version"));
- serializer.attribute(NS, OS_ARCH_ATTR, System.getProperty("os.arch"));
- serializer.attribute(NS, JAVA_VENDOR_ATTR, System.getProperty("java.vendor"));
- serializer.attribute(NS, JAVA_VERSION_ATTR, System.getProperty("java.version"));
-
- // Build Info
- serializer.startTag(NS, BUILD_TAG);
- for (Entry<String, String> entry : result.getInvocationInfo().entrySet()) {
- serializer.attribute(NS, entry.getKey(), entry.getValue());
- if (Strings.isNullOrEmpty(result.getBuildFingerprint()) &&
- entry.getKey().equals(BUILD_FINGERPRINT)) {
- result.setBuildFingerprint(entry.getValue());
- }
- }
- serializer.endTag(NS, BUILD_TAG);
-
- // Run history - this contains a list of start and end times of previous runs. More
- // information may be added in the future.
- Collection<InvocationResult.RunHistory> runHistories =
- ((InvocationResult) result).getRunHistories();
- if (!runHistories.isEmpty()) {
- serializer.startTag(NS, RUN_HISTORY_TAG);
- for (InvocationResult.RunHistory runHistory : runHistories) {
- serializer.startTag(NS, RUN_TAG);
- serializer.attribute(NS, START_TIME_ATTR, String.valueOf(runHistory.startTime));
- serializer.attribute(NS, END_TIME_ATTR, String.valueOf(runHistory.endTime));
- serializer.endTag(NS, RUN_TAG);
- }
- serializer.endTag(NS, RUN_HISTORY_TAG);
- }
-
- // Summary
- serializer.startTag(NS, SUMMARY_TAG);
- serializer.attribute(NS, PASS_ATTR, Integer.toString(passed));
- serializer.attribute(NS, FAILED_ATTR, Integer.toString(failed));
- serializer.attribute(NS, MODULES_DONE_ATTR,
- Integer.toString(result.getModuleCompleteCount()));
- serializer.attribute(NS, MODULES_TOTAL_ATTR,
- Integer.toString(result.getModules().size()));
- serializer.endTag(NS, SUMMARY_TAG);
-
- // Results
- for (IModuleResult module : result.getModules()) {
- serializer.startTag(NS, MODULE_TAG);
- serializer.attribute(NS, NAME_ATTR, module.getName());
- serializer.attribute(NS, ABI_ATTR, module.getAbi());
- serializer.attribute(NS, RUNTIME_ATTR, String.valueOf(module.getRuntime()));
- serializer.attribute(NS, DONE_ATTR, Boolean.toString(module.isDone()));
- serializer.attribute(NS, PASS_ATTR,
- Integer.toString(module.countResults(TestStatus.PASS)));
- for (ICaseResult cr : module.getResults()) {
- serializer.startTag(NS, CASE_TAG);
- serializer.attribute(NS, NAME_ATTR, cr.getName());
- for (ITestResult r : cr.getResults()) {
- TestStatus status = r.getResultStatus();
- if (status == null) {
- continue; // test was not executed, don't report
- }
- serializer.startTag(NS, TEST_TAG);
- serializer.attribute(NS, RESULT_ATTR, status.getValue());
- serializer.attribute(NS, NAME_ATTR, r.getName());
- if (r.isSkipped()) {
- serializer.attribute(NS, SKIPPED_ATTR, Boolean.toString(true));
- }
- String message = r.getMessage();
- if (message != null) {
- serializer.startTag(NS, FAILURE_TAG);
- serializer.attribute(NS, MESSAGE_ATTR, message);
- String stackTrace = r.getStackTrace();
- if (stackTrace != null) {
- serializer.startTag(NS, STACK_TAG);
- serializer.text(stackTrace);
- serializer.endTag(NS, STACK_TAG);
- }
- serializer.endTag(NS, FAILURE_TAG);
- }
- String bugreport = r.getBugReport();
- if (bugreport != null) {
- serializer.startTag(NS, BUGREPORT_TAG);
- serializer.text(bugreport);
- serializer.endTag(NS, BUGREPORT_TAG);
- }
- String logcat = r.getLog();
- if (logcat != null) {
- serializer.startTag(NS, LOGCAT_TAG);
- serializer.text(logcat);
- serializer.endTag(NS, LOGCAT_TAG);
- }
- String screenshot = r.getScreenshot();
- if (screenshot != null) {
- serializer.startTag(NS, SCREENSHOT_TAG);
- serializer.text(screenshot);
- serializer.endTag(NS, SCREENSHOT_TAG);
- }
- ReportLog report = r.getReportLog();
- if (report != null) {
- ReportLog.serialize(serializer, report);
- }
-
- // Test result history contains a list of execution time for each test item.
- List<TestResultHistory> testResultHistories = r.getTestResultHistories();
- if (testResultHistories != null) {
- for (TestResultHistory resultHistory : testResultHistories) {
- TestResultHistory.serialize(serializer, resultHistory, r.getName());
- }
- }
-
- serializer.endTag(NS, TEST_TAG);
- }
- serializer.endTag(NS, CASE_TAG);
- }
- serializer.endTag(NS, MODULE_TAG);
- }
- serializer.endDocument();
- createChecksum(resultDir, result);
- return resultFile;
- }
-
- /**
- * Generate html report listing an failed tests
- */
- public static File createFailureReport(File inputXml) {
- File failureReport = new File(inputXml.getParentFile(), FAILURE_REPORT_NAME);
- try (InputStream xslStream = ResultHandler.class.getResourceAsStream(
- String.format("/report/%s", FAILURE_XSL_FILE_NAME));
- OutputStream outputStream = new FileOutputStream(failureReport)) {
-
- Transformer transformer = TransformerFactory.newInstance().newTransformer(
- new StreamSource(xslStream));
- transformer.transform(new StreamSource(inputXml), new StreamResult(outputStream));
- } catch (IOException | TransformerException ignored) { }
- return failureReport;
- }
-
- private static void createChecksum(File resultDir, IInvocationResult invocationResult) {
- RetryChecksumStatus retryStatus = invocationResult.getRetryChecksumStatus();
- switch (retryStatus) {
- case NotRetry: case RetryWithChecksum:
- // Do not disrupt the process if there is a problem generating checksum.
- ChecksumReporter.tryCreateChecksum(resultDir, invocationResult);
- break;
- case RetryWithoutChecksum:
- // If the previous run has an invalid checksum file,
- // copy it into current results folder for future troubleshooting
- File retryDirectory = invocationResult.getRetryDirectory();
- Path retryChecksum = FileSystems.getDefault().getPath(
- retryDirectory.getAbsolutePath(), ChecksumReporter.NAME);
- if (!retryChecksum.toFile().exists()) {
- // if no checksum file, check for a copy from a previous retry
- retryChecksum = FileSystems.getDefault().getPath(
- retryDirectory.getAbsolutePath(), ChecksumReporter.PREV_NAME);
- }
-
- if (retryChecksum.toFile().exists()) {
- File checksumCopy = new File(resultDir, ChecksumReporter.PREV_NAME);
- try (FileOutputStream stream = new FileOutputStream(checksumCopy)) {
- Files.copy(retryChecksum, stream);
- } catch (IOException e) {
- // Do not disrupt the process if there is a problem copying checksum
- }
- }
- }
- }
-
-
- /**
- * Find the IInvocationResult for the given sessionId.
- */
- public static IInvocationResult findResult(File resultsDir, Integer sessionId) {
- return findResult(resultsDir, sessionId, true);
- }
-
- /**
- * Find the IInvocationResult for the given sessionId.
- */
- private static IInvocationResult findResult(
- File resultsDir, Integer sessionId, Boolean useChecksum) {
- if (sessionId < 0) {
- throw new IllegalArgumentException(
- String.format("Invalid session id [%d] ", sessionId));
- }
- File resultDir = getResultDirectory(resultsDir, sessionId);
- IInvocationResult result = getResultFromDir(resultDir, useChecksum);
- if (result == null) {
- throw new RuntimeException(String.format("Could not find session [%d]", sessionId));
- }
- return result;
- }
-
- /**
- * Get the result directory for the given sessionId.
- */
- public static File getResultDirectory(File resultsDir, Integer sessionId) {
- if (sessionId < 0) {
- throw new IllegalArgumentException(
- String.format("Invalid session id [%d] ", sessionId));
- }
- List<File> allResultDirs = getResultDirectories(resultsDir);
- if (sessionId >= allResultDirs.size()) {
- throw new IllegalArgumentException(String.format("Invalid session id [%d], results " +
- "directory (%s) contains only %d results",
- sessionId, resultsDir.getAbsolutePath(), allResultDirs.size()));
- }
- return allResultDirs.get(sessionId);
- }
-
- /**
- * Get a list of child directories that contain test invocation results
- * @param resultsDir the root test result directory
- * @return the list of {@link File} results directory.
- */
- public static List<File> getResultDirectories(File resultsDir) {
- List<File> directoryList = new ArrayList<>();
- File[] files = resultsDir.listFiles();
- if (files == null || files.length == 0) {
- // No results, just return the empty list
- return directoryList;
- }
- for (File resultDir : files) {
- if (!resultDir.isDirectory()) {
- continue;
- }
- // Only include if it contain results file
- File resultFile = new File(resultDir, TEST_RESULT_FILE_NAME);
- if (!resultFile.exists()) {
- continue;
- }
- directoryList.add(resultDir);
- }
- Collections.sort(directoryList, (d1, d2) -> d1.getName().compareTo(d2.getName()));
- return directoryList;
- }
-
- /**
- * 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 toReadableDateString(long time) {
- SimpleDateFormat dateFormat =
- new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
- return dateFormat.format(new Date(time));
- }
-
- /**
- * When nullable is null, return an empty string. Otherwise, return the value in nullable.
- */
- private static String nullToEmpty(String nullable) {
- return nullable == null ? "" : nullable;
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/ResultType.java b/common/util/src/com/android/compatibility/common/util/ResultType.java
deleted file mode 100644
index 9d0a5fa..0000000
--- a/common/util/src/com/android/compatibility/common/util/ResultType.java
+++ /dev/null
@@ -1,45 +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.compatibility.common.util;
-
-/**
- * Enum for distinguishing results.
- */
-public enum ResultType {
- /** Lower score is better. */
- LOWER_BETTER,
- /** Higher score is better. */
- HIGHER_BETTER,
- /** This value is not directly correlated with score. */
- NEUTRAL,
- /** Presence of this type requires some attention although it may not be an error. */
- WARNING;
-
- /**
- * @return a string to be used in the report.
- */
- public String toReportString() {
- return name().toLowerCase();
- }
-
- /**
- * Returns a {@link ResultType} given a string from the report.
- */
- public static ResultType parseReportString(String value) {
- return ResultType.valueOf(value.toUpperCase());
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/ResultUnit.java b/common/util/src/com/android/compatibility/common/util/ResultUnit.java
deleted file mode 100644
index 131ba8f..0000000
--- a/common/util/src/com/android/compatibility/common/util/ResultUnit.java
+++ /dev/null
@@ -1,59 +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.compatibility.common.util;
-
-/**
- * Enum for representing the unit of results.
- */
-public enum ResultUnit {
- /** for value with no unit */
- NONE,
- /** milli-seconds */
- MS,
- /** frames per second */
- FPS,
- /** operations per second */
- OPS,
- /** kilo-bytes-per-second, not bits-per-second */
- KBPS,
- /** mega-bytes-per-second */
- MBPS,
- /** amount of data, bytes */
- BYTE,
- /** tell how many times it did happen. */
- COUNT,
- /** unit for benchmarking with generic score. */
- SCORE,
- /** radian */
- RADIAN,
- /** Audio or Video frames count, dropped, repeated, etc... */
- FRAMES;
-
- /**
- * @return a string to be used in the report.
- */
- public String toReportString() {
- return name().toLowerCase();
- }
-
- /**
- * Returns a {@link ResultUnit} given a string from the report.
- */
- public static ResultUnit parseReportString(String value) {
- return ResultUnit.valueOf(value.toUpperCase());
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/ResultUploader.java b/common/util/src/com/android/compatibility/common/util/ResultUploader.java
deleted file mode 100644
index 7348284..0000000
--- a/common/util/src/com/android/compatibility/common/util/ResultUploader.java
+++ /dev/null
@@ -1,73 +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.compatibility.common.util;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.GZIPOutputStream;
-
-/**
- * Uploads a result through a HTTP POST multipart/form-data request containing
- * the test result XML.
- */
-public class ResultUploader {
-
- private static final int RESULT_XML_BYTES = 500 * 1024;
-
- /* package */ MultipartForm mMultipartForm;
-
- public ResultUploader(String serverUrl, String suiteName) {
- mMultipartForm = new MultipartForm(serverUrl).addFormValue("suite", suiteName);
- }
-
- /**
- * Uploads the given file to the server.
- *
- * @param reportFile The file to upload.
- * @param referenceUrl A reference url to use.
- * @throws IOException
- */
- public int uploadResult(File reportFile, String referenceUrl) throws IOException {
- InputStream input = new FileInputStream(reportFile);
- try {
- byte[] data = getBytes(input);
- mMultipartForm.addFormFile("resultXml", "test-result.xml.gz", data);
- if (referenceUrl != null && !referenceUrl.trim().isEmpty()) {
- mMultipartForm.addFormValue("referenceUrl", referenceUrl);
- }
- return mMultipartForm.submit();
- } finally {
- input.close();
- }
- }
-
- private static byte[] getBytes(InputStream input) throws IOException {
- ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(RESULT_XML_BYTES);
- GZIPOutputStream gzipOutput = new GZIPOutputStream(byteOutput);
- byte[] buffer = new byte[1024];
- int count;
- while ((count = input.read(buffer)) > 0) {
- gzipOutput.write(buffer, 0, count);
- }
- gzipOutput.close();
- return byteOutput.toByteArray();
- }
-
-}
diff --git a/common/util/src/com/android/compatibility/common/util/RetryChecksumStatus.java b/common/util/src/com/android/compatibility/common/util/RetryChecksumStatus.java
deleted file mode 100644
index a86ab37..0000000
--- a/common/util/src/com/android/compatibility/common/util/RetryChecksumStatus.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.android.compatibility.common.util;
-
-
-public enum RetryChecksumStatus {
- NotRetry,
- RetryWithChecksum,
- RetryWithoutChecksum
-}
diff --git a/common/util/src/com/android/compatibility/common/util/Stacktrace.java b/common/util/src/com/android/compatibility/common/util/Stacktrace.java
deleted file mode 100644
index 27bf9ca..0000000
--- a/common/util/src/com/android/compatibility/common/util/Stacktrace.java
+++ /dev/null
@@ -1,70 +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.compatibility.common.util;
-
-/**
- * Helper methods for dealing with stack traces
- */
-public class Stacktrace {
-
- private static final int SAFETY_DEPTH = 4;
- private static final String TEST_POSTFIX = "Test";
-
- private Stacktrace() {}
-
- /**
- * @return classname#methodname from call stack of the current thread
- */
- public static String getTestCallerClassMethodName() {
- return getTestCallerClassMethodName(false /*includeLineNumber*/);
- }
-
- /**
- * @return classname#methodname from call stack of the current thread
- */
- public static String getTestCallerClassMethodNameLineNumber() {
- return getTestCallerClassMethodName(true /*includeLineNumber*/);
- }
-
- /**
- * @return classname#methodname from call stack of the current thread
- */
- private static String getTestCallerClassMethodName(boolean includeLineNumber) {
- StackTraceElement[] elements = Thread.currentThread().getStackTrace();
- // Look for the first class name in the elements array that ends with Test
- for (int i = 0; i < elements.length; i++) {
- if (elements[i].getClassName().endsWith(TEST_POSTFIX)) {
- return buildClassMethodName(elements, i, includeLineNumber);
- }
- }
-
- // Use a reasonable default if the test name isn't found
- return buildClassMethodName(elements, SAFETY_DEPTH, includeLineNumber);
- }
-
- private static String buildClassMethodName(
- StackTraceElement[] elements, int depth, boolean includeLineNumber) {
- depth = Math.min(depth, elements.length - 1);
- StringBuilder builder = new StringBuilder();
- builder.append(elements[depth].getClassName()).append("#")
- .append(elements[depth].getMethodName());
- if (includeLineNumber) {
- builder.append(":").append(elements[depth].getLineNumber());
- }
- return builder.toString();
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/Stat.java b/common/util/src/com/android/compatibility/common/util/Stat.java
deleted file mode 100644
index 9748440..0000000
--- a/common/util/src/com/android/compatibility/common/util/Stat.java
+++ /dev/null
@@ -1,182 +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.compatibility.common.util;
-
-import java.util.Arrays;
-
-/**
- * Utilities for doing statistics
- */
-public class Stat {
- /**
- * Private constructor for static class.
- */
- private Stat() {}
-
- /**
- * Collection of statistical propertirs like average, max, min, and stddev
- */
- public static class StatResult {
- public double mAverage;
- public double mMin;
- public double mMax;
- public double mStddev;
- public int mDataCount;
- public StatResult(double average, double min, double max, double stddev, int dataCount) {
- mAverage = average;
- mMin = min;
- mMax = max;
- mStddev = stddev;
- mDataCount = dataCount;
- }
- }
-
- /**
- * Calculate statistics properties likes average, min, max, and stddev for the given array
- */
- public static StatResult getStat(double[] data) {
- double average = data[0];
- double min = data[0];
- double max = data[0];
- for (int i = 1; i < data.length; i++) {
- average += data[i];
- if (data[i] > max) {
- max = data[i];
- }
- if (data[i] < min) {
- min = data[i];
- }
- }
- average /= data.length;
- double sumOfSquares = 0.0;
- for (int i = 0; i < data.length; i++) {
- double diff = average - data[i];
- sumOfSquares += diff * diff;
- }
- double variance = sumOfSquares / (data.length - 1);
- double stddev = Math.sqrt(variance);
- return new StatResult(average, min, max, stddev, data.length);
- }
-
- /**
- * Calculate statistics properties likes average, min, max, and stddev for the given array
- * while rejecting outlier +/- median * rejectionThreshold.
- * rejectionThreshold should be bigger than 0.0 and be lowerthan 1.0
- */
- public static StatResult getStatWithOutlierRejection(double[] data, double rejectionThreshold) {
- double[] dataCopied = Arrays.copyOf(data, data.length);
- Arrays.sort(dataCopied);
- int medianIndex = dataCopied.length / 2;
- double median;
- if (dataCopied.length % 2 == 1) {
- median = dataCopied[medianIndex];
- } else {
- median = (dataCopied[medianIndex - 1] + dataCopied[medianIndex]) / 2.0;
- }
- double thresholdMin = median * (1.0 - rejectionThreshold);
- double thresholdMax = median * (1.0 + rejectionThreshold);
-
- double[] validData = new double[data.length];
- int index = 0;
- for (int i = 0; i < data.length; i++) {
- if ((data[i] > thresholdMin) && (data[i] < thresholdMax)) {
- validData[index] = data[i];
- index++;
- }
- // TODO report rejected data
- }
- return getStat(Arrays.copyOf(validData, index));
- }
-
- /**
- * return the average value of the passed array
- */
- public static double getAverage(double[] data) {
- double sum = data[0];
- for (int i = 1; i < data.length; i++) {
- sum += data[i];
- }
- return sum / data.length;
- }
-
- /**
- * return the minimum value of the passed array
- */
- public static double getMin(double[] data) {
- double min = data[0];
- for (int i = 1; i < data.length; i++) {
- if (data[i] < min) {
- min = data[i];
- }
- }
- return min;
- }
-
- /**
- * return the maximum value of the passed array
- */
- public static double getMax(double[] data) {
- double max = data[0];
- for (int i = 1; i < data.length; i++) {
- if (data[i] > max) {
- max = data[i];
- }
- }
- return max;
- }
-
- /**
- * Calculate rate per sec for given change happened during given timeInMSec.
- * timeInSec with 0 value will be changed to small value to prevent divide by zero.
- * @param change total change of quality for the given duration timeInMSec.
- * @param timeInMSec
- */
- public static double calcRatePerSec(double change, double timeInMSec) {
- if (timeInMSec == 0) {
- return change * 1000.0 / 0.001; // do not allow zero
- } else {
- return change * 1000.0 / timeInMSec;
- }
- }
-
- /**
- * array version of calcRatePerSecArray
- */
- public static double[] calcRatePerSecArray(double change, double[] timeInMSec) {
- double[] result = new double[timeInMSec.length];
- change *= 1000.0;
- for (int i = 0; i < timeInMSec.length; i++) {
- if (timeInMSec[i] == 0) {
- result[i] = change / 0.001;
- } else {
- result[i] = change / timeInMSec[i];
- }
- }
- return result;
- }
-
- /**
- * Get the value of the 95th percentile using nearest rank algorithm.
- */
- public static double get95PercentileValue(double[] values) {
- Arrays.sort(values);
- // zero-based array index
- int index = (int) Math.round(values.length * 0.95 + .5) - 1;
- return values[index];
- }
-
-}
diff --git a/common/util/src/com/android/compatibility/common/util/StreamUtil.java b/common/util/src/com/android/compatibility/common/util/StreamUtil.java
deleted file mode 100644
index 1909c21..0000000
--- a/common/util/src/com/android/compatibility/common/util/StreamUtil.java
+++ /dev/null
@@ -1,72 +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.compatibility.common.util;
-
-import com.google.common.io.Closeables;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.nio.charset.StandardCharsets;
-
-
-public class StreamUtil {
-
- // 16K buffer size
- private static final int BUFFER_SIZE = 16 * 1024;
- /**
- * Copies contents of origStream to destStream.
- * <p/>
- * Recommended to provide a buffered stream for input and output
- *
- * @param inStream the {@link InputStream}
- * @param outStream the {@link OutputStream}
- * @throws IOException
- */
- public static void copyStreams(InputStream inStream, OutputStream outStream)
- throws IOException {
- byte[] buf = new byte[BUFFER_SIZE];
- int size = -1;
- while ((size = inStream.read(buf)) != -1) {
- outStream.write(buf, 0, size);
- }
- }
-
- /**
- * Reads {@code inputStream} converting it into a string. Does NOT close it.
- *
- * @throws IOException
- */
- public static String readInputStream(InputStream inputStream) throws IOException {
- ByteArrayOutputStream result = new ByteArrayOutputStream();
- byte[] buffer = new byte[1024];
- int length;
- while ((length = inputStream.read(buffer)) != -1) {
- result.write(buffer, 0, length);
- }
- return result.toString(StandardCharsets.UTF_8.name());
- }
-
- public static void drainAndClose(Reader reader) {
- try {
- while (reader.read() >= 0) {}
- } catch (IOException ignored) {}
- Closeables.closeQuietly(reader);
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/TestResult.java b/common/util/src/com/android/compatibility/common/util/TestResult.java
deleted file mode 100644
index d2a9ca9..0000000
--- a/common/util/src/com/android/compatibility/common/util/TestResult.java
+++ /dev/null
@@ -1,302 +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.compatibility.common.util;
-
-import java.util.List;
-
-/**
- * Represents a single test result.
- */
-public class TestResult implements ITestResult {
-
- private final ICaseResult mParent;
- private final String mTestName;
- private TestStatus mResult;
- private String mMessage;
- private String mStackTrace;
- private ReportLog mReport;
- private String mBugReport;
- private String mLog;
- private String mScreenshot;
- private boolean mIsRetry;
- private boolean mSkipped;
- private List<TestResultHistory> mTestResultHistories;
-
- /**
- * Create a {@link TestResult} for the given test name.
- */
- public TestResult(ICaseResult parent, String name) {
- mParent = parent;
- mTestName = name;
- reset();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getName() {
- return mTestName;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getFullName() {
- return String.format("%s#%s", mParent.getName(), getName());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TestStatus getResultStatus() {
- return mResult;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setResultStatus(TestStatus status) {
- mResult = status;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getMessage() {
- return mMessage;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setMessage(String message) {
- mMessage = message;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getStackTrace() {
- return mStackTrace;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setStackTrace(String stackTrace) {
- mStackTrace = sanitizeStackTrace(stackTrace);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ReportLog getReportLog() {
- return mReport;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setReportLog(ReportLog report) {
- mReport = report;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getBugReport() {
- return mBugReport;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setBugReport(String path) {
- mBugReport = path;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLog() {
- return mLog;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setLog(String path) {
- mLog = path;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getScreenshot() {
- return mScreenshot;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setScreenshot(String path) {
- mScreenshot = path;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void failed(String trace) {
- mSkipped = false;
- setResultStatus(TestStatus.FAIL);
- int index = trace.indexOf('\n');
- if (index < 0) {
- // Trace is a single line, just set the message to be the same as the stacktrace.
- setMessage(trace);
- } else {
- setMessage(trace.substring(0, index));
- }
- setStackTrace(trace);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void passed(ReportLog report) {
- mSkipped = false;
- if (getResultStatus() != TestStatus.FAIL) {
- setResultStatus(TestStatus.PASS);
- if (report != null) {
- setReportLog(report);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void skipped() {
- if (getResultStatus() == null) {
- mSkipped = true;
- setResultStatus(TestStatus.PASS);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSkipped() {
- return mSkipped;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void reset() {
- mResult = null;
- mMessage = null;
- mStackTrace = null;
- mReport = null;
- mBugReport = null;
- mLog = null;
- mScreenshot = null;
- mIsRetry = false;
- mSkipped = false;
- mTestResultHistories = null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setRetry(boolean isRetry) {
- mIsRetry = isRetry;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isRetry() {
- return mIsRetry;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void removeResult() {
- setResultStatus(TestStatus.FAIL);
- setStackTrace("");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int compareTo(ITestResult another) {
- return getName().compareTo(another.getName());
- }
-
- /**
- * Strip out any invalid XML characters that might cause the report to be unviewable.
- * http://www.w3.org/TR/REC-xml/#dt-character
- */
- static String sanitizeStackTrace(String trace) {
- if (trace != null) {
- return trace.replaceAll("[^\\u0009\\u000A\\u000D\\u0020-\\uD7FF\\uE000-\\uFFFD]", "");
- } else {
- return null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<TestResultHistory> getTestResultHistories() {
- return mTestResultHistories;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setTestResultHistories(List<TestResultHistory> resultHistories) {
- mTestResultHistories = resultHistories;
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/TestResultHistory.java b/common/util/src/com/android/compatibility/common/util/TestResultHistory.java
deleted file mode 100644
index 15a9319..0000000
--- a/common/util/src/com/android/compatibility/common/util/TestResultHistory.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2019 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.compatibility.common.util;
-
-import org.xmlpull.v1.XmlSerializer;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * Utility class to add test case result history to the report. This class records per-case history
- * for CTS Verifier. If this field is used for large test suites like CTS, it may cause performance
- * issues in APFE. Thus please do not use this class in other test suites.
- */
-public class TestResultHistory implements Serializable {
-
- private static final long serialVersionUID = 10L;
-
- private static final String ENCODING = "UTF-8";
- private static final String TYPE = "org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer";
-
- // XML constants
- private static final String SUB_TEST_ATTR = "subtest";
- private static final String RUN_HISTORY_TAG = "RunHistory";
- private static final String RUN_TAG = "Run";
- private static final String START_TIME_ATTR = "start";
- private static final String END_TIME_ATTR = "end";
- private static final String IS_AUTOMATED_ATTR = "isAutomated";
-
- private final String mTestName;
- private final Set<ExecutionRecord> mExecutionRecords;
-
- /**
- * Constructor of test result history.
- *
- * @param testName a string of test name.
- * @param executionRecords a Set of ExecutionRecords.
- */
- public TestResultHistory(String testName, Set<ExecutionRecord> executionRecords) {
- this.mTestName = testName;
- this.mExecutionRecords = executionRecords;
- }
-
- /** Get test name */
- public String getTestName() {
- return mTestName;
- }
-
- /** Get a set of ExecutionRecords. */
- public Set<ExecutionRecord> getExecutionRecords() {
- return mExecutionRecords;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- TestResultHistory that = (TestResultHistory) o;
- return Objects.equals(mTestName, that.mTestName)
- && Objects.equals(mExecutionRecords, that.mExecutionRecords);
- }
-
- /** {@inheritDoc} */
- @Override
- public int hashCode() {
- return Objects.hash(mTestName, mExecutionRecords);
- }
-
- /**
- * Serializes a given {@link TestResultHistory} to XML.
- *
- * @param serializer given serializer.
- * @param resultHistory test result history with test name and execution record.
- * @param testName top-level test name.
- * @throws IOException
- */
- public static void serialize(
- XmlSerializer serializer, TestResultHistory resultHistory, String testName)
- throws IOException {
- if (resultHistory == null) {
- throw new IllegalArgumentException("Test result history was null");
- }
-
- serializer.startTag(null, RUN_HISTORY_TAG);
- // Only show sub-test names in test attribute in run history node.
- String name = resultHistory.getTestName().replaceFirst(testName + ":", "");
- if (!name.isEmpty() && !name.equalsIgnoreCase(testName)) {
- serializer.attribute(null, SUB_TEST_ATTR, name);
- }
-
- for (ExecutionRecord execRecord : resultHistory.getExecutionRecords()) {
- serializer.startTag(null, RUN_TAG);
- serializer.attribute(null, START_TIME_ATTR, String.valueOf(execRecord.getStartTime()));
- serializer.attribute(null, END_TIME_ATTR, String.valueOf(execRecord.getEndTime()));
- serializer.attribute(
- null, IS_AUTOMATED_ATTR, String.valueOf(execRecord.getIsAutomated()));
- serializer.endTag(null, RUN_TAG);
- }
- serializer.endTag(null, RUN_HISTORY_TAG);
- }
-
- /** Execution Record about start time, end time and isAutomated */
- public static class ExecutionRecord implements Serializable {
-
- private static final long serialVersionUID = 0L;
- // Start time of test case.
- private final long startTime;
- // End time of test case.
- private final long endTime;
- // Whether test case was executed through automation.
- private final boolean isAutomated;
-
- public ExecutionRecord(long startTime, long endTime, boolean isAutomated) {
- this.startTime = startTime;
- this.endTime = endTime;
- this.isAutomated = isAutomated;
- }
-
- public long getStartTime() {
- return startTime;
- }
-
- public long getEndTime() {
- return endTime;
- }
-
- public boolean getIsAutomated() {
- return isAutomated;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- ExecutionRecord that = (ExecutionRecord) o;
- return startTime == that.startTime
- && endTime == that.endTime
- && isAutomated == that.isAutomated;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(startTime, endTime, isAutomated);
- }
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/TestStatus.java b/common/util/src/com/android/compatibility/common/util/TestStatus.java
deleted file mode 100644
index 5a9b170..0000000
--- a/common/util/src/com/android/compatibility/common/util/TestStatus.java
+++ /dev/null
@@ -1,55 +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.compatibility.common.util;
-
-/**
- * An enum of possible test statuses.
- */
-public enum TestStatus {
- PASS("pass"),
- FAIL("fail");
-
- private final String mValue;
-
- private TestStatus(String storedValue) {
- mValue = storedValue;
- }
-
- /**
- * Get the String representation of this test status that should be stored in
- * xml
- */
- public String getValue() {
- return mValue;
- }
-
- /**
- * Find the {@link TestStatus} corresponding to given string value
- * <p/>
- * Performs a case insensitive search
- *
- * @param value
- * @return the {@link TestStatus} or <code>null</code> if it could not be found
- */
- static TestStatus getStatus(String value) {
- for (TestStatus status : TestStatus.values()) {
- if (value.compareToIgnoreCase(status.getValue()) == 0) {
- return status;
- }
- }
- return null;
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/VendorInterfaceTest.java b/common/util/src/com/android/compatibility/common/util/VendorInterfaceTest.java
deleted file mode 100644
index 5bcaf0c..0000000
--- a/common/util/src/com/android/compatibility/common/util/VendorInterfaceTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2017 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.compatibility.common.util;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation marking a test case as part of the cts-vendor-interface plan for VTS's CTS on
- * AOSP requirement.
- * <p>
- * Test classes and test cases marked with this annotation will be included in the
- * cts-vendor-interface plan
- * by default.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD, ElementType.TYPE})
-public @interface VendorInterfaceTest {
-}
diff --git a/common/util/src/com/android/compatibility/common/util/VersionCodes.java b/common/util/src/com/android/compatibility/common/util/VersionCodes.java
deleted file mode 100644
index 224b6c8..0000000
--- a/common/util/src/com/android/compatibility/common/util/VersionCodes.java
+++ /dev/null
@@ -1,52 +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.compatibility.common.util;
-
-public class VersionCodes {
- public static final int CUR_DEVELOPMENT = 10000;
- public static final int BASE = 1;
- public static final int BASE_1_1 = 2;
- public static final int CUPCAKE = 3;
- public static final int DONUT = 4;
- public static final int ECLAIR = 5;
- public static final int ECLAIR_0_1 = 6;
- public static final int ECLAIR_MR1 = 7;
- public static final int FROYO = 8;
- public static final int GINGERBREAD = 9;
- public static final int GINGERBREAD_MR1 = 10;
- public static final int HONEYCOMB = 11;
- public static final int HONEYCOMB_MR1 = 12;
- public static final int HONEYCOMB_MR2 = 13;
- public static final int ICE_CREAM_SANDWICH = 14;
- public static final int ICE_CREAM_SANDWICH_MR1 = 15;
- public static final int JELLY_BEAN = 16;
- public static final int JELLY_BEAN_MR1 = 17;
- public static final int JELLY_BEAN_MR2 = 18;
- public static final int KITKAT = 19;
- public static final int KITKAT_WATCH = 20;
- public static final int L = 21;
- public static final int LOLLIPOP = 21;
- public static final int LOLLIPOP_MR1 = 22;
- public static final int M = 23;
- public static final int N = 24;
- public static final int N_MR1 = 25;
- public static final int O = 26;
- public static final int O_MR1 = 27;
- public static final int P = 28;
- public static final int Q = 29;
- public static final int R = 30;
- public static final int S = CUR_DEVELOPMENT;
-}
diff --git a/common/util/src/com/android/compatibility/common/util/ZipUtil.java b/common/util/src/com/android/compatibility/common/util/ZipUtil.java
deleted file mode 100644
index b44fd46..0000000
--- a/common/util/src/com/android/compatibility/common/util/ZipUtil.java
+++ /dev/null
@@ -1,129 +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.compatibility.common.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-public class ZipUtil {
-
- /**
- * Utility method to create a zip file containing the given directory and
- * all its contents.
- *
- * @param dir the directory to zip
- * @param zipFile the zip file to create - it should not already exist
- * @throws IOException if failed to create zip file
- */
- public static void createZip(File dir, File zipFile) throws IOException {
- ZipOutputStream out = null;
- try {
- FileOutputStream fileStream = new FileOutputStream(zipFile);
- out = new ZipOutputStream(new BufferedOutputStream(fileStream));
- addToZip(out, dir, new LinkedList<String>());
- } catch (IOException e) {
- zipFile.delete();
- throw e;
- } catch (RuntimeException e) {
- zipFile.delete();
- throw e;
- } finally {
- out.close();
- }
- }
-
- /**
- * Recursively adds given file and its contents to ZipOutputStream
- *
- * @param out the {@link ZipOutputStream}
- * @param file the {@link File} to add to the stream
- * @param relativePathSegs the relative path of file, including separators
- * @throws IOException if failed to add file to zip
- */
- public static void addToZip(ZipOutputStream out, File file, List<String> relativePathSegs)
- throws IOException {
- relativePathSegs.add(file.getName());
- if (file.isDirectory()) {
- // note: it appears even on windows, ZipEntry expects '/' as a path separator
- relativePathSegs.add("/");
- }
- ZipEntry zipEntry = new ZipEntry(buildPath(relativePathSegs));
- out.putNextEntry(zipEntry);
- if (file.isFile()) {
- writeToStream(file, out);
- }
- out.closeEntry();
- if (file.isDirectory()) {
- // recursively add contents
- File[] subFiles = file.listFiles();
- if (subFiles == null) {
- throw new IOException(String.format("Could not read directory %s",
- file.getAbsolutePath()));
- }
- for (File subFile : subFiles) {
- addToZip(out, subFile, relativePathSegs);
- }
- // remove the path separator
- relativePathSegs.remove(relativePathSegs.size()-1);
- }
- // remove the last segment, added at beginning of method
- relativePathSegs.remove(relativePathSegs.size()-1);
- }
-
- /**
- * Builds a file system path from a stack of relative path segments
- *
- * @param relativePathSegs the list of relative paths
- * @return a {@link String} containing all relativePathSegs
- */
- private static String buildPath(List<String> relativePathSegs) {
- StringBuilder pathBuilder = new StringBuilder();
- for (String segment : relativePathSegs) {
- pathBuilder.append(segment);
- }
- return pathBuilder.toString();
- }
-
- /**
- * Helper method to write input file contents to output stream.
- *
- * @param file the input {@link File}
- * @param out the {@link OutputStream}
- *
- * @throws IOException
- */
- private static void writeToStream(File file, OutputStream out) throws IOException {
- InputStream inputStream = null;
- try {
- inputStream = new BufferedInputStream(new FileInputStream(file));
- StreamUtil.copyStreams(inputStream, out);
- } finally {
- inputStream.close();
- }
- }
-
-}
diff --git a/common/util/tests/Android.bp b/common/util/tests/Android.bp
index 2943a79..d657120 100644
--- a/common/util/tests/Android.bp
+++ b/common/util/tests/Android.bp
@@ -14,15 +14,20 @@
java_test_host {
name: "compatibility-common-util-tests",
+ // Restrict visibility to only those targets that need to access it.
+ visibility: ["//visibility:private"],
defaults: ["cts_error_prone_rules"],
srcs: ["src/**/*.java"],
+// test_options: {
+// unit_test: true,
+// },
- libs: [
+ static_libs: [
+ "compatibility-common-util-hostsidelib",
"junit",
"kxml2-2.3.0",
"tradefed",
- "compatibility-common-util-hostsidelib",
],
// Holds golden sample files in assets for validation
diff --git a/common/util/tests/assets/logcat.txt b/common/util/tests/assets/logcat.txt
index ffb28ad..b9d10d0 100644
--- a/common/util/tests/assets/logcat.txt
+++ b/common/util/tests/assets/logcat.txt
@@ -229,6 +229,7 @@
05-04 21:59:23.743 9363 9363 F DEBUG : #22 pc 00000000001a1f94 /system/lib64/hw/bluetooth.default.so (run_thread(void*)+184)
05-04 21:59:23.743 9363 9363 F DEBUG : #23 pc 0000000000067d80 /system/lib64/libc.so (__pthread_start(void*)+36)
05-04 21:59:23.743 9363 9363 F DEBUG : #24 pc 000000000001ec18 /system/lib64/libc.so (__start_thread+68)
+1-25 19:47:35.417 8080 11665 F MPEG4Extractor: frameworks/av/media/libstagefright/MPEG4Extractor.cpp:6853 CHECK_EQ( (unsigned)ptr[0],1u) failed: 129 vs. 1
11-25 19:47:35.417 8080 11665 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 11665 (generic)
11-25 19:47:35.487 940 940 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-25 19:47:35.487 940 940 F DEBUG : Build fingerprint: 'samsung/hero2qltezc/hero2qltechn:6.0.1/MMB29M/G9350ZCU2APJ6:user/release-keys'
diff --git a/common/util/tests/src/com/android/compatibility/common/util/CrashUtilsTest.java b/common/util/tests/src/com/android/compatibility/common/util/CrashUtilsTest.java
index 7ae3136..071733f 100644
--- a/common/util/tests/src/com/android/compatibility/common/util/CrashUtilsTest.java
+++ b/common/util/tests/src/com/android/compatibility/common/util/CrashUtilsTest.java
@@ -54,40 +54,29 @@
public void testGetAllCrashes() throws Exception {
JSONArray expectedResults = new JSONArray();
expectedResults.put(createCrashJson(
- 11071, 11189, "AudioOut_D", "/system/bin/audioserver", "e9380000", "SIGSEGV", null));
+ 11071, 11189, "AudioOut_D", "/system/bin/audioserver", "e9380000", "SIGSEGV"));
expectedResults.put(createCrashJson(
- 12736, 12761, "Binder:12736_2", "/system/bin/audioserver", "0", "SIGSEGV", null));
+ 12736, 12761, "Binder:12736_2", "/system/bin/audioserver", "0", "SIGSEGV"));
expectedResults.put(createCrashJson(
- 26201, 26227, "Binder:26201_3", "/system/bin/audioserver", "0", "SIGSEGV", null));
+ 26201, 26227, "Binder:26201_3", "/system/bin/audioserver", "0", "SIGSEGV"));
expectedResults.put(createCrashJson(
- 26246, 26282, "Binder:26246_5", "/system/bin/audioserver", "0", "SIGSEGV", null));
+ 26246, 26282, "Binder:26246_5", "/system/bin/audioserver", "0", "SIGSEGV"));
expectedResults.put(createCrashJson(
- 245, 245, "installd", "/system/bin/installd", null, "SIGABRT",
- "'utils.cpp:67] Check failed: is_valid_package_name(package_name) == 0 '"));
+ 245, 245, "installd", "/system/bin/installd", null, "SIGABRT"));
expectedResults.put(createCrashJson(
- 6371, 8072, "media.codec", "omx@1.0-service", "ed000000", "SIGSEGV", null));
+ 6371, 8072, "media.codec", "omx@1.0-service", "ed000000", "SIGSEGV"));
expectedResults.put(createCrashJson(
- 8373, 8414, "loo", "com.android.bluetooth", null, "SIGABRT",
- "'[FATAL:allocation_tracker.cc(143)] Check failed: map_entry != allocations.end()."));
+ 8373, 8414, "loo", "com.android.bluetooth", null, "SIGABRT"));
expectedResults.put(createCrashJson(
- 8080, 11665, "generic", "/system/bin/mediaserver", null, "SIGABRT",
- "'frameworks/av/media/libstagefright/MPEG4Extractor.cpp:6853 CHECK_EQ( (unsigned)ptr[0],1u) failed: 129 vs. 1'"));
+ 11071, 11189, "synthetic_thread", "synthetic_process_0", "e9380000", "SIGSEGV"));
expectedResults.put(createCrashJson(
- 11071, 11189, "synthetic_thread", "synthetic_process_0", "e9380000", "SIGSEGV", null));
- expectedResults.put(createCrashJson(
- 12736, 12761, "synthetic_thread", "synthetic_process_1", "0", "SIGSEGV", null));
+ 12736, 12761, "synthetic_thread", "synthetic_process_1", "0", "SIGSEGV"));
- Assert.assertEquals(expectedResults.toString() + "\n" + mCrashes.toString() + "\n", expectedResults.toString(), mCrashes.toString());
+ Assert.assertEquals(mCrashes.toString(), expectedResults.toString());
}
public JSONObject createCrashJson(
- int pid,
- int tid,
- String name,
- String process,
- String faultaddress,
- String signal,
- String abortMessage) {
+ int pid, int tid, String name, String process, String faultaddress, String signal) {
JSONObject json = new JSONObject();
try {
json.put(CrashUtils.PID, pid);
@@ -96,7 +85,6 @@
json.put(CrashUtils.PROCESS, process);
json.put(CrashUtils.FAULT_ADDRESS, faultaddress);
json.put(CrashUtils.SIGNAL, signal);
- json.put(CrashUtils.ABORT_MESSAGE, abortMessage);
} catch (JSONException e) {}
return json;
}
@@ -155,41 +143,9 @@
@Test
public void testNullFaultAddress() throws Exception {
JSONArray crashes = new JSONArray();
- crashes.put(createCrashJson(8373, 8414, "loo", "com.android.bluetooth", null, "SIGSEGV", ""));
+ crashes.put(createCrashJson(8373, 8414, "loo", "com.android.bluetooth", null, "SIGSEGV"));
Assert.assertTrue(CrashUtils.securityCrashDetected(crashes, new CrashUtils.Config()
.checkMinAddress(true)
.setProcessPatterns(Pattern.compile("com\\.android\\.bluetooth"))));
}
-
- @Test
- public void testAbortMessageInclude() throws Exception {
- JSONArray crashes = new JSONArray();
- crashes.put(createCrashJson(8373, 8414, "loo", "com.android.bluetooth", null, "SIGABRT",
- "'[FATAL:allocation_tracker.cc(143)] Check failed: map_entry != allocations.end()."));
- Assert.assertTrue(CrashUtils.securityCrashDetected(crashes, new CrashUtils.Config()
- .appendSignals(CrashUtils.SIGABRT)
- .appendAbortMessageIncludes("Check failed:")
- .setProcessPatterns(Pattern.compile("com\\.android\\.bluetooth"))));
-
- Assert.assertFalse(CrashUtils.securityCrashDetected(crashes, new CrashUtils.Config()
- .appendSignals(CrashUtils.SIGABRT)
- .appendAbortMessageIncludes("include not matches")
- .setProcessPatterns(Pattern.compile("com\\.android\\.bluetooth"))));
- }
-
- @Test
- public void testAbortMessageExclude() throws Exception {
- JSONArray crashes = new JSONArray();
- crashes.put(createCrashJson(8373, 8414, "loo", "com.android.bluetooth", null, "SIGABRT",
- "'[FATAL:allocation_tracker.cc(143)] Check failed: map_entry != allocations.end()."));
- Assert.assertFalse(CrashUtils.securityCrashDetected(crashes, new CrashUtils.Config()
- .appendSignals(CrashUtils.SIGABRT)
- .appendAbortMessageExcludes("Check failed:")
- .setProcessPatterns(Pattern.compile("com\\.android\\.bluetooth"))));
-
- Assert.assertTrue(CrashUtils.securityCrashDetected(crashes, new CrashUtils.Config()
- .appendSignals(CrashUtils.SIGABRT)
- .appendAbortMessageExcludes("exclude not matches")
- .setProcessPatterns(Pattern.compile("com\\.android\\.bluetooth"))));
- }
}
diff --git a/common/util/tests/src/com/android/compatibility/common/util/ResultHandlerTest.java b/common/util/tests/src/com/android/compatibility/common/util/ResultHandlerTest.java
index 9155b93..581e201 100644
--- a/common/util/tests/src/com/android/compatibility/common/util/ResultHandlerTest.java
+++ b/common/util/tests/src/com/android/compatibility/common/util/ResultHandlerTest.java
@@ -92,6 +92,9 @@
private static final String METHOD_3 = "testBlah3";
private static final String METHOD_4 = "testBlah4";
private static final String METHOD_5 = "testBlah5";
+ private static final String METHOD_6_BRACKETS = "testBlah6[suffix]";
+ private static final String SUB_METHOD_3 = "subTestBlah3";
+ private static final String SUB_METHOD_6_BRACKETS = "subTestBlah6[suffix]";
private static final String SUMMARY_SOURCE = String.format("%s#%s:20", CLASS_B, METHOD_4);
private static final String SUMMARY_MESSAGE = "Headline";
private static final double SUMMARY_VALUE = 9001;
@@ -316,7 +319,8 @@
moduleBTest3.setLog(LOGCAT);
moduleBTest3.setScreenshot(SCREENSHOT);
List<TestResultHistory> resultHistories = new ArrayList<TestResultHistory>();
- TestResultHistory resultHistory = new TestResultHistory(METHOD_3, executionRecords);
+ TestResultHistory resultHistory =
+ new TestResultHistory(METHOD_3 + ":" + SUB_METHOD_3, executionRecords);
resultHistories.add(resultHistory);
moduleBTest3.setTestResultHistories(resultHistories);
ITestResult moduleBTest4 = moduleBCase.getOrCreateResult(METHOD_4);
@@ -333,6 +337,15 @@
moduleBTest4.setReportLog(report);
ITestResult moduleBTest5 = moduleBCase.getOrCreateResult(METHOD_5);
moduleBTest5.skipped();
+ // For test name with bracket as suffix in CTS Verifier.
+ ITestResult moduleBTest6 = moduleBCase.getOrCreateResult(METHOD_6_BRACKETS);
+ moduleBTest6.setResultStatus(TestStatus.FAIL);
+ List<TestResultHistory> resultHistories2 = new ArrayList<TestResultHistory>();
+ TestResultHistory resultHistory2 =
+ new TestResultHistory(
+ METHOD_6_BRACKETS + ":" + SUB_METHOD_6_BRACKETS, executionRecords);
+ resultHistories2.add(resultHistory2);
+ moduleBTest6.setTestResultHistories(resultHistories2);
// Serialize to file
File res =
@@ -514,7 +527,13 @@
IInvocationResult result, String expectedBuildFingerprint, boolean newTestFormat,
boolean checkResultHistories) throws Exception {
assertEquals("Expected 3 passes", 3, result.countResults(TestStatus.PASS));
- assertEquals("Expected 1 failure", 1, result.countResults(TestStatus.FAIL));
+ if (checkResultHistories) {
+ assertEquals("Expected 1 failure", 1, result.countResults(TestStatus.FAIL));
+ } else {
+ // CTS Verifier needs to check the condition of the test name with bracket,
+ // so adds one more test with failure result.
+ assertEquals("Expected 2 failure", 2, result.countResults(TestStatus.FAIL));
+ }
Map<String, String> buildInfo = result.getInvocationInfo();
assertEquals("Incorrect Build Fingerprint", expectedBuildFingerprint, result.getBuildFingerprint());
@@ -558,7 +577,13 @@
IModuleResult moduleB = modules.get(1);
assertEquals("Expected 2 passes", 2, moduleB.countResults(TestStatus.PASS));
- assertEquals("Expected 1 failure", 1, moduleB.countResults(TestStatus.FAIL));
+ if (checkResultHistories) {
+ assertEquals("Expected 1 failure", 1, moduleB.countResults(TestStatus.FAIL));
+ } else {
+ // CTS Verifier needs to check the condition of the test name with bracket,
+ // so adds one more test with failure result.
+ assertEquals("Expected 2 failure", 2, moduleB.countResults(TestStatus.FAIL));
+ }
assertEquals("Incorrect ABI", ABI, moduleB.getAbi());
assertEquals("Incorrect name", NAME_B, moduleB.getName());
assertEquals("Incorrect ID", ID_B, moduleB.getId());
@@ -568,7 +593,13 @@
ICaseResult moduleBCase = moduleBCases.get(0);
assertEquals("Incorrect name", CLASS_B, moduleBCase.getName());
List<ITestResult> moduleBResults = moduleBCase.getResults();
- assertEquals("Expected 3 results", 3, moduleBResults.size());
+ if (checkResultHistories) {
+ assertEquals("Expected 3 results", 3, moduleBResults.size());
+ } else {
+ // CTS Verifier needs to check the condition of the test name with bracket,
+ // so adds one more test with failure result.
+ assertEquals("Expected 4 results", 4, moduleBResults.size());
+ }
ITestResult moduleBTest3 = moduleBResults.get(0);
assertEquals("Incorrect name", METHOD_3, moduleBTest3.getName());
assertEquals("Incorrect result", TestStatus.FAIL, moduleBTest3.getResultStatus());
@@ -589,7 +620,10 @@
assertEquals("Expected 1 test result history", 1, resultHistories.size());
for (TestResultHistory resultHistory : resultHistories) {
assertNotNull("Expected test result history", resultHistory);
- assertEquals("Incorrect test name", METHOD_3, resultHistory.getTestName());
+ assertEquals(
+ "Incorrect test name",
+ SUB_METHOD_3,
+ resultHistory.getSubTestName(METHOD_3, resultHistory.getTestName()));
for (TestResultHistory.ExecutionRecord execRecord :
resultHistory.getExecutionRecords()) {
assertEquals(
@@ -633,6 +667,34 @@
assertNull("Unexpected message", moduleBTest5.getMessage());
assertNull("Unexpected stack trace", moduleBTest5.getStackTrace());
assertNull("Unexpected report", moduleBTest5.getReportLog());
+ if (!checkResultHistories) {
+ // CTS Verifier needs to check the condition of the test name with bracket,
+ // so adds one more test with failure result.
+ ITestResult moduleBTest6 = moduleBResults.get(3);
+ assertEquals("Incorrect name", METHOD_6_BRACKETS, moduleBTest6.getName());
+ assertEquals("Incorrect result", TestStatus.FAIL, moduleBTest6.getResultStatus());
+ List<TestResultHistory> resultHistories2 = moduleBTest6.getTestResultHistories();
+ assertNotNull("Expected test result history list", resultHistories2);
+ assertEquals("Expected 1 test result history", 1, resultHistories2.size());
+ for (TestResultHistory resultHistory : resultHistories2) {
+ assertNotNull("Expected test result history", resultHistory);
+ assertEquals(
+ "Incorrect test name",
+ SUB_METHOD_6_BRACKETS,
+ resultHistory.getSubTestName(
+ METHOD_6_BRACKETS, resultHistory.getTestName()));
+ for (TestResultHistory.ExecutionRecord execRecord :
+ resultHistory.getExecutionRecords()) {
+ assertEquals(
+ "Incorrect test start time", TEST_START_MS, execRecord.getStartTime());
+ assertEquals("Incorrect test end time", TEST_END_MS, execRecord.getEndTime());
+ assertEquals(
+ "Incorrect test is automated",
+ TEST_IS_AUTOMATED,
+ execRecord.getIsAutomated());
+ }
+ }
+ }
}
/** Return all XML nodes that match the given xPathExpression. */
diff --git a/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java b/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java
deleted file mode 100644
index a7f8460..0000000
--- a/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java
+++ /dev/null
@@ -1,45 +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.compatibility.common.util;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * A test suite for all util unit tests.
- *
- * <p>All tests listed here should be self-contained, and do not require any external dependencies.
- */
-@RunWith(Suite.class)
-@SuiteClasses({
- BackupUtilsTest.class,
- BusinessLogicTest.class,
- CaseResultTest.class,
- CrashUtilsTest.class,
- DynamicConfigTest.class,
- LightInvocationResultTest.class,
- MetricsXmlSerializerTest.class,
- MultipartFormTest.class,
- ReportLogTest.class,
- ResultHandlerTest.class,
- StatTest.class,
- TestResultTest.class,
- ReadElfTest.class,
-})
-public class UnitTests {
- // empty on purpose
-}
diff --git a/test_defs.sh b/test_defs.sh
deleted file mode 100644
index 1d9cf57..0000000
--- a/test_defs.sh
+++ /dev/null
@@ -1,46 +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.
-
-# Common tools for running unit tests of the compatibility libs
-
-JAR_DIR=${ANDROID_HOST_OUT}/framework
-TF_CONSOLE=com.android.tradefed.command.Console
-
-COMMON_JARS="
- ddmlib-prebuilt\
- tradefed"
-
-checkFile() {
- if [ ! -f "$1" ]; then
- echo "Unable to locate $1"
- exit
- fi;
-}
-
-build_jar_path() {
- JAR_PATH=
- for JAR in ${2} ${COMMON_JARS}; do
- checkFile ${1}/${JAR}.jar
- JAR_PATH=${JAR_PATH}:${1}/${JAR}.jar
- done
-}
-
-run_tests() {
- build_jar_path "${JAR_DIR}" "${2}"
- for CLASS in ${1}; do
- java $RDBG_FLAG -cp ${JAR_PATH} ${TF_CONSOLE} run singleCommand host -n --class ${CLASS} ${3}
- done
-}
diff --git a/tools/cts-test-metrics/CtsCameraTestCases.reportlog.json b/tools/cts-test-metrics/CtsCameraTestCases.reportlog.json
deleted file mode 100644
index 81a9ef1..0000000
--- a/tools/cts-test-metrics/CtsCameraTestCases.reportlog.json
+++ /dev/null
@@ -1 +0,0 @@
-{"test_reprocessing_throughput":[{"camera_id":"0","format":35,"reprocess_type":"YUV reprocessing","capture_message":"capture latency","latency":[237.0,102.0,99.0,105.0,124.0,92.0],"camera_reprocessing_average_latency":126.5},{"camera_id":"0","format":34,"reprocess_type":"opaque reprocessing","capture_message":"capture latency","latency":[206.0,91.0,92.0,89.0,119.0,84.0],"camera_reprocessing_average_latency":113.5},{"camera_id":"1","format":35,"reprocess_type":"YUV reprocessing","capture_message":"capture latency","latency":[216.0,84.0,80.0,83.0,93.0,76.0],"camera_reprocessing_average_latency":105.33333333333333},{"camera_id":"1","format":34,"reprocess_type":"opaque reprocessing","capture_message":"capture latency","latency":[212.0,83.0,71.0,80.0,93.0,74.0],"camera_reprocessing_average_latency":102.16666666666667},{"camera_id":"0","format":35,"reprocess_type":"YUV reprocessing","capture_message":"capture latency","latency":[228.0,105.0,85.0,86.0,116.0,83.0],"camera_reprocessing_average_latency":117.16666666666667},{"camera_id":"0","format":34,"reprocess_type":"opaque reprocessing","capture_message":"capture latency","latency":[195.0,89.0,94.0,94.0,116.0,86.0],"camera_reprocessing_average_latency":112.33333333333333},{"camera_id":"1","format":35,"reprocess_type":"YUV reprocessing","capture_message":"capture latency","latency":[150.0,83.0,75.0,75.0,102.0,76.0],"camera_reprocessing_average_latency":93.5},{"camera_id":"1","format":34,"reprocess_type":"opaque reprocessing","capture_message":"capture latency","latency":[198.0,85.0,78.0,71.0,95.0,77.0],"camera_reprocessing_average_latency":100.66666666666667}],"test_camera_launch_average":[{"camera_launch_average_time_for_all_cameras":326.1},{"camera_launch_average_time_for_all_cameras":321.8}],"test_reprocessing_latency":[{"camera_id":"0","format":35,"reprocess_type":"YUV reprocessing","capture_message":"shot to shot latency","latency":[303.0,254.0,259.0,196.0,201.0,195.0],"camera_reprocessing_shot_to_shot_average_latency":234.66666666666666},{"camera_id":"0","format":34,"reprocess_type":"opaque reprocessing","capture_message":"shot to shot latency","latency":[248.0,172.0,209.0,188.0,201.0,204.0],"camera_reprocessing_shot_to_shot_average_latency":203.66666666666666},{"camera_id":"1","format":35,"reprocess_type":"YUV reprocessing","capture_message":"shot to shot latency","latency":[190.0,238.0,220.0,213.0,144.0,154.0],"camera_reprocessing_shot_to_shot_average_latency":193.16666666666666},{"camera_id":"1","format":34,"reprocess_type":"opaque reprocessing","capture_message":"shot to shot latency","latency":[237.0,166.0,153.0,148.0,162.0,140.0],"camera_reprocessing_shot_to_shot_average_latency":167.66666666666666},{"camera_id":"0","format":35,"reprocess_type":"YUV reprocessing","capture_message":"shot to shot latency","latency":[302.0,262.0,256.0,197.0,200.0,201.0],"camera_reprocessing_shot_to_shot_average_latency":236.33333333333334},{"camera_id":"0","format":34,"reprocess_type":"opaque reprocessing","capture_message":"shot to shot latency","latency":[251.0,166.0,199.0,199.0,213.0,201.0],"camera_reprocessing_shot_to_shot_average_latency":204.83333333333334},{"camera_id":"1","format":35,"reprocess_type":"YUV reprocessing","capture_message":"shot to shot latency","latency":[199.0,153.0,159.0,164.0,152.0,166.0],"camera_reprocessing_shot_to_shot_average_latency":165.5},{"camera_id":"1","format":34,"reprocess_type":"opaque reprocessing","capture_message":"shot to shot latency","latency":[210.0,143.0,161.0,162.0,158.0,156.0],"camera_reprocessing_shot_to_shot_average_latency":165.0}],"test_high_quality_reprocessing_latency":[{"camera_id":"0","format":35,"reprocess_type":"YUV reprocessing","capture_message":"shot to shot latency for High Quality noise reduction and edge modes","latency":[479.0,398.0,351.0,487.0,461.0,395.0],"camera_reprocessing_shot_to_shot_average_latency":428.5},{"camera_id":"0","format":34,"reprocess_type":"opaque reprocessing","capture_message":"shot to shot latency for High Quality noise reduction and edge modes","latency":[355.0,324.0,335.0,334.0,336.0,347.0],"camera_reprocessing_shot_to_shot_average_latency":338.5},{"camera_id":"1","format":35,"reprocess_type":"YUV reprocessing","capture_message":"shot to shot latency for High Quality noise reduction and edge modes","latency":[235.0,220.0,223.0,228.0,222.0,227.0],"camera_reprocessing_shot_to_shot_average_latency":225.83333333333334},{"camera_id":"1","format":34,"reprocess_type":"opaque reprocessing","capture_message":"shot to shot latency for High Quality noise reduction and edge modes","latency":[256.0,186.0,230.0,215.0,226.0,242.0],"camera_reprocessing_shot_to_shot_average_latency":225.83333333333334},{"camera_id":"0","format":35,"reprocess_type":"YUV reprocessing","capture_message":"shot to shot latency for High Quality noise reduction and edge modes","latency":[415.0,327.0,336.0,340.0,323.0,332.0],"camera_reprocessing_shot_to_shot_average_latency":345.5},{"camera_id":"0","format":34,"reprocess_type":"opaque reprocessing","capture_message":"shot to shot latency for High Quality noise reduction and edge modes","latency":[381.0,302.0,331.0,332.0,336.0,333.0],"camera_reprocessing_shot_to_shot_average_latency":335.8333333333333},{"camera_id":"1","format":35,"reprocess_type":"YUV reprocessing","capture_message":"shot to shot latency for High Quality noise reduction and edge modes","latency":[231.0,222.0,223.0,227.0,227.0,223.0],"camera_reprocessing_shot_to_shot_average_latency":225.5},{"camera_id":"1","format":34,"reprocess_type":"opaque reprocessing","capture_message":"shot to shot latency for High Quality noise reduction and edge modes","latency":[275.0,178.0,222.0,224.0,249.0,204.0],"camera_reprocessing_shot_to_shot_average_latency":225.33333333333334}],"test_single_capture":[{"camera_id":"0","camera_capture_latency":[476.0,639.0,654.0,639.0,665.0],"camera_capture_result_latency":[260.0,465.0,490.0,471.0,474.0]},{"camera_id":"1","camera_capture_latency":[461.0,639.0,627.0,637.0,631.0],"camera_capture_result_latency":[341.0,530.0,533.0,533.0,535.0]},{"camera_id":"0","camera_capture_latency":[465.0,643.0,660.0,649.0,642.0],"camera_capture_result_latency":[251.0,467.0,491.0,474.0,475.0]},{"camera_id":"1","camera_capture_latency":[457.0,541.0,533.0,546.0,534.0],"camera_capture_result_latency":[338.0,475.0,467.0,477.0,471.0]}],"test_single_capture_average":[{"camera_capture_result_average_latency_for_all_cameras":463.2},{"camera_capture_result_average_latency_for_all_cameras":438.6}],"test_reprocessing_capture_stall":[{"camera_id":"0","format":35,"reprocess_type":"YUV reprocessing","max_capture_timestamp_gaps":[66.929849,66.927076,66.827072],"capture_average_frame_duration":[66.742792,66.742792,66.742792],"camera_reprocessing_average_max_capture_timestamp_gaps":66.89466566666665},{"camera_id":"0","format":34,"reprocess_type":"opaque reprocessing","max_capture_timestamp_gaps":[66.838494,66.862969,67.054342],"capture_average_frame_duration":[66.742792,66.742792,66.742792],"camera_reprocessing_average_max_capture_timestamp_gaps":66.91860166666667},{"camera_id":"1","format":35,"reprocess_type":"YUV reprocessing","max_capture_timestamp_gaps":[75.091,75.156,75.092],"capture_average_frame_duration":[75.08460800000003,75.08460800000003,75.08460800000003],"camera_reprocessing_average_max_capture_timestamp_gaps":75.113},{"camera_id":"1","format":34,"reprocess_type":"opaque reprocessing","max_capture_timestamp_gaps":[75.096,75.09,75.091],"capture_average_frame_duration":[75.08460800000003,75.08460800000003,75.08460800000003],"camera_reprocessing_average_max_capture_timestamp_gaps":75.09233333333333},{"camera_id":"0","format":35,"reprocess_type":"YUV reprocessing","max_capture_timestamp_gaps":[66.810656,67.101617,66.811857],"capture_average_frame_duration":[66.742792,66.742792,66.742792],"camera_reprocessing_average_max_capture_timestamp_gaps":66.90804333333334},{"camera_id":"0","format":34,"reprocess_type":"opaque reprocessing","max_capture_timestamp_gaps":[133.322575,66.919741,66.95088],"capture_average_frame_duration":[66.742792,66.742792,66.742792],"camera_reprocessing_average_max_capture_timestamp_gaps":89.06439866666666},{"camera_id":"1","format":35,"reprocess_type":"YUV reprocessing","max_capture_timestamp_gaps":[80.088,80.091,80.089],"capture_average_frame_duration":[80.08507200000001,80.08507200000001,80.08507200000001],"camera_reprocessing_average_max_capture_timestamp_gaps":80.08933333333333},{"camera_id":"1","format":34,"reprocess_type":"opaque reprocessing","max_capture_timestamp_gaps":[80.092,80.091,80.091],"capture_average_frame_duration":[80.08507200000001,80.08507200000001,80.08507200000001],"camera_reprocessing_average_max_capture_timestamp_gaps":80.09133333333334}],"test_camera_launch":[{"camera_id":"0","camera_open_time":[116.0,85.0,88.0,83.0,86.0],"camera_configure_stream_time":[20.0,11.0,11.0,10.0,10.0],"camera_start_preview_time":[312.0,224.0,223.0,219.0,230.0],"camera_camera_stop_preview":[278.0,255.0,265.0,268.0,267.0],"camera_camera_close_time":[107.0,124.0,103.0,108.0,127.0],"camera_launch_time":[448.0,320.0,322.0,312.0,326.0]},{"camera_id":"1","camera_open_time":[72.0,67.0,67.0,67.0,65.0],"camera_configure_stream_time":[12.0,10.0,11.0,10.0,11.0],"camera_start_preview_time":[227.0,231.0,224.0,226.0,233.0],"camera_camera_stop_preview":[167.0,162.0,171.0,170.0,168.0],"camera_camera_close_time":[96.0,87.0,91.0,85.0,90.0],"camera_launch_time":[311.0,308.0,302.0,303.0,309.0]},{"camera_id":"0","camera_open_time":[96.0,85.0,89.0,89.0,84.0],"camera_configure_stream_time":[14.0,10.0,10.0,10.0,10.0],"camera_start_preview_time":[262.0,220.0,224.0,221.0,226.0],"camera_camera_stop_preview":[259.0,251.0,271.0,257.0,265.0],"camera_camera_close_time":[117.0,153.0,120.0,122.0,118.0],"camera_launch_time":[372.0,315.0,323.0,320.0,320.0]},{"camera_id":"1","camera_open_time":[71.0,67.0,68.0,70.0,69.0],"camera_configure_stream_time":[11.0,10.0,10.0,10.0,10.0],"camera_start_preview_time":[228.0,235.0,233.0,237.0,239.0],"camera_camera_stop_preview":[167.0,169.0,169.0,162.0,173.0],"camera_camera_close_time":[95.0,89.0,93.0,94.0,103.0],"camera_launch_time":[310.0,312.0,311.0,317.0,318.0]}],"test_high_quality_reprocessing_throughput":[{"camera_id":"0","format":35,"reprocess_type":"YUV reprocessing","capture_message":"capture latency for High Quality noise reduction and edge modes","latency":[272.0,246.0,211.0,210.0,235.0,202.0],"camera_reprocessing_average_latency":229.33333333333334},{"camera_id":"0","format":34,"reprocess_type":"opaque reprocessing","capture_message":"capture latency for High Quality noise reduction and edge modes","latency":[304.0,210.0,206.0,209.0,226.0,229.0],"camera_reprocessing_average_latency":230.66666666666666},{"camera_id":"1","format":35,"reprocess_type":"YUV reprocessing","capture_message":"capture latency for High Quality noise reduction and edge modes","latency":[246.0,123.0,116.0,114.0,131.0,109.0],"camera_reprocessing_average_latency":139.83333333333334},{"camera_id":"1","format":34,"reprocess_type":"opaque reprocessing","capture_message":"capture latency for High Quality noise reduction and edge modes","latency":[211.0,112.0,116.0,112.0,123.0,110.0],"camera_reprocessing_average_latency":130.66666666666666},{"camera_id":"0","format":35,"reprocess_type":"YUV reprocessing","capture_message":"capture latency for High Quality noise reduction and edge modes","latency":[349.0,215.0,214.0,214.0,238.0,213.0],"camera_reprocessing_average_latency":240.5},{"camera_id":"0","format":34,"reprocess_type":"opaque reprocessing","capture_message":"capture latency for High Quality noise reduction and edge modes","latency":[326.0,206.0,204.0,206.0,225.0,232.0],"camera_reprocessing_average_latency":233.16666666666666},{"camera_id":"1","format":35,"reprocess_type":"YUV reprocessing","capture_message":"capture latency for High Quality noise reduction and edge modes","latency":[238.0,119.0,130.0,116.0,130.0,114.0],"camera_reprocessing_average_latency":141.16666666666666},{"camera_id":"1","format":34,"reprocess_type":"opaque reprocessing","capture_message":"capture latency for High Quality noise reduction and edge modes","latency":[249.0,117.0,122.0,113.0,129.0,119.0],"camera_reprocessing_average_latency":141.5}]}
\ No newline at end of file
diff --git a/tools/cts-test-metrics/CtsUiHostTestCases.reportlog.json b/tools/cts-test-metrics/CtsUiHostTestCases.reportlog.json
deleted file mode 100644
index 6355fe3..0000000
--- a/tools/cts-test-metrics/CtsUiHostTestCases.reportlog.json
+++ /dev/null
@@ -1 +0,0 @@
-{"test_install_time":[{"install_time":[1950.0,1722.0,1762.0,1678.0,1738.0,1694.0,1787.0,1797.0,1799.0,1786.0],"install_time_average":1771.3},{"install_time":[1976.0,1986.0,1930.0,1729.0,1859.0,1875.0,1904.0,1805.0,1748.0,1875.0],"install_time_average":1868.7}]}
\ No newline at end of file
diff --git a/tools/cts-test-metrics/README b/tools/cts-test-metrics/README
deleted file mode 100644
index cb68f3a..0000000
--- a/tools/cts-test-metrics/README
+++ /dev/null
@@ -1,14 +0,0 @@
-The parse_test_metrics.py script can be used to parse test metrics json files. Run the following
-command to see a demo:
-python parse_test_metrics.py CtsCameraTestCases.reportlog.json
-
-To parse multiple files, list all files as arguments. Try the following:
-python parse_test_metrics.py CtsCameraTestCases.reportlog.json CtsUiHostTestCases.reportlog.json
-python parse_test_metrics.py *.json
-
-Test metrics json files can be found in $CTS_ROOT/repository/results/$RESULT_DIR/report-log-files/
-directory.
-
-The MetricsParser class defines functions to parse a json file. The _Parse function takes a filename
-as input, reads the json file and adds the json object to json_data. The _PrintJson function
-takes the filename and corresponding json_data and prints out the streams as key, value pairs.
diff --git a/tools/cts-test-metrics/parse_test_metrics.py b/tools/cts-test-metrics/parse_test_metrics.py
deleted file mode 100755
index 839e372..0000000
--- a/tools/cts-test-metrics/parse_test_metrics.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/python
-# 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.
-#
-
-import argparse, json, sys
-
-class MetricsParser(object):
- """Executor of this utility"""
-
- def __init__(self):
- self._parser = argparse.ArgumentParser('Parse CTS Test metrics jsons')
- self._parser.add_argument('filenames', metavar='filenames', nargs='+',
- help='filenames of metrics jsons to be parsed')
- self._metrics = []
-
- def _ParseArgs(self):
- self._args = self._parser.parse_args()
-
- def _Parse(self, filename):
- json_file = open(filename)
- json_data = json.load(json_file)
- self._metrics.append(json_data)
- self._PrintJson(filename, json_data)
-
- def _PrintJson(self, filename, json_data):
- print "\nFilename: %s" % filename
- stream_names = json_data.keys()
- for stream_name in stream_names:
- metrics_list = json_data.get(stream_name)
- for metrics in metrics_list:
- print "\nStream Name: %s" % stream_name
- for key in metrics.keys():
- print "Key: %s \t Value: %s" % (key, str(metrics.get(key)))
-
- def Run(self):
- self._ParseArgs()
- try:
- for filename in self._args.filenames:
- self._Parse(filename)
- except (IOError, ValueError) as e:
- print >> sys.stderr, e
- raise KeyboardInterrupt
-
-if __name__ == '__main__':
- MetricsParser().Run()
-
diff --git a/tools/cts-tradefed/Android.bp b/tools/cts-tradefed/Android.bp
deleted file mode 100644
index 987b665..0000000
--- a/tools/cts-tradefed/Android.bp
+++ /dev/null
@@ -1,36 +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.
-
-java_library_host {
- name: "cts-tradefed-harness",
-
- java_resource_dirs: ["res"],
- libs: [
- "tradefed",
- "compatibility-host-util",
- ],
- static_libs: [
- "compatibility-tradefed",
- ],
-}
-
-tradefed_binary_host {
- name: "cts-tradefed",
- wrapper: "etc/cts-tradefed",
- short_name: "CTS",
- full_name: "Compatibility Test Suite",
- version: "11_r1",
- static_libs: ["cts-tradefed-harness"],
- required: ["compatibility-host-util"],
-}
diff --git a/tools/cts-tradefed/DynamicConfig.xml b/tools/cts-tradefed/DynamicConfig.xml
deleted file mode 100644
index 60b0e98..0000000
--- a/tools/cts-tradefed/DynamicConfig.xml
+++ /dev/null
@@ -1,21 +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.
--->
-
-<!--TODO(b/117957288): Remove dynamic config from suite-level.-->
-<dynamicConfig>
- <entry key="media_files_url">
- <value>https://dl.google.com/dl/android/cts/android-cts-media-1.4.zip</value>
- </entry>
-</dynamicConfig>
diff --git a/tools/cts-tradefed/README b/tools/cts-tradefed/README
deleted file mode 100644
index 99d155a..0000000
--- a/tools/cts-tradefed/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' to run the default CTS plan
-
-Some other useful commands are
-
-To run a test module:
-'run cts --module <module_name>'
-
-To run a specific test:
-'run cts --module <module_name> --test <test_name>'
-
-To shard a plan test run on multiple devices
-'run cts --shard-count <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/cts-tradefed/etc/cts-tradefed b/tools/cts-tradefed/etc/cts-tradefed
deleted file mode 100755
index 23227a9..0000000
--- a/tools/cts-tradefed/etc/cts-tradefed
+++ /dev/null
@@ -1,134 +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.
-
-# launcher script for 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;
-}
-
-# readlink does not work on MacOS so rely on our own realpath
-realpath() {
- [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
-}
-
-checkPath aapt
-checkPath adb
-checkPath java
-
-# check java version
-JAVA_VERSION=$(java -version 2>&1 | grep -m 1 'version [ "]\(1\.8\|9\|11\).*[ "]')
-if [ "${JAVA_VERSION}" == "" ]; then
- echo "Wrong java version. 1.8, 9, or 11 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
- CTS_ROOT=${ANDROID_HOST_OUT}/cts
- else
- CTS_ROOT=${ANDROID_BUILD_TOP}/${OUT_DIR:-out}/host/${OS}/cts
- fi
- if [ ! -d ${CTS_ROOT} ]; then
- echo "Could not find $CTS_ROOT in Android build environment. Try 'make cts'"
- exit
- fi;
-fi;
-
-if [ -z ${CTS_ROOT} ]; then
- # assume we're in an extracted cts install
- CTS_ROOT="$(dirname $(realpath $0))/../.."
-fi;
-
-JAR_DIR=${CTS_ROOT}/android-cts/tools
-JARS="tradefed
- tradefed-test-framework
- loganalysis
- compatibility-host-util
- compatibility-host-util-tests
- cts-tradefed
- cts-tradefed-tests
- compatibility-common-util-tests
- compatibility-tradefed-tests"
-
-for JAR in $JARS; do
- checkFile ${JAR_DIR}/${JAR}.jar
- JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar
-done
-JAR_PATH=${JAR_PATH:1} # Strip off leading ':'
-
-OPTIONAL_JARS="
- google-tradefed
- google-tradefed-tests
- google-tf-prod-tests"
-
-STANDALONE_JAR_DIR=${ANDROID_HOST_OUT}/framework
-for JAR in $OPTIONAL_JARS; do
- if [ -f "${JAR_DIR}/${JAR}.jar" ]; then
- JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar
- elif [ -f "${STANDALONE_JAR_DIR}/${JAR}.jar" ]; then
- JAR_PATH=${JAR_PATH}:${STANDALONE_JAR_DIR}/${JAR}.jar
- fi;
-done
-
-# load any shared libraries for host-side executables
-LIB_DIR=${CTS_ROOT}/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
-
-# include any host-side test jars
-for j in ${CTS_ROOT}/android-cts/testcases/*.jar; do
- JAR_PATH=${JAR_PATH}:$j
-done
-
-java $RDBG_FLAG -Xmx6g -XX:+HeapDumpOnOutOfMemoryError -cp ${JAR_PATH} -DCTS_ROOT=${CTS_ROOT} com.android.compatibility.common.tradefed.command.CompatibilityConsole "$@"
-
diff --git a/tools/cts-tradefed/res/config/basic-reporters.xml b/tools/cts-tradefed/res/config/basic-reporters.xml
deleted file mode 100644
index 6fddf24..0000000
--- a/tools/cts-tradefed/res/config/basic-reporters.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Configuration with basic CTS reporters" >
-</configuration>
diff --git a/tools/cts-tradefed/res/config/collect-tests-only.xml b/tools/cts-tradefed/res/config/collect-tests-only.xml
deleted file mode 100644
index a3769a9..0000000
--- a/tools/cts-tradefed/res/config/collect-tests-only.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Runs CTS from a pre-existing CTS installation">
-
- <include name="cts" />
-
- <!-- This tells cts-tradefed and the server what the plan name is, reports that have this plan
- name should not be accepted, as it doesn't actually run the tests it simply marks all of
- them as passed.
- Obviously no one would modify the report before uploading to falsify this
- information, as that would be dishonest, and dishonesty kills kittens :'( -->
- <option name="plan" value="collect-tests-only" />
-
- <option name="skip-preconditions" value="true" />
- <option name="skip-system-status-check" value="com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker" />
- <option name="preparer-whitelist" value="com.android.tradefed.targetprep.suite.SuiteApkInstaller" />
- <option name="preparer-whitelist" value="com.android.compatibility.common.tradefed.targetprep.ApkInstaller" />
- <option name="preparer-whitelist" value="com.android.compatibility.common.tradefed.targetprep.FilePusher" />
-
- <option name="compatibility:collect-tests-only" value="true" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/csi-known-failures.xml b/tools/cts-tradefed/res/config/csi-known-failures.xml
deleted file mode 100644
index 3d896b2..0000000
--- a/tools/cts-tradefed/res/config/csi-known-failures.xml
+++ /dev/null
@@ -1,95 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 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="Known fialures on CSI">
- <!-- Exclude the known failure of CtsAppCases affect other tests in NotificationManagerTest -->
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.NotificationManagerTest#testNotificationManagerBubble_checkActivityFlagsDocumentLaunchMode" />
-
- <!-- Exclude known failure of CtsMediaTestCases -->
- <!-- CSI doesn't seem to include ringtones. -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.RingtoneManagerTest" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.RingtoneTest" />
-
- <!-- Following failures take about 10 min each, so exclude them to reduce test time. -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.StreamingMediaPlayerTest#testHTTP_H263_AMR_Video2" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.StreamingMediaPlayerTest#testHTTP_H264Base_AAC_Video2" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.StreamingMediaPlayerTest#testHTTP_MPEG4SP_AAC_Video2" />
-
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoCodecTest#testParallelEncodingAndDecodingAVC" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoCodecTest#testParallelEncodingAndDecodingHEVC" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoCodecTest#testParallelEncodingAndDecodingVP8" />
-
- <!-- Failures will crash the test harness, so exclude it here (even though only failed with VP9 decoder). -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderRotationTest" />
-
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther0Perf0320x0240" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther0Perf0720x0480" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther0Perf1280x0720" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther1Perf0320x0240" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther1Perf0720x0480" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther1Perf1280x0720" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther1Perf1920x1080" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther0Perf0352x0288" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther0Perf0640x0360" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther0Perf0720x0480" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther0Perf1280x0720" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther0Perf1920x1080" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther1Perf0352x0288" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther1Perf0640x0360" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther1Perf0720x0480" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther1Perf1280x0720" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther1Perf1920x1080" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther1Perf3840x2160" />
-
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH263SurfMinMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfArbitraryH" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfArbitraryW" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfNearMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfNearMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfNearMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfQCIF" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfArbitraryH" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfArbitraryW" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfNearMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfNearMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfNearMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfNearMinMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8Surf480p" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfArbitraryH" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfArbitraryW" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfNearMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfNearMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfNearMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfQCIF" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9Surf480p" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfArbitraryH" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfArbitraryW" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfNearMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfNearMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfNearMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfQCIF" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-automated.xml b/tools/cts-tradefed/res/config/cts-automated.xml
deleted file mode 100644
index 150f8b9..0000000
--- a/tools/cts-tradefed/res/config/cts-automated.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Runs CTS with common options set for an automated run on userdebug/eng builds">
-
- <include name="cts" />
-
- <option name="plan" value="cts" />
-
- <option name="skip-preconditions" value="false" />
- <option name="skip-system-status-check" value="com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker" />
-
- <!-- Tell all AndroidJUnitTests to exclude certain annotations -->
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:exclude-annotation:android.platform.test.annotations.RestrictedBuildTest" />
-
- <!-- Tell all HostTests to exclude certain annotations -->
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.HostTest:exclude-annotation:android.platform.test.annotations.RestrictedBuildTest" />
- <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:exclude-annotation:android.platform.test.annotations.RestrictedBuildTest" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-camera.xml b/tools/cts-tradefed/res/config/cts-camera.xml
deleted file mode 100644
index 47377b4..0000000
--- a/tools/cts-tradefed/res/config/cts-camera.xml
+++ /dev/null
@@ -1,33 +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="Runs CTS-camera from a pre-existing CTS installation">
-
- <include name="cts" />
-
- <option name="plan" value="cts-camera" />
-
- <!-- All camera CTS tests -->
- <option name="compatibility:include-filter" value="CtsCameraTestCases" />
-
- <!-- Other camera related CTS tests -->
- <option name="compatibility:include-filter"
- value="CtsAppTestCases android.app.cts.SystemFeaturesTest#testCameraFeatures"/>
- <option name="compatibility:include-filter"
- value="CtsPermissionTestCases android.permission.cts.CameraPermissionTest"/>
- <option name="compatibility:include-filter"
- value="CtsPermissionTestCases android.permission.cts.Camera2PermissionTest"/>
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-common.xml b/tools/cts-tradefed/res/config/cts-common.xml
deleted file mode 100644
index c1dffd2..0000000
--- a/tools/cts-tradefed/res/config/cts-common.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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 configuration for cts and cts-reference-aosp">
-
- <include name="everything" />
- <option name="compatibility:run-suite-tag" value="cts" />
- <!-- Enable module parameterization to run instant_app modules in main CTS -->
- <option name="compatibility:enable-parameterized-modules" value="true" />
- <include name="cts-preconditions" />
- <include name="cts-system-checkers" />
- <include name="cts-known-failures" />
-
- <option name="test-tag" value="cts" />
-
- <option name="enable-root" value="false" />
- <!-- retain 200MB of host log -->
- <option name="max-log-size" value="200" />
- <!-- retain 200MB of logcat -->
- <option name="max-tmp-logcat-file" value="209715200" />
-
- <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
- <option name="run-command" value="settings put global package_verifier_enable 0" />
- <option name="teardown-command" value="settings put global package_verifier_enable 1"/>
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.PropertyCheck">
- <option name="property-name" value="ro.build.type" />
- <option name="expected-value" value="user"/> <!-- Device should have user build -->
- <option name="throw-error" value="false"/> <!-- Only print warning if not user build -->
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.PropertyCheck">
- <option name="property-name" value="ro.product.locale" />
- <option name="expected-value" value="en-US"/> <!-- Device locale should be US English -->
- <option name="throw-error" value="false"/> <!-- Only print warning if not en-US -->
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.PropertyCheck">
- <option name="property-name" value="persist.sys.test_harness" />
- <option name="expected-value" value="false"/> <!-- Device shouldn't be in test harness mode -->
- <option name="throw-error" value="true"/>
- </target_preparer>
-
- <template-include name="reporters" default="basic-reporters" />
-
- <!-- Include additional test metadata output. -->
- <template-include name="metadata-reporters" default="empty" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-dev.xml b/tools/cts-tradefed/res/config/cts-dev.xml
deleted file mode 100644
index 11c1052..0000000
--- a/tools/cts-tradefed/res/config/cts-dev.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Runs CTS with common options set developer workflow: skips most checks">
-
- <include name="cts" />
-
- <option name="log-level" value="verbose" />
- <option name="skip-preconditions" value="true" />
- <option name="skip-device-info" value="true" />
- <option name="result-reporter:compress-logs" value="false" />
-
- <option name="plan" value="cts-dev" />
- <option name="compatibility:skip-all-system-status-check" value="true" />
- <option name="compatibility:primary-abi-only" value="true" />
- <!-- Avoid module parameterization in cts-dev -->
- <option name="compatibility:enable-parameterized-modules" value="false" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-device-files.xml b/tools/cts-tradefed/res/config/cts-device-files.xml
deleted file mode 100644
index 6acf7bb..0000000
--- a/tools/cts-tradefed/res/config/cts-device-files.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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="CTS device files collection">
- <option name="plan" value="cts-device-files" />
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DeviceFileCollector">
- <option name="src-file" value="/sys/fs/selinux/policy" />
- <option name="dest-file" value="vintf-files/sepolicy"/>
- <option name="property" key="ro.treble.enabled" value="true"/>
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DeviceFileCollector">
- <option name="src-file" value="/proc/config.gz" />
- <option name="dest-file" value="vintf-files/proc_config.gz"/>
- <option name="property" key="ro.treble.enabled" value="true"/>
- </target_preparer>
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-exclude-instant.xml b/tools/cts-tradefed/res/config/cts-exclude-instant.xml
deleted file mode 100644
index 402d227..0000000
--- a/tools/cts-tradefed/res/config/cts-exclude-instant.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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="Excluded tests applicable only to instant mode">
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:exclude-annotation:android.platform.test.annotations.AppModeInstant" />
- <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:exclude-annotation:android.platform.test.annotations.AppModeInstant" />
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.HostTest:exclude-annotation:android.platform.test.annotations.AppModeInstant" />
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-exclude.xml b/tools/cts-tradefed/res/config/cts-exclude.xml
deleted file mode 100644
index f6899a4..0000000
--- a/tools/cts-tradefed/res/config/cts-exclude.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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="Excluded tests from main CTS runs">
- <!-- b/64127136 -->
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForBinderInVendorBan" />
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForSocketsBetweenCoreAndVendorBan" />
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForVendorExecutingCore" />
-
- <!-- Test Harness Mode tests are not a part of CTS. They are a part
- of their own testing plan, as they reset the device during the
- test. It's possible and ideal in the future to incorporate the
- tests into CTS, but until then, they should be excluded. -->
- <option name="compatibility:exclude-filter" value="CtsTestHarnessModeTestCases" />
-
- <!-- Exclude downstreaming tests from CTS, i.e. tests added after the
- first major release for this API level (They are pulled into GTS
- instead). -->
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:exclude-annotation:com.android.compatibility.common.util.CtsDownstreamingTest" />
- <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:exclude-annotation:com.android.compatibility.common.util.CtsDownstreamingTest" />
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-filtered-sample.xml b/tools/cts-tradefed/res/config/cts-filtered-sample.xml
deleted file mode 100644
index e4f454b..0000000
--- a/tools/cts-tradefed/res/config/cts-filtered-sample.xml
+++ /dev/null
@@ -1,39 +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="Runs CTS from a pre-existing CTS installation">
-
- <include name="common-compatibility-config" />
-
- <option name="plan" value="cts-filtered-sample" />
-
- <!-- Tell all AndroidJUnitTests to only run the medium sized tests -->
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:size:medium" />
-
- <!-- Include 64bit CtsContentTestCases and tell it which timeout to use -->
- <option name="compatibility:include-filter" value="arm64-v8a CtsContentTestCases" />
- <option name="compatibility:module-arg" value="arm64-v8a CtsContentTestCases:test-timeout:600" />
-
- <!-- Include CtsGestureTestCases but only run the tests on arm32 -->
- <option name="compatibility:include-filter" value="armeabi-v7a CtsGestureTestCases" />
-
- <!-- Exclude CtsMediaStressTestCases -->
- <option name="compatibility:exclude-filter" value="CtsMediaStressTestCases" />
-
- <!-- Include CtsUtilTestCases but only run the small tests -->
- <option name="compatibility:include-filter" value="CtsUtilTestCases" />
- <option name="compatibility:module-arg" value="CtsUtilTestCases:size:small" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-foldable.xml b/tools/cts-tradefed/res/config/cts-foldable.xml
deleted file mode 100644
index 1a3e256..0000000
--- a/tools/cts-tradefed/res/config/cts-foldable.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 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="CTS plan for foldable devices">
-
- <include name="cts" />
-
- <option name="plan" value="cts-foldable" />
- <option name="result-attribute" key="display_mode" value="1" />
-
- <!-- CTS tests to be excluded in this plan-->
- <option name="compatibility:exclude-filter" value="CtsDeqpTestCases" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-global-presubmit.xml b/tools/cts-tradefed/res/config/cts-global-presubmit.xml
deleted file mode 100644
index 5a858e7..0000000
--- a/tools/cts-tradefed/res/config/cts-global-presubmit.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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 CTS global presubmit test cases">
-
- <include name="cts-automated" />
-
- <option name="plan" value="cts" />
-
- <!-- Include modules with presubmit test cases, repeat for each applicable module -->
- <!--option name="compatibility:include-filter" value="<CTS module name goes here>" /-->
-
- <!-- Only run tests with @GlobalPresubmit annotation. -->
- <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:include-annotation:android.platform.test.annotations.GlobalPresubmit" />
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:include-annotation:android.platform.test.annotations.GlobalPresubmit" />
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.HostTest:include-annotation:android.platform.test.annotations.GlobalPresubmit" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-java.xml b/tools/cts-tradefed/res/config/cts-java.xml
deleted file mode 100644
index 722d8f7..0000000
--- a/tools/cts-tradefed/res/config/cts-java.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Runs Core Java Tests from a pre-existing CTS installation">
-
- <include name="cts" />
-
- <option name="plan" value="cts-java" />
-
- <!-- Include CtsLibcoreTestCases -->
- <option name="compatibility:include-filter" value="CtsLibcoreTestCases" />
-
- <!-- Exclude CtsLibcoreTestCases harmony -->
- <option name="compatibility:exclude-filter" value="CtsLibcoreTestCases android.core.tests.libcore.package.harmony" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-jvmti.xml b/tools/cts-tradefed/res/config/cts-jvmti.xml
deleted file mode 100644
index ce60582..0000000
--- a/tools/cts-tradefed/res/config/cts-jvmti.xml
+++ /dev/null
@@ -1,114 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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 JVMTI Tests from a pre-existing CTS installation">
-
- <!-- Using cts-dev to avoid system checkers. -->
- <include name="cts-dev" />
-
- <option name="plan" value="cts-jvmti" />
-
- <!-- Include all JVMTI test cases -->
- <option name="compatibility:include-filter" value="CtsJvmtiAttachingHostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRedefineClassesHostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest902HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest903HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest904HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest905HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest906HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest907HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest908HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest910HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest911HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest912HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest913HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest914HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest915HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest917HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest918HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest919HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest920HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest922HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest923HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest924HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest926HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest927HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest928HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest930HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest931HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest932HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest940HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest942HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest944HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest945HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest947HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest951HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest982HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest983HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest984HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest985HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest986HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest988HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest989HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest990HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest991HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest992HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest993HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest994HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest995HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest996HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest997HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1900HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1901HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1902HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1903HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1904HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1906HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1907HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1908HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1909HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1910HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1911HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1912HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1913HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1914HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1915HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1916HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1917HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1920HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1921HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1922HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1923HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1924HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1925HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1926HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1927HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1928HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1930HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1931HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1932HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1933HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1934HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1936HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1937HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1939HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1941HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1942HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1943HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1953HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiTaggingHostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiTrackingHostTestCases" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-known-failures.xml b/tools/cts-tradefed/res/config/cts-known-failures.xml
deleted file mode 100644
index 68c7d05..0000000
--- a/tools/cts-tradefed/res/config/cts-known-failures.xml
+++ /dev/null
@@ -1,219 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Configuration with CTS known failures" >
- <!-- <option name="compatibility:exclude-filter" value="MODULE_NAME" /> Excludes whole module -->
- <!-- <option name="compatibility:exclude-filter" value="MODULE_NAME PACKAGE_NAME" /> Excludes whole package -->
- <!-- <option name="compatibility:exclude-filter" value="MODULE_NAME PACKAGE_NAME.CLASS_NAME" /> Excludes whole class -->
- <!-- <option name="compatibility:exclude-filter" value="MODULE_NAME PACKAGE_NAME.CLASS_NAME#TEST_NAME" /> Excludes individual test -->
-
- <!-- b/38182235 -->
- <option name="compatibility:exclude-filter" value="CtsLocationTestCases android.location.cts.GnssTtffTests#testTtffWithNetwork" />
- <option name="compatibility:exclude-filter" value="CtsLocationTestCases[instant] android.location.cts.GnssTtffTests#testTtffWithNetwork" />
-
- <!-- b/23776893 -->
- <option name="compatibility:exclude-filter" value="CtsDumpsysHostTestCases android.dumpsys.cts.DumpsysHostTest#testBatterystatsOutput" />
- <option name="compatibility:exclude-filter" value="CtsDumpsysHostTestCases android.dumpsys.cts.DumpsysHostTest#testGfxinfoFramestats" />
-
- <!-- b/16720689 -->
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthrowDebuggerLaunchTest#testDebuggerLaunch001" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthrowDebuggerLaunchTest#testDebuggerLaunch002" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthrowDebuggerLaunchTest#testDebuggerLaunch003" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthrowDebuggerLaunchTest#testDebuggerLaunch004" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthrowLaunchDebugger001#testDebugger002" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthrowLaunchDebugger002#testDebugger" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.ClassUnloadTest#testClassUnloadEvent" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.MonitorContendedEnteredTest#testMonitorContendedEnteredForClassMatch" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.MonitorContendedEnterTest#testMonitorContendedEnterForClassMatch" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.MonitorWaitedTest#testMonitorWaitedForClassExclude" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.MonitorWaitedTest#testMonitorWaitedForClassMatchExact" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.MonitorWaitedTest#testMonitorWaitedForClassMatchFirst" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.MonitorWaitedTest#testMonitorWaitedForClassMatchSecond" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.MonitorWaitedTest#testMonitorWaitedForClassOnly" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.MonitorWaitTest#testMonitorWaitForClassExclude" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.MonitorWaitTest#testMonitorWaitForClassMatchExact" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.MonitorWaitTest#testMonitorWaitForClassMatchFirst" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.MonitorWaitTest#testMonitorWaitForClassMatchSecond" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.Events.MonitorWaitTest#testMonitorWaitForClassOnly" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.ReferenceType.ClassFileVersionTest#testClassFileVersion001" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.ReferenceType.NestedTypesTest#testNestedTypes001" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.ThreadReference.StopTest#testStop001" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.VirtualMachine.HoldEventsTest#testHoldEvents001" />
- <option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.VirtualMachine.ReleaseEventsTest#testReleaseEvents001" />
-
- <!-- b/21262226 -->
- <option name="compatibility:exclude-filter" value="CtsJobSchedulerTestCases android.jobscheduler.cts.ConnectivityConstraintTest#testConnectivityConstraintExecutes_withMobile" />
- <option name="compatibility:exclude-filter" value="CtsJobSchedulerTestCases android.jobscheduler.cts.ConnectivityConstraintTest#testUnmeteredConstraintFails_withMobile" />
-
- <!-- b/18682315 -->
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.SSLCertificateSocketFactoryTest#test_createSocket_bind" />
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.SSLCertificateSocketFactoryTest#test_createSocket_simple" />
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.SSLCertificateSocketFactoryTest#test_createSocket_wrapping" />
-
- <!-- b/17394321 -->
- <option name="compatibility:exclude-filter" value="CtsOpenGlPerfTestCases android.openglperf.cts.GlAppSwitchTest#testGlActivitySwitchingFast" />
- <option name="compatibility:exclude-filter" value="CtsOpenGlPerfTestCases android.openglperf.cts.GlAppSwitchTest#testGlActivitySwitchingSlow" />
-
- <!-- b/113071420-->
- <option name="compatibility:exclude-filter" value="x86 CtsPerfettoTestCases PerfettoTest#TestFtraceProducer" />
-
- <!-- b/18461670 -->
- <option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.AudioPolicyBinderTest#test_getStreamVolumeLeak" />
- <option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.AudioPolicyBinderTest#test_isStreamActive" />
- <option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.AudioPolicyBinderTest#test_isStreamActiveRemotely" />
- <option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.AudioPolicyBinderTest#test_startAudioSource" />
- <option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.AudioPolicyBinderTest#test_startOutput" />
- <option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.AudioPolicyBinderTest#test_stopOutput" />
- <!-- b/27218502 -->
- <option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.MediaCryptoTest#testMediaCryptoClearKey" />
- <option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.MediaCryptoTest#testMediaCryptoWidevine" />
-
- <!-- b/63916274 -->
- <option name="compatibility:exclude-filter" value="CtsTelecomTestCases android.telecom.cts.WiredHeadsetTest" />
-
- <!-- b/62302163 -->
- <option name="compatibility:exclude-filter" value="CtsSecurityBulletinHostTestCases android.security.cts.Poc17_04#testPocCVE_2017_0564" />
-
- <!-- b/72460579 -->
- <option name="compatibility:exclude-filter" value="CtsSecurityBulletinHostTestCases android.security.cts.Poc17_05#testPocCVE_2017_0630" />
-
- <!-- b/27873815 -->
- <option name="compatibility:exclude-filter" value="arm64-v8a CtsRenderscriptLegacyTestCases" />
- <option name="compatibility:exclude-filter" value="x86_64 CtsRenderscriptLegacyTestCases" />
- <option name="compatibility:exclude-filter" value="mips64 CtsRenderscriptLegacyTestCases" />
-
- <!-- b/17536113 -->
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.UsageStatsTest#testNoAccessSilentlyFails" />
-
- <!-- b/26235244 -->
- <option name="compatibility:exclude-filter" value="android.util.cts.EventLogTest#testWriteEventWithOversizeValue" />
-
- <!-- b/63115400 -->
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testAospFileContexts" />
- <!-- b/64221494 -->
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testAospPropertyContexts" />
- <!-- b/64221494 -->
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testAospSeappContexts" />
-
- <!-- b/63378294 b/64382381 -->
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxNeverallowRulesTest#testNeverallowRules440" />
-
- <!-- b/36686383 -->
- <option name="compatibility:exclude-filter" value="CtsIncidentHostTestCases com.android.server.cts.ErrorsTest#testANR" />
-
- <!-- b/33090965 -->
- <option name="compatibility:exclude-filter" value="CtsVideoTestCases android.video.cts.VideoEncoderDecoderTest#testVp9Goog0Perf0320x0180" />
- <option name="compatibility:exclude-filter" value="CtsVideoTestCases android.video.cts.VideoEncoderDecoderTest#testVp9Goog0Perf0640x0360" />
- <option name="compatibility:exclude-filter" value="CtsVideoTestCases android.video.cts.VideoEncoderDecoderTest#testVp9Goog0Perf1280x0720" />
- <option name="compatibility:exclude-filter" value="CtsVideoTestCases android.video.cts.VideoEncoderDecoderTest#testVp9Goog0Perf1920x1080" />
-
- <!-- b/63916274 -->
- <option name="compatibility:exclude-filter" value="CtsTelecomTestCases android.telecom.cts.WiredHeadsetTest" />
-
- <!-- b/38463882 -->
- <option name="compatibility:exclude-filter" value="x86_64 CtsLiblogTestCases liblog#event_log_tags" />
-
- <!-- b/38464828 -->
- <option name="compatibility:exclude-filter" value="CtsFileSystemTestCases android.filesystem.cts.AlmostFullTest" />
-
- <!-- b/37271927 -->
- <option name="compatibility:exclude-filter" value="CtsViewTestCases android.view.cts.ViewTest#testUpdateDragShadow" />
-
- <!-- b/62481870 -->
- <option name="compatibility:exclude-filter" value="CtsNativeMediaAAudioTestCases android.nativemedia.aaudio.AAudioOutputStreamCallbackTest#testPlayback" />
-
- <!-- b/134654621 -->
- <option name="compatibility:exclude-filter" value="CtsWindowManagerDeviceTestCases android.server.wm.AppConfigurationTests#testTaskCloseRestoreFreeOrientation" />
- <option name="compatibility:exclude-filter" value="CtsWindowManagerDeviceTestCases android.server.wm.AppConfigurationTests#testAppOrientationRequestConfigClears" />
-
- <!-- b/62976713 -->
- <option name="compatibility:exclude-filter" value="arm64-v8a CtsMediaBitstreamsTestCases" />
- <option name="compatibility:exclude-filter" value="x86_64 CtsMediaBitstreamsTestCases" />
- <option name="compatibility:exclude-filter" value="mips64 CtsMediaBitstreamsTestCases" />
-
- <!-- b/38420898 -->
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyAccelMultiChannel" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyGyroMultiChannel" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyMagMultiChannel" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyAccelMultiMode" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyGyroMultiMode" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyMagMultiMode" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRegisterMultipleChannelsUsingSameMemory" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testCloseWithoutConfigStop" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyAccelGyroSingleChannel" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyAccelMagSingleChannel" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyGyroMagSingleChannel" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyAccelUncalAccelSingleChannel" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyGyroUncalGyroSingleChannel" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyMagUncalMagSingleChannel" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testTimestampAccel" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testTimestampGyro" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testTimestampMag" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testAtomicCounterAccel" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testAtomicCounterGyro" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testAtomicCounterMag" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRegisterMultipleChannels" />
- <option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testReconfigure" />
-
- <!-- b/65843095 -->
- <option name="compatibility:exclude-filter" value="CtsLogdTestCases logd#statistics" />
- <option name="compatibility:exclude-filter" value="CtsLogdTestCases logd#sepolicy_rate_limiter" />
-
- <!-- b/67377433 -->
- <!-- fails only on angler/bullhead userdebug -->
- <option name="compatibility:exclude-filter" value="CtsLiblogTestCases liblog#wrap_mode_blocks" />
-
- <!-- b/132274449 -->
- <option name="compatibility:exclude-filter" value="CtsStatsdHostTestCases android.cts.statsd.validation.BatteryStatsValidationTests#testConnectivityStateChange" />
- <option name="compatibility:exclude-filter" value="CtsStatsdHostTestCases[instant] android.cts.statsd.validation.BatteryStatsValidationTests#testConnectivityStateChange" />
-
- <!-- b/148080781 -->
- <option name="compatibility:exclude-filter" value="CtsStatsdHostTestCases android.cts.statsd.atom.UidAtomTests#testForegroundServiceState" />
- <option name="compatibility:exclude-filter" value="CtsStatsdHostTestCases[instant] android.cts.statsd.atom.UidAtomTests#testForegroundServiceState" />
-
- <!-- b/110354076 -->
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.DeviceOwnerTest#testCreateAndManageUser_DontSkipSetupWizard" />
-
- <!-- b/123280814 -->
- <option name="compatibility:exclude-filter" value="CtsLocation2TestCases android.location2.cts.LocationManagerTest#testGetCoarseLocationUpdates_withListener" />
- <option name="compatibility:exclude-filter" value="CtsLocation2TestCases android.location2.cts.LocationManagerTest#testGetNetworkProviderLocationUpdates_withListener" />
-
- <!-- b/116002979 -->
- <option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.ListeningPortsTest" />
-
- <!-- b/117107760 -->
- <option name="compatibility:exclude-filter" value="CtsHarmfulAppWarningHostTestCases android.harmfulappwarning.cts.HarmfulAppWarningTest#testDismissDialog" />
- <option name="compatibility:exclude-filter" value="CtsHarmfulAppWarningHostTestCases android.harmfulappwarning.cts.HarmfulAppWarningTest#testLaunchAnyway" />
- <option name="compatibility:exclude-filter" value="CtsHarmfulAppWarningHostTestCases android.harmfulappwarning.cts.HarmfulAppWarningTest#testUninstall" />
-
- <!-- b/119312212 -->
- <option name="compatibility:exclude-filter" value="CtsAngleIntegrationHostTestCases android.angle.cts.CtsAngleDebugOptionHostTest#testDebugOptionOn" />
-
- <!-- b/129859594 -->
- <option name="compatibility:exclude-filter" value="CtsAtomicInstallTestCases com.android.tests.atomicinstall.AtomicInstallTest#testFailInconsistentMultiPackageCommit" />
-
- <!-- b/126548816 -->
- <option name="compatibility:exclude-filter" value="CtsRcsTestCases" />
-
- <!-- b/112688380 -->
- <option name="compatibility:exclude-filter" value="CtsActivityManagerDeviceTestCases android.server.am.ActivityManagerAppConfigurationTests#testAppOrientationRequestConfigClears" />
- <option name="compatibility:exclude-filter" value="CtsActivityManagerDeviceTestCases android.server.am.ActivityManagerAppConfigurationTests#testTaskCloseRestoreFreeOrientation" />
- <!-- b/112688380, b/139936670 -->
- <option name="compatibility:exclude-filter" value="CtsWindowManagerDeviceTestCases android.server.wm.AppConfigurationTests#testAppOrientationRequestConfigClears" />
- <option name="compatibility:exclude-filter" value="CtsWindowManagerDeviceTestCases android.server.wm.AppConfigurationTests#testTaskCloseRestoreFreeOrientation" />
-
- <!-- b/135533962 -->
- <option name="compatibility:exclude-filter" value="arm64-v8a CtsWrapWrapDebugMallocDebugTestCases" />
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-meerkat.xml b/tools/cts-tradefed/res/config/cts-meerkat.xml
deleted file mode 100644
index 3c44071..0000000
--- a/tools/cts-tradefed/res/config/cts-meerkat.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 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="Tests monitored by Meerkat Platform team (anti-abuse related).">
-
- <include name="cts" />
-
- <option name="plan" value="cts-meerkat" />
-
- <!-- Disable instant tests -->
- <option name="compatibility:enable-parameterized-modules" value="false" />
-
- <!-- System Alert Window (SAW) -->
- <option name="compatibility:include-filter" value="CtsSystemIntentTestCases"/>
- <option name="compatibility:include-filter" value="CtsMediaTestCases android.media.cts.MediaProjectionTest"/>
-
- <!-- Toasts -->
- <option name="compatibility:include-filter" value="CtsWindowManagerDeviceTestCases android.server.wm.ToastWindowTest"/>
- <option name="compatibility:include-filter" value="CtsWidgetTestCases android.widget.cts.ToastTest"/>
- <option name="compatibility:include-filter" value="CtsWidgetTestCases29 android.widget.cts29.ToastTest"/>
- <option name="compatibility:include-filter" value="CtsToastTestCases android.widget.toast.cts.LegacyToastTest"/>
-
- <!-- Background activity launch -->
- <option name="compatibility:include-filter" value="CtsWindowManagerDeviceTestCases android.server.wm.lifecycle.ActivityStarterTests"/>
- <option name="compatibility:include-filter" value="CtsActivityManagerBackgroundActivityTestCases android.server.wm.BackgroundActivityLaunchTest"/>
-
- <!-- Icon hiding -->
- <option name="compatibility:include-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.LimitAppIconHidingTest"/>
- <option name="compatibility:include-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.DeviceOwnerTest"/>
- <option name="compatibility:include-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.LauncherAppsProfileTest"/>
-
- <!-- App ops -->
- <option name="compatibility:include-filter" value="CtsAppOpsTestCases android.app.appops.cts.AppOpsTest"/>
- <option name="compatibility:include-filter" value="CtsWindowManagerDeviceTestCases android.server.wm.AlertWindowsTests"/>
- <option name="compatibility:include-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityLoggingTest"/>
- <option name="compatibility:include-filter" value="CtsPackageInstallTestCases android.packageinstaller.install.cts.SessionTest"/>
- <option name="compatibility:include-filter" value="CtsPackageInstallTestCases android.packageinstaller.install.cts.ExternalSourcesTestAppOpAllowed"/>
- <option name="compatibility:include-filter" value="CtsPackageUninstallTestCases"/>
-
- <!-- Tests that we've added for b/72485440 and in ag/3789406 -->
- <option name="compatibility:include-filter" value="CtsContentTestCases android.content.cts.ContextTest"/>
- <option name="compatibility:include-filter" value="CtsContentTestCases android.content.cts.ContextMoreTest"/>
- <option name="compatibility:include-filter" value="CtsContentTestCases android.content.cts.ContextWrapperTest"/>
-
- <!-- Tests that we've added for b/73451844 -->
- <option name="compatibility:include-filter" value="CtsContentTestCases android.content.pm.cts.PackageManagerTest"/>
-
- <!-- Network watchlist tests -->
- <option name="compatibility:include-filter" value="CtsNetTestCases android.net.cts.NetworkWatchlistTest"/>
-
- <!-- App data isolation -->
- <option name="compatibility:include-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.AppDataIsolationTests"/>
-
- <!-- Install attribution -->
- <option name="compatibility:include-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.AppSecurityTests"/>
- <option name="compatibility:include-filter" value="CtsPackageInstallTestCases android.packageinstaller.install.cts.InstallSourceInfoTest"/>
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-on-csi-no-apks.xml b/tools/cts-tradefed/res/config/cts-on-csi-no-apks.xml
deleted file mode 100644
index 12ce8c7..0000000
--- a/tools/cts-tradefed/res/config/cts-on-csi-no-apks.xml
+++ /dev/null
@@ -1,141 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 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="Excluded tests for APKs not in CSI">
-
- <!-- No Browser2 -->
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testViewNormalUrl" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testViewSecureUrl" />
- <option name="compatibility:exclude-filter" value="CtsMatchFlagTestCases android.matchflags.cts.MatchFlagTests#startNoBrowserRequireDefault" />
- <option name="compatibility:exclude-filter" value="CtsMatchFlagTestCases android.matchflags.cts.MatchFlagTests#startNoBrowserIntentWithNoMatchingApps" />
-
- <!-- No Calendar -->
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testCalendarAddAppointment" />
-
- <!-- No Camera2 -->
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testCamera" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testImageCaptureIntentsHandledBySystem" />
-
- <!-- No Contacts -->
- <option name="compatibility:exclude-filter" value="CtsContactsProviderTestCases android.provider.cts.contacts.ContactsContractIntentsTest#testPickContactDir" />
- <option name="compatibility:exclude-filter" value="CtsContactsProviderTestCases android.provider.cts.contacts.ContactsContractIntentsTest#testViewContactDir" />
- <option name="compatibility:exclude-filter" value="CtsContactsProviderTestCases android.provider.cts.contacts.ContactsContract_ContactsTest#testContentUri" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testContactsCallLogs" />
-
- <!-- No DeskClock -->
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testAlarmClockDismissAlarm" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testAlarmClockSetAlarm" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testAlarmClockSetTimer" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testAlarmClockShowAlarms" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testAlarmClockShowTimers" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testAlarmClockSnoozeAlarm" />
-
- <!-- No Dialer -->
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testDialPhoneNumber" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testDialVoicemail" />
-
- <!-- No Launcher and Home -->
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityEmbeddedDisplayTest" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityEmbeddedHierarchyTest" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityEndToEndTest" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityFocusAndInputFocusSyncTest" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityGestureDispatchTest" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityGlobalActionsTest" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityMagnificationTest#testA11yNodeInfoVisibility_whenOutOfMagnifiedArea_shouldVisible" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityPaneTest" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityTakeScreenshotTest#testTakeScreenshotWithSecureWindow_GetScreenshotAndVerifyBitmap" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityTextActionTest" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityTextTraversalTest" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityViewTreeReportingTest" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityWindowQueryTest" />
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityWindowReportingTest" />
- <option name="compatibility:exclude-filter" value="CtsAdminPackageInstallerTestCases android.packageinstaller.admin.cts.SessionCommitBroadcastTest#testBroadcastNotReceivedForDifferentLauncher" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActivityManagerProcessStateTest#testBgRestrictedForegroundService" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActivityManagerProcessStateTest#testCantSaveStateLaunchAndBackground" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActivityManagerProcessStateTest#testCantSaveStateLaunchAndSwitch" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActivityManagerTest#testKillingPidsOnImperceptible" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActivityManagerTest#testTimeTrackingAPI_ChainedActivityExit" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActivityManagerTest#testTimeTrackingAPI_SimpleStartExit" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActivityManagerTest#testTimeTrackingAPI_SwitchAwayTriggers" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.BooleanTileServiceTest" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.TileServiceTest" />
- <option name="compatibility:exclude-filter" value="CtsShortcutManagerLauncher1" />
- <option name="compatibility:exclude-filter" value="CtsShortcutManagerLauncher2" />
- <option name="compatibility:exclude-filter" value="CtsShortcutManagerLauncher3" />
- <option name="compatibility:exclude-filter" value="CtsShortcutManagerLauncher4" />
- <option name="compatibility:exclude-filter" value="CtsShortcutManagerPackage1" />
- <option name="compatibility:exclude-filter" value="CtsShortcutManagerPackage2" />
- <option name="compatibility:exclude-filter" value="CtsShortcutManagerPackage3" />
- <option name="compatibility:exclude-filter" value="CtsShortcutManagerPackage4" />
- <option name="compatibility:exclude-filter" value="CtsShortcutManagerTestCases" />
- <option name="compatibility:exclude-filter" value="CtsShortcutManagerThrottlingTest" />
-
- <!-- No Music -->
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testMusicPlayback" />
-
- <!-- No QuickSearchBox -->
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testWebSearchNormalUrl" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testWebSearchPlainText" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testWebSearchSecureUrl" />
-
- <!-- No Settings -->
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilitySettingsTest" />
- <option name="compatibility:exclude-filter" value="CtsAdminTestCases android.admin.cts.DeviceAdminActivationTest" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.SettingsIntentTest" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testAddNetworksIntent" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testInteractAcrossProfilesSettings" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testLocationScanningSettings" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testNotificationPolicyDetailIntent" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testPictureInPictureSettings" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testPowerUsageSummarySettings" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testRequestSetAutofillServiceIntent" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testSettings" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testTapAnPaySettings" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testUsageAccessSettings" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testVoiceInputSettingsIntent" />
- <option name="compatibility:exclude-filter" value="CtsSettingsHostTestCases" />
-
- <!-- No SettingsIntelligence -->
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testSettingsSearchIntent" />
-
- <!-- No StorageManager -->
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testManageStorage" />
-
- <!-- No SystemUI -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.AudioPlaybackCaptureTest" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.MediaProjectionTest" />
- <option name="compatibility:exclude-filter" value="CtsPermission3TestCases android.permission3.cts.PermissionTest22#testCompatRevoked" />
- <option name="compatibility:exclude-filter" value="CtsPermission3TestCases android.permission3.cts.PermissionTest23#testGranted" />
- <option name="compatibility:exclude-filter" value="CtsPermission3TestCases android.permission3.cts.PermissionTest23#testRevokeAffectsWholeGroup" />
- <option name="compatibility:exclude-filter" value="CtsPermission3TestCases android.permission3.cts.PermissionTest23#testGrantPreviouslyRevokedWithPrejudiceShowsPrompt" />
- <option name="compatibility:exclude-filter" value="CtsPermission3TestCases android.permission3.cts.PermissionTest23#testNoResidualPermissionsOnUninstall" />
- <option name="compatibility:exclude-filter" value="CtsPermission3TestCases android.permission3.cts.PermissionUpgradeTest#testRevokePropagatedOnUpgradeOldToNewModel" />
-
- <option name="compatibility:exclude-filter" value="CtsViewTestCases android.view.cts.SurfaceViewSyncTest" />
- <option name="compatibility:exclude-filter" value="CtsViewTestCases android.view.cts.ASurfaceControlTest" />
-
- <!-- No WebView -->
- <option name="compatibility:exclude-filter" value="CtsAssistTestCases android.assist.cts.WebViewTest#testWebView" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.WebViewActivityTest" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.WebViewMultiScreenLoginActivityTest" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.inline.InlineWebViewActivityTest" />
- <option name="compatibility:exclude-filter" value="CtsHostsideWebViewTests" />
- <option name="compatibility:exclude-filter" value="CtsTextTestCases android.text.cts.EmojiTest" />
- <option name="compatibility:exclude-filter" value="CtsUiRenderingTestCases android.uirendering.cts.testclasses.LayerTests#testWebViewWithParentLayer" />
- <option name="compatibility:exclude-filter" value="CtsUiRenderingTestCases android.uirendering.cts.testclasses.LayerTests#testWebViewWithAlphaLayer" />
- <option name="compatibility:exclude-filter" value="CtsUiRenderingTestCases android.uirendering.cts.testclasses.LayerTests#testWebViewWithOffsetLayer" />
- <option name="compatibility:exclude-filter" value="CtsUiRenderingTestCases android.uirendering.cts.testclasses.PathClippingTests#testWebViewClipWithCircle" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-on-csi.xml b/tools/cts-tradefed/res/config/cts-on-csi.xml
deleted file mode 100644
index bb39714..0000000
--- a/tools/cts-tradefed/res/config/cts-on-csi.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 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 subset of CTS-on-GSI tests using a core system image (CSI)">
-
- <include name="cts-on-gsi" />
- <include name="cts-on-csi-no-apks" />
- <include name="csi-known-failures" />
-
- <option name="plan" value="cts-on-csi" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-on-gsi-exclude.xml b/tools/cts-tradefed/res/config/cts-on-gsi-exclude.xml
deleted file mode 100644
index 54c907e..0000000
--- a/tools/cts-tradefed/res/config/cts-on-gsi-exclude.xml
+++ /dev/null
@@ -1,403 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 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="Excluded tests from cts-on-gsi">
- <!-- Tell all AndroidJUnitTests to exclude certain annotations -->
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:exclude-annotation:android.platform.test.annotations.RestrictedBuildTest" />
-
- <!-- Tell all HostTests to exclude certain annotations -->
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.HostTest:exclude-annotation:android.platform.test.annotations.RestrictedBuildTest" />
- <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:exclude-annotation:android.platform.test.annotations.RestrictedBuildTest" />
-
- <!-- Radio system of a general system image is not checked -->
- <option name="compatibility:exclude-filter" value="CtsTelephonyTestCases" />
- <option name="compatibility:exclude-filter" value="CtsTelephony2TestCases" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.SystemFeaturesTest#testLocationFeatures" />
- <option name="compatibility:exclude-filter" value="CtsIncidentHostTestCases com.android.server.cts.PackageIncidentTest#testPackageServiceDump" />
-
- <!-- Exclude telephony related testcases -->
- <option name="compatibility:exclude-filter" value="CtsCarrierApiTestCases android.carrierapi.cts.CarrierApiTest#testSimCardPresent" />
- <option name="compatibility:exclude-filter" value="CtsCarrierApiTestCases android.carrierapi.cts.CarrierApiTest#testGetIccAuthentication" />
- <option name="compatibility:exclude-filter" value="CtsCarrierApiTestCases android.carrierapi.cts.CarrierApiTest#testHasCarrierPrivileges" />
- <option name="compatibility:exclude-filter" value="CtsCarrierApiTestCases android.carrierapi.cts.CarrierApiTest#testSendDialerSpecialCode" />
- <option name="compatibility:exclude-filter" value="CtsJobSchedulerTestCases android.jobscheduler.cts.ConnectivityConstraintTest#testConnectivityConstraintExecutes_metered" />
- <option name="compatibility:exclude-filter" value="CtsNetTestCasesLegacyApi22 android.net.cts.legacy.api22.ConnectivityManagerLegacyTest#testStartUsingNetworkFeature_enableHipri" />
- <option name="compatibility:exclude-filter" value="CtsPermission2TestCases android.permission2.cts.NoReceiveSmsPermissionTest#testAppSpecificSmsToken" />
- <option name="compatibility:exclude-filter" value="CtsPermission2TestCases android.permission2.cts.NoReceiveSmsPermissionTest#testReceiveTextMessage" />
- <option name="compatibility:exclude-filter" value="CtsPermissionTestCases android.permission.cts.NoSystemFunctionPermissionTest#testSendSms" />
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForBinderInVendorBan" />
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForSocketsBetweenCoreAndVendorBan" />
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForVendorExecutingCore" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testAppDetails" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testAppSummary" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testCallback" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testDeviceSummary" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testTagDetails" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testUidDetails" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testUserSummary" />
-
- <!-- Exclude not applicable testcases-->
- <option name="compatibility:exclude-filter" value="CtsSignatureTestCases" />
- <option name="compatibility:exclude-filter" value="CtsOsTestCases android.os.cts.UsbDebuggingTest#testUsbDebugging" />
-
- <!--
- Exclude testcases failing on Pixel devices
- TODO(jaeshin@): b/68300743
- -->
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testVoiceCommand" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testVoiceSearchHandsFree" />
-
- <!-- Excluded tese case - TODO(jiyong): b/67739526 to reenable that -->
- <option name="compatibility:exclude-filter" value="CtsJniTestCases android.jni.cts.JniStaticTest#test_linker_namespaces" />
-
- <!-- b/68190722: Remove testcases that require RRO which is planned for Pi -->
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActionBarTest#testOpenOptionsMenu" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActionBarTest#testOptionsMenuKey" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActivityKeyboardShortcutsTest#testRequestShowKeyboardShortcuts" />
-
- <!-- b/66924299: Remove testcase that logd reads kernel log -->
- <option name="compatibility:exclude-filter" value="CtsLiblogTestCases liblog#android_logger_get_" />
-
- <!-- b/71958344: Exclude until CTS releases it -->
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.OverlayHostTest#testInstallingOverlayHasNoEffect" />
-
- <!-- b/65561379: Exclude android.media.cts.MediaPlayerFlakyNetworkTest -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.MediaPlayerFlakyNetworkTest" />
-
- <!-- b/161837932: Fix MediaPlayerTests that use "too small" resolution -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.MediaPlayerTest#testOnSubtitleDataListener" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.MediaPlayerTest#testChangeSubtitleTrack" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.MediaPlayerTest#testDeselectTrackForSubtitleTracks" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.MediaPlayerTest#testGetTrackInfoForVideoWithSubtitleTracks" />
-
- <!-- b/69329663: DirectBootHostTest#testDirectBootNative flaky -->
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DirectBootHostTest#testDirectBootNative" />
-
- <!-- b/74375238: CtsAppSecurityHostTestCases imcomplete test failure -->
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testCreateDocumentAtInitialLocation" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testCreateExisting" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.android.appsecurity.cts.DocumentsTest#testCreateNew" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testCreateWebLink" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testEject" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testFindDocumentPathInScopedAccess" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testGetContent" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testOpenDocumentAtInitialLocation" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testOpenDocumentTreeAtInitialLocation" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testOpenSimple" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testOpenVirtual" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testTransferDocument" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testTree" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.ScopedDirectoryAccessTest#testDeniesOnceButAllowsAskingAgain" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.ScopedDirectoryAccessTest#testDeniesOnceForAll" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.android.appsecurity.cts.ScopedDirectoryAccessTest#testDeniesOnceForAllClearedWhenPackageRemoved" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.android.appsecurity.cts.ScopedDirectoryAccessTest#testNotAskedAgain" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.ScopedDirectoryAccessTest#testUserAccepts" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.ScopedDirectoryAccessTest#testUserAcceptsNewDirectory" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.android.appsecurity.cts.ScopedDirectoryAccessTest#testUserRejects" />
-
- <!-- b/74583365: CtsAppSecurityHostTestCases flaky -->
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.AdoptableHostTest#testApps " />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.AdoptableHostTest#testEjected" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.AdoptableHostTest#testPackageInstaller" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.AdoptableHostTest#testPrimaryStorage" />
-
- <!-- b/152359655: ResumeOnReboot can't work on GSI -->
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.ResumeOnRebootHostTest" />
-
- <!-- b/77175538: CtsViewTestCases failure flaky -->
- <option name="compatibility:exclude-filter" value="CtsViewTestCases android.view.cts.PixelCopyTest#testWindowProducerCopyToRGBA16F" />
-
- <!-- b/73727333: CtsSystemUiTestCases failure flaky -->
- <option name="compatibility:exclude-filter" value="CtsSystemUiTestCases android.systemui.cts.LightBarTests#testLightNavigationBar" />
- <option name="compatibility:exclude-filter" value="CtsSystemUiTestCases android.systemui.cts.LightBarThemeTest#testNavigationBarDivider" />
-
- <!-- b/73727934: CtsAutoFillServiceTestCases flaky -->
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutoFinishSessionTest#hideParentToFinishSession" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutoFinishSessionTest#removeBothViewsToFinishSession" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutoFinishSessionTest#removeParentInBackground" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutofillValueTest#autofillCompoundButtonWithTextValue" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutofillValueTest#autofillDatePickerWithTextValue" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutofillValueTest#autofillEmptyTextValue" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutofillValueTest#autofillInvalidListValueToRadioGroup" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutofillValueTest#autofillInvalidListValueToSpinner" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutofillValueTest#autofillSpinnerWithTextValue" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutofillValueTest#autofillTextWithListValue" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutofillValueTest#autofillTimePickerWithTextValue" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutofillValueTest#autofillToggleValueWithFalse" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutofillValueTest#autofillToggleValueWithTrue" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.AutofillValueTest#autofillZeroListValueToSpinner" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#checkFillSelectionAfterSelectingTwoDatasets" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#checkFillSelectionIsResetAfterReturningError" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#checkFillSelectionIsResetAfterReturningNull" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.android.autofillservice.cts.LoginActivityTest#checkFillSelectionIsResetAfterTimeout" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutoFillMultipleDatasetsPickFirst" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutoFillMultipleDatasetsPickSecond" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutoFillMultipleDatasetsPickThird" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutoFillOneDatasetAndMoveFocusAround" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutoFillOneDatasetAndSave" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutoFillOneDatasetAndSaveHidingOverlays" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutoFillOneDatasetAndSaveWhenFlagSecure" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutoFillOneDatasetWhenFlagSecure" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutoFillTwoDatasetsUnevenNumberOfFieldsFillsAll" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutoFillWhenViewHasChildAccessibilityNodes" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutofillCallbacks" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutofillManuallyAfterServiceReturnedNoDatasets" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutofillManuallyAgainAfterAutomaticallyAutofilledBefore" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutofillManuallyAndSaveAfterServiceReturnedNoDatasets" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutofillManuallyOneDataset" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutofillManuallyPartialField" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutofillManuallyTwoDatasetsPickFirst" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutofillManuallyTwoDatasetsPickSecond" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutofillMultipleDatasetsCustomPresentationFirstDatasetMissingSecondField" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutofillMultipleDatasetsCustomPresentationSameFields" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutofillMultipleDatasetsCustomPresentationSecondDatasetMissingFirstField" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testAutofillOneDatasetCustomPresentation" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testCancelMultipleTimes" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testCommitMultipleTimes" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testDatasetAuthFiltering" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testDatasetAuthMixedFilteringSelectAuth" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testDatasetAuthMixedSelectAuth" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testDatasetAuthMixedSelectNonAuth" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testDatasetAuthTwoDatasets" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testDatasetAuthTwoFieldsNoValues" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testDatasetAuthTwoFieldsReplaceResponse" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testDatasetAuthTwoFieldsUserCancelsFirstAttempt" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testFillResponseAuthBothFieldsUserCancelsFirstAttempt" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testFillResponseAuthJustOneField" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testFillResponseAuthServiceHasNoData" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testFillResponseAuthServiceHasNoDataButCanSave" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testFillResponseAuthWhenAppCallsCancel" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testFillResponseFiltering" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.LoginActivityTest#testUiNotShownAfterAutofilled" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.OptionalSaveActivityTest#testAutofillAllChangedIgnored" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.OptionalSaveActivityTest#testAutofillAllChangedSecondRequiredSaveAll" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.OptionalSaveActivityTest#testAutofillAllFirstRequiredChangedBackToInitialState" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.PartitionedActivityTest#testAutofill4PartitionsAutomatically" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.PartitionedActivityTest#testAutofill4PartitionsManually" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.PartitionedActivityTest#testAutofill4PartitionsMixManualAndAuto" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.PartitionedActivityTest#testAutofillMultipleAuthDatasetsInSequence" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.PartitionedActivityTest#testAutofillMultipleAuthDatasetsNoOverlap" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.PartitionedActivityTest#testAutofillMultipleAuthDatasetsOverlapPickSecond" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.PartitionedActivityTest#testAutofillMultipleDatasetsMixedAuthNoAuthNoOverlap" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.PartitionedActivityTest#testAutofillMultipleDatasetsNoOverlap" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.PartitionedActivityTest#testAutofillMultipleDatasetsOverlappingPicksSecond" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.PartitionedActivityTest#testAutofillTwoPartitionsInSequence" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.PartitionedActivityTest#testAutofillTwoPartitionsSkipFirst" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.SimpleSaveActivityTest#testAutoFillOneDatasetAndSave_usingUiAutomatorOnly" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.SimpleSaveActivityTest#testDismissSave_byTappingBack" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.SimpleSaveActivityTest#testTapHomeWhileDatasetPickerUiIsShowing" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.SimpleSaveActivityTest#testTapHomeWhileSaveUiIsShowing" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.SimpleSaveActivityTest#testTapLink_tapBack_thenStartOverBySayingNoAndFocus" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.SimpleSaveActivityTest#testTapLink_tapBack_thenStartOverBySayingYesAndFocus" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.VirtualContainerActivityTest#testAutofillManuallyOneDataset" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.VirtualContainerActivityTest#testAutofillManuallyTwoDatasetsPickSecond" />
- <option name="compatibility:exclude-filter" value="CtsAutoFillServiceTestCases android.autofillservice.cts.VirtualContainerActivityTest#testAutofillTwoDatasets" />
-
- <!-- b/80390042: CtsContentTestCases failure flaky -->
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.ContentProviderCursorWindowTest#testQuery" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.res.cts.PrivateAttributeTest#testNoAttributesAfterLastPublicAttribute" />
-
- <!-- b/80388296: CtsDevicePolicyManagerTestCases failure flaky -->
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testDisallowAutofill_allowed" />
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testPackageInstallUserRestrictions" />
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testPermissionAppUpdate" />
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testPermissionGrant" />
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testPermissionMixedPolicies" />
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testPermissionPolicy" />
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testSuspendPackage" />
-
- <!-- b/80407835: CtsServicesHostTestCases failure flaky -->
- <option name="compatibility:exclude-filter" value="CtsServicesHostTestCases android.server.cts.KeyguardTests#testDialogShowWhenLockedActivity" />
- <option name="compatibility:exclude-filter" value="CtsServicesHostTestCases android.server.cts.KeyguardTests#testTranslucentShowWhenLockedActivity" />
-
- <!-- b/80388295: CtsAccessibilityServiceTestCases failure flaky -->
- <option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityGestureDispatchTest#testClickWhenMagnified_matchesActualTouch" />
-
- <!-- b/80284482: Flaky tests -->
- <option name="compatibility:exclude-filter" value="CtsAlarmManagerTestCases android.alarmmanager.cts.AppStandbyTests#testAllowWhileIdleAlarms" />
- <option name="compatibility:exclude-filter" value="CtsAlarmManagerTestCases android.alarmmanager.cts.AppStandbyTests#testBucketUpgradeToNoDelay" />
- <option name="compatibility:exclude-filter" value="CtsAlarmManagerTestCases android.alarmmanager.cts.AppStandbyTests#testBucketUpgradeToSmallerDelay" />
- <option name="compatibility:exclude-filter" value="CtsAlarmManagerTestCases android.alarmmanager.cts.AppStandbyTests#testFrequentDelay" />
- <option name="compatibility:exclude-filter" value="CtsAlarmManagerTestCases android.alarmmanager.cts.AppStandbyTests#testRareDelay" />
- <option name="compatibility:exclude-filter" value="CtsAlarmManagerTestCases android.alarmmanager.cts.AppStandbyTests#testWorkingSetDelay" />
-
- <!-- b/110260628: A confirmed GSI incompatibility (waiver) -->
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.DeviceOwnerTest#testCreateAndManageUser_DontSkipSetupWizard" />
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.DeviceOwnerTest#testSecurityLoggingWithSingleUser" />
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement" />
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.MixedProfileOwnerTest#testKeyManagement" />
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testKeyManagement" />
-
- <!-- b/110405497: Flaky tests (waiver) -->
- <option name="compatibility:exclude-filter" value="CtsKeystoreTestCases android.keystore.cts.KeyAttestationTest#testDeviceIdAttestation" />
-
- <!-- b/141113818: Allows unlock for CTS-on-GSI -->
- <option name="compatibility:exclude-filter" value="CtsKeystoreTestCases android.keystore.cts.KeyAttestationTest#testEcAttestation_DeviceLocked" />
- <option name="compatibility:exclude-filter" value="CtsKeystoreTestCases android.keystore.cts.KeyAttestationTest#testRsaAttestation_DeviceLocked" />
-
- <!-- b/110385515: Flaky due to a particular SIM card requirement (excluded) -->
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.ConnectivityManagerTest#testOpenConnection" />
- <option name="compatibility:exclude-filter" value="CtsWifiTestCases android.net.wifi.rtt.cts.WifiRttTest#testRangingToTestAp" />
-
- <!-- b/110261912: Flaky tests -->
- <option name="compatibility:exclude-filter" value="CtsProviderTestCases android.provider.cts.BlockedNumberContractTest#testProviderInteractionsAsRegularApp_fails" />
-
- <!-- b/80077839: Incompatibility with GSI (waiver) -->
- <option name="compatibility:exclude-filter" value="CtsStatsdHostTestCases android.cts.statsd.atom.HostAtomTests#testBluetoothActivityInfo" />
- <option name="compatibility:exclude-filter" value="CtsStatsdHostTestCases android.cts.statsd.atom.HostAtomTests#testScreenStateChangedAtom" />
- <option name="compatibility:exclude-filter" value="CtsStatsdHostTestCases android.cts.statsd.validation.ValidationTests#testPartialWakelock" />
-
- <!-- b/110417203: Flaky tests -->
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testUidTagStateDetails" />
-
- <!-- b/80077786: MyVerizonServices fail -->
- <option name="compatibility:exclude-filter" value="CtsPermission2TestCases android.permission2.cts.PrivappPermissionsTest#testPrivappPermissionsEnforcement" />
-
- <!-- b/111101428: CtsOsTestCases irrelevant test cases -->
- <option name="compatibility:exclude-filter" value="CtsOsTestCases android.os.cts.BuildTest#testIsSecureUserBuild" />
- <option name="compatibility:exclude-filter" value="CtsOsTestCases android.os.cts.BuildVersionTest#testBuildFingerprint" />
-
- <!-- b/111147583: CtsSecurityTestCases irrelevant test cases -->
- <option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.VerifiedBootTest#testVerifiedBootSupport" />
-
- <!-- b/110405126: CtsPermissionTestCases flaky (due to SIM card setting) -->
- <option name="compatibility:exclude-filter" value="CtsPermissionTestCases android.permission.cts.TelephonyManagerPermissionTest#testGetDeviceId" />
- <option name="compatibility:exclude-filter" value="CtsPermissionTestCases android.permission.cts.TelephonyManagerPermissionTest#testGetImei" />
- <option name="compatibility:exclude-filter" value="CtsPermissionTestCases android.permission.cts.TelephonyManagerPermissionTest#testGetLine1Number" />
- <option name="compatibility:exclude-filter" value="CtsPermissionTestCases android.permission.cts.TelephonyManagerPermissionTest#testGetSimSerialNumber" />
- <option name="compatibility:exclude-filter" value="CtsPermissionTestCases android.permission.cts.TelephonyManagerPermissionTest#testGetSubscriberId" />
- <option name="compatibility:exclude-filter" value="CtsPermissionTestCases android.permission.cts.TelephonyManagerPermissionTest#testSetDataEnabled" />
- <option name="compatibility:exclude-filter" value="CtsPermissionTestCases android.permission.cts.TelephonyManagerPermissionTest#testVoiceMailNumber" />
-
- <!-- b/111967702: CtsSecurityTestCases irrelevant test cases -->
- <option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.BannedFilesTest#testNoSu" />
- <option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.BannedFilesTest#testNoSuInPath" />
-
- <!-- b/116170534: CtsMediaTestCases regression (9.0 R4 waiver) -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.DecoderTest#testH265HDR10StaticMetadata" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VolumeShaperTest#testPlayerCornerCase" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VolumeShaperTest#testPlayerCornerCase2" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VolumeShaperTest#testPlayerCubicMonotonic" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VolumeShaperTest#testPlayerDuck" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VolumeShaperTest#testPlayerJoin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VolumeShaperTest#testPlayerRamp" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VolumeShaperTest#testPlayerRunDuringPauseStop" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VolumeShaperTest#testPlayerStepRamp" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VolumeShaperTest#testPlayerTwoShapers" />
-
- <!-- b/157286547 CtsIncidentHostTestCases ErrorsTest failure -->
- <option name="compatibility:exclude-filter" value="CtsIncidentHostTestCases com.android.server.cts.ErrorsTest#testThrowException" />
- <option name="compatibility:exclude-filter" value="CtsIncidentHostTestCases com.android.server.cts.ErrorsTest#testNativeCrash" />
-
- <!-- b/112450846: CtsAppSecurityHostTestCases multi-user, fixing on Q -->
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.StorageHostTest#testCache" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.StorageHostTest#testVerifyAppStats" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.StorageHostTest#testVerifyStats" />
-
- <!-- b/111167329: CtsCameraTestCases failure -->
- <option name="compatibility:exclude-filter" value="CtsCameraTestCases android.hardware.camera2.cts.SurfaceViewPreviewTest#testSurfaceSet"/>
-
- <!-- b/135588722: CtsUsesLibraryHostTestCases (10_r1 waiver) -->
- <option name="compatibility:exclude-filter" value="CtsUsesLibraryHostTestCases android.classloaders.cts.UsesLibraryHostTest#testMissingLibrary_full"/>
- <option name="compatibility:exclude-filter" value="CtsUsesLibraryHostTestCases android.classloaders.cts.UsesLibraryHostTest#testUsesLibrary_full"/>
- <option name="compatibility:exclude-filter" value="CtsCompilationTestCases android.compilation.cts.AdbRootDependentCompilationTest"/>
-
- <!-- b/145371681: CtsContentSuggestionsTestCases and CtsAppPredictionServiceTestCases (10_r2 waiver) -->
- <option name="compatibility:exclude-filter" value="CtsAppPredictionServiceTestCases" />
- <option name="compatibility:exclude-filter" value="CtsContentSuggestionsTestCases" />
-
- <!-- b/143513519: CtsCameraTestCases (10_r3 waiver) -->
- <option name="compatibility:exclude-filter" value="CtsCameraTestCases android.camera.cts.HeifWriterTest#testHeif"/>
-
- <!-- b/155107044: CtsNetTestCases -->
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testInterfaceCountersUdp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm64Tcp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testInterfaceCountersUdp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacMd5Tcp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha512Tcp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacMd5Tcp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha512Tcp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha1Udp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha1Udp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha1Tcp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha1Tcp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm128Tcp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm128Tcp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm96Tcp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha1Tcp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm96Tcp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testCryptTcp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm128Udp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testCryptUdp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAuthUdp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testCryptUdp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAuthUdp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testCryptTcp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha1Udp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testCryptTcp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAuthUdp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testIkeOverUdpEncapSocket"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm128Udp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm128Udp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha256Tcp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha256Tcp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacMd5Udp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm96Tcp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testInterfaceCountersUdp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha512Udp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha512Udp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha256Tcp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha384Udp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha384Udp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha256Udp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm64Tcp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm64Tcp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha512Udp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm96Udp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha384Tcp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm96Udp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha384Udp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha256Udp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacMd5Udp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAuthTcp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacMd5Udp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAuthTcp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha384Tcp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm128Tcp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testCryptUdp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAuthTcp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacMd5Tcp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm64Udp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha256Udp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm64Udp4"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha384Tcp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm64Udp6"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesGcm96Udp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.IpSecManagerTest#testAesCbcHmacSha512Tcp4UdpEncap"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.TrafficStatsTest#testTrafficStatsForLocalhost"/>
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.TrafficStatsTest#testValidTotalStats"/>
-
- <!-- b/150807956: Temporarily disabled due to bad experiment channel -->
- <option name="compatibility:exclude-filter" value="CtsUiRenderingTestCases android.uirendering.cts.testclasses.LayerTests#testWebViewWithLayerAndComplexClip" />
- <option name="compatibility:exclude-filter" value="CtsUiRenderingTestCases android.uirendering.cts.testclasses.PathClippingTests#testWebViewClipWithCircle" />
-
- <!-- b/159295445, b/159294948: CtsDevicePolicyManagerTestCases -->
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.MixedDeviceOwnerTest#testDelegatedCertInstallerDeviceIdAttestation" />
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testDelegatedCertInstallerDeviceIdAttestation" />
- <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testDeviceIdAttestationForProfileOwner" />
-
- <!-- b/153032202: CtsSystemUiTestCases (10_r3 waiver) -->
- <option name="compatibility:exclude-filter" value="CtsSystemUiTestCases android.systemui.cts.WindowInsetsBehaviorTests#swipeOutsideLimit_systemUiVisible_allEventsCanceled"/>
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-on-gsi-presubmit.xml b/tools/cts-tradefed/res/config/cts-on-gsi-presubmit.xml
deleted file mode 100644
index 3c42a12..0000000
--- a/tools/cts-tradefed/res/config/cts-on-gsi-presubmit.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 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 subset of CTS-on-GSI tests selected for presubmit testing">
- <option name="plan" value="cts-on-gsi-presubmit" />
- <include name="cts-automated" />
- <!-- CTS-on-GSI is not expected to run parameterized modules -->
- <option name="compatibility:enable-parameterized-modules" value="false" />
- <option name="compatibility:primary-abi-only" value="true" />
-
- <include name="cts-on-gsi-exclude" />
-
- <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:include-annotation:android.platform.test.annotations.Presubmit" />
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:include-annotation:android.platform.test.annotations.Presubmit" />
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.HostTest:include-annotation:android.platform.test.annotations.Presubmit" />
-</configuration>
-
diff --git a/tools/cts-tradefed/res/config/cts-on-gsi-sim.xml b/tools/cts-tradefed/res/config/cts-on-gsi-sim.xml
deleted file mode 100644
index 5150942..0000000
--- a/tools/cts-tradefed/res/config/cts-on-gsi-sim.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 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 cts-on-gsi on device with SIM card">
-
- <include name="cts-on-gsi" />
-
- <include name="cts-sim-include" />
-
- <option name="plan" value="cts-on-gsi-sim" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-on-gsi.xml b/tools/cts-tradefed/res/config/cts-on-gsi.xml
deleted file mode 100644
index a87ba2e..0000000
--- a/tools/cts-tradefed/res/config/cts-on-gsi.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 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 subset of CTS tests using a general system image (GSI)">
- <!-- Enforce collecting vendor build information -->
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsDeviceInfoCollector" />
-
- <!-- Common CTS config -->
- <include name="cts" />
-
- <!-- CTS-on-GSI is not expected to run parameterized modules -->
- <option name="compatibility:enable-parameterized-modules" value="false" />
- <option name="compatibility:primary-abi-only" value="true" />
-
- <include name="cts-on-gsi-exclude" />
- <!-- Overwrite the "cts" plan configured in cts.xml -->
- <option name="plan" value="cts-on-gsi" />
-
- <!-- For CTS-on-GSI, override the suite name to VTS for the R release only -->
- <option name="cts-on-gsi-variant" value="true" />
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-preconditions.xml b/tools/cts-tradefed/res/config/cts-preconditions.xml
deleted file mode 100644
index 6a4f47e..0000000
--- a/tools/cts-tradefed/res/config/cts-preconditions.xml
+++ /dev/null
@@ -1,83 +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="CTS precondition configs">
-
- <include name="cts-device-files" />
-
- <option name="plan" value="cts-preconditions" />
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DynamicConfigPusher">
- <option name="target" value="host" />
- <!-- the name under which to find the configuration -->
- <option name="config-filename" value="cts" />
- <option name="extract-from-resource" value="true" />
- <!-- the name of the resource inside the jar -->
- <option name="dynamic-resource-name" value="cts-tradefed" />
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.StayAwakePreparer" />
-
- <!-- Disable "Android Beta Program" -->
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.PackageDisabler" >
- <option name="package" value="com.android.yadayada"/>
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.SettingsPreparer">
- <option name="device-setting" value="verifier_verify_adb_installs"/>
- <option name="setting-type" value="global"/>
- <option name="set-value" value="0"/>
- </target_preparer>
-
- <!-- Disable crash error dialogs to avoid affecting following tests -->
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.SettingsPreparer">
- <option name="device-setting" value="hide_error_dialogs"/>
- <option name="setting-type" value="global"/>
- <option name="set-value" value="1"/>
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkPreconditionCheck">
- <option name="apk" value="CtsPreconditions.apk"/>
- <option name="package" value="com.android.preconditions.cts"/>
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.WifiCheck" />
-
- <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
- <option name="run-command" value="rm -rf /sdcard/device-info-files" />
- <option name="run-command" value="rm -rf /sdcard/report-log-files" />
- <!-- Disable keyguard -->
- <option name="run-command" value="locksettings set-disabled true"/>
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DeviceInfoCollector">
- <option name="apk" value="CtsDeviceInfo.apk"/>
- <option name="package" value="com.android.compatibility.common.deviceinfo"/>
- <option name="src-dir" value="/sdcard/device-info-files/"/>
- <option name="dest-dir" value="device-info-files/"/>
- <option name="temp-dir" value="temp-device-info-files/"/>
- <option name="throw-error" value="false"/>
- </target_preparer>
-
- <!-- The following values are used in cts/common/device-side/util/DeviceReportLog.java,
- cts/harness/common/host-side/util/MetricsReportLog.java and tools/tradefed-host/util/ReportLogUtil.java.
- Any change in these values must also be translated to the stated files.
- -->
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ReportLogCollector">
- <option name="src-dir" value="/sdcard/report-log-files/"/>
- <option name="dest-dir" value="report-log-files/"/>
- <option name="temp-dir" value="temp-report-logs/"/>
- </target_preparer>
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-presubmit.xml b/tools/cts-tradefed/res/config/cts-presubmit.xml
deleted file mode 100644
index 5997779..0000000
--- a/tools/cts-tradefed/res/config/cts-presubmit.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Runs CTS presubmit test cases">
-
- <include name="cts-automated" />
-
- <!-- Only run tests with @Presubmit annotation -->
- <!-- This serve as a base config for CTS tests used for presubmit;
- additional filtering parameters should be applied to further narrow
- down the choice of tests, e.g. module filter
- -->
- <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:include-annotation:android.platform.test.annotations.Presubmit" />
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:include-annotation:android.platform.test.annotations.Presubmit" />
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.HostTest:include-annotation:android.platform.test.annotations.Presubmit" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-sim-include.xml b/tools/cts-tradefed/res/config/cts-sim-include.xml
deleted file mode 100644
index 161f5af..0000000
--- a/tools/cts-tradefed/res/config/cts-sim-include.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 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="Include CTS test that require SIM card">
-
- <!-- CTS tests that need SIM card-->
- <option name="compatibility:include-filter" value="CtsCarrierApiTestCases" />
- <option name="compatibility:include-filter" value="CtsJobSchedulerTestCases" />
- <option name="compatibility:include-filter" value="CtsNetTestCases" />
- <option name="compatibility:include-filter" value="CtsNetTestCasesLegacyApi22" />
- <option name="compatibility:include-filter" value="CtsOmapiTestCases" />
- <option name="compatibility:include-filter" value="CtsPermissionTestCases" />
- <option name="compatibility:include-filter" value="CtsPermission2TestCases" />
- <option name="compatibility:include-filter" value="CtsSecureElementAccessControlTestCases1" />
- <option name="compatibility:include-filter" value="CtsSecureElementAccessControlTestCases2" />
- <option name="compatibility:include-filter" value="CtsSecureElementAccessControlTestCases3" />
- <option name="compatibility:include-filter" value="signed-CtsSecureElementAccessControlTestCases1" />
- <option name="compatibility:include-filter" value="signed-CtsSecureElementAccessControlTestCases2" />
- <option name="compatibility:include-filter" value="signed-CtsSecureElementAccessControlTestCases3" />
- <option name="compatibility:include-filter" value="CtsSimRestrictedApisTestCases" />
- <option name="compatibility:include-filter" value="CtsStatsdHostTestCases" />
- <option name="compatibility:include-filter" value="CtsTelecomTestCases" />
- <option name="compatibility:include-filter" value="CtsTelecomTestCases2" />
- <option name="compatibility:include-filter" value="CtsTelecomTestCases3" />
- <option name="compatibility:include-filter" value="CtsTelephonyTestCases" />
- <option name="compatibility:include-filter" value="CtsTelephony2TestCases" />
- <option name="compatibility:include-filter" value="CtsTelephony3TestCases" />
- <option name="compatibility:include-filter" value="CtsTelephonySdk28TestCases" />
- <option name="compatibility:include-filter" value="CtsUsageStatsTestCases" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-sim.xml b/tools/cts-tradefed/res/config/cts-sim.xml
deleted file mode 100644
index 234c33f..0000000
--- a/tools/cts-tradefed/res/config/cts-sim.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 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 CTS-sim on device with SIM card">
-
- <include name="cts" />
-
- <include name="cts-sim-include" />
-
- <option name="plan" value="cts-sim" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-system-checkers.xml b/tools/cts-tradefed/res/config/cts-system-checkers.xml
deleted file mode 100644
index 7639bf9..0000000
--- a/tools/cts-tradefed/res/config/cts-system-checkers.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="CTS system checker configs">
- <system_checker class="com.android.tradefed.suite.checker.UserChecker" />
- <system_checker class="com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker" />
- <system_checker class="com.android.tradefed.suite.checker.ShellStatusChecker" />
- <system_checker class="com.android.tradefed.suite.checker.EnforcedSeLinuxChecker">
- <!-- We expect selinux enforced for CTS -->
- <option name="expect-enforced" value="true" />
- </system_checker>
- <system_checker class="com.android.tradefed.suite.checker.KeyguardStatusChecker" />
- <system_checker class="com.android.tradefed.suite.checker.LeakedThreadStatusChecker" />
- <system_checker class="com.android.tradefed.suite.checker.TimeStatusChecker" />
- <system_checker class="com.android.tradefed.suite.checker.DeviceSettingChecker" />
- <system_checker class="com.android.tradefed.suite.checker.SystemServerStatusChecker" />
- <system_checker class="com.android.tradefed.suite.checker.SystemServerFileDescriptorChecker" />
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-virtual-device-stable.xml b/tools/cts-tradefed/res/config/cts-virtual-device-stable.xml
deleted file mode 100644
index 085ef90..0000000
--- a/tools/cts-tradefed/res/config/cts-virtual-device-stable.xml
+++ /dev/null
@@ -1,222 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 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 stable set of CTS tests for virtual devices">
-
- <include name="cts-virtual-device" />
-
- <option name="plan" value="cts-virtual-device-stable" />
-
- <!-- CTS tests shown to be stable on virtual devices-->
- <option name="compatibility:include-filter" value="CtsAccelerationTestCases" />
- <option name="compatibility:include-filter" value="CtsAlarmClockTestCases" />
- <option name="compatibility:include-filter" value="CtsAndroidTestBase27ApiSignatureTestCases" />
- <option name="compatibility:include-filter" value="CtsAndroidTestMockCurrentApiSignatureTestCases" />
- <option name="compatibility:include-filter" value="CtsAndroidTestRunnerCurrentApiSignatureTestCases" />
- <option name="compatibility:include-filter" value="CtsAnimationTestCases" />
- <option name="compatibility:include-filter" value="CtsApacheHttpLegacy27ApiSignatureTestCases" />
- <option name="compatibility:include-filter" value="CtsApacheHttpLegacyCurrentApiSignatureTestCases" />
- <option name="compatibility:include-filter" value="CtsApacheHttpLegacyUsesLibraryApiSignatureTestCases" />
- <option name="compatibility:include-filter" value="CtsAppComponentFactoryTestCases" />
- <option name="compatibility:include-filter" value="CtsAppUsageHostTestCases" />
- <option name="compatibility:include-filter" value="CtsAslrMallocTestCases" />
- <option name="compatibility:include-filter" value="CtsAtraceHostTestCases" />
- <option name="compatibility:include-filter" value="CtsBackgroundRestrictionsTestCases" />
- <option name="compatibility:include-filter" value="CtsBionicTestCases" />
- <option name="compatibility:include-filter" value="CtsCalendarcommon2TestCases" />
- <option name="compatibility:include-filter" value="CtsClassLoaderFactoryInMemoryDexClassLoaderTestCases" />
- <option name="compatibility:include-filter" value="CtsClassLoaderFactoryPathClassLoaderTestCases" />
- <option name="compatibility:include-filter" value="CtsCompilationTestCases" />
- <option name="compatibility:include-filter" value="CtsContactsProviderWipe" />
- <option name="compatibility:include-filter" value="CtsCppToolsTestCases" />
- <option name="compatibility:include-filter" value="CtsCurrentApiSignatureTestCases" />
- <option name="compatibility:include-filter" value="CtsDatabaseTestCases" />
- <option name="compatibility:include-filter" value="CtsDebugTestCases" />
- <option name="compatibility:include-filter" value="CtsDeviceIdleHostTestCases" />
- <option name="compatibility:include-filter" value="CtsDexMetadataHostTestCases" />
- <option name="compatibility:include-filter" value="CtsDreamsTestCases" />
- <option name="compatibility:include-filter" value="CtsDynamicLinkerTestCases" />
- <option name="compatibility:include-filter" value="CtsEdiHostTestCases" />
- <option name="compatibility:include-filter" value="CtsExtendedMockingTestCases" />
- <option name="compatibility:include-filter" value="CtsFragmentTestCases" />
- <option name="compatibility:include-filter" value="CtsFragmentTestCasesSdk26" />
- <option name="compatibility:include-filter" value="CtsGestureTestCases" />
- <option name="compatibility:include-filter" value="CtsHiddenApiBlacklistApi27TestCases" />
- <option name="compatibility:include-filter" value="CtsHiddenApiBlacklistApi28TestCases" />
- <option name="compatibility:include-filter" value="CtsHiddenApiBlacklistCurrentApiTestCases" />
- <option name="compatibility:include-filter" value="CtsHiddenApiBlacklistDebugClassTestCases" />
- <option name="compatibility:include-filter" value="CtsHiddenApiKillswitchDebugClassTestCases" />
- <option name="compatibility:include-filter" value="CtsHiddenApiKillswitchWhitelistTestCases" />
- <option name="compatibility:include-filter" value="CtsHiddenApiKillswitchWildcardTestCases" />
- <option name="compatibility:include-filter" value="CtsHostsideNumberBlockingTestCases" />
- <option name="compatibility:include-filter" value="CtsHostsideTvTests" />
- <option name="compatibility:include-filter" value="CtsHostsideWebViewTests" />
- <option name="compatibility:include-filter" value="CtsHostTzDataTests" />
- <option name="compatibility:include-filter" value="CtsIcuTestCases" />
- <option name="compatibility:include-filter" value="CtsInlineMockingTestCases" />
- <option name="compatibility:include-filter" value="CtsInputMethodTestCases" />
- <option name="compatibility:include-filter" value="CtsIntentSignatureTestCases" />
- <option name="compatibility:include-filter" value="CtsJankDeviceTestCases" />
- <option name="compatibility:include-filter" value="CtsJdwpSecurityHostTestCases" />
- <option name="compatibility:include-filter" value="CtsJdwpTestCases" />
- <option name="compatibility:include-filter" value="CtsJniTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiAttachingHostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiAttachingTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRedefineClassesHostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1900HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1901HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1902HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1903HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1904HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1906HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1907HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1908HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1909HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1910HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1911HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1912HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1913HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1914HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1915HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1916HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1917HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1920HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1921HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1922HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1923HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1924HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1925HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1926HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1927HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1928HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1930HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1931HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1932HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1933HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1934HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1936HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1937HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1939HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1941HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1942HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1943HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1953HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest1958HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest902HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest903HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest904HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest905HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest906HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest907HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest908HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest910HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest911HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest912HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest913HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest914HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest915HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest917HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest918HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest919HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest920HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest922HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest923HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest924HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest926HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest927HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest928HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest930HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest931HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest932HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest940HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest942HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest944HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest945HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest947HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest951HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest982HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest983HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest984HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest985HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest986HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest988HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest989HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest990HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest991HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest992HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest993HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest994HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest996HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiRunTest997HostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiTaggingHostTestCases" />
- <option name="compatibility:include-filter" value="CtsJvmtiTrackingHostTestCases" />
- <option name="compatibility:include-filter" value="CtsKernelConfigTestCases" />
- <option name="compatibility:include-filter" value="CtsLeanbackJankTestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreApiEvolutionTestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreCoreApiTestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreCorePlatformApiTestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreJsr166TestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreLegacy22TestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreOjTestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreOkHttpTestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreSimpleMModuleTestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreSimpleModuleTestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreWycheproofBCTestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreWycheproofConscryptTestCases" />
- <option name="compatibility:include-filter" value="CtsLiblogTestCases" />
- <option name="compatibility:include-filter" value="CtsLocationFineTestCases" />
- <option name="compatibility:include-filter" value="CtsLocationCoarseTestCases" />
- <option name="compatibility:include-filter" value="CtsLocationNoneTestCases" />
- <option name="compatibility:include-filter" value="CtsLogdTestCases" />
- <option name="compatibility:include-filter" value="CtsMockingDebuggableTestCases" />
- <option name="compatibility:include-filter" value="CtsMockingTestCases" />
- <option name="compatibility:include-filter" value="CtsMultiUserHostTestCases" />
- <option name="compatibility:include-filter" value="CtsNativeNetTestCases" />
- <option name="compatibility:include-filter" value="CtsNativeNetTestCases" />
- <option name="compatibility:include-filter" value="CtsNdefTestCases" />
- <option name="compatibility:include-filter" value="CtsNdkBinderTestCases" />
- <option name="compatibility:include-filter" value="CtsNetTestCasesLegacyPermission22" />
- <option name="compatibility:include-filter" value="CtsNNAPITestCases" />
- <option name="compatibility:include-filter" value="CtsOmapiTestCases" />
- <option name="compatibility:include-filter" value="CtsPdfTestCases" />
- <option name="compatibility:include-filter" value="CtsPermissionTestCasesSdk28" />
- <option name="compatibility:include-filter" value="CtsPreference2TestCases" />
- <option name="compatibility:include-filter" value="CtsPreferenceTestCases" />
- <option name="compatibility:include-filter" value="CtsProtoTestCases" />
- <option name="compatibility:include-filter" value="CtsRenderscriptLegacyTestCases" />
- <option name="compatibility:include-filter" value="CtsRsBlasTestCases" />
- <option name="compatibility:include-filter" value="CtsRsCppTestCases" />
- <option name="compatibility:include-filter" value="CtsSecureElementAccessControlTestCases1" />
- <option name="compatibility:include-filter" value="CtsSecureElementAccessControlTestCases2" />
- <option name="compatibility:include-filter" value="CtsSecureElementAccessControlTestCases3" />
- <option name="compatibility:include-filter" value="CtsSliceTestCases" />
- <option name="compatibility:include-filter" value="CtsSustainedPerformanceHostTestCases" />
- <option name="compatibility:include-filter" value="CtsSystemApiAnnotationTestCases" />
- <option name="compatibility:include-filter" value="CtsTelecomTestCases2" />
- <option name="compatibility:include-filter" value="CtsTelephony2TestCases" />
- <option name="compatibility:include-filter" value="CtsTelephony3TestCases" />
- <option name="compatibility:include-filter" value="CtsTextTestCases" />
- <option name="compatibility:include-filter" value="CtsToastTestCases" />
- <option name="compatibility:include-filter" value="CtsTransitionTestCases" />
- <option name="compatibility:include-filter" value="CtsTvProviderTestCases" />
- <option name="compatibility:include-filter" value="CtsUiDeviceTestCases" />
- <option name="compatibility:include-filter" value="CtsUsbTests" />
- <option name="compatibility:include-filter" value="CtsVoiceInteractionTestCases" />
- <option name="compatibility:include-filter" value="CtsVrTestCases" />
- <option name="compatibility:include-filter" value="CtsWifiBroadcastsHostTestCases" />
- <option name="compatibility:include-filter" value="CtsWrapWrapDebugMallocDebugTestCases" />
- <option name="compatibility:include-filter" value="CtsWrapWrapDebugTestCases" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-virtual-device.xml b/tools/cts-tradefed/res/config/cts-virtual-device.xml
deleted file mode 100644
index 697ee2f..0000000
--- a/tools/cts-tradefed/res/config/cts-virtual-device.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Runs CTS with common options set for an automated run on userdebug/eng builds, and per module rules suitable for virtual devices">
-
- <include name="cts-automated" />
-
- <!-- Tell all AndroidJUnitTests to exclude certain annotations -->
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:exclude-annotation:android.support.test.filters.RequiresDevice" />
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:exclude-annotation:androidx.test.filters.RequiresDevice" />
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:exclude-annotation:android.platform.test.annotations.RequiresDevice" />
-
- <!-- Tell all HostTests to exclude certain annotations -->
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.HostTest:exclude-annotation:android.platform.test.annotations.RequiresDevice" />
- <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:exclude-annotation:android.platform.test.annotations.RequiresDevice" />
-
- <!-- add per module rules for virtual devices below -->
- <option name="compatibility:module-arg" value="CtsDeqpTestCases:include-filter:dEQP-GLES2.functional.prerequisite#*" />
- <option name="compatibility:module-arg" value="CtsDeqpTestCases:include-filter:dEQP-EGL.*" />
- <option name="compatibility:module-arg" value="CtsLibcoreTestCases:core-expectation:/virtualdeviceknownfailures.txt" />
-
- <!-- Virtual devices usually run as root -->
- <option name="compatibility:skip-system-status-check" value="com.android.tradefed.suite.checker.ShellStatusChecker" />
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts.xml b/tools/cts-tradefed/res/config/cts.xml
deleted file mode 100644
index bc5c447..0000000
--- a/tools/cts-tradefed/res/config/cts.xml
+++ /dev/null
@@ -1,24 +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="Runs CTS from a pre-existing CTS installation">
-
- <include name="cts-common" />
- <include name="cts-exclude" />
- <include name="cts-exclude-instant" />
-
- <option name="plan" value="cts" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/retry.xml b/tools/cts-tradefed/res/config/retry.xml
deleted file mode 100644
index 0a01dc3..0000000
--- a/tools/cts-tradefed/res/config/retry.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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 retry of a previous CTS session.">
- <object type="previous_loader" class="com.android.compatibility.common.tradefed.result.suite.PreviousResultLoader" />
- <test class="com.android.tradefed.testtype.suite.retry.RetryRescheduler" />
-
- <logger class="com.android.tradefed.log.FileLogger">
- <option name="log-level-display" value="WARN" />
- </logger>
-</configuration>
diff --git a/tools/cts-tradefed/res/config/security-bulletin.xml b/tools/cts-tradefed/res/config/security-bulletin.xml
deleted file mode 100644
index 02175a9..0000000
--- a/tools/cts-tradefed/res/config/security-bulletin.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Runs Security Patch test cases">
-
- <option name="plan" value="security-bulletin" />
-
- <include name="cts"/>
-
- <option name="compatibility:include-filter" value="CtsSecurityTestCases" />
-
- <option name="compatibility:include-filter" value="CtsSecurityHostTestCases" />
-
- <!-- Only run tests with @SecurityTest annotation. -->
- <option name="compatibility:module-arg" value="CtsSecurityHostTestCases:include-annotation:android.platform.test.annotations.SecurityTest"/>
-
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:include-annotation:android.platform.test.annotations.SecurityTest" />
-
-</configuration>
diff --git a/tools/cts-tradefed/tests/Android.bp b/tools/cts-tradefed/tests/Android.bp
deleted file mode 100644
index 0d0bcea..0000000
--- a/tools/cts-tradefed/tests/Android.bp
+++ /dev/null
@@ -1,26 +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.
-
-java_library_host {
- name: "cts-tradefed-tests",
-
- srcs: ["src/**/*.java"],
-
- libs: [
- "tradefed",
- "cts-tradefed",
- ],
- // We ship the Deqp Runner tests with the CTS one to validate them.
- static_libs: ["CtsDeqpRunnerTests"],
-}
diff --git a/tools/cts-tradefed/tests/run_cts_tests.sh b/tools/cts-tradefed/tests/run_cts_tests.sh
deleted file mode 100755
index 428b9ec..0000000
--- a/tools/cts-tradefed/tests/run_cts_tests.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2018 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.
-
-# A simple helper script that runs the CTS harness unit tests
-
-CTS_DIR=`dirname $0`/../etc
-
-${CTS_DIR}/cts-tradefed run singleCommand host -n \
- --console-result-reporter:suppress-passed-tests \
- --class com.android.compatibility.common.tradefed.UnitTests \
- --class com.android.compatibility.common.util.HostUnitTests \
- --class com.android.compatibility.common.util.UnitTests \
- --class com.android.compatibility.tradefed.CtsTradefedTest \
- --class com.drawelements.deqp.runner.DeqpTestRunnerTest \
- "$@"
diff --git a/tools/cts-tradefed/tests/src/com/android/compatibility/tradefed/CtsTradefedTest.java b/tools/cts-tradefed/tests/src/com/android/compatibility/tradefed/CtsTradefedTest.java
deleted file mode 100644
index 5d5df59..0000000
--- a/tools/cts-tradefed/tests/src/com/android/compatibility/tradefed/CtsTradefedTest.java
+++ /dev/null
@@ -1,73 +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.compatibility.tradefed;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.OptionSetter;
-import com.android.tradefed.util.FileUtil;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-
-/**
- * Tests for cts-tradefed.
- */
-public class CtsTradefedTest extends TestCase {
-
- private static final String PROPERTY_NAME = "CTS_ROOT";
- private static final String SUITE_FULL_NAME = "Compatibility Test Suite";
- private static final String SUITE_NAME = "CTS";
- private static final String SUITE_PLAN = "cts";
- private static final String DYNAMIC_CONFIG_URL = "";
-
- private String mOriginalProperty = null;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mOriginalProperty = System.getProperty(PROPERTY_NAME);
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (mOriginalProperty != null) {
- System.setProperty(PROPERTY_NAME, mOriginalProperty);
- }
- super.tearDown();
- }
-
- public void testSuiteInfoLoad() throws Exception {
- // Test the values in the manifest can be loaded
- File root = FileUtil.createTempDir("root");
- System.setProperty(PROPERTY_NAME, root.getAbsolutePath());
- File base = new File(root, "android-cts");
- base.mkdirs();
- File tests = new File(base, "testcases");
- tests.mkdirs();
- CompatibilityBuildProvider provider = new CompatibilityBuildProvider();
- OptionSetter setter = new OptionSetter(provider);
- setter.setOptionValue("plan", SUITE_PLAN);
- setter.setOptionValue("dynamic-config-url", DYNAMIC_CONFIG_URL);
- IBuildInfo info = provider.getBuild();
- CompatibilityBuildHelper helper = new CompatibilityBuildHelper(info);
- assertEquals("Incorrect suite full name", SUITE_FULL_NAME, helper.getSuiteFullName());
- assertEquals("Incorrect suite name", SUITE_NAME, helper.getSuiteName());
- FileUtil.recursiveDelete(root);
- }
-}