diff options
author | Insaf Latypov <saferif@google.com> | 2016-11-24 16:23:40 +0000 |
---|---|---|
committer | Insaf Latypov <saferif@google.com> | 2016-11-25 16:38:14 +0000 |
commit | 0fc92f209e3729a19ee847ce0a8773be074ec23b (patch) | |
tree | d4b4bdd0dd93cbc9d360a98b0a7d6f8ed323a425 | |
parent | a7b0225149a36fbaa20d82bd709b6ba54acdbca6 (diff) | |
download | AfwTestHarness-0fc92f209e3729a19ee847ce0a8773be074ec23b.tar.gz |
Fix build of Android O branch
Build configuration is updated according to the changes in Android O
branch.
Change-Id: I63b9541e395f6e91818a93fc9964977f2214c710
14 files changed, 41 insertions, 460 deletions
diff --git a/AfwTestCaseList.mk b/AfwTestCaseList.mk index d9e1a93..4528746 100644 --- a/AfwTestCaseList.mk +++ b/AfwTestCaseList.mk @@ -42,8 +42,8 @@ AFW_TH_SUPPORT_PACKAGE_APKS := $(call afw-th-get-package-paths,$(afw_th_support_ # All the XMLs that will end up under the repository/testcases # and that need to be created before making the final AfW Test Harness distribution. -AFW_TH_TEST_XMLS := $(call afw-th-get-test-xmls,$(afw_th_test_packages)) \ - $(call afw-th-get-test-xmls,$(afw_th_host_libraries)) +AFW_TH_TEST_CONFIGS := $(call afw-th-get-test-configs,$(afw_th_test_packages)) \ + $(call afw-th-get-test-configs,$(afw_th_host_libraries)) # The following files will be placed in the tools directory of the Harness distribution AFW_TH_TOOLS_LIST := diff --git a/AfwTestHarnessBuild.mk b/AfwTestHarnessBuild.mk index c1fdb1e..1dd8c2f 100644 --- a/AfwTestHarnessBuild.mk +++ b/AfwTestHarnessBuild.mk @@ -22,6 +22,7 @@ afw_th_tools_src_dir := $(afw_th_src_dir)/tools afw_th_tests_src_dir := $(afw_th_src_dir)/tests TH_COMPATIBILITY_HOST_UTIL_JAR := $(HOST_OUT_JAVA_LIBRARIES)/compatibility-host-util.jar +TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar AFW_TH_TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/afw-test-tradefed.jar AFW_TH_TF_EXEC_PATH ?= $(HOST_OUT_EXECUTABLES)/afw-test-tradefed AFW_TH_TF_README_PATH := $(afw_th_tools_src_dir)/tradefed-host/README @@ -52,7 +53,7 @@ $(INTERNAL_AFW_TH_TARGET): PRIVATE_NAME := android-cts $(INTERNAL_AFW_TH_TARGET): PRIVATE_AFW_TH_DIR := $(afw_th_dir) $(INTERNAL_AFW_TH_TARGET): PRIVATE_DIR := $(afw_th_dir)/android-cts $(INTERNAL_AFW_TH_TARGET): TMP_DIR := $(afw_th_dir)/temp -$(INTERNAL_AFW_TH_TARGET): $(afw_th_dir)/all_afw_th_files_stamp $(AFW_TH_TEST_XMLS) +$(INTERNAL_AFW_TH_TARGET): $(afw_th_dir)/all_afw_th_files_stamp $(AFW_TH_TEST_CONFIGS) $(hide) echo "Package Android for Work Test Harness: $@" $(hide) $(ACP) -f $(afw_th_src_dir)/afw-test.props $(PRIVATE_DIR)/testcases $(hide) $(ACP) -f $(afw_th_src_dir)/zip_exclude.lst $(afw_th_dir) diff --git a/AfwTestHarnessBuildUtil.mk b/AfwTestHarnessBuildUtil.mk index 204d351..3bb8629 100644 --- a/AfwTestHarnessBuildUtil.mk +++ b/AfwTestHarnessBuildUtil.mk @@ -21,8 +21,8 @@ define afw-th-get-package-paths $(foreach pkg,$(1),$(AFW_TH_TESTCASES_OUT)/$(pkg).apk) endef -define afw-th-get-test-xmls - $(foreach name,$(1),$(AFW_TH_TESTCASES_OUT)/$(name).xml) +define afw-th-get-test-configs + $(foreach name,$(1),$(AFW_TH_TESTCASES_OUT)/$(name).config) endef define afw-th-get-lib-paths diff --git a/build/test_host_java_library.mk b/build/test_host_java_library.mk index 25bd9ba..2964116 100644 --- a/build/test_host_java_library.mk +++ b/build/test_host_java_library.mk @@ -26,31 +26,5 @@ afw_test_library_jar := $(AFW_TH_TESTCASES_OUT)/$(LOCAL_MODULE).jar $(afw_test_library_jar): $(LOCAL_BUILT_MODULE) $(copy-file-to-target) -afw_test_src_dirs := $(LOCAL_PATH)/src -afw_test_src_dirs += $(sort $(dir $(LOCAL_GENERATED_SOURCES))) -afw_test_src_dirs := $(addprefix -s , $(afw_test_src_dirs)) - -afw_test_library_xml := $(AFW_TH_TESTCASES_OUT)/$(LOCAL_MODULE).xml -$(afw_test_library_xml): PRIVATE_SRC_DIRS := $(afw_test_src_dirs) -$(afw_test_library_xml): PRIVATE_AFW_TEST_TEST_PACKAGE_NAME_ := com.android.afwtest.$(notdir $(LOCAL_PATH)) -$(afw_test_library_xml): PRIVATE_TEST_PACKAGE := $(PRIVATE_AFW_TEST_TEST_PACKAGE_NAME_) -$(afw_test_library_xml): PRIVATE_LIBRARY := $(LOCAL_MODULE) -$(afw_test_library_xml): PRIVATE_JAR_PATH := $(LOCAL_MODULE).jar -$(afw_test_library_xml): $(afw_test_library_jar) -$(afw_test_library_xml): $(afw_test_module_test_config) -$(afw_test_library_xml): $(CTS_EXPECTATIONS) $(CTS_UNSUPPORTED_ABIS) $(CTS_JAVA_TEST_SCANNER_DOCLET) $(CTS_JAVA_TEST_SCANNER) $(CTS_XML_GENERATOR) - $(hide) echo Generating test description for host library $(PRIVATE_LIBRARY) - $(hide) mkdir -p $(AFW_TH_TESTCASES_OUT) - $(hide) $(CTS_JAVA_TEST_SCANNER) $(PRIVATE_SRC_DIRS) \ - -d $(CTS_JAVA_TEST_SCANNER_DOCLET) | \ - $(CTS_XML_GENERATOR) -t hostSideOnly \ - -j $(PRIVATE_JAR_PATH) \ - -n $(PRIVATE_LIBRARY) \ - -p $(PRIVATE_TEST_PACKAGE) \ - -e $(CTS_EXPECTATIONS) \ - -b $(CTS_UNSUPPORTED_ABIS) \ - -a $(CTS_TARGET_ARCH) \ - -o $@ - # Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma. -$(my_register_name) : $(afw_test_library_jar) $(afw_test_library_xml) $(afw_test_module_test_config) +$(my_register_name) : $(afw_test_library_jar) $(afw_test_module_test_config) diff --git a/build/test_package.mk b/build/test_package.mk index 76d2ede..816f065 100644 --- a/build/test_package.mk +++ b/build/test_package.mk @@ -26,35 +26,4 @@ LOCAL_PROGUARD_ENABLED := disabled include $(BUILD_AFW_TEST_SUPPORT_PACKAGE) include $(BUILD_AFW_TEST_MODULE_TEST_CONFIG) -afw_test_src_dirs := $(LOCAL_PATH) -afw_test_src_dirs += $(sort $(dir $(LOCAL_GENERATED_SOURCES))) -afw_test_src_dirs := $(addprefix -s , $(afw_test_src_dirs)) - -afw_test_package_xml := $(AFW_TH_TESTCASES_OUT)/$(LOCAL_PACKAGE_NAME).xml -$(afw_test_package_xml): PRIVATE_SRC_DIRS := $(afw_test_src_dirs) -$(afw_test_package_xml): PRIVATE_INSTRUMENTATION := $(LOCAL_INSTRUMENTATION_FOR) -$(afw_test_package_xml): PRIVATE_PACKAGE := $(LOCAL_PACKAGE_NAME) -$(afw_test_package_xml): PRIVATE_AFW_TEST_PACKAGE_NAME_ := com.android.afwtest.$(notdir $(LOCAL_PATH)) -$(afw_test_package_xml): PRIVATE_TEST_PACKAGE := $(PRIVATE_AFW_TEST_PACKAGE_NAME_) -$(afw_test_package_xml): PRIVATE_MANIFEST := $(LOCAL_PATH)/AndroidManifest.xml -$(afw_test_package_xml): PRIVATE_TEST_TYPE := '' -$(afw_test_package_xml): $(afw_test_support_apks) -$(afw_test_package_xml): $(afw_test_module_test_config) -$(afw_test_package_xml): $(CTS_JAVA_TEST_SCANNER_DOCLET) $(CTS_JAVA_TEST_SCANNER) $(CTS_XML_GENERATOR) - $(hide) echo Generating test description for java package $(PRIVATE_PACKAGE) - $(hide) mkdir -p $(AFW_TH_TESTCASES_OUT) - $(hide) $(CTS_JAVA_TEST_SCANNER) \ - $(PRIVATE_SRC_DIRS) \ - -d $(CTS_JAVA_TEST_SCANNER_DOCLET) | \ - $(CTS_XML_GENERATOR) \ - -t $(PRIVATE_TEST_TYPE) \ - -m $(PRIVATE_MANIFEST) \ - -i "$(PRIVATE_INSTRUMENTATION)" \ - -n $(PRIVATE_PACKAGE) \ - -p $(PRIVATE_TEST_PACKAGE) \ - -e $(CTS_EXPECTATIONS) \ - -b $(CTS_UNSUPPORTED_ABIS) \ - -a $(CTS_TARGET_ARCH) \ - -o $@ - -$(my_register_name) : $(afw_test_package_xml) $(afw_test_module_test_config) +$(my_register_name) : $(afw_test_module_test_config) diff --git a/tools/tradefed-host/etc/afw-test-tradefed b/tools/tradefed-host/etc/afw-test-tradefed index cd1e421..b524042 100755 --- a/tools/tradefed-host/etc/afw-test-tradefed +++ b/tools/tradefed-host/etc/afw-test-tradefed @@ -81,7 +81,7 @@ if [ -z ${CTS_ROOT} ]; then fi; JAR_DIR=${CTS_ROOT}/android-cts/tools -JARS="tradefed-prebuilt.jar afw-test-tradefed.jar compatibility-host-util.jar" +JARS="tradefed.jar afw-test-tradefed.jar compatibility-host-util.jar" for JAR in $JARS; do checkFile ${JAR_DIR}/${JAR} diff --git a/tools/tradefed-host/res/config/cts.xml b/tools/tradefed-host/res/config/cts.xml index c1e6f2e..dbe3613 100644 --- a/tools/tradefed-host/res/config/cts.xml +++ b/tools/tradefed-host/res/config/cts.xml @@ -16,9 +16,8 @@ <configuration description="Runs a test plan from Afw Test Harness installation"> - <option name="compatibility:plan" value="cts"/> - - <build_provider class="com.android.cts.tradefed.build.CtsBuildProvider" /> + <build_provider class="com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider" /> + <option name="compatibility-build-provider:plan" value="cts"/> <device_recovery class="com.android.tradefed.device.WaitDeviceRecovery" > <option name="device-wait-time" value="480000"/> <option name="bootloader-wait-time" value="60000"/> @@ -44,6 +43,7 @@ <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/"/> </target_preparer> </configuration> diff --git a/tools/tradefed-host/src/com/android/afwtest/tradefed/targetprep/AfwTestEnvDumper.java b/tools/tradefed-host/src/com/android/afwtest/tradefed/targetprep/AfwTestEnvDumper.java index 6d6717e..0c3a2e6 100644 --- a/tools/tradefed-host/src/com/android/afwtest/tradefed/targetprep/AfwTestEnvDumper.java +++ b/tools/tradefed-host/src/com/android/afwtest/tradefed/targetprep/AfwTestEnvDumper.java @@ -31,6 +31,7 @@ import com.android.tradefed.targetprep.TargetSetupError; import com.android.tradefed.util.StreamUtil; import java.io.File; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -108,7 +109,7 @@ public class AfwTestEnvDumper extends AfwTestTargetPreparer implements ITargetCl * @param buildInfo reference to {@link IBuildInfo} * @return {@link File} object of a unique file */ - private File getDumpFile(IBuildInfo buildInfo) { + private File getDumpFile(IBuildInfo buildInfo) throws FileNotFoundException { return new File(getCtsBuildHelper(buildInfo).getLogsDir(), String.format("%s_%s_%s.txt", mFileNamePrefix, diff --git a/tools/tradefed-host/src/com/android/afwtest/tradefed/targetprep/AfwTestTargetPreparer.java b/tools/tradefed-host/src/com/android/afwtest/tradefed/targetprep/AfwTestTargetPreparer.java index cfca249..6d3fd38 100644 --- a/tools/tradefed-host/src/com/android/afwtest/tradefed/targetprep/AfwTestTargetPreparer.java +++ b/tools/tradefed-host/src/com/android/afwtest/tradefed/targetprep/AfwTestTargetPreparer.java @@ -17,7 +17,7 @@ package com.android.afwtest.tradefed.targetprep; import com.android.afwtest.tradefed.TestConfig; -import com.android.cts.tradefed.build.CtsBuildHelper; +import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper; import com.android.tradefed.build.IBuildInfo; import com.android.tradefed.device.DeviceNotAvailableException; import com.android.tradefed.device.ITestDevice; @@ -29,6 +29,7 @@ import com.android.tradefed.util.CommandStatus; import com.android.tradefed.util.RunUtil; import java.io.File; +import java.io.FileNotFoundException; import java.util.concurrent.TimeUnit; @@ -37,18 +38,18 @@ import java.util.concurrent.TimeUnit; */ public abstract class AfwTestTargetPreparer { - private CtsBuildHelper mBuildHelper; + private CompatibilityBuildHelper mBuildHelper; private Long mTimeoutSecs = TimeUnit.MINUTES.toSeconds(5); /** - * Gets an instance of {@link CtsBuildHelper}. + * Gets an instance of {@link CompatibilityBuildHelper}. * * @param buildInfo reference to {@link IBuildInfo} - * @return reference to {@link CtsBuildHelper} instance + * @return reference to {@link CompatibilityBuildHelper} instance */ - protected CtsBuildHelper getCtsBuildHelper(IBuildInfo buildInfo) { + protected CompatibilityBuildHelper getCtsBuildHelper(IBuildInfo buildInfo) { if (mBuildHelper == null) { - mBuildHelper = CtsBuildHelper.createBuildHelper(buildInfo); + mBuildHelper = new CompatibilityBuildHelper(buildInfo); } return mBuildHelper; } @@ -59,8 +60,8 @@ public abstract class AfwTestTargetPreparer { * @param buildInfo reference to {@link IBuildInfo} * @return File path to repository folder. */ - protected File getRepositoryDir(IBuildInfo buildInfo) { - return new File(getCtsBuildHelper(buildInfo).getCtsDir(), "repository"); + protected File getRepositoryDir(IBuildInfo buildInfo) throws FileNotFoundException { + return getCtsBuildHelper(buildInfo).getDir(); } /** @@ -70,8 +71,12 @@ public abstract class AfwTestTargetPreparer { * @param fileName apk file name * @return {@link File} of the apk */ - protected File getApk(IBuildInfo buildInfo, String fileName) { - return new File(getCtsBuildHelper(buildInfo).getTestCasesDir(), fileName); + protected File getApk(IBuildInfo buildInfo, String fileName) throws TargetSetupError { + try { + return new File(getCtsBuildHelper(buildInfo).getTestsDir(), fileName); + } catch (FileNotFoundException e) { + throw new TargetSetupError(String.format("Couldn't get apk: %s", fileName), e); + } } /** diff --git a/tools/tradefed-host/src/com/android/afwtest/tradefed/targetprep/AfwTestWifiPreparer.java b/tools/tradefed-host/src/com/android/afwtest/tradefed/targetprep/AfwTestWifiPreparer.java index 1355be8..302eb8a 100644 --- a/tools/tradefed-host/src/com/android/afwtest/tradefed/targetprep/AfwTestWifiPreparer.java +++ b/tools/tradefed-host/src/com/android/afwtest/tradefed/targetprep/AfwTestWifiPreparer.java @@ -28,6 +28,7 @@ import com.android.tradefed.util.RunUtil; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Properties; @@ -89,7 +90,12 @@ public final class AfwTestWifiPreparer extends AfwTestTargetPreparer implements throw new TargetSetupError("wifi-ssid-key not specified"); } - File configFile = new File(getCtsBuildHelper(buildInfo).getTestCasesDir(), mConfigFileName); + File configFile; + try { + configFile = new File(getCtsBuildHelper(buildInfo).getTestsDir(), mConfigFileName); + } catch (FileNotFoundException e) { + throw new TargetSetupError("Couldn't find tests directory"); + } Properties props; try { props = readProperties(configFile); diff --git a/tools/tradefed-host/src/com/android/afwtest/tradefed/testtype/AfwTest.java b/tools/tradefed-host/src/com/android/afwtest/tradefed/testtype/AfwTest.java index 4e5d5df..b9f6d8c 100644 --- a/tools/tradefed-host/src/com/android/afwtest/tradefed/testtype/AfwTest.java +++ b/tools/tradefed-host/src/com/android/afwtest/tradefed/testtype/AfwTest.java @@ -17,10 +17,10 @@ package com.android.afwtest.tradefed.testtype; import com.android.afwtest.tradefed.TestConfig; +import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper; import com.android.compatibility.common.tradefed.testtype.IModuleRepo; import com.android.compatibility.common.tradefed.testtype.CompatibilityTest; import com.android.compatibility.common.tradefed.testtype.ModuleRepo; -import com.android.cts.tradefed.build.CtsBuildHelper; import com.android.tradefed.build.IBuildInfo; import com.android.tradefed.config.Option; import com.android.tradefed.config.OptionClass; @@ -53,10 +53,10 @@ public class AfwTest extends CompatibilityTest { private boolean mScreenshot = false; /** - * A {@link CtsBuildHelper} instance to access afw-test build info, such as the + * A {@link CompatibilityBuildHelper} instance to access afw-test build info, such as the * absolute paths of the test plan file and test case apks. */ - private CtsBuildHelper mAfwTestBuild = null; + private CompatibilityBuildHelper mAfwTestBuild = null; /** * {@inheritDoc} @@ -79,7 +79,7 @@ public class AfwTest extends CompatibilityTest { public void setBuild(IBuildInfo build) { super.setBuild(build); - mAfwTestBuild = CtsBuildHelper.createBuildHelper(build); + mAfwTestBuild = new CompatibilityBuildHelper(build); } /** @@ -125,6 +125,6 @@ public class AfwTest extends CompatibilityTest { * @return {@link File} object keeping loaded content from afw-test.props */ protected File getTestConfigFile() throws IOException { - return new File(mAfwTestBuild.getTestCasesDir(), "afw-test.props"); + return new File(mAfwTestBuild.getTestsDir(), "afw-test.props"); } } diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java deleted file mode 100644 index 54569b1..0000000 --- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.cts.tradefed.build; - -import com.android.tradefed.build.IBuildInfo; -import com.android.tradefed.build.IFolderBuildInfo; - -import java.io.File; -import java.io.FileNotFoundException; - -/** - * Helper class for retrieving files from the CTS install. - * <p/> - * Encapsulates the filesystem layout of the CTS installation. - */ -public class CtsBuildHelper { - - static final String CTS_DIR_NAME = "android-cts"; - private final String mSuiteName = "CTS"; - /** The root location of the extracted CTS package */ - private final File mRootDir; - /** the {@link #CTS_DIR_NAME} directory */ - private final File mCtsDir; - - /** - * Creates a {@link CtsBuildHelper}. - * - * @param rootDir the parent folder that contains the "android-cts" directory and all its - * contents. - */ - public CtsBuildHelper(File rootDir) { - mRootDir = rootDir; - mCtsDir = new File(mRootDir, CTS_DIR_NAME); - } - - /** - * Alternate {@link CtsBuildHelper} constructor that takes the {@link IFolderBuildInfo} - * representation of a CTS build. - * - * @param build the {@link IFolderBuildInfo} - * @throws FileNotFoundException - */ - public CtsBuildHelper(IFolderBuildInfo build) throws FileNotFoundException { - this(build.getRootDir()); - } - - /** - * A helper factory method that creates and validates a {@link CtsBuildHelper} given an - * {@link IBuildInfo}. - * - * @param build the {@link IBuildInfo} - * @return the {@link CtsBuildHelper} - * @throws IllegalArgumentException if provided <var>build</var> is not a valid CTS build - */ - public static CtsBuildHelper createBuildHelper(IBuildInfo build) { - if (!(build instanceof IFolderBuildInfo)) { - throw new IllegalArgumentException(String.format( - "Wrong build type. Expected %s, received %s", IFolderBuildInfo.class.getName(), - build.getClass().getName())); - } - try { - CtsBuildHelper ctsBuild = new CtsBuildHelper((IFolderBuildInfo)build); - ctsBuild.validateStructure(); - return ctsBuild; - } catch (FileNotFoundException e) { - throw new IllegalArgumentException("Invalid CTS build provided.", e); - } - } - - public String getSuiteName() { - return mSuiteName; - } - - /** - * @return a {@link File} representing the parent folder of the CTS installation - */ - public File getRootDir() { - return mRootDir; - } - - /** - * @return a {@link File} representing the "android-cts" folder of the CTS installation - */ - public File getCtsDir() { - return mCtsDir; - } - - /** - * @return a {@link File} representing the test application file with given name - * @throws FileNotFoundException if file does not exist - */ - public File getTestApp(String appFileName) throws FileNotFoundException { - File apkFile = new File(getTestCasesDir(), appFileName); - if (!apkFile.exists()) { - throw new FileNotFoundException(String.format("CTS test app file %s does not exist", - apkFile.getAbsolutePath())); - } - return apkFile; - } - - private File getRepositoryDir() { - return new File(getCtsDir(), "repository"); - } - - /** - * @return a {@link File} representing the results directory. - */ - public File getResultsDir() { - return new File(getCtsDir(), "results"); - } - - /** - * @return a {@link File} representing the directory to store result logs. - */ - public File getLogsDir() { - return new File(getCtsDir(), "logs"); - } - - /** - * @return a {@link File} representing the test cases directory - */ - public File getTestCasesDir() { - return new File(getCtsDir(), "testcases"); - } - - /** - * Check the validity of the CTS build file system structure. - * @throws FileNotFoundException if any major directories are missing - */ - public void validateStructure() throws FileNotFoundException { - if (!getCtsDir().exists()) { - throw new FileNotFoundException(String.format( - "CTS install folder %s does not exist", getCtsDir().getAbsolutePath())); - } - if (!getTestCasesDir().exists()) { - throw new FileNotFoundException(String.format( - "CTS test cases folder %s does not exist", - getTestCasesDir().getAbsolutePath())); - } - } -} diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java deleted file mode 100644 index 94ac368..0000000 --- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.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.cts.tradefed.build; - -import com.android.ddmlib.Log; -import com.android.tradefed.build.FolderBuildInfo; -import com.android.tradefed.build.IBuildInfo; -import com.android.tradefed.build.IBuildProvider; -import com.android.tradefed.build.IFolderBuildInfo; -import com.android.tradefed.config.Option; - -import java.io.File; - -/** - * A simple {@link IBuildProvider} that uses a pre-existing CTS install. - */ -public class CtsBuildProvider implements IBuildProvider { - private static final String TAG = "afwtest"; - - public static final String CTS_BUILD_VERSION = "2.2"; - - public static final String CTS_PACKAGE = "com.android.compatibility.common.tradefed.testtype"; - - @Option(name="cts-install-path", description="the path to the cts installation to use") - private String mCtsRootDirPath = System.getProperty("CTS_ROOT"); - - /** - * {@inheritDoc} - */ - @Override - public IBuildInfo getBuild() { - Log.i(TAG, String.format("Afw Test Harness Version: %s", CTS_BUILD_VERSION)); - - if (mCtsRootDirPath == null) { - throw new IllegalArgumentException("Missing --cts-install-path"); - } - IFolderBuildInfo ctsBuild = new FolderBuildInfo( - Package.getPackage(CTS_PACKAGE).getImplementationVersion(), "cts", "cts"); - ctsBuild.setRootDir(new File(mCtsRootDirPath)); - return ctsBuild; - } - - /** - * {@inheritDoc} - */ - @Override - public void buildNotTested(IBuildInfo info) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void cleanUp(IBuildInfo info) { - // ignore - } -} diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java deleted file mode 100644 index b765976..0000000 --- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.cts.tradefed.testtype; - -import com.android.afwtest.tradefed.TestConfig; -import com.android.compatibility.common.util.AbiUtils; -import com.android.cts.tradefed.build.CtsBuildHelper; -import com.android.ddmlib.Log; -import com.android.tradefed.build.IBuildInfo; -import com.android.tradefed.device.DeviceNotAvailableException; -import com.android.tradefed.device.ITestDevice; -import com.android.tradefed.result.ITestInvocationListener; -import com.android.tradefed.testtype.IAbi; -import com.android.tradefed.testtype.IBuildReceiver; -import com.android.tradefed.testtype.InstrumentationTest; - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.concurrent.TimeUnit; - -/** - * An {@link InstrumentationTest} that will install CTS apks - * before test execution, and uninstall on execution completion. - */ -public class CtsInstrumentationApkTest extends InstrumentationTest implements IBuildReceiver { - - private static final String LOG_TAG = "afwtest.CtsInstrumentationApkTest"; - - // Default execution timeout for afw test packages - private static final long TEST_TIMEOUT_MS = TimeUnit.MINUTES.toMillis(10); - - // 1 min in milliseconds - private static final long ONE_MIN_MS = TimeUnit.MINUTES.toMillis(1); - - /** ADB shell command to disable package verification. */ - private static final String ADB_SHELL_CMD_DISABLE_PKG_VERIFY = - "settings put global package_verifier_enable 0"; - - - /** The file names of the CTS apks to install */ - private Collection<String> mInstallFileNames = new ArrayList<String>(); - private Collection<String> mUninstallPackages = new ArrayList<String>(); - protected CtsBuildHelper mCtsBuild = null; - protected IAbi mAbi = null; - - /** - * @param abi the ABI to run the test on - */ - public void setAbi(IAbi abi) { - mAbi = abi; - } - - /** - * {@inheritDoc} - */ - @Override - public void setBuild(IBuildInfo build) { - mCtsBuild = CtsBuildHelper.createBuildHelper(build); - } - - /** - * Add an apk to install. - * - * @param apkFileName the apk file name - * @param packageName the apk's Android package name - */ - public void addInstallApk(String apkFileName, String packageName) { - mInstallFileNames.add(apkFileName); - mUninstallPackages.add(packageName); - } - - /** - * {@inheritDoc} - */ - @Override - public void run(final ITestInvocationListener listener) - throws DeviceNotAvailableException { - ITestDevice testDevice = getDevice(); - - Log.d(LOG_TAG, "Running customized CtsInstrumentationRunner."); - - if (testDevice == null) { - Log.e(LOG_TAG, "Missing device."); - return; - } - if (mCtsBuild == null) { - Log.e(LOG_TAG, "Missing build"); - return; - } - - // Disable package verification in case it was not done. - Log.i(LOG_TAG, testDevice.executeShellCommand(ADB_SHELL_CMD_DISABLE_PKG_VERIFY)); - - boolean success = true; - for (String apkFileName : mInstallFileNames) { - Log.d(LOG_TAG, String.format("Installing %s on %s", apkFileName, - testDevice.getSerialNumber())); - try { - File apkFile = mCtsBuild.getTestApp(apkFileName); - String errorCode = null; - String[] options = {AbiUtils.createAbiFlag(mAbi.getName())}; - errorCode = testDevice.installPackage(apkFile, true, options); - if (errorCode != null) { - Log.e(LOG_TAG, String.format("Failed to install %s on %s. Reason: %s", - apkFileName, testDevice.getSerialNumber(), errorCode)); - success = false; - } - } catch (FileNotFoundException e) { - Log.e(LOG_TAG, String.format("Could not find file %s", apkFileName)); - success = false; - } - } - if (success) { - long testTimeout = - TimeUnit.MINUTES.toMillis(TestConfig.getInstance().getTestTimeoutMin(0)); - if (testTimeout == 0) { - testTimeout = TEST_TIMEOUT_MS + - TestConfig.getInstance().getTimeoutSize() * ONE_MIN_MS * 5; - } - Log.i(LOG_TAG, String.format("Instrumentation test timeout = %d seconds", - TimeUnit.MILLISECONDS.toSeconds(testTimeout))); - - super.setTestTimeout((int)testTimeout); - // Shell timeout must be larger than test timeout - super.setShellTimeout(testTimeout + ONE_MIN_MS); - super.run(listener); - } - for (String packageName : mUninstallPackages) { - Log.d(LOG_TAG, String.format("Uninstalling %s on %s", packageName, - testDevice.getSerialNumber())); - testDevice.uninstallPackage(packageName); - } - } -} |