Allow additional flags to be passed to native device tests.

Adds an option to GTest that allows additional test flags to be passed to the test execution command on the device. Driving use case: Widevine has tests that can execute against different license environments based on a flag passed to the test. This option enables execution of automated tests against multiple license environments by passing a different option flag to the TF test command.

Bug: 23593222

Change-Id: Ie3acedd1556b318a8b9b65001118047d8002a509
diff --git a/src/com/android/tradefed/testtype/GTest.java b/src/com/android/tradefed/testtype/GTest.java
index c259c31..c014000 100644
--- a/src/com/android/tradefed/testtype/GTest.java
+++ b/src/com/android/tradefed/testtype/GTest.java
@@ -45,7 +45,7 @@
     private boolean mRunDisabledTests = false;
 
     @Option(name = "native-test-device-path",
-      description="The path on the device where native tests are located.")
+            description="The path on the device where native tests are located.")
     private String mNativeTestDevicePath = DEFAULT_NATIVETEST_PATH;
 
     @Option(name = "module-name",
@@ -67,8 +67,8 @@
     private List<String> mExcludeFilters = new ArrayList<>();
 
     @Option(name = "native-test-timeout", description =
-        "The max time in ms for a gtest to run. " +
-        "Test run will be aborted if any test takes longer.")
+            "The max time in ms for a gtest to run. " +
+            "Test run will be aborted if any test takes longer.")
     private int mMaxTestTimeMs = 1 * 60 * 1000;
 
     @Option(name = "send-coverage",
@@ -87,6 +87,11 @@
             description = "adb shell command(s) to run after GTest.")
     private List<String> mAfterTestCmd = new ArrayList<>();
 
+    @Option(name = "native-test-flag", description =
+            "Additional flag values to pass to the native test's shell command. " +
+            "Flags should be complete, including any necessary dashes: \"--flag=value\"")
+    private List<String> mGTestFlags = new ArrayList<>();
+
     /** coverage target value. Just report all gtests as 'native' for now */
     private static final String COVERAGE_TARGET = "Native";
 
@@ -228,6 +233,10 @@
         if (mRunDisabledTests) {
             flags = String.format("%s %s", flags, GTEST_FLAG_RUN_DISABLED_TESTS);
         }
+
+        for (String gTestFlag : mGTestFlags) {
+            flags = String.format("%s %s", flags, gTestFlag);
+        }
         return flags;
     }