OSDN Git Service

Merge "Catch classes inheriting from themselves in the class linker."
[android-x86/art.git] / tools / run-jdwp-tests.sh
1 #!/bin/bash
2 #
3 # Copyright (C) 2015 The Android Open Source Project
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 if [ ! -d libcore ]; then
18   echo "Script needs to be run at the root of the android tree"
19   exit 1
20 fi
21
22 # Jar containing all the tests.
23 test_jack=${OUT_DIR-out}/host/common/obj/JAVA_LIBRARIES/apache-harmony-jdwp-tests-hostdex_intermediates/classes.jack
24
25 if [ ! -f $test_jack ]; then
26   echo "Before running, you must build jdwp tests and vogar:" \
27        "make apache-harmony-jdwp-tests-hostdex vogar vogar.jar"
28   exit 1
29 fi
30
31 art="/data/local/tmp/system/bin/art"
32 art_debugee="sh /data/local/tmp/system/bin/art"
33 args=$@
34 debuggee_args="-Xcompiler-option --debuggable"
35 device_dir="--device-dir=/data/local/tmp"
36 # We use the art script on target to ensure the runner and the debuggee share the same
37 # image.
38 vm_command="--vm-command=$art"
39 image_compiler_option=""
40 debug="no"
41 verbose="no"
42 image="-Ximage:/data/art-test/core-optimizing-pic.art"
43 vm_args=""
44 # By default, we run the whole JDWP test suite.
45 test="org.apache.harmony.jpda.tests.share.AllTests"
46 host="no"
47
48 while true; do
49   if [[ "$1" == "--mode=host" ]]; then
50     host="yes"
51     # Specify bash explicitly since the art script cannot, since it has to run on the device
52     # with mksh.
53     art="bash ${OUT_DIR-out}/host/linux-x86/bin/art"
54     art_debugee="bash ${OUT_DIR-out}/host/linux-x86/bin/art"
55     # We force generation of a new image to avoid build-time and run-time classpath differences.
56     image="-Ximage:/system/non/existent/vogar.art"
57     # We do not need a device directory on host.
58     device_dir=""
59     # Vogar knows which VM to use on host.
60     vm_command=""
61     shift
62   elif [[ $1 == -Ximage:* ]]; then
63     image="$1"
64     shift
65   elif [[ $1 == "--debug" ]]; then
66     debug="yes"
67     # Remove the --debug from the arguments.
68     args=${args/$1}
69     shift
70   elif [[ $1 == "--verbose" ]]; then
71     verbose="yes"
72     # Remove the --verbose from the arguments.
73     args=${args/$1}
74     shift
75   elif [[ $1 == "--test" ]]; then
76     # Remove the --test from the arguments.
77     args=${args/$1}
78     shift
79     test=$1
80     # Remove the test from the arguments.
81     args=${args/$1}
82     shift
83   elif [[ "$1" == "" ]]; then
84     break
85   else
86     shift
87   fi
88 done
89
90 if [[ "$image" != "" ]]; then
91   vm_args="--vm-arg $image"
92 fi
93 vm_args="$vm_args --vm-arg -Xusejit:true"
94 debuggee_args="$debuggee_args -Xusejit:true"
95 if [[ $debug == "yes" ]]; then
96   art="$art -d"
97   art_debugee="$art_debugee -d"
98   vm_args="$vm_args --vm-arg -XXlib:libartd.so"
99 fi
100 if [[ $verbose == "yes" ]]; then
101   # Enable JDWP logs in the debuggee.
102   art_debugee="$art_debugee -verbose:jdwp"
103 fi
104
105 # Run the tests using vogar.
106 vogar $vm_command \
107       $vm_args \
108       --verbose \
109       $args \
110       $device_dir \
111       $image_compiler_option \
112       --timeout 800 \
113       --vm-arg -Djpda.settings.verbose=true \
114       --vm-arg -Djpda.settings.syncPort=34016 \
115       --vm-arg -Djpda.settings.transportAddress=127.0.0.1:55107 \
116       --vm-arg -Djpda.settings.debuggeeJavaPath="$art_debugee $image $debuggee_args" \
117       --classpath $test_jack \
118       --toolchain jack --language JN \
119       --vm-arg -Xcompiler-option --vm-arg --debuggable \
120       $test
121
122 vogar_exit_status=$?
123
124 echo "Killing stalled dalvikvm processes..."
125 if [[ $host == "yes" ]]; then
126   pkill -9 -f /bin/dalvikvm
127 else
128   adb shell pkill -9 -f /bin/dalvikvm
129 fi
130 echo "Done."
131
132 exit $vogar_exit_status