blob: 0747712e7fd6279401cc5d405b7357b393554b03 [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
22# Jar containing all the tests.
Alex Lightb15fea22015-09-17 16:59:09 -070023test_jar=${OUT_DIR-out}/host/linux-x86/framework/apache-harmony-jdwp-tests-hostdex.jar
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000024
Nicolas Geoffrayf4ff1d42015-05-14 14:03:51 +000025if [ ! -f $test_jar ]; then
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000026 echo "Before running, you must build jdwp tests and vogar:" \
Nicolas Geoffrayf4ff1d42015-05-14 14:03:51 +000027 "make apache-harmony-jdwp-tests-hostdex vogar vogar.jar"
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000028 exit 1
29fi
30
31art="/data/local/tmp/system/bin/art"
Nicolas Geoffray33e1f8f2015-04-24 14:37:29 +010032art_debugee="sh /data/local/tmp/system/bin/art"
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000033args=$@
Nicolas Geoffrayd553b432015-07-13 14:35:17 +010034debuggee_args="-Xcompiler-option --debuggable"
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000035device_dir="--device-dir=/data/local/tmp"
Nicolas Geoffrayd06dc9c2015-03-30 15:30:26 +010036# We use the art script on target to ensure the runner and the debuggee share the same
37# image.
38vm_command="--vm-command=$art"
Nicolas Geoffraya2c18612015-03-30 23:01:28 +010039image_compiler_option=""
Nicolas Geoffray9648a632015-06-15 14:35:01 +010040debug="no"
Sebastien Hertza646aaf2015-09-10 12:03:51 +020041verbose="no"
Nicolas Geoffray8d10e452015-10-28 17:01:04 +000042image="-Ximage:/data/art-test/core-jit.art"
Nicolas Geoffray95186552015-10-28 13:06:21 +000043vm_args=""
Sebastien Hertza646aaf2015-09-10 12:03:51 +020044# By default, we run the whole JDWP test suite.
45test="org.apache.harmony.jpda.tests.share.AllTests"
Hiroshi Yamauchia166bbb2015-11-19 16:24:31 -080046host="no"
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000047
48while true; do
49 if [[ "$1" == "--mode=host" ]]; then
Hiroshi Yamauchia166bbb2015-11-19 16:24:31 -080050 host="yes"
Nicolas Geoffray59786902015-03-30 16:34:16 +010051 # Specify bash explicitly since the art script cannot, since it has to run on the device
52 # with mksh.
Alex Lightb15fea22015-09-17 16:59:09 -070053 art="bash ${OUT_DIR-out}/host/linux-x86/bin/art"
54 art_debugee="bash ${OUT_DIR-out}/host/linux-x86/bin/art"
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000055 # We force generation of a new image to avoid build-time and run-time classpath differences.
56 image="-Ximage:/system/non/existent"
Nicolas Geoffrayd06dc9c2015-03-30 15:30:26 +010057 # We do not need a device directory on host.
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000058 device_dir=""
Nicolas Geoffrayd06dc9c2015-03-30 15:30:26 +010059 # Vogar knows which VM to use on host.
60 vm_command=""
Nicolas Geoffraya2c18612015-03-30 23:01:28 +010061 # We only compile the image on the host. Note that not providing this option
Nicolas Geoffray9648a632015-06-15 14:35:01 +010062 # for target testing puts us below the adb command limit for vogar.
Nicolas Geoffraya2c18612015-03-30 23:01:28 +010063 image_compiler_option="--vm-arg -Ximage-compiler-option --vm-arg --debuggable"
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000064 shift
65 elif [[ $1 == -Ximage:* ]]; then
66 image="$1"
67 shift
Nicolas Geoffray9648a632015-06-15 14:35:01 +010068 elif [[ $1 == "--debug" ]]; then
69 debug="yes"
70 # Remove the --debug from the arguments.
71 args=${args/$1}
72 shift
Sebastien Hertza646aaf2015-09-10 12:03:51 +020073 elif [[ $1 == "--verbose" ]]; then
74 verbose="yes"
75 # Remove the --verbose from the arguments.
76 args=${args/$1}
77 shift
78 elif [[ $1 == "--test" ]]; then
79 # Remove the --test from the arguments.
80 args=${args/$1}
81 shift
82 test=$1
83 # Remove the test from the arguments.
84 args=${args/$1}
85 shift
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +000086 elif [[ "$1" == "" ]]; then
87 break
88 else
89 shift
90 fi
91done
92
Nicolas Geoffray95186552015-10-28 13:06:21 +000093if [[ "$image" != "" ]]; then
94 vm_args="--vm-arg $image"
95fi
96vm_args="$vm_args --vm-arg -Xusejit:true"
Nicolas Geoffraye2725c52015-10-26 18:40:41 +000097debuggee_args="$debuggee_args -Xusejit:true"
Nicolas Geoffray9648a632015-06-15 14:35:01 +010098if [[ $debug == "yes" ]]; then
99 art="$art -d"
100 art_debugee="$art_debugee -d"
101 vm_args="$vm_args --vm-arg -XXlib:libartd.so"
102fi
Sebastien Hertza646aaf2015-09-10 12:03:51 +0200103if [[ $verbose == "yes" ]]; then
104 # Enable JDWP logs in the debuggee.
105 art_debugee="$art_debugee -verbose:jdwp"
106fi
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100107
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000108# Run the tests using vogar.
Nicolas Geoffrayd06dc9c2015-03-30 15:30:26 +0100109vogar $vm_command \
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100110 $vm_args \
Nicolas Geoffray9620b9d2015-03-30 12:28:26 +0100111 --verbose \
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000112 $args \
113 $device_dir \
Nicolas Geoffraya2c18612015-03-30 23:01:28 +0100114 $image_compiler_option \
Nicolas Geoffray472b00c2015-05-06 14:57:09 +0100115 --timeout 800 \
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000116 --vm-arg -Djpda.settings.verbose=true \
117 --vm-arg -Djpda.settings.syncPort=34016 \
Nicolas Geoffraya2c18612015-03-30 23:01:28 +0100118 --vm-arg -Djpda.settings.transportAddress=127.0.0.1:55107 \
Nicolas Geoffray33e1f8f2015-04-24 14:37:29 +0100119 --vm-arg -Djpda.settings.debuggeeJavaPath="\"$art_debugee $image $debuggee_args\"" \
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000120 --classpath $test_jar \
Nicolas Geoffray96cd87a2015-03-26 16:48:29 +0000121 --vm-arg -Xcompiler-option --vm-arg --debuggable \
Sebastien Hertza646aaf2015-09-10 12:03:51 +0200122 $test
Hiroshi Yamauchia166bbb2015-11-19 16:24:31 -0800123
124vogar_exit_status=$?
125
126echo "Killing stalled dalvikvm processes..."
127if [[ $host == "yes" ]]; then
128 pkill -9 -f /bin/dalvikvm
129else
130 adb shell pkill -9 -f /bin/dalvikvm
131fi
132echo "Done."
133
134exit $vogar_exit_status