diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-06-21 07:10:42 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-06-21 07:10:42 +0000 |
commit | 07115b3acb37253a6f404b2c0b85ca608065c4ca (patch) | |
tree | 468ebe84540ee5a229cc19a63e60bc530ceebc95 | |
parent | 8403b0d2dea68ea0e39e01fdb14f290cabefde74 (diff) | |
parent | 1c18c8678de95ab20398e687af58b66f0a1594d5 (diff) | |
download | tradefederation-07115b3acb37253a6f404b2c0b85ca608065c4ca.tar.gz |
release-request-5bf29450-4eb0-4d71-a15a-d8858bf184d3-for-git_oc-release-4120128 snap-temp-L37600000076154351
Change-Id: If5d49da4fc868b3b5929f69f39b3ab6334587c6f
-rw-r--r-- | src/com/android/tradefed/command/CommandScheduler.java | 12 | ||||
-rw-r--r-- | src/com/android/tradefed/util/AbiUtils.java | 18 | ||||
-rw-r--r-- | tests/src/com/android/tradefed/util/AbiUtilsTest.java | 27 |
3 files changed, 53 insertions, 4 deletions
diff --git a/src/com/android/tradefed/command/CommandScheduler.java b/src/com/android/tradefed/command/CommandScheduler.java index 6ac6c8f54..2fa611888 100644 --- a/src/com/android/tradefed/command/CommandScheduler.java +++ b/src/com/android/tradefed/command/CommandScheduler.java @@ -1467,10 +1467,14 @@ public class CommandScheduler extends Thread implements ICommandScheduler, IComm private synchronized void throwIfDeviceInInvocationThread(List<ITestDevice> devices) { for (ITestDevice device : devices) { - if (mInvocationThreadMap.containsKey(device)) { - throw new IllegalStateException( - String.format("Attempting invocation on device %s when one is already " - + "running", device.getSerialNumber())); + for (IInvocationContext context : mInvocationThreadMap.keySet()) { + if (context.getDevices().contains(device)) { + throw new IllegalStateException( + String.format( + "Attempting invocation on device %s when one is already " + + "running", + device.getSerialNumber())); + } } } } 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"); |