Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 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 | |
Shubham Ajmera | c33c087 | 2017-07-20 18:41:52 -0700 | [diff] [blame] | 22 | if [ -z "$ANDROID_JAVA_TOOLCHAIN" ] ; then |
| 23 | source build/envsetup.sh |
| 24 | setpaths # include platform prebuilt java, javac, etc in $PATH. |
| 25 | fi |
| 26 | |
Andreas Gampe | ebd089d | 2016-07-18 14:56:56 -0700 | [diff] [blame] | 27 | if [ -z "$ANDROID_HOST_OUT" ] ; then |
| 28 | ANDROID_HOST_OUT=${OUT_DIR-$ANDROID_BUILD_TOP/out}/host/linux-x86 |
| 29 | fi |
| 30 | |
Igor Murashkin | 84f2632 | 2017-06-06 11:36:33 -0700 | [diff] [blame] | 31 | using_jack=true |
| 32 | if [[ $ANDROID_COMPILE_WITH_JACK == false ]]; then |
| 33 | using_jack=false |
| 34 | fi |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 35 | |
Igor Murashkin | 84f2632 | 2017-06-06 11:36:33 -0700 | [diff] [blame] | 36 | function jlib_suffix { |
| 37 | local str=$1 |
| 38 | local suffix="jar" |
| 39 | if $using_jack; then |
| 40 | suffix="jack" |
| 41 | fi |
| 42 | echo "$str.$suffix" |
| 43 | } |
| 44 | |
| 45 | # Jar containing all the tests. |
| 46 | test_jar=$(jlib_suffix "${ANDROID_HOST_OUT}/../common/obj/JAVA_LIBRARIES/apache-harmony-jdwp-tests-hostdex_intermediates/classes") |
| 47 | |
| 48 | if [ ! -f $test_jar ]; then |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 49 | echo "Before running, you must build jdwp tests and vogar:" \ |
Roland Levillain | 7235dd1 | 2016-05-20 18:16:54 +0100 | [diff] [blame] | 50 | "make apache-harmony-jdwp-tests-hostdex vogar" |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 51 | exit 1 |
| 52 | fi |
| 53 | |
| 54 | art="/data/local/tmp/system/bin/art" |
Nicolas Geoffray | 33e1f8f | 2015-04-24 14:37:29 +0100 | [diff] [blame] | 55 | art_debugee="sh /data/local/tmp/system/bin/art" |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 56 | args=$@ |
Nicolas Geoffray | d553b43 | 2015-07-13 14:35:17 +0100 | [diff] [blame] | 57 | debuggee_args="-Xcompiler-option --debuggable" |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 58 | device_dir="--device-dir=/data/local/tmp" |
Nicolas Geoffray | d06dc9c | 2015-03-30 15:30:26 +0100 | [diff] [blame] | 59 | # We use the art script on target to ensure the runner and the debuggee share the same |
| 60 | # image. |
| 61 | vm_command="--vm-command=$art" |
Nicolas Geoffray | a2c1861 | 2015-03-30 23:01:28 +0100 | [diff] [blame] | 62 | image_compiler_option="" |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 63 | debug="no" |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 64 | verbose="no" |
Nicolas Geoffray | b76bc78 | 2016-09-14 12:33:34 +0000 | [diff] [blame] | 65 | image="-Ximage:/data/art-test/core.art" |
Nicolas Geoffray | 9518655 | 2015-10-28 13:06:21 +0000 | [diff] [blame] | 66 | vm_args="" |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 67 | # By default, we run the whole JDWP test suite. |
| 68 | test="org.apache.harmony.jpda.tests.share.AllTests" |
Hiroshi Yamauchi | a166bbb | 2015-11-19 16:24:31 -0800 | [diff] [blame] | 69 | host="no" |
Roland Levillain | 5db109b | 2016-05-19 12:24:17 +0100 | [diff] [blame] | 70 | # Use JIT compiling by default. |
| 71 | use_jit=true |
Andreas Gampe | 85b286b | 2015-12-30 19:37:48 -0800 | [diff] [blame] | 72 | variant_cmdline_parameter="--variant=X32" |
Sebastien Hertz | c3b208c | 2017-03-27 11:35:54 +0200 | [diff] [blame] | 73 | # Timeout of JDWP test in ms. |
| 74 | # |
| 75 | # Note: some tests expect a timeout to check that *no* reply/event is received for a specific case. |
| 76 | # A lower timeout can save up several minutes when running the whole test suite, especially for |
| 77 | # continuous testing. This value can be adjusted to fit the configuration of the host machine(s). |
| 78 | jdwp_test_timeout=10000 |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 79 | |
| 80 | while true; do |
| 81 | if [[ "$1" == "--mode=host" ]]; then |
Hiroshi Yamauchi | a166bbb | 2015-11-19 16:24:31 -0800 | [diff] [blame] | 82 | host="yes" |
Nicolas Geoffray | 5978690 | 2015-03-30 16:34:16 +0100 | [diff] [blame] | 83 | # Specify bash explicitly since the art script cannot, since it has to run on the device |
| 84 | # with mksh. |
Alex Light | b15fea2 | 2015-09-17 16:59:09 -0700 | [diff] [blame] | 85 | art="bash ${OUT_DIR-out}/host/linux-x86/bin/art" |
| 86 | art_debugee="bash ${OUT_DIR-out}/host/linux-x86/bin/art" |
Andreas Gampe | 8994a04 | 2015-12-30 19:03:17 +0000 | [diff] [blame] | 87 | # We force generation of a new image to avoid build-time and run-time classpath differences. |
| 88 | image="-Ximage:/system/non/existent/vogar.art" |
Nicolas Geoffray | d06dc9c | 2015-03-30 15:30:26 +0100 | [diff] [blame] | 89 | # We do not need a device directory on host. |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 90 | device_dir="" |
Nicolas Geoffray | d06dc9c | 2015-03-30 15:30:26 +0100 | [diff] [blame] | 91 | # Vogar knows which VM to use on host. |
| 92 | vm_command="" |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 93 | shift |
| 94 | elif [[ $1 == -Ximage:* ]]; then |
| 95 | image="$1" |
| 96 | shift |
Roland Levillain | 5db109b | 2016-05-19 12:24:17 +0100 | [diff] [blame] | 97 | elif [[ "$1" == "--no-jit" ]]; then |
| 98 | use_jit=false |
| 99 | # Remove the --no-jit from the arguments. |
| 100 | args=${args/$1} |
| 101 | shift |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 102 | elif [[ $1 == "--debug" ]]; then |
| 103 | debug="yes" |
| 104 | # Remove the --debug from the arguments. |
| 105 | args=${args/$1} |
| 106 | shift |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 107 | elif [[ $1 == "--verbose" ]]; then |
| 108 | verbose="yes" |
| 109 | # Remove the --verbose from the arguments. |
| 110 | args=${args/$1} |
| 111 | shift |
| 112 | elif [[ $1 == "--test" ]]; then |
| 113 | # Remove the --test from the arguments. |
| 114 | args=${args/$1} |
| 115 | shift |
| 116 | test=$1 |
| 117 | # Remove the test from the arguments. |
| 118 | args=${args/$1} |
| 119 | shift |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 120 | elif [[ "$1" == "" ]]; then |
| 121 | break |
Andreas Gampe | 85b286b | 2015-12-30 19:37:48 -0800 | [diff] [blame] | 122 | elif [[ $1 == --variant=* ]]; then |
| 123 | variant_cmdline_parameter=$1 |
| 124 | shift |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 125 | else |
| 126 | shift |
| 127 | fi |
| 128 | done |
| 129 | |
Andreas Gampe | 85b286b | 2015-12-30 19:37:48 -0800 | [diff] [blame] | 130 | # For the host: |
| 131 | # |
| 132 | # If, on the other hand, there is a variant set, use it to modify the art_debugee parameter to |
| 133 | # force the fork to have the same bitness as the controller. This should be fine and not impact |
| 134 | # testing (cross-bitness), as the protocol is always 64-bit anyways (our implementation). |
| 135 | # |
| 136 | # Note: this isn't necessary for the device as the BOOTCLASSPATH environment variable is set there |
| 137 | # and used as a fallback. |
| 138 | if [[ $host == "yes" ]]; then |
| 139 | variant=${variant_cmdline_parameter:10} |
| 140 | if [[ $variant == "x32" || $variant == "X32" ]]; then |
| 141 | art_debugee="$art_debugee --32" |
| 142 | elif [[ $variant == "x64" || $variant == "X64" ]]; then |
| 143 | art_debugee="$art_debugee --64" |
| 144 | else |
| 145 | echo "Error, do not understand variant $variant_cmdline_parameter." |
| 146 | exit 1 |
| 147 | fi |
| 148 | fi |
| 149 | |
Nicolas Geoffray | 9518655 | 2015-10-28 13:06:21 +0000 | [diff] [blame] | 150 | if [[ "$image" != "" ]]; then |
| 151 | vm_args="--vm-arg $image" |
| 152 | fi |
Roland Levillain | 5db109b | 2016-05-19 12:24:17 +0100 | [diff] [blame] | 153 | if $use_jit; then |
Nicolas Geoffray | 49cda06 | 2017-04-21 13:08:25 +0100 | [diff] [blame] | 154 | vm_args="$vm_args --vm-arg -Xcompiler-option --vm-arg --compiler-filter=quicken" |
| 155 | debuggee_args="$debuggee_args -Xcompiler-option --compiler-filter=quicken" |
Roland Levillain | 5db109b | 2016-05-19 12:24:17 +0100 | [diff] [blame] | 156 | fi |
| 157 | vm_args="$vm_args --vm-arg -Xusejit:$use_jit" |
| 158 | debuggee_args="$debuggee_args -Xusejit:$use_jit" |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 159 | if [[ $debug == "yes" ]]; then |
| 160 | art="$art -d" |
| 161 | art_debugee="$art_debugee -d" |
Andreas Gampe | 1c5b42f | 2017-06-15 18:20:45 -0700 | [diff] [blame] | 162 | vm_args="$vm_args --vm-arg -XXlib:libartd.so --vm-arg -XX:SlowDebug=true" |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 163 | fi |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 164 | if [[ $verbose == "yes" ]]; then |
| 165 | # Enable JDWP logs in the debuggee. |
| 166 | art_debugee="$art_debugee -verbose:jdwp" |
| 167 | fi |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 168 | |
Igor Murashkin | 84f2632 | 2017-06-06 11:36:33 -0700 | [diff] [blame] | 169 | if $using_jack; then |
| 170 | toolchain_args="--toolchain jack --language JN --jack-arg -g" |
| 171 | else |
| 172 | toolchain_args="--toolchain jdk --language CUR" |
| 173 | fi |
| 174 | |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 175 | # Run the tests using vogar. |
Nicolas Geoffray | d06dc9c | 2015-03-30 15:30:26 +0100 | [diff] [blame] | 176 | vogar $vm_command \ |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 177 | $vm_args \ |
Nicolas Geoffray | 9620b9d | 2015-03-30 12:28:26 +0100 | [diff] [blame] | 178 | --verbose \ |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 179 | $args \ |
| 180 | $device_dir \ |
Nicolas Geoffray | a2c1861 | 2015-03-30 23:01:28 +0100 | [diff] [blame] | 181 | $image_compiler_option \ |
Nicolas Geoffray | 472b00c | 2015-05-06 14:57:09 +0100 | [diff] [blame] | 182 | --timeout 800 \ |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 183 | --vm-arg -Djpda.settings.verbose=true \ |
Sebastien Hertz | c3b208c | 2017-03-27 11:35:54 +0200 | [diff] [blame] | 184 | --vm-arg -Djpda.settings.timeout=$jdwp_test_timeout \ |
| 185 | --vm-arg -Djpda.settings.waitingTime=$jdwp_test_timeout \ |
Nicolas Geoffray | a2c1861 | 2015-03-30 23:01:28 +0100 | [diff] [blame] | 186 | --vm-arg -Djpda.settings.transportAddress=127.0.0.1:55107 \ |
Paul Duffin | 1acc729 | 2015-12-01 13:56:52 +0000 | [diff] [blame] | 187 | --vm-arg -Djpda.settings.debuggeeJavaPath="$art_debugee $image $debuggee_args" \ |
Igor Murashkin | 84f2632 | 2017-06-06 11:36:33 -0700 | [diff] [blame] | 188 | --classpath "$test_jar" \ |
| 189 | $toolchain_args \ |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 190 | --vm-arg -Xcompiler-option --vm-arg --debuggable \ |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 191 | $test |
Hiroshi Yamauchi | a166bbb | 2015-11-19 16:24:31 -0800 | [diff] [blame] | 192 | |
| 193 | vogar_exit_status=$? |
| 194 | |
| 195 | echo "Killing stalled dalvikvm processes..." |
| 196 | if [[ $host == "yes" ]]; then |
| 197 | pkill -9 -f /bin/dalvikvm |
| 198 | else |
| 199 | adb shell pkill -9 -f /bin/dalvikvm |
| 200 | fi |
| 201 | echo "Done." |
| 202 | |
| 203 | exit $vogar_exit_status |