Add option to only run primary ABI instead of all

Also add it as default for dev.

Bug: 28269862
Change-Id: I23017a2af907f86e089cd879c85fda4b2aac970a
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
index 4b7f90c..0154909 100644
--- 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
@@ -87,6 +87,7 @@
     private 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 PRIMARY_ABI_RUN = "primary-abi-only";
     public static final String DEVICE_TOKEN_OPTION = "device-token";
     private static final String URL = "dynamic-config-url";
 
@@ -164,6 +165,11 @@
             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"
                     + "prerequisits such as requiring a SIM card. Format is <serial>:<token>",
@@ -410,6 +416,10 @@
     Set<IAbi> getAbis() throws DeviceNotAvailableException {
         Set<IAbi> abis = new HashSet<>();
         Set<String> archAbis = AbiUtils.getAbisForArch(SuiteInfo.TARGET_ARCH);
+        if (mPrimaryAbiRun) {
+            // Get the primary from the device and make it the --abi to run.
+            mAbiName = mDevice.getProperty("ro.product.cpu.abi").trim();
+        }
         for (String abi : AbiFormatter.getSupportedAbis(mDevice, "")) {
             // Only test against ABIs supported by Compatibility, and if the
             // --abi option was given, it must match.
@@ -418,7 +428,7 @@
                 abis.add(new Abi(abi, AbiUtils.getBitness(abi)));
             }
         }
-        if (abis == null || abis.isEmpty()) {
+        if (abis.isEmpty()) {
             if (mAbiName == null) {
                 throw new IllegalArgumentException("Could not get device's ABIs");
             } else {
diff --git a/tools/cts-tradefed/res/config/cts-dev.xml b/tools/cts-tradefed/res/config/cts-dev.xml
index 5bf0c8e..0cf53ca 100644
--- a/tools/cts-tradefed/res/config/cts-dev.xml
+++ b/tools/cts-tradefed/res/config/cts-dev.xml
@@ -23,5 +23,6 @@
 
     <option name="compatibility:plan" value="cts-dev" />
     <option name="compatibility:skip-all-system-status-check" value="true" />
+    <option name="compatibility:primary-abi-only" value="true" />
 
 </configuration>