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