ART: Fixup JDWP tests script

The tests have problems on the host because of boot images. Vogar
by default runs in 32-bit mode, but the art script, used for forked
debuggee processes, by default runs in 64-bit. The JDWP forks also
do not set a boot classpath. With that mismatch, when the tests
are run in 32-bit mode on a 64-bit enabled host, the forked processes
will die.

Check whether a --variant parameter was passed to the test (and if
not assume it's x32). If the parameter is x32, then adapt the
debuggee command to ensure the forked runtime also runs in 32-bit
mode and finds the image from the controller. Similarly handle
the x64 case.

Change-Id: Ic22477e33702e1a7c1ca94466bf02df4cb201723
diff --git a/tools/run-jdwp-tests.sh b/tools/run-jdwp-tests.sh
index bdb2d4b..01dae43 100755
--- a/tools/run-jdwp-tests.sh
+++ b/tools/run-jdwp-tests.sh
@@ -50,6 +50,7 @@
 host="no"
 # Use JIT compiling by default.
 use_jit=true
+variant_cmdline_parameter="--variant=X32"
 
 while true; do
   if [[ "$1" == "--mode=host" ]]; then
@@ -93,11 +94,34 @@
     shift
   elif [[ "$1" == "" ]]; then
     break
+  elif [[ $1 == --variant=* ]]; then
+    variant_cmdline_parameter=$1
+    shift
   else
     shift
   fi
 done
 
+# For the host:
+#
+# If, on the other hand, there is a variant set, use it to modify the art_debugee parameter to
+# force the fork to have the same bitness as the controller. This should be fine and not impact
+# testing (cross-bitness), as the protocol is always 64-bit anyways (our implementation).
+#
+# Note: this isn't necessary for the device as the BOOTCLASSPATH environment variable is set there
+#       and used as a fallback.
+if [[ $host == "yes" ]]; then
+  variant=${variant_cmdline_parameter:10}
+  if [[ $variant == "x32" || $variant == "X32" ]]; then
+    art_debugee="$art_debugee --32"
+  elif [[ $variant == "x64" || $variant == "X64" ]]; then
+    art_debugee="$art_debugee --64"
+  else
+    echo "Error, do not understand variant $variant_cmdline_parameter."
+    exit 1
+  fi
+fi
+
 if [[ "$image" != "" ]]; then
   vm_args="--vm-arg $image"
 fi