From 0f742fa9b049572ecda44af3459d9472f3016a06 Mon Sep 17 00:00:00 2001 From: mikehoran Date: Tue, 18 Jul 2017 15:42:48 -0700 Subject: Add support for android host test cases. When determining location of tradefed config and build file, search both TARGET and HOST out dirs, but prefer TARGET out dir. Test: ./tests/run_tradefed_tests.sh tradefed.sh run template/local_min --template:map test=CtsAadbHostTestCases tradefed.sh run google/template/local --template:map test=net_test_osi Bug: 36782030 Change-Id: Ic996cc249730901dfdd0e637e01048ca09724560 (cherry picked from commit eb230acbb5395a5feb43ef73b1f09352a9dbf256) --- src/com/android/tradefed/config/ConfigurationFactory.java | 5 ++--- src/com/android/tradefed/util/SystemUtil.java | 14 ++++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src/com/android/tradefed') diff --git a/src/com/android/tradefed/config/ConfigurationFactory.java b/src/com/android/tradefed/config/ConfigurationFactory.java index 628702b15..7128190c6 100644 --- a/src/com/android/tradefed/config/ConfigurationFactory.java +++ b/src/com/android/tradefed/config/ConfigurationFactory.java @@ -220,6 +220,7 @@ public class ConfigurationFactory implements IConfigurationFactory { for (String configFileName : possibleConfigFileNames) { File config = FileUtil.findFile(testCasesDir, configFileName); if (config != null) { + CLog.d("Using config: %s/%s", testCasesDir.getAbsoluteFile(), configFileName); return config; } } @@ -272,9 +273,7 @@ public class ConfigurationFactory implements IConfigurationFactory { } else { if (templateMap != null) { // Clearing the map before returning the cached config to - // avoid seeing them as - // unused. - CLog.d("Using cached configuration, ensuring map is clean."); + // avoid seeing them as unused. templateMap.clear(); } } diff --git a/src/com/android/tradefed/util/SystemUtil.java b/src/com/android/tradefed/util/SystemUtil.java index b1e9284ef..727ad9108 100644 --- a/src/com/android/tradefed/util/SystemUtil.java +++ b/src/com/android/tradefed/util/SystemUtil.java @@ -25,9 +25,8 @@ import com.google.common.annotations.VisibleForTesting; import java.io.File; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; import java.util.List; -import java.util.Set; + /** Utility class for making system calls. */ public class SystemUtil { @@ -63,14 +62,17 @@ public class SystemUtil { /** Get a list of {@link File} pointing to tests directories external to Tradefed. */ public static List getExternalTestCasesDirs() { List testCasesDirs = new ArrayList(); - // TODO(b/36782030): Add ENV_ANDROID_HOST_OUT_TESTCASES back to the list. - Set testCasesDirNames = - new HashSet( - Arrays.asList(singleton.getEnv(ENV_ANDROID_TARGET_OUT_TESTCASES))); + // TODO(b/36782030): Support running both HOST and TARGET tests. + List testCasesDirNames = + // List order matters. ConfigurationFactory caller uses first dir with test config. + Arrays.asList( + singleton.getEnv(ENV_ANDROID_TARGET_OUT_TESTCASES), + singleton.getEnv(ENV_ANDROID_HOST_OUT_TESTCASES)); for (String testCasesDirName : testCasesDirNames) { if (testCasesDirName != null) { File dir = new File(testCasesDirName); if (dir.exists() && dir.isDirectory()) { + CLog.d("Found test case dir: %s", testCasesDirName); testCasesDirs.add(dir); } else { CLog.w( -- cgit v1.2.3