blob: 355646b71392f7b6e35b6910666676141c8d4ae8 [file] [log] [blame]
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +00001#!/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
17if [ ! -d libcore ]; then
18 echo "Script needs to be run at the root of the android tree"
19 exit 1
20fi
21
Colin Crosse0ef0a82017-07-27 21:29:18 +000022source build/envsetup.sh >&/dev/null # for get_build_var, setpaths
23setpaths # include platform prebuilt java, javac, etc in $PATH.
Shubham Ajmerac33c0872017-07-20 18:41:52 -070024
Andreas Gampeebd089d2016-07-18 14:56:56 -070025if [ -z "$ANDROID_HOST_OUT" ] ; then
26 ANDROID_HOST_OUT=${OUT_DIR-$ANDROID_BUILD_TOP/out}/host/linux-x86
27fi
28
Colin Crosse0ef0a82017-07-27 21:29:18 +000029using_jack=$(get_build_var ANDROID_COMPILE_WITH_JACK)
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000030
Igor Murashkin84f26322017-06-06 11:36:33 -070031function jlib_suffix {
32 local str=$1
33 local suffix="jar"
Colin Crosse0ef0a82017-07-27 21:29:18 +000034 if [[ $using_jack == "true" ]]; then
Igor Murashkin84f26322017-06-06 11:36:33 -070035 suffix="jack"
36 fi
37 echo "$str.$suffix"
38}
39
40# Jar containing all the tests.
41test_jar=$(jlib_suffix "${ANDROID_HOST_OUT}/../common/obj/JAVA_LIBRARIES/apache-harmony-jdwp-tests-hostdex_intermediates/classes")
42
43if [ ! -f $test_jar ]; then
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000044 echo "Before running, you must build jdwp tests and vogar:" \
Roland Levillain7235dd12016-05-20 18:16:54 +010045 "make apache-harmony-jdwp-tests-hostdex vogar"
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000046 exit 1
47fi
48
49art="/data/local/tmp/system/bin/art"
Nicolas Geoffray33e1f8f2015-04-24 14:37:29 +010050art_debugee="sh /data/local/tmp/system/bin/art"
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000051args=$@
Nicolas Geoffrayd553b432015-07-13 14:35:17 +010052debuggee_args="-Xcompiler-option --debuggable"
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000053device_dir="--device-dir=/data/local/tmp"
Nicolas Geoffrayd06dc9c2015-03-30 15:30:26 +010054# We use the art script on target to ensure the runner and the debuggee share the same
55# image.
56vm_command="--vm-command=$art"
Nicolas Geoffraya2c18612015-03-30 23:01:28 +010057image_compiler_option=""
Nicolas Geoffray9648a632015-06-15 14:35:01 +010058debug="no"
Sebastien Hertza646aaf2015-09-10 12:03:51 +020059verbose="no"
Nicolas Geoffrayb76bc782016-09-14 12:33:34 +000060image="-Ximage:/data/art-test/core.art"
Nicolas Geoffray95186552015-10-28 13:06:21 +000061vm_args=""
Sebastien Hertza646aaf2015-09-10 12:03:51 +020062# By default, we run the whole JDWP test suite.
63test="org.apache.harmony.jpda.tests.share.AllTests"
Hiroshi Yamauchia166bbb2015-11-19 16:24:31 -080064host="no"
Roland Levillain5db109b2016-05-19 12:24:17 +010065# Use JIT compiling by default.
66use_jit=true
Andreas Gampe85b286b2015-12-30 19:37:48 -080067variant_cmdline_parameter="--variant=X32"
Sebastien Hertzc3b208c2017-03-27 11:35:54 +020068# Timeout of JDWP test in ms.
69#
70# Note: some tests expect a timeout to check that *no* reply/event is received for a specific case.
71# A lower timeout can save up several minutes when running the whole test suite, especially for
72# continuous testing. This value can be adjusted to fit the configuration of the host machine(s).
73jdwp_test_timeout=10000
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000074
75while true; do
76 if [[ "$1" == "--mode=host" ]]; then
Hiroshi Yamauchia166bbb2015-11-19 16:24:31 -080077 host="yes"
Nicolas Geoffray59786902015-03-30 16:34:16 +010078 # Specify bash explicitly since the art script cannot, since it has to run on the device
79 # with mksh.
Alex Lightb15fea22015-09-17 16:59:09 -070080 art="bash ${OUT_DIR-out}/host/linux-x86/bin/art"
81 art_debugee="bash ${OUT_DIR-out}/host/linux-x86/bin/art"
Andreas Gampe8994a042015-12-30 19:03:17 +000082 # We force generation of a new image to avoid build-time and run-time classpath differences.
83 image="-Ximage:/system/non/existent/vogar.art"
Nicolas Geoffrayd06dc9c2015-03-30 15:30:26 +010084 # We do not need a device directory on host.
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000085 device_dir=""
Nicolas Geoffrayd06dc9c2015-03-30 15:30:26 +010086 # Vogar knows which VM to use on host.
87 vm_command=""
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000088 shift
89 elif [[ $1 == -Ximage:* ]]; then
90 image="$1"
91 shift
Roland Levillain5db109b2016-05-19 12:24:17 +010092 elif [[ "$1" == "--no-jit" ]]; then
93 use_jit=false
94 # Remove the --no-jit from the arguments.
95 args=${args/$1}
96 shift
Nicolas Geoffray9648a632015-06-15 14:35:01 +010097 elif [[ $1 == "--debug" ]]; then
98 debug="yes"
99 # Remove the --debug from the arguments.
100 args=${args/$1}
101 shift
Sebastien Hertza646aaf2015-09-10 12:03:51 +0200102 elif [[ $1 == "--verbose" ]]; then
103 verbose="yes"
104 # Remove the --verbose from the arguments.
105 args=${args/$1}
106 shift
107 elif [[ $1 == "--test" ]]; then
108 # Remove the --test from the arguments.
109 args=${args/$1}
110 shift
111 test=$1
112 # Remove the test from the arguments.
113 args=${args/$1}
114 shift
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000115 elif [[ "$1" == "" ]]; then
116 break
Andreas Gampe85b286b2015-12-30 19:37:48 -0800117 elif [[ $1 == --variant=* ]]; then
118 variant_cmdline_parameter=$1
119 shift
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000120 else
121 shift
122 fi
123done
124
Nicolas Geoffrayc0c07852017-08-08 09:44:15 +0100125# Make sure the debuggee doesn't clean up what the debugger has generated.
126art_debugee="$art_debugee --no-clean"
127
Andreas Gampe85b286b2015-12-30 19:37:48 -0800128# For the host:
129#
130# If, on the other hand, there is a variant set, use it to modify the art_debugee parameter to
131# force the fork to have the same bitness as the controller. This should be fine and not impact
132# testing (cross-bitness), as the protocol is always 64-bit anyways (our implementation).
133#
134# Note: this isn't necessary for the device as the BOOTCLASSPATH environment variable is set there
135# and used as a fallback.
136if [[ $host == "yes" ]]; then
137 variant=${variant_cmdline_parameter:10}
138 if [[ $variant == "x32" || $variant == "X32" ]]; then
139 art_debugee="$art_debugee --32"
140 elif [[ $variant == "x64" || $variant == "X64" ]]; then
141 art_debugee="$art_debugee --64"
142 else
143 echo "Error, do not understand variant $variant_cmdline_parameter."
144 exit 1
145 fi
146fi
147
Nicolas Geoffray95186552015-10-28 13:06:21 +0000148if [[ "$image" != "" ]]; then
149 vm_args="--vm-arg $image"
150fi
Roland Levillain5db109b2016-05-19 12:24:17 +0100151if $use_jit; then
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100152 vm_args="$vm_args --vm-arg -Xcompiler-option --vm-arg --compiler-filter=quicken"
153 debuggee_args="$debuggee_args -Xcompiler-option --compiler-filter=quicken"
Roland Levillain5db109b2016-05-19 12:24:17 +0100154fi
155vm_args="$vm_args --vm-arg -Xusejit:$use_jit"
156debuggee_args="$debuggee_args -Xusejit:$use_jit"
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100157if [[ $debug == "yes" ]]; then
158 art="$art -d"
159 art_debugee="$art_debugee -d"
Andreas Gampe1c5b42f2017-06-15 18:20:45 -0700160 vm_args="$vm_args --vm-arg -XXlib:libartd.so --vm-arg -XX:SlowDebug=true"
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100161fi
Sebastien Hertza646aaf2015-09-10 12:03:51 +0200162if [[ $verbose == "yes" ]]; then
163 # Enable JDWP logs in the debuggee.
164 art_debugee="$art_debugee -verbose:jdwp"
165fi
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100166
Colin Crosse0ef0a82017-07-27 21:29:18 +0000167if [[ $using_jack == "true" ]]; then
Igor Murashkin84f26322017-06-06 11:36:33 -0700168 toolchain_args="--toolchain jack --language JN --jack-arg -g"
169else
170 toolchain_args="--toolchain jdk --language CUR"
171fi
172
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000173# Run the tests using vogar.
Nicolas Geoffrayd06dc9c2015-03-30 15:30:26 +0100174vogar $vm_command \
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100175 $vm_args \
Nicolas Geoffray9620b9d2015-03-30 12:28:26 +0100176 --verbose \
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000177 $args \
178 $device_dir \
Nicolas Geoffraya2c18612015-03-30 23:01:28 +0100179 $image_compiler_option \
Nicolas Geoffray472b00c2015-05-06 14:57:09 +0100180 --timeout 800 \
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000181 --vm-arg -Djpda.settings.verbose=true \
Sebastien Hertzc3b208c2017-03-27 11:35:54 +0200182 --vm-arg -Djpda.settings.timeout=$jdwp_test_timeout \
183 --vm-arg -Djpda.settings.waitingTime=$jdwp_test_timeout \
Nicolas Geoffraya2c18612015-03-30 23:01:28 +0100184 --vm-arg -Djpda.settings.transportAddress=127.0.0.1:55107 \
Paul Duffin1acc7292015-12-01 13:56:52 +0000185 --vm-arg -Djpda.settings.debuggeeJavaPath="$art_debugee $image $debuggee_args" \
Igor Murashkin84f26322017-06-06 11:36:33 -0700186 --classpath "$test_jar" \
187 $toolchain_args \
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000188 --vm-arg -Xcompiler-option --vm-arg --debuggable \
Sebastien Hertza646aaf2015-09-10 12:03:51 +0200189 $test
Hiroshi Yamauchia166bbb2015-11-19 16:24:31 -0800190
191vogar_exit_status=$?
192
193echo "Killing stalled dalvikvm processes..."
194if [[ $host == "yes" ]]; then
195 pkill -9 -f /bin/dalvikvm
196else
197 adb shell pkill -9 -f /bin/dalvikvm
198fi
199echo "Done."
200
201exit $vogar_exit_status