Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Runner for an individual run-test. |
| 4 | |
| 5 | msg() { |
| 6 | if [ "$QUIET" = "n" ]; then |
| 7 | echo "$@" |
| 8 | fi |
| 9 | } |
| 10 | |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 11 | ANDROID_ROOT="/system" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 12 | ARCHITECTURES_32="(arm|x86|mips|none)" |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 13 | ARCHITECTURES_64="(arm64|x86_64|mips64|none)" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 14 | ARCHITECTURES_PATTERN="${ARCHITECTURES_32}" |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 15 | BOOT_IMAGE="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 16 | COMPILE_FLAGS="" |
| 17 | DALVIKVM="dalvikvm32" |
| 18 | DEBUGGER="n" |
| 19 | DEV_MODE="n" |
| 20 | DEX2OAT="" |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 21 | EXPERIMENTAL="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 22 | FALSE_BIN="/system/bin/false" |
| 23 | FLAGS="" |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 24 | ANDROID_FLAGS="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 25 | GDB="" |
Nicolas Geoffray | baf9102 | 2014-10-08 09:56:45 +0100 | [diff] [blame] | 26 | GDB_ARGS="" |
| 27 | GDB_SERVER="gdbserver" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 28 | HAVE_IMAGE="y" |
| 29 | HOST="n" |
| 30 | INTERPRETER="n" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 31 | JIT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 32 | INVOKE_WITH="" |
| 33 | ISA=x86 |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 34 | LIBRARY_DIRECTORY="lib" |
| 35 | MAIN="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 36 | OPTIMIZE="y" |
| 37 | PATCHOAT="" |
| 38 | PREBUILD="y" |
| 39 | QUIET="n" |
| 40 | RELOCATE="y" |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 41 | STRIP_DEX="n" |
Jeff Hao | 207a37d | 2014-10-29 17:24:25 -0700 | [diff] [blame] | 42 | SECONDARY_DEX="" |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 43 | TIME_OUT="gdb" # "n" (disabled), "timeout" (use timeout), "gdb" (use gdb) |
| 44 | # Value in seconds |
Hiroshi Yamauchi | dcf0d4b | 2015-09-09 18:59:42 -0700 | [diff] [blame] | 45 | if [ "$ART_USE_READ_BARRIER" = "true" ]; then |
Mathieu Chartier | 2576be2 | 2016-05-24 10:24:53 -0700 | [diff] [blame] | 46 | TIME_OUT_VALUE=1800 # 30 minutes. |
Hiroshi Yamauchi | dcf0d4b | 2015-09-09 18:59:42 -0700 | [diff] [blame] | 47 | else |
Mathieu Chartier | 2576be2 | 2016-05-24 10:24:53 -0700 | [diff] [blame] | 48 | TIME_OUT_VALUE=1200 # 20 minutes. |
Hiroshi Yamauchi | dcf0d4b | 2015-09-09 18:59:42 -0700 | [diff] [blame] | 49 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 50 | USE_GDB="n" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 51 | USE_JVM="n" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 52 | VERIFY="y" # y=yes,n=no,s=softfail |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 53 | ZYGOTE="" |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 54 | DEX_VERIFY="" |
Andreas Gampe | 6535703 | 2015-02-19 15:10:24 -0800 | [diff] [blame] | 55 | USE_DEX2OAT_AND_PATCHOAT="y" |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 56 | INSTRUCTION_SET_FEATURES="" |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 57 | ARGS="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 58 | |
| 59 | while true; do |
| 60 | if [ "x$1" = "x--quiet" ]; then |
| 61 | QUIET="y" |
| 62 | shift |
Alex Light | faf90b6 | 2016-08-12 14:43:48 -0700 | [diff] [blame] | 63 | elif [ "x$1" = "x-O" ]; then |
| 64 | # Ignore this option. |
| 65 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 66 | elif [ "x$1" = "x--lib" ]; then |
| 67 | shift |
| 68 | if [ "x$1" = "x" ]; then |
| 69 | echo "$0 missing argument to --lib" 1>&2 |
| 70 | exit 1 |
| 71 | fi |
| 72 | LIB="$1" |
| 73 | shift |
Alex Light | 97acf19 | 2016-03-17 09:59:38 -0700 | [diff] [blame] | 74 | elif [ "x$1" = "x--gc-stress" ]; then |
| 75 | # Give an extra 5 mins if we are gc-stress. |
| 76 | TIME_OUT_VALUE=$((${TIME_OUT_VALUE} + 300)) |
| 77 | shift |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 78 | elif [ "x$1" = "x--testlib" ]; then |
| 79 | shift |
| 80 | if [ "x$1" = "x" ]; then |
| 81 | echo "$0 missing argument to --testlib" 1>&2 |
| 82 | exit 1 |
| 83 | fi |
Mathieu Chartier | de286fd | 2015-09-03 18:10:29 -0700 | [diff] [blame] | 84 | ARGS="${ARGS} $1" |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 85 | shift |
David Srbecky | 5288611 | 2016-01-22 13:56:47 +0000 | [diff] [blame] | 86 | elif [ "x$1" = "x--args" ]; then |
| 87 | shift |
| 88 | if [ "x$1" = "x" ]; then |
| 89 | echo "$0 missing argument to --args" 1>&2 |
| 90 | exit 1 |
| 91 | fi |
| 92 | ARGS="${ARGS} $1" |
| 93 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 94 | elif [ "x$1" = "x-Xcompiler-option" ]; then |
| 95 | shift |
| 96 | option="$1" |
| 97 | FLAGS="${FLAGS} -Xcompiler-option $option" |
| 98 | COMPILE_FLAGS="${COMPILE_FLAGS} $option" |
| 99 | shift |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 100 | elif [ "x$1" = "x--android-runtime-option" ]; then |
| 101 | shift |
| 102 | option="$1" |
| 103 | ANDROID_FLAGS="${ANDROID_FLAGS} $option" |
| 104 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 105 | elif [ "x$1" = "x--runtime-option" ]; then |
| 106 | shift |
| 107 | option="$1" |
| 108 | FLAGS="${FLAGS} $option" |
| 109 | shift |
| 110 | elif [ "x$1" = "x--boot" ]; then |
| 111 | shift |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 112 | BOOT_IMAGE="$1" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 113 | shift |
| 114 | elif [ "x$1" = "x--no-dex2oat" ]; then |
| 115 | DEX2OAT="-Xcompiler:${FALSE_BIN}" |
Andreas Gampe | 6535703 | 2015-02-19 15:10:24 -0800 | [diff] [blame] | 116 | USE_DEX2OAT_AND_PATCHOAT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 117 | shift |
| 118 | elif [ "x$1" = "x--no-patchoat" ]; then |
| 119 | PATCHOAT="-Xpatchoat:${FALSE_BIN}" |
Andreas Gampe | 6535703 | 2015-02-19 15:10:24 -0800 | [diff] [blame] | 120 | USE_DEX2OAT_AND_PATCHOAT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 121 | shift |
| 122 | elif [ "x$1" = "x--relocate" ]; then |
| 123 | RELOCATE="y" |
| 124 | shift |
| 125 | elif [ "x$1" = "x--no-relocate" ]; then |
| 126 | RELOCATE="n" |
| 127 | shift |
| 128 | elif [ "x$1" = "x--prebuild" ]; then |
| 129 | PREBUILD="y" |
| 130 | shift |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 131 | elif [ "x$1" = "x--strip-dex" ]; then |
| 132 | STRIP_DEX="y" |
| 133 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 134 | elif [ "x$1" = "x--host" ]; then |
| 135 | HOST="y" |
Nicolas Geoffray | 8eedb47 | 2014-10-29 14:05:59 +0000 | [diff] [blame] | 136 | ANDROID_ROOT="$ANDROID_HOST_OUT" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 137 | shift |
| 138 | elif [ "x$1" = "x--no-prebuild" ]; then |
| 139 | PREBUILD="n" |
| 140 | shift |
| 141 | elif [ "x$1" = "x--no-image" ]; then |
| 142 | HAVE_IMAGE="n" |
| 143 | shift |
Jeff Hao | 207a37d | 2014-10-29 17:24:25 -0700 | [diff] [blame] | 144 | elif [ "x$1" = "x--secondary" ]; then |
| 145 | SECONDARY_DEX=":$DEX_LOCATION/$TEST_NAME-ex.jar" |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 146 | # Enable cfg-append to make sure we get the dump for both dex files. |
| 147 | # (otherwise the runtime compilation of the secondary dex will overwrite |
| 148 | # the dump of the first one) |
| 149 | FLAGS="${FLAGS} -Xcompiler-option --dump-cfg-append" |
| 150 | COMPILE_FLAGS="${COMPILE_FLAGS} --dump-cfg-append" |
Jeff Hao | 207a37d | 2014-10-29 17:24:25 -0700 | [diff] [blame] | 151 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 152 | elif [ "x$1" = "x--debug" ]; then |
| 153 | DEBUGGER="y" |
Brian Carlstrom | 93d6ce5 | 2014-11-04 22:31:35 -0800 | [diff] [blame] | 154 | TIME_OUT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 155 | shift |
| 156 | elif [ "x$1" = "x--gdb" ]; then |
| 157 | USE_GDB="y" |
| 158 | DEV_MODE="y" |
Brian Carlstrom | 93d6ce5 | 2014-11-04 22:31:35 -0800 | [diff] [blame] | 159 | TIME_OUT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 160 | shift |
Mathieu Chartier | c0a8a80 | 2014-10-17 15:58:01 -0700 | [diff] [blame] | 161 | elif [ "x$1" = "x--gdb-arg" ]; then |
| 162 | shift |
| 163 | gdb_arg="$1" |
| 164 | GDB_ARGS="${GDB_ARGS} $gdb_arg" |
| 165 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 166 | elif [ "x$1" = "x--zygote" ]; then |
| 167 | ZYGOTE="-Xzygote" |
| 168 | msg "Spawning from zygote" |
| 169 | shift |
| 170 | elif [ "x$1" = "x--dev" ]; then |
| 171 | DEV_MODE="y" |
| 172 | shift |
| 173 | elif [ "x$1" = "x--interpreter" ]; then |
| 174 | INTERPRETER="y" |
| 175 | shift |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 176 | elif [ "x$1" = "x--jit" ]; then |
| 177 | JIT="y" |
| 178 | shift |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 179 | elif [ "x$1" = "x--jvm" ]; then |
| 180 | USE_JVM="y" |
| 181 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 182 | elif [ "x$1" = "x--invoke-with" ]; then |
| 183 | shift |
| 184 | if [ "x$1" = "x" ]; then |
| 185 | echo "$0 missing argument to --invoke-with" 1>&2 |
| 186 | exit 1 |
| 187 | fi |
| 188 | if [ "x$INVOKE_WITH" = "x" ]; then |
| 189 | INVOKE_WITH="$1" |
| 190 | else |
| 191 | INVOKE_WITH="$INVOKE_WITH $1" |
| 192 | fi |
| 193 | shift |
| 194 | elif [ "x$1" = "x--no-verify" ]; then |
| 195 | VERIFY="n" |
| 196 | shift |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 197 | elif [ "x$1" = "x--verify-soft-fail" ]; then |
| 198 | VERIFY="s" |
| 199 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 200 | elif [ "x$1" = "x--no-optimize" ]; then |
| 201 | OPTIMIZE="n" |
| 202 | shift |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 203 | elif [ "x$1" = "x--android-root" ]; then |
| 204 | shift |
| 205 | ANDROID_ROOT="$1" |
| 206 | shift |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 207 | elif [ "x$1" = "x--instruction-set-features" ]; then |
| 208 | shift |
| 209 | INSTRUCTION_SET_FEATURES="$1" |
| 210 | shift |
Mathieu Chartier | 2576be2 | 2016-05-24 10:24:53 -0700 | [diff] [blame] | 211 | elif [ "x$1" = "x--timeout" ]; then |
| 212 | shift |
| 213 | TIME_OUT_VALUE="$1" |
| 214 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 215 | elif [ "x$1" = "x--" ]; then |
| 216 | shift |
| 217 | break |
| 218 | elif [ "x$1" = "x--64" ]; then |
| 219 | ISA="x86_64" |
| 220 | GDB_SERVER="gdbserver64" |
| 221 | DALVIKVM="dalvikvm64" |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 222 | LIBRARY_DIRECTORY="lib64" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 223 | ARCHITECTURES_PATTERN="${ARCHITECTURES_64}" |
| 224 | shift |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 225 | elif [ "x$1" = "x--pic-test" ]; then |
| 226 | FLAGS="${FLAGS} -Xcompiler-option --compile-pic" |
| 227 | COMPILE_FLAGS="${COMPILE_FLAGS} --compile-pic" |
| 228 | shift |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 229 | elif [ "x$1" = "x--experimental" ]; then |
| 230 | if [ "$#" -lt 2 ]; then |
| 231 | echo "missing --experimental option" 1>&2 |
| 232 | exit 1 |
| 233 | fi |
| 234 | EXPERIMENTAL="$EXPERIMENTAL $2" |
| 235 | shift 2 |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 236 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
| 237 | echo "unknown $0 option: $1" 1>&2 |
| 238 | exit 1 |
| 239 | else |
| 240 | break |
| 241 | fi |
| 242 | done |
| 243 | |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 244 | if [ "$USE_JVM" = "n" ]; then |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 245 | FLAGS="${FLAGS} ${ANDROID_FLAGS}" |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 246 | for feature in ${EXPERIMENTAL}; do |
Alex Light | fa02285 | 2015-10-28 09:13:20 -0700 | [diff] [blame] | 247 | FLAGS="${FLAGS} -Xexperimental:${feature} -Xcompiler-option --runtime-arg -Xcompiler-option -Xexperimental:${feature}" |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 248 | COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xexperimental:${feature}" |
| 249 | done |
| 250 | fi |
| 251 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 252 | if [ "x$1" = "x" ] ; then |
| 253 | MAIN="Main" |
| 254 | else |
| 255 | MAIN="$1" |
Andreas Gampe | f2fdc73 | 2014-06-11 08:20:47 -0700 | [diff] [blame] | 256 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 257 | fi |
| 258 | |
| 259 | if [ "$ZYGOTE" = "" ]; then |
| 260 | if [ "$OPTIMIZE" = "y" ]; then |
| 261 | if [ "$VERIFY" = "y" ]; then |
| 262 | DEX_OPTIMIZE="-Xdexopt:verified" |
| 263 | else |
| 264 | DEX_OPTIMIZE="-Xdexopt:all" |
| 265 | fi |
| 266 | msg "Performing optimizations" |
| 267 | else |
| 268 | DEX_OPTIMIZE="-Xdexopt:none" |
| 269 | msg "Skipping optimizations" |
| 270 | fi |
| 271 | |
| 272 | if [ "$VERIFY" = "y" ]; then |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 273 | JVM_VERIFY_ARG="-Xverify:all" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 274 | msg "Performing verification" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 275 | elif [ "$VERIFY" = "s" ]; then |
| 276 | JVM_VERIFY_ARG="Xverify:all" |
| 277 | DEX_VERIFY="-Xverify:softfail" |
| 278 | msg "Forcing verification to be soft fail" |
| 279 | else # VERIFY = "n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 280 | DEX_VERIFY="-Xverify:none" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 281 | JVM_VERIFY_ARG="-Xverify:none" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 282 | msg "Skipping verification" |
| 283 | fi |
| 284 | fi |
| 285 | |
| 286 | msg "------------------------------" |
| 287 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 288 | if [ "$DEBUGGER" = "y" ]; then |
| 289 | # Use this instead for ddms and connect by running 'ddms': |
| 290 | # DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y" |
| 291 | # TODO: add a separate --ddms option? |
| 292 | |
| 293 | PORT=12345 |
| 294 | msg "Waiting for jdb to connect:" |
| 295 | if [ "$HOST" = "n" ]; then |
| 296 | msg " adb forward tcp:$PORT tcp:$PORT" |
| 297 | fi |
| 298 | msg " jdb -attach localhost:$PORT" |
| 299 | DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y" |
| 300 | fi |
| 301 | |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 302 | if [ "$USE_JVM" = "y" ]; then |
Mathieu Chartier | a61894d | 2015-04-23 16:32:54 -0700 | [diff] [blame] | 303 | # Xmx is necessary since we don't pass down the ART flags to JVM. |
Andreas Gampe | 3f1dc56 | 2015-05-18 15:52:22 -0700 | [diff] [blame] | 304 | cmdline="${JAVA} ${DEBUGGER_OPTS} ${JVM_VERIFY_ARG} -Xmx256m -classpath classes ${FLAGS} $MAIN $@" |
| 305 | if [ "$DEV_MODE" = "y" ]; then |
| 306 | echo $cmdline |
| 307 | fi |
| 308 | $cmdline |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 309 | exit |
| 310 | fi |
| 311 | |
| 312 | |
| 313 | if [ "$HAVE_IMAGE" = "n" ]; then |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 314 | DALVIKVM_BOOT_OPT="-Ximage:/system/non-existant/core.art" |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 315 | else |
| 316 | DALVIKVM_BOOT_OPT="-Ximage:${BOOT_IMAGE}" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 317 | fi |
| 318 | |
| 319 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 320 | if [ "$USE_GDB" = "y" ]; then |
| 321 | if [ "$HOST" = "n" ]; then |
| 322 | GDB="$GDB_SERVER :5039" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 323 | else |
| 324 | if [ `uname` = "Darwin" ]; then |
| 325 | GDB=lldb |
Mathieu Chartier | c0a8a80 | 2014-10-17 15:58:01 -0700 | [diff] [blame] | 326 | GDB_ARGS="$GDB_ARGS -- $DALVIKVM" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 327 | DALVIKVM= |
| 328 | else |
| 329 | GDB=gdb |
Mathieu Chartier | c0a8a80 | 2014-10-17 15:58:01 -0700 | [diff] [blame] | 330 | GDB_ARGS="$GDB_ARGS --args $DALVIKVM" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 331 | # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line. |
| 332 | # gdbargs="--annotate=3 $gdbargs" |
| 333 | fi |
| 334 | fi |
| 335 | fi |
| 336 | |
| 337 | if [ "$INTERPRETER" = "y" ]; then |
Nicolas Geoffray | e722d29 | 2015-12-15 11:51:37 +0000 | [diff] [blame] | 338 | INT_OPTS="-Xint" |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 339 | if [ "$VERIFY" = "y" ] ; then |
Richard Uhler | f4b3487 | 2016-04-13 11:03:46 -0700 | [diff] [blame] | 340 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=interpret-only" |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 341 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=interpret-only" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 342 | elif [ "$VERIFY" = "s" ]; then |
Richard Uhler | f4b3487 | 2016-04-13 11:03:46 -0700 | [diff] [blame] | 343 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=verify-at-runtime" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 344 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify-at-runtime" |
| 345 | DEX_VERIFY="${DEX_VERIFY} -Xverify:softfail" |
| 346 | else # VERIFY = "n" |
Richard Uhler | f4b3487 | 2016-04-13 11:03:46 -0700 | [diff] [blame] | 347 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=verify-none" |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 348 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify-none" |
| 349 | DEX_VERIFY="${DEX_VERIFY} -Xverify:none" |
| 350 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 351 | fi |
| 352 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 353 | if [ "$JIT" = "y" ]; then |
Nicolas Geoffray | e722d29 | 2015-12-15 11:51:37 +0000 | [diff] [blame] | 354 | INT_OPTS="-Xusejit:true" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 355 | if [ "$VERIFY" = "y" ] ; then |
Richard Uhler | f4b3487 | 2016-04-13 11:03:46 -0700 | [diff] [blame] | 356 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=verify-at-runtime" |
Mathieu Chartier | e86deef | 2015-03-19 13:43:37 -0700 | [diff] [blame] | 357 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify-at-runtime" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 358 | else |
Richard Uhler | f4b3487 | 2016-04-13 11:03:46 -0700 | [diff] [blame] | 359 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=verify-none" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 360 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify-none" |
| 361 | DEX_VERIFY="${DEX_VERIFY} -Xverify:none" |
| 362 | fi |
| 363 | fi |
| 364 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 365 | JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni" |
| 366 | |
| 367 | if [ "$RELOCATE" = "y" ]; then |
| 368 | COMPILE_FLAGS="${COMPILE_FLAGS} --include-patch-information --runtime-arg -Xnorelocate" |
| 369 | FLAGS="${FLAGS} -Xrelocate -Xcompiler-option --include-patch-information" |
| 370 | if [ "$HOST" = "y" ]; then |
| 371 | # Run test sets a fairly draconian ulimit that we will likely blow right over |
| 372 | # since we are relocating. Get the total size of the /system/framework directory |
| 373 | # in 512 byte blocks and set it as the ulimit. This should be more than enough |
| 374 | # room. |
| 375 | if [ ! `uname` = "Darwin" ]; then # TODO: Darwin doesn't support "du -B..." |
Alex Light | d26b7e4 | 2016-04-08 09:44:54 -0700 | [diff] [blame] | 376 | ulimit -S $(du -c -B512 ${ANDROID_HOST_OUT}/framework 2>/dev/null | tail -1 | cut -f1) || exit 1 |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 377 | fi |
| 378 | fi |
| 379 | else |
| 380 | FLAGS="$FLAGS -Xnorelocate" |
| 381 | COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xnorelocate" |
Mathieu Chartier | cae2ed9 | 2015-06-09 13:02:50 -0700 | [diff] [blame] | 382 | if [ "$HOST" = "y" ]; then |
| 383 | # Increase ulimit to 64MB in case we are running hprof test. |
| 384 | ulimit -S 64000 || exit 1 |
| 385 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 386 | fi |
| 387 | |
| 388 | if [ "$HOST" = "n" ]; then |
| 389 | ISA=$(adb shell ls -F /data/dalvik-cache | grep -Ewo "${ARCHITECTURES_PATTERN}") |
| 390 | if [ x"$ISA" = "x" ]; then |
| 391 | echo "Unable to determine architecture" |
| 392 | exit 1 |
| 393 | fi |
| 394 | fi |
| 395 | |
| 396 | dex2oat_cmdline="true" |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 397 | mkdir_locations="${DEX_LOCATION}/dalvik-cache/$ISA" |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 398 | strip_cmdline="true" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 399 | |
Mathieu Chartier | 92ec594 | 2016-04-11 12:03:48 -0700 | [diff] [blame] | 400 | # Pick a base that will force the app image to get relocated. |
| 401 | app_image="--base=0x4000 --app-image-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.art" |
Jeff Hao | dcdc85b | 2015-12-04 14:06:18 -0800 | [diff] [blame] | 402 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 403 | if [ "$PREBUILD" = "y" ]; then |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 404 | mkdir_locations="${mkdir_locations} ${DEX_LOCATION}/oat/$ISA" |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 405 | dex2oat_cmdline="$INVOKE_WITH $ANDROID_ROOT/bin/dex2oatd \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 406 | $COMPILE_FLAGS \ |
Nicolas Geoffray | 68e25eb | 2014-10-29 23:02:11 +0000 | [diff] [blame] | 407 | --boot-image=${BOOT_IMAGE} \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 408 | --dex-file=$DEX_LOCATION/$TEST_NAME.jar \ |
Andreas Gampe | 1475924 | 2016-03-23 10:54:21 -0700 | [diff] [blame] | 409 | --oat-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.odex \ |
Jeff Hao | dcdc85b | 2015-12-04 14:06:18 -0800 | [diff] [blame] | 410 | ${app_image} \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 411 | --instruction-set=$ISA" |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 412 | if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then |
| 413 | dex2oat_cmdline="${dex2oat_cmdline} --instruction-set-features=${INSTRUCTION_SET_FEATURES}" |
| 414 | fi |
Andreas Gampe | 2ea7b70 | 2015-08-07 08:07:16 -0700 | [diff] [blame] | 415 | |
| 416 | # Add in a timeout. This is important for testing the compilation/verification time of |
| 417 | # pathological cases. |
| 418 | # Note: as we don't know how decent targets are (e.g., emulator), only do this on the host for |
| 419 | # now. We should try to improve this. |
| 420 | # The current value is rather arbitrary. run-tests should compile quickly. |
| 421 | if [ "$HOST" != "n" ]; then |
| 422 | # Use SIGRTMIN+2 to try to dump threads. |
| 423 | # Use -k 1m to SIGKILL it a minute later if it hasn't ended. |
| 424 | dex2oat_cmdline="timeout -k 1m -s SIGRTMIN+2 1m ${dex2oat_cmdline}" |
| 425 | fi |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 426 | fi |
| 427 | |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 428 | if [ "$STRIP_DEX" = "y" ]; then |
| 429 | strip_cmdline="zip --quiet --delete $DEX_LOCATION/$TEST_NAME.jar classes.dex" |
| 430 | fi |
| 431 | |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 432 | DALVIKVM_ISA_FEATURES_ARGS="" |
| 433 | if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then |
| 434 | DALVIKVM_ISA_FEATURES_ARGS="-Xcompiler-option --instruction-set-features=${INSTRUCTION_SET_FEATURES}" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 435 | fi |
| 436 | |
Nicolas Geoffray | c525604 | 2015-12-26 19:41:37 +0000 | [diff] [blame] | 437 | # java.io.tmpdir can only be set at launch time. |
| 438 | TMP_DIR_OPTION="" |
| 439 | if [ "$HOST" = "n" ]; then |
| 440 | TMP_DIR_OPTION="-Djava.io.tmpdir=/data/local/tmp" |
| 441 | fi |
| 442 | |
Nicolas Geoffray | a73280d | 2016-02-15 13:05:16 +0000 | [diff] [blame] | 443 | # We set DumpNativeStackOnSigQuit to false to avoid stressing libunwind. |
| 444 | # b/27185632 |
| 445 | # b/24664297 |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 446 | dalvikvm_cmdline="$INVOKE_WITH $GDB $ANDROID_ROOT/bin/$DALVIKVM \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 447 | $GDB_ARGS \ |
| 448 | $FLAGS \ |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 449 | $DEX_VERIFY \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 450 | -XXlib:$LIB \ |
| 451 | $PATCHOAT \ |
| 452 | $DEX2OAT \ |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 453 | $DALVIKVM_ISA_FEATURES_ARGS \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 454 | $ZYGOTE \ |
| 455 | $JNI_OPTS \ |
| 456 | $INT_OPTS \ |
| 457 | $DEBUGGER_OPTS \ |
| 458 | $DALVIKVM_BOOT_OPT \ |
Nicolas Geoffray | c525604 | 2015-12-26 19:41:37 +0000 | [diff] [blame] | 459 | $TMP_DIR_OPTION \ |
Nicolas Geoffray | a73280d | 2016-02-15 13:05:16 +0000 | [diff] [blame] | 460 | -XX:DumpNativeStackOnSigQuit:false \ |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 461 | -cp $DEX_LOCATION/$TEST_NAME.jar$SECONDARY_DEX $MAIN $ARGS" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 462 | |
Andreas Gampe | 3ad5d5e | 2015-02-03 18:26:55 -0800 | [diff] [blame] | 463 | # Remove whitespace. |
| 464 | dex2oat_cmdline=$(echo $dex2oat_cmdline) |
| 465 | dalvikvm_cmdline=$(echo $dalvikvm_cmdline) |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 466 | |
| 467 | if [ "$HOST" = "n" ]; then |
| 468 | adb root > /dev/null |
| 469 | adb wait-for-device |
| 470 | if [ "$QUIET" = "n" ]; then |
| 471 | adb shell rm -r $DEX_LOCATION |
| 472 | adb shell mkdir -p $DEX_LOCATION |
| 473 | adb push $TEST_NAME.jar $DEX_LOCATION |
| 474 | adb push $TEST_NAME-ex.jar $DEX_LOCATION |
| 475 | else |
| 476 | adb shell rm -r $DEX_LOCATION >/dev/null 2>&1 |
| 477 | adb shell mkdir -p $DEX_LOCATION >/dev/null 2>&1 |
| 478 | adb push $TEST_NAME.jar $DEX_LOCATION >/dev/null 2>&1 |
| 479 | adb push $TEST_NAME-ex.jar $DEX_LOCATION >/dev/null 2>&1 |
| 480 | fi |
| 481 | |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 482 | LD_LIBRARY_PATH=/data/art-test/$ISA |
Nicolas Geoffray | eb441dd | 2014-10-31 15:34:50 +0000 | [diff] [blame] | 483 | if [ "$ANDROID_ROOT" != "/system" ]; then |
| 484 | # Current default installation is dalvikvm 64bits and dex2oat 32bits, |
| 485 | # so we can only use LD_LIBRARY_PATH when testing on a local |
| 486 | # installation. |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 487 | LD_LIBRARY_PATH=$ANDROID_ROOT/$LIBRARY_DIRECTORY:$LD_LIBRARY_PATH |
Nicolas Geoffray | eb441dd | 2014-10-31 15:34:50 +0000 | [diff] [blame] | 488 | fi |
| 489 | |
Dimitry Ivanov | 90d48f2 | 2016-05-05 17:24:28 -0700 | [diff] [blame] | 490 | PUBLIC_LIBS=libart.so:libartd.so |
| 491 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 492 | # Create a script with the command. The command can get longer than the longest |
| 493 | # allowed adb command and there is no way to get the exit status from a adb shell |
| 494 | # command. |
| 495 | cmdline="cd $DEX_LOCATION && \ |
| 496 | export ANDROID_DATA=$DEX_LOCATION && \ |
Dimitry Ivanov | 90d48f2 | 2016-05-05 17:24:28 -0700 | [diff] [blame] | 497 | export ANDROID_ADDITIONAL_PUBLIC_LIBRARIES=$PUBLIC_LIBS && \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 498 | export DEX_LOCATION=$DEX_LOCATION && \ |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 499 | export ANDROID_ROOT=$ANDROID_ROOT && \ |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 500 | mkdir -p ${mkdir_locations} && \ |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 501 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH && \ |
Nicolas Geoffray | 4f7fdd2 | 2015-04-24 11:57:37 +0100 | [diff] [blame] | 502 | export PATH=$ANDROID_ROOT/bin:$PATH && \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 503 | $dex2oat_cmdline && \ |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 504 | $strip_cmdline && \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 505 | $dalvikvm_cmdline" |
| 506 | |
| 507 | cmdfile=$(tempfile -p "cmd-" -s "-$TEST_NAME") |
| 508 | echo "$cmdline" > $cmdfile |
| 509 | |
| 510 | if [ "$DEV_MODE" = "y" ]; then |
| 511 | echo $cmdline |
| 512 | fi |
| 513 | |
| 514 | if [ "$QUIET" = "n" ]; then |
| 515 | adb push $cmdfile $DEX_LOCATION/cmdline.sh |
| 516 | else |
| 517 | adb push $cmdfile $DEX_LOCATION/cmdline.sh > /dev/null 2>&1 |
| 518 | fi |
| 519 | |
| 520 | adb shell sh $DEX_LOCATION/cmdline.sh |
| 521 | |
| 522 | rm -f $cmdfile |
| 523 | else |
| 524 | export ANDROID_PRINTF_LOG=brief |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 525 | |
| 526 | # By default, and for prebuild dex2oat, we are interested in errors being logged. In dev mode |
| 527 | # we want debug messages. |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 528 | if [ "$DEV_MODE" = "y" ]; then |
| 529 | export ANDROID_LOG_TAGS='*:d' |
| 530 | else |
Andreas Gampe | e4301ff | 2015-02-17 19:25:29 -0800 | [diff] [blame] | 531 | export ANDROID_LOG_TAGS='*:e' |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 532 | fi |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 533 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 534 | export ANDROID_DATA="$DEX_LOCATION" |
Nicolas Geoffray | 8eedb47 | 2014-10-29 14:05:59 +0000 | [diff] [blame] | 535 | export ANDROID_ROOT="${ANDROID_ROOT}" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 536 | export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib" |
| 537 | export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib" |
| 538 | export PATH="$PATH:${ANDROID_ROOT}/bin" |
| 539 | |
David Srbecky | c9ede38 | 2015-06-20 06:03:53 +0100 | [diff] [blame] | 540 | # Temporarily disable address space layout randomization (ASLR). |
| 541 | # This is needed on the host so that the linker loads core.oat at the necessary address. |
| 542 | export LD_USE_LOAD_BIAS=1 |
| 543 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 544 | cmdline="$dalvikvm_cmdline" |
| 545 | |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 546 | if [ "$TIME_OUT" = "gdb" ]; then |
| 547 | if [ `uname` = "Darwin" ]; then |
| 548 | # Fall back to timeout on Mac. |
| 549 | TIME_OUT="timeout" |
Hiroshi Yamauchi | c823eff | 2015-09-01 16:21:35 -0700 | [diff] [blame] | 550 | elif [ "$ISA" = "x86" ]; then |
| 551 | # prctl call may fail in 32-bit on an older (3.2) 64-bit Linux kernel. Fall back to timeout. |
| 552 | TIME_OUT="timeout" |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 553 | else |
| 554 | # Check if gdb is available. |
| 555 | gdb --eval-command="quit" > /dev/null 2>&1 |
| 556 | if [ $? != 0 ]; then |
| 557 | # gdb isn't available. Fall back to timeout. |
| 558 | TIME_OUT="timeout" |
| 559 | fi |
| 560 | fi |
| 561 | fi |
| 562 | |
| 563 | if [ "$TIME_OUT" = "timeout" ]; then |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 564 | # Add timeout command if time out is desired. |
Andreas Gampe | 038bb22 | 2015-01-13 19:48:14 -0800 | [diff] [blame] | 565 | # |
Andreas Gampe | 6fb9256 | 2016-08-01 21:53:57 -0700 | [diff] [blame] | 566 | # Note: We first send SIGRTMIN+2 (usually 36) to ART, which will induce a full thread dump |
| 567 | # before abort. However, dumping threads might deadlock, so we also use the "-k" |
| 568 | # option to definitely kill the child. |
| 569 | cmdline="timeout -k 120s -s SIGRTMIN+2 ${TIME_OUT_VALUE}s $cmdline" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 570 | fi |
| 571 | |
| 572 | if [ "$DEV_MODE" = "y" ]; then |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 573 | echo "mkdir -p ${mkdir_locations} && $dex2oat_cmdline && $strip_cmdline && $cmdline" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 574 | fi |
| 575 | |
| 576 | cd $ANDROID_BUILD_TOP |
| 577 | |
David Srbecky | 2e4afe8 | 2016-01-27 18:42:06 +0000 | [diff] [blame] | 578 | rm -rf ${DEX_LOCATION}/dalvik-cache/ |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 579 | mkdir -p ${mkdir_locations} || exit 1 |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 580 | $dex2oat_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; } |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 581 | $strip_cmdline || { echo "Strip failed." >&2 ; exit 3; } |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 582 | |
| 583 | # For running, we must turn off logging when dex2oat or patchoat are missing. Otherwise we use |
| 584 | # the same defaults as for prebuilt: everything when --dev, otherwise errors and above only. |
| 585 | if [ "$DEV_MODE" = "y" ]; then |
| 586 | export ANDROID_LOG_TAGS='*:d' |
| 587 | elif [ "$USE_DEX2OAT_AND_PATCHOAT" = "n" ]; then |
| 588 | # All tests would log the error of failing dex2oat/patchoat. Be silent here and only |
| 589 | # log fatal events. |
| 590 | export ANDROID_LOG_TAGS='*:s' |
| 591 | else |
| 592 | # We are interested in LOG(ERROR) output. |
| 593 | export ANDROID_LOG_TAGS='*:e' |
| 594 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 595 | |
| 596 | if [ "$USE_GDB" = "y" ]; then |
| 597 | # When running under gdb, we cannot do piping and grepping... |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 598 | $cmdline "$@" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 599 | else |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 600 | if [ "$TIME_OUT" != "gdb" ]; then |
| 601 | trap 'kill -INT -$pid' INT |
| 602 | $cmdline "$@" 2>&1 & pid=$! |
| 603 | wait $pid |
| 604 | # Add extra detail if time out is enabled. |
| 605 | if [ ${PIPESTATUS[0]} = 124 ] && [ "$TIME_OUT" = "timeout" ]; then |
| 606 | echo -e "\e[91mTEST TIMED OUT!\e[0m" >&2 |
| 607 | fi |
| 608 | else |
| 609 | # With a thread dump that uses gdb if a timeout. |
| 610 | trap 'kill -INT -$pid' INT |
| 611 | $cmdline "$@" 2>&1 & pid=$! |
| 612 | # Spawn a watcher process. |
| 613 | ( sleep $TIME_OUT_VALUE && \ |
| 614 | echo "##### Thread dump using gdb on test timeout" && \ |
| 615 | ( gdb -q -p $pid --eval-command="info thread" --eval-command="thread apply all bt" \ |
| 616 | --eval-command="call exit(124)" --eval-command=quit || \ |
| 617 | kill $pid )) 2> /dev/null & watcher=$! |
| 618 | wait $pid |
| 619 | test_exit_status=$? |
| 620 | pkill -P $watcher 2> /dev/null # kill the sleep which will in turn end the watcher as well |
| 621 | if [ $test_exit_status = 0 ]; then |
| 622 | # The test finished normally. |
| 623 | exit 0 |
| 624 | else |
| 625 | # The test failed or timed out. |
| 626 | if [ $test_exit_status = 124 ]; then |
| 627 | # The test timed out. |
| 628 | echo -e "\e[91mTEST TIMED OUT!\e[0m" >&2 |
| 629 | fi |
| 630 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 631 | fi |
| 632 | fi |
| 633 | fi |