Add scripts to run jdwp tests on oj-libjdwp
Test: ./art/tools/run-libjdwp-tests.sh --mode=host
Bug: 62821960
Change-Id: I9d40834cf6168441ef2bc3fd2effb357ab8a3d45
diff --git a/tools/run-libjdwp-tests.sh b/tools/run-libjdwp-tests.sh
new file mode 100755
index 0000000..964bb38
--- /dev/null
+++ b/tools/run-libjdwp-tests.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+if [[ ! -d libcore ]]; then
+ echo "Script needs to be run at the root of the android tree"
+ exit 1
+fi
+
+if [[ `uname` != 'Linux' ]]; then
+ echo "Script cannot be run on $(uname). It is Linux only."
+ exit 2
+fi
+
+args=("$@")
+debug="no"
+has_variant="no"
+has_mode="no"
+mode="target"
+
+while true; do
+ if [[ $1 == "--debug" ]]; then
+ debug="yes"
+ shift
+ elif [[ "$1" == "--mode=jvm" ]]; then
+ has_mode="yes"
+ mode="ri"
+ shift
+ elif [[ "$1" == --mode=host ]]; then
+ has_mode="yes"
+ mode="host"
+ shift
+ elif [[ $1 == --variant=* ]]; then
+ has_variant="yes"
+ shift
+ elif [[ "$1" == "" ]]; then
+ break
+ else
+ shift
+ fi
+done
+
+if [[ "$has_mode" = "no" ]]; then
+ args+=(--mode=device)
+fi
+
+if [[ "$has_variant" = "no" ]]; then
+ args+=(--variant=X32)
+fi
+
+# We don't use full paths since it is difficult to determine them for device
+# tests and not needed due to resolution rules of dlopen.
+if [[ "$debug" = "yes" ]]; then
+ args+=(-Xplugin:libopenjdkjvmtid.so)
+else
+ args+=(-Xplugin:libopenjdkjvmti.so)
+fi
+
+expect_path=$PWD/art/tools/libjdwp_oj_art_failures.txt
+function verbose_run() {
+ echo "$@"
+ env "$@"
+}
+
+verbose_run ./art/tools/run-jdwp-tests.sh \
+ "${args[@]}" \
+ --jdwp-path "libjdwp.so" \
+ --expectations "$expect_path"