blob: 07c300e7a713cb5592f674d09823a54517b437d5 [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
Andreas Gampeebd089d2016-07-18 14:56:56 -070022if [ -z "$ANDROID_HOST_OUT" ] ; then
23 ANDROID_HOST_OUT=${OUT_DIR-$ANDROID_BUILD_TOP/out}/host/linux-x86
24fi
25
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000026# Jar containing all the tests.
Andreas Gampeebd089d2016-07-18 14:56:56 -070027test_jack=${ANDROID_HOST_OUT}/../common/obj/JAVA_LIBRARIES/apache-harmony-jdwp-tests-hostdex_intermediates/classes.jack
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000028
Sebastien Hertz6705dab2016-02-17 17:05:52 +010029if [ ! -f $test_jack ]; then
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000030 echo "Before running, you must build jdwp tests and vogar:" \
Roland Levillain7235dd12016-05-20 18:16:54 +010031 "make apache-harmony-jdwp-tests-hostdex vogar"
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000032 exit 1
33fi
34
35art="/data/local/tmp/system/bin/art"
Nicolas Geoffray33e1f8f2015-04-24 14:37:29 +010036art_debugee="sh /data/local/tmp/system/bin/art"
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000037args=$@
Nicolas Geoffrayd553b432015-07-13 14:35:17 +010038debuggee_args="-Xcompiler-option --debuggable"
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000039device_dir="--device-dir=/data/local/tmp"
Nicolas Geoffrayd06dc9c2015-03-30 15:30:26 +010040# We use the art script on target to ensure the runner and the debuggee share the same
41# image.
42vm_command="--vm-command=$art"
Nicolas Geoffraya2c18612015-03-30 23:01:28 +010043image_compiler_option=""
Nicolas Geoffray9648a632015-06-15 14:35:01 +010044debug="no"
Sebastien Hertza646aaf2015-09-10 12:03:51 +020045verbose="no"
Nicolas Geoffrayb76bc782016-09-14 12:33:34 +000046image="-Ximage:/data/art-test/core.art"
Nicolas Geoffray95186552015-10-28 13:06:21 +000047vm_args=""
Sebastien Hertza646aaf2015-09-10 12:03:51 +020048# By default, we run the whole JDWP test suite.
49test="org.apache.harmony.jpda.tests.share.AllTests"
Hiroshi Yamauchia166bbb2015-11-19 16:24:31 -080050host="no"
Roland Levillain5db109b2016-05-19 12:24:17 +010051# Use JIT compiling by default.
52use_jit=true
Andreas Gampe85b286b2015-12-30 19:37:48 -080053variant_cmdline_parameter="--variant=X32"
Sebastien Hertzc3b208c2017-03-27 11:35:54 +020054# Timeout of JDWP test in ms.
55#
56# Note: some tests expect a timeout to check that *no* reply/event is received for a specific case.
57# A lower timeout can save up several minutes when running the whole test suite, especially for
58# continuous testing. This value can be adjusted to fit the configuration of the host machine(s).
59jdwp_test_timeout=10000
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000060
61while true; do
62 if [[ "$1" == "--mode=host" ]]; then
Hiroshi Yamauchia166bbb2015-11-19 16:24:31 -080063 host="yes"
Nicolas Geoffray59786902015-03-30 16:34:16 +010064 # Specify bash explicitly since the art script cannot, since it has to run on the device
65 # with mksh.
Alex Lightb15fea22015-09-17 16:59:09 -070066 art="bash ${OUT_DIR-out}/host/linux-x86/bin/art"
67 art_debugee="bash ${OUT_DIR-out}/host/linux-x86/bin/art"
Andreas Gampe8994a042015-12-30 19:03:17 +000068 # We force generation of a new image to avoid build-time and run-time classpath differences.
69 image="-Ximage:/system/non/existent/vogar.art"
Nicolas Geoffrayd06dc9c2015-03-30 15:30:26 +010070 # We do not need a device directory on host.
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000071 device_dir=""
Nicolas Geoffrayd06dc9c2015-03-30 15:30:26 +010072 # Vogar knows which VM to use on host.
73 vm_command=""
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000074 shift
75 elif [[ $1 == -Ximage:* ]]; then
76 image="$1"
77 shift
Roland Levillain5db109b2016-05-19 12:24:17 +010078 elif [[ "$1" == "--no-jit" ]]; then
79 use_jit=false
80 # Remove the --no-jit from the arguments.
81 args=${args/$1}
82 shift
Nicolas Geoffray9648a632015-06-15 14:35:01 +010083 elif [[ $1 == "--debug" ]]; then
84 debug="yes"
85 # Remove the --debug from the arguments.
86 args=${args/$1}
87 shift
Sebastien Hertza646aaf2015-09-10 12:03:51 +020088 elif [[ $1 == "--verbose" ]]; then
89 verbose="yes"
90 # Remove the --verbose from the arguments.
91 args=${args/$1}
92 shift
93 elif [[ $1 == "--test" ]]; then
94 # Remove the --test from the arguments.
95 args=${args/$1}
96 shift
97 test=$1
98 # Remove the test from the arguments.
99 args=${args/$1}
100 shift
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000101 elif [[ "$1" == "" ]]; then
102 break
Andreas Gampe85b286b2015-12-30 19:37:48 -0800103 elif [[ $1 == --variant=* ]]; then
104 variant_cmdline_parameter=$1
105 shift
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000106 else
107 shift
108 fi
109done
110
Andreas Gampe85b286b2015-12-30 19:37:48 -0800111# For the host:
112#
113# If, on the other hand, there is a variant set, use it to modify the art_debugee parameter to
114# force the fork to have the same bitness as the controller. This should be fine and not impact
115# testing (cross-bitness), as the protocol is always 64-bit anyways (our implementation).
116#
117# Note: this isn't necessary for the device as the BOOTCLASSPATH environment variable is set there
118# and used as a fallback.
119if [[ $host == "yes" ]]; then
120 variant=${variant_cmdline_parameter:10}
121 if [[ $variant == "x32" || $variant == "X32" ]]; then
122 art_debugee="$art_debugee --32"
123 elif [[ $variant == "x64" || $variant == "X64" ]]; then
124 art_debugee="$art_debugee --64"
125 else
126 echo "Error, do not understand variant $variant_cmdline_parameter."
127 exit 1
128 fi
129fi
130
Nicolas Geoffray95186552015-10-28 13:06:21 +0000131if [[ "$image" != "" ]]; then
132 vm_args="--vm-arg $image"
133fi
Roland Levillain5db109b2016-05-19 12:24:17 +0100134if $use_jit; then
135 vm_args="$vm_args --vm-arg -Xcompiler-option --vm-arg --compiler-filter=interpret-only"
136 debuggee_args="$debuggee_args -Xcompiler-option --compiler-filter=interpret-only"
137fi
138vm_args="$vm_args --vm-arg -Xusejit:$use_jit"
139debuggee_args="$debuggee_args -Xusejit:$use_jit"
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100140if [[ $debug == "yes" ]]; then
141 art="$art -d"
142 art_debugee="$art_debugee -d"
143 vm_args="$vm_args --vm-arg -XXlib:libartd.so"
144fi
Sebastien Hertza646aaf2015-09-10 12:03:51 +0200145if [[ $verbose == "yes" ]]; then
146 # Enable JDWP logs in the debuggee.
147 art_debugee="$art_debugee -verbose:jdwp"
148fi
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100149
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000150# Run the tests using vogar.
Nicolas Geoffrayd06dc9c2015-03-30 15:30:26 +0100151vogar $vm_command \
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100152 $vm_args \
Nicolas Geoffray9620b9d2015-03-30 12:28:26 +0100153 --verbose \
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000154 $args \
155 $device_dir \
Nicolas Geoffraya2c18612015-03-30 23:01:28 +0100156 $image_compiler_option \
Nicolas Geoffray472b00c2015-05-06 14:57:09 +0100157 --timeout 800 \
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000158 --vm-arg -Djpda.settings.verbose=true \
Sebastien Hertzc3b208c2017-03-27 11:35:54 +0200159 --vm-arg -Djpda.settings.timeout=$jdwp_test_timeout \
160 --vm-arg -Djpda.settings.waitingTime=$jdwp_test_timeout \
Nicolas Geoffraya2c18612015-03-30 23:01:28 +0100161 --vm-arg -Djpda.settings.transportAddress=127.0.0.1:55107 \
Paul Duffin1acc7292015-12-01 13:56:52 +0000162 --vm-arg -Djpda.settings.debuggeeJavaPath="$art_debugee $image $debuggee_args" \
Orion Hodson6530cab2017-04-24 14:32:00 +0100163 --classpath $test_jack \
Sebastien Hertzd8aa5032016-02-22 10:55:24 +0000164 --toolchain jack --language JN \
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000165 --vm-arg -Xcompiler-option --vm-arg --debuggable \
Yohann Roussel0004e852016-12-07 16:41:07 +0100166 --jack-arg -g \
Sebastien Hertza646aaf2015-09-10 12:03:51 +0200167 $test
Hiroshi Yamauchia166bbb2015-11-19 16:24:31 -0800168
169vogar_exit_status=$?
170
171echo "Killing stalled dalvikvm processes..."
172if [[ $host == "yes" ]]; then
173 pkill -9 -f /bin/dalvikvm
174else
175 adb shell pkill -9 -f /bin/dalvikvm
176fi
177echo "Done."
178
179exit $vogar_exit_status