Add --cdex-fast and --cdex-none variant to testrunner

Added --cdex-fast and --cdex-none variant options. These are passed
to ART through the compact-dex-level option.

Bug: 63756964
Test: test/testrunner/testrunner.py --host --cdex-fast -j40
Test: Commented out header writing in compact_dex_writer.cc and confirmed tests fail.

Change-Id: I408555b48286d2c4c5eca72e2cabe956aa1e9835
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index 31f43fc..4844d1e 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -184,6 +184,10 @@
     elif [ "x$1" = "x--prebuild" ]; then
         PREBUILD="y"
         shift
+    elif [ "x$1" = "x--compact-dex-level" ]; then
+        shift
+        COMPILE_FLAGS="${COMPILE_FLAGS} --compact-dex-level=$1"
+        shift
     elif [ "x$1" = "x--jvmti-redefine-stress" ]; then
         # APP_IMAGE doesn't really work with jvmti redefine stress
         USE_JVMTI="y"
diff --git a/test/knownfailures.json b/test/knownfailures.json
index 5cd7888..ae1830a 100644
--- a/test/knownfailures.json
+++ b/test/knownfailures.json
@@ -383,7 +383,7 @@
         "tests": ["629-vdex-speed",
                   "634-vdex-duplicate"],
         "description": ["Profile driven dexlayout does not work with vdex or dex verifier."],
-        "variant": "speed-profile"
+        "variant": "speed-profile | cdex-fast"
     },
     {
         "test_patterns": ["616-cha.*"],
@@ -649,5 +649,11 @@
         "tests": "661-oat-writer-layout",
         "variant": "interp-ac | interpreter | jit | no-dex2oat | no-prebuild | no-image | trace",
         "description": ["Test is designed to only check --compiler-filter=speed"]
+    },
+    {
+        "tests": ["628-vdex", "975-iface-private"],
+        "variant": "cdex-fast",
+        "description": ["CompactDex doesn't yet work with input-vdex or 975-iface private"]
     }
+
 ]
diff --git a/test/run-test b/test/run-test
index fdb2ee4..75fe15c 100755
--- a/test/run-test
+++ b/test/run-test
@@ -225,6 +225,11 @@
         run_args="${run_args} --prebuild"
         prebuild_mode="yes"
         shift;
+    elif [ "x$1" = "x--compact-dex-level" ]; then
+        option="$1"
+        shift
+        run_args="${run_args} $option $1"
+        shift;
     elif [ "x$1" = "x--strip-dex" ]; then
         run_args="${run_args} --strip-dex"
         shift;
@@ -660,6 +665,7 @@
         echo "    -Xcompiler-option     Pass an option to the compiler."
         echo "    --build-option        Pass an option to the build script."
         echo "    --runtime-option      Pass an option to the runtime."
+        echo "    --compact-dex-level   Specify a compact dex level to the compiler."
         echo "    --debug               Wait for the default debugger to attach."
         echo "    --debug-agent <agent-path>"
         echo "                          Wait for the given debugger agent to attach. Currently"
diff --git a/test/testrunner/testrunner.py b/test/testrunner/testrunner.py
index 554b8a5..9399857 100755
--- a/test/testrunner/testrunner.py
+++ b/test/testrunner/testrunner.py
@@ -141,6 +141,7 @@
   VARIANT_TYPE_DICT['debuggable'] = {'ndebuggable', 'debuggable'}
   VARIANT_TYPE_DICT['gc'] = {'gcstress', 'gcverify', 'cms'}
   VARIANT_TYPE_DICT['prebuild'] = {'no-prebuild', 'no-dex2oat', 'prebuild'}
+  VARIANT_TYPE_DICT['cdex_level'] = {'cdex-none', 'cdex-fast'}
   VARIANT_TYPE_DICT['relocate'] = {'relocate-npatchoat', 'relocate', 'no-relocate'}
   VARIANT_TYPE_DICT['jni'] = {'jni', 'forcecopy', 'checkjni'}
   VARIANT_TYPE_DICT['address_sizes'] = {'64', '32'}
@@ -183,6 +184,9 @@
   if not _user_input_variants['prebuild']: # Default
     _user_input_variants['prebuild'].add('prebuild')
 
+  if not _user_input_variants['cdex_level']: # Default
+    _user_input_variants['cdex_level'].add('cdex-none')
+
   # By default only run without jvmti
   if not _user_input_variants['jvmti']:
     _user_input_variants['jvmti'].add('no-jvmti')
@@ -339,10 +343,11 @@
                              _user_input_variants['relocate'], _user_input_variants['trace'],
                              _user_input_variants['gc'], _user_input_variants['jni'],
                              _user_input_variants['image'], _user_input_variants['pictest'],
-                             _user_input_variants['debuggable'], _user_input_variants['jvmti'])
+                             _user_input_variants['debuggable'], _user_input_variants['jvmti'],
+                             _user_input_variants['cdex_level'])
 
   for test, target, run, prebuild, compiler, relocate, trace, gc, \
-      jni, image, pictest, debuggable, jvmti in config:
+      jni, image, pictest, debuggable, jvmti, cdex_level in config:
     for address_size in _user_input_variants['address_sizes_target'][target]:
       if stop_testrunner:
         # When ART_TEST_KEEP_GOING is set to false, then as soon as a test
@@ -356,6 +361,7 @@
       test_name += target + '-run-test-'
       test_name += run + '-'
       test_name += prebuild + '-'
+      test_name += cdex_level + '-'
       test_name += compiler + '-'
       test_name += relocate + '-'
       test_name += trace + '-'
@@ -369,7 +375,7 @@
       test_name += address_size
 
       variant_set = {target, run, prebuild, compiler, relocate, trace, gc, jni,
-                     image, pictest, debuggable, jvmti, address_size}
+                     image, pictest, debuggable, jvmti, cdex_level, address_size}
 
       options_test = options_all
 
@@ -386,6 +392,9 @@
       elif prebuild == 'no-dex2oat':
         options_test += ' --no-prebuild --no-dex2oat'
 
+      # Add option and remove the cdex- prefix.
+      options_test += ' --compact-dex-level ' + cdex_level.replace('cdex-','')
+
       if compiler == 'optimizing':
         options_test += ' --optimizing'
       elif compiler == 'regalloc_gc':
@@ -806,6 +815,7 @@
   regex += '(' + '|'.join(VARIANT_TYPE_DICT['pictest']) + ')-'
   regex += '(' + '|'.join(VARIANT_TYPE_DICT['debuggable']) + ')-'
   regex += '(' + '|'.join(VARIANT_TYPE_DICT['jvmti']) + ')-'
+  regex += '(' + '|'.join(VARIANT_TYPE_DICT['cdex_level']) + ')-'
   regex += '(' + '|'.join(RUN_TEST_SET) + ')'
   regex += '(' + '|'.join(VARIANT_TYPE_DICT['address_sizes']) + ')$'
   match = re.match(regex, test_name)
@@ -822,8 +832,9 @@
     _user_input_variants['pictest'].add(match.group(10))
     _user_input_variants['debuggable'].add(match.group(11))
     _user_input_variants['jvmti'].add(match.group(12))
-    _user_input_variants['address_sizes'].add(match.group(14))
-    return {match.group(13)}
+    _user_input_variants['cdex_level'].add(match.group(13))
+    _user_input_variants['address_sizes'].add(match.group(15))
+    return {match.group(14)}
   raise ValueError(test_name + " is not a valid test")