aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-06-20 21:59:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-06-20 21:59:59 +0000
commit31b12a6f98b4489806e5ed4a2bad3179c9ac750e (patch)
tree594e5b55745ead64bc545e37243c6abba70eba74
parentc1afda5d7ba34d5d8e8dd713fba2ae5778afd34c (diff)
parent46cbec99c14a689a0e4465432c32a22375a9cee8 (diff)
downloadtradefederation-31b12a6f98b4489806e5ed4a2bad3179c9ac750e.tar.gz
Merge "Add getBaseArchForAbi util method" into oc-dev
-rw-r--r--src/com/android/tradefed/util/AbiUtils.java18
-rw-r--r--tests/src/com/android/tradefed/util/AbiUtilsTest.java27
2 files changed, 45 insertions, 0 deletions
diff --git a/src/com/android/tradefed/util/AbiUtils.java b/src/com/android/tradefed/util/AbiUtils.java
index 03607f138..693ff5536 100644
--- a/src/com/android/tradefed/util/AbiUtils.java
+++ b/src/com/android/tradefed/util/AbiUtils.java
@@ -78,6 +78,8 @@ public class AbiUtils {
private static final Map<String, String> ABI_TO_ARCH = new HashMap<String, String>();
+ private static final Map<String, String> ABI_TO_BASE_ARCH = new HashMap<String, String>();
+
static {
ABIS_32BIT.add(ABI_ARM_V7A);
ABIS_32BIT.add(ABI_X86);
@@ -113,6 +115,13 @@ public class AbiUtils {
ABI_TO_ARCH.put(ABI_X86_64, ARCH_X86_64);
ABI_TO_ARCH.put(ABI_MIPS, BASE_ARCH_MIPS);
ABI_TO_ARCH.put(ABI_MIPS64, ARCH_MIPS64);
+
+ ABI_TO_BASE_ARCH.put(ABI_ARM_V7A, BASE_ARCH_ARM);
+ ABI_TO_BASE_ARCH.put(ABI_ARM_64_V8A, BASE_ARCH_ARM);
+ ABI_TO_BASE_ARCH.put(ABI_X86, BASE_ARCH_X86);
+ ABI_TO_BASE_ARCH.put(ABI_X86_64, BASE_ARCH_X86);
+ ABI_TO_BASE_ARCH.put(ABI_MIPS, BASE_ARCH_MIPS);
+ ABI_TO_BASE_ARCH.put(ABI_MIPS64, BASE_ARCH_MIPS);
}
/**
@@ -142,8 +151,17 @@ public class AbiUtils {
return ABI_TO_ARCH.get(abi);
}
+ /** Returns the base architecture matching the abi. */
+ public static String getBaseArchForAbi(String abi) {
+ if (abi == null || abi.isEmpty()) {
+ throw new IllegalArgumentException("Abi cannot be null or empty");
+ }
+ return ABI_TO_BASE_ARCH.get(abi);
+ }
+
/**
* Returns the set of ABIs supported by Compatibility.
+ *
* @return a new Set containing the supported ABIs.
*/
public static Set<String> getAbisSupportedByCompatibility() {
diff --git a/tests/src/com/android/tradefed/util/AbiUtilsTest.java b/tests/src/com/android/tradefed/util/AbiUtilsTest.java
index b5e3652d3..b93208e2c 100644
--- a/tests/src/com/android/tradefed/util/AbiUtilsTest.java
+++ b/tests/src/com/android/tradefed/util/AbiUtilsTest.java
@@ -122,6 +122,33 @@ public class AbiUtilsTest {
}
@Test
+ public void getBaseArchForAbi_emptyNull() {
+ try {
+ AbiUtils.getBaseArchForAbi(null);
+ Assert.fail("Should have thrown an exception");
+ } catch (IllegalArgumentException expected) {
+ Assert.assertEquals("Abi cannot be null or empty", expected.getMessage());
+ }
+ try {
+ AbiUtils.getBaseArchForAbi("");
+ Assert.fail("Should have thrown an exception");
+ } catch (IllegalArgumentException expected) {
+ Assert.assertEquals("Abi cannot be null or empty", expected.getMessage());
+ }
+ }
+
+ @Test
+ public void getBaseArchForAbi() {
+ assertEquals(AbiUtils.BASE_ARCH_ARM, AbiUtils.getBaseArchForAbi(AbiUtils.ABI_ARM_V7A));
+ assertEquals(AbiUtils.BASE_ARCH_ARM, AbiUtils.getBaseArchForAbi(AbiUtils.ABI_ARM_64_V8A));
+ assertEquals(AbiUtils.BASE_ARCH_X86, AbiUtils.getBaseArchForAbi(AbiUtils.ABI_X86));
+ assertEquals(AbiUtils.BASE_ARCH_X86, AbiUtils.getBaseArchForAbi(AbiUtils.ABI_X86_64));
+ assertEquals(AbiUtils.BASE_ARCH_MIPS, AbiUtils.getBaseArchForAbi(AbiUtils.ABI_MIPS));
+ assertEquals(AbiUtils.BASE_ARCH_MIPS, AbiUtils.getBaseArchForAbi(AbiUtils.ABI_MIPS64));
+ }
+
+
+ @Test
public void testParseFromProperty() {
Set<String> abiSet = new HashSet<>();
abiSet.add("arm64-v8a");