Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Runner for an individual run-test. |
| 4 | |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 5 | # Check how many colors the terminal can display. |
| 6 | ncolors=$(tput colors 2>/dev/null) |
| 7 | |
| 8 | # Check that stdout is connected to a terminal and that we have at least 1 color. |
| 9 | # This ensures that if the stdout is not connected to a terminal and instead |
| 10 | # the stdout will be used for a log, it will not append the color characters. |
| 11 | if [[ -t 1 && ${ncolors} && ${ncolors} -ge 1 ]]; then |
| 12 | bold_red="$(tput bold)$(tput setaf 1)" |
| 13 | fi |
| 14 | |
| 15 | readonly bold_red |
| 16 | |
| 17 | error_msg() { |
| 18 | echo -e "${bold_red}ERROR: $@" 1>&2 |
| 19 | } |
| 20 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 21 | if [[ -z "$ANDROID_BUILD_TOP" ]]; then |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 22 | error_msg 'ANDROID_BUILD_TOP environment variable is empty; did you forget to run `lunch`?' |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 23 | exit 1 |
| 24 | fi |
| 25 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 26 | msg() { |
| 27 | if [ "$QUIET" = "n" ]; then |
| 28 | echo "$@" |
| 29 | fi |
| 30 | } |
| 31 | |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 32 | ANDROID_ROOT="/system" |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 33 | ANDROID_ART_ROOT="/apex/com.android.art" |
Victor Chang | 6461124 | 2019-07-05 16:32:41 +0100 | [diff] [blame] | 34 | ANDROID_I18N_ROOT="/apex/com.android.i18n" |
Neil Fuller | 26a5dd6 | 2019-03-13 15:16:35 +0000 | [diff] [blame] | 35 | ANDROID_TZDATA_ROOT="/apex/com.android.tzdata" |
Vladimir Marko | be0d3cf | 2020-02-12 10:52:22 +0000 | [diff] [blame] | 36 | ARCHITECTURES_32="(arm|x86|none)" |
| 37 | ARCHITECTURES_64="(arm64|x86_64|none)" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 38 | ARCHITECTURES_PATTERN="${ARCHITECTURES_32}" |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 39 | GET_DEVICE_ISA_BITNESS_FLAG="--32" |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 40 | BOOT_IMAGE="" |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 41 | CHROOT= |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 42 | COMPILE_FLAGS="" |
| 43 | DALVIKVM="dalvikvm32" |
| 44 | DEBUGGER="n" |
Alex Light | 54dabfb | 2018-09-19 16:29:09 -0700 | [diff] [blame] | 45 | WITH_AGENT=() |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 46 | DEBUGGER_AGENT="" |
| 47 | WRAP_DEBUGGER_AGENT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 48 | DEV_MODE="n" |
Nicolas Geoffray | b0c6cb5 | 2020-04-20 15:12:42 +0100 | [diff] [blame] | 49 | DEX2OAT_NDEBUG_BINARY="dex2oat32" |
| 50 | DEX2OAT_DEBUG_BINARY="dex2oatd32" |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 51 | EXPERIMENTAL="" |
Nicolas Geoffray | 90355fe | 2017-02-20 09:25:40 +0000 | [diff] [blame] | 52 | FALSE_BIN="false" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 53 | FLAGS="" |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 54 | ANDROID_FLAGS="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 55 | GDB="" |
Nicolas Geoffray | baf9102 | 2014-10-08 09:56:45 +0100 | [diff] [blame] | 56 | GDB_ARGS="" |
Stelios Ioannou | 816b0da | 2021-06-03 13:25:50 +0100 | [diff] [blame] | 57 | GDB_DEX2OAT="" |
| 58 | GDB_DEX2OAT_ARGS="" |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 59 | GDBSERVER_DEVICE="gdbserver" |
| 60 | GDBSERVER_HOST="gdbserver" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 61 | HAVE_IMAGE="y" |
| 62 | HOST="n" |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 63 | BIONIC="n" |
| 64 | CREATE_ANDROID_ROOT="n" |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 65 | USE_ZIPAPEX="n" |
| 66 | ZIPAPEX_LOC="" |
Alex Light | 6f342dd | 2019-03-27 17:15:42 +0000 | [diff] [blame] | 67 | USE_EXTRACTED_ZIPAPEX="n" |
| 68 | EXTRACTED_ZIPAPEX_LOC="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 69 | INTERPRETER="n" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 70 | JIT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 71 | INVOKE_WITH="" |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 72 | IS_JVMTI_TEST="n" |
Alex Light | 280e6c3 | 2020-03-03 13:52:07 -0800 | [diff] [blame] | 73 | ADD_LIBDIR_ARGUMENTS="n" |
Martin Stjernholm | 0d0f8df | 2021-04-28 16:47:01 +0100 | [diff] [blame] | 74 | SUFFIX64="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 75 | ISA=x86 |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 76 | LIBRARY_DIRECTORY="lib" |
Colin Cross | afd3c9e | 2016-09-16 13:47:21 -0700 | [diff] [blame] | 77 | TEST_DIRECTORY="nativetest" |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 78 | MAIN="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 79 | OPTIMIZE="y" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 80 | PREBUILD="y" |
| 81 | QUIET="n" |
Nicolas Geoffray | 94e25db | 2017-01-27 14:54:28 +0000 | [diff] [blame] | 82 | RELOCATE="n" |
Jeff Hao | 207a37d | 2014-10-29 17:24:25 -0700 | [diff] [blame] | 83 | SECONDARY_DEX="" |
David Srbecky | 352482c | 2019-10-16 15:59:52 +0100 | [diff] [blame] | 84 | TIME_OUT="n" # "n" (disabled), "timeout" (use timeout), "gdb" (use gdb) |
Andreas Gampe | 148c160 | 2019-06-10 16:47:46 -0700 | [diff] [blame] | 85 | TIMEOUT_DUMPER=signal_dumper |
Andreas Gampe | 6ad30a2 | 2019-09-12 15:12:36 -0700 | [diff] [blame] | 86 | # Values in seconds. |
Martin Stjernholm | cb497cf | 2019-09-27 18:42:55 +0100 | [diff] [blame] | 87 | TIME_OUT_EXTRA=0 |
Andreas Gampe | 6ad30a2 | 2019-09-12 15:12:36 -0700 | [diff] [blame] | 88 | TIME_OUT_VALUE= |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 89 | USE_GDB="n" |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 90 | USE_GDBSERVER="n" |
| 91 | GDBSERVER_PORT=":5039" |
Stelios Ioannou | 816b0da | 2021-06-03 13:25:50 +0100 | [diff] [blame] | 92 | USE_GDB_DEX2OAT="n" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 93 | USE_JVM="n" |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 94 | USE_JVMTI="n" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 95 | VERIFY="y" # y=yes,n=no,s=softfail |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 96 | ZYGOTE="" |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 97 | DEX_VERIFY="" |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 98 | INSTRUCTION_SET_FEATURES="" |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 99 | ARGS="" |
David Brazdil | feb2282 | 2019-02-13 21:25:57 +0000 | [diff] [blame] | 100 | VDEX_ARGS="" |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 101 | EXTERNAL_LOG_TAGS="n" # if y respect externally set ANDROID_LOG_TAGS. |
| 102 | DRY_RUN="n" # if y prepare to run the test but don't run it. |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 103 | TEST_VDEX="n" |
Nicolas Geoffray | 327cfcf | 2021-10-12 14:13:25 +0100 | [diff] [blame] | 104 | TEST_DEX2OAT_DM="n" |
| 105 | TEST_RUNTIME_DM="n" |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 106 | TEST_IS_NDEBUG="n" |
Calin Juravle | 857f058 | 2016-12-20 14:36:59 +0000 | [diff] [blame] | 107 | APP_IMAGE="y" |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 108 | SECONDARY_APP_IMAGE="y" |
| 109 | SECONDARY_CLASS_LOADER_CONTEXT="" |
| 110 | SECONDARY_COMPILATION="y" |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 111 | JVMTI_STRESS="n" |
Alex Light | c38c369 | 2017-06-27 15:45:14 -0700 | [diff] [blame] | 112 | JVMTI_STEP_STRESS="n" |
Alex Light | 43e935d | 2017-06-19 15:40:40 -0700 | [diff] [blame] | 113 | JVMTI_FIELD_STRESS="n" |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 114 | JVMTI_TRACE_STRESS="n" |
| 115 | JVMTI_REDEFINE_STRESS="n" |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 116 | PROFILE="n" |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 117 | RANDOM_PROFILE="n" |
Alex Light | 483208d | 2017-09-26 09:31:17 -0700 | [diff] [blame] | 118 | # The normal dex2oat timeout. |
Shubham Ajmera | f97cbd6 | 2017-10-11 10:00:57 -0700 | [diff] [blame] | 119 | DEX2OAT_TIMEOUT="300" # 5 mins |
Alex Light | 483208d | 2017-09-26 09:31:17 -0700 | [diff] [blame] | 120 | # The *hard* timeout where we really start trying to kill the dex2oat. |
Shubham Ajmera | f97cbd6 | 2017-10-11 10:00:57 -0700 | [diff] [blame] | 121 | DEX2OAT_RT_TIMEOUT="360" # 6 mins |
Alex Light | 8d94ddd | 2019-12-18 11:13:03 -0800 | [diff] [blame] | 122 | CREATE_RUNNER="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 123 | |
Igor Murashkin | 271a0f8 | 2017-02-14 21:14:17 +0000 | [diff] [blame] | 124 | # if "y", run 'sync' before dalvikvm to make sure all files from |
| 125 | # build step (e.g. dex2oat) were finished writing. |
| 126 | SYNC_BEFORE_RUN="n" |
| 127 | |
Andreas Gampe | 1c5b42f | 2017-06-15 18:20:45 -0700 | [diff] [blame] | 128 | # When running a debug build, we want to run with all checks. |
| 129 | ANDROID_FLAGS="${ANDROID_FLAGS} -XX:SlowDebug=true" |
Andreas Gampe | e8f74ca | 2018-01-02 09:26:16 -0800 | [diff] [blame] | 130 | # The same for dex2oatd, both prebuild and runtime-driven. |
| 131 | ANDROID_FLAGS="${ANDROID_FLAGS} -Xcompiler-option --runtime-arg -Xcompiler-option -XX:SlowDebug=true" |
| 132 | COMPILER_FLAGS="${COMPILER_FLAGS} --runtime-arg -XX:SlowDebug=true" |
Andreas Gampe | 1c5b42f | 2017-06-15 18:20:45 -0700 | [diff] [blame] | 133 | |
David Srbecky | 4fa07a5 | 2020-03-31 20:52:09 +0100 | [diff] [blame] | 134 | # Let the compiler and runtime know that we are running tests. |
| 135 | COMPILE_FLAGS="${COMPILE_FLAGS} --compile-art-test" |
Roland Levillain | b7724c4 | 2020-04-21 16:51:54 +0100 | [diff] [blame] | 136 | ANDROID_FLAGS="${ANDROID_FLAGS} -Xcompiler-option --compile-art-test" |
David Srbecky | 4fa07a5 | 2020-03-31 20:52:09 +0100 | [diff] [blame] | 137 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 138 | while true; do |
| 139 | if [ "x$1" = "x--quiet" ]; then |
| 140 | QUIET="y" |
| 141 | shift |
Alex Light | 483208d | 2017-09-26 09:31:17 -0700 | [diff] [blame] | 142 | elif [ "x$1" = "x--dex2oat-rt-timeout" ]; then |
| 143 | shift |
| 144 | if [ "x$1" = "x" ]; then |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 145 | error_msg "$0 missing argument to --dex2oat-rt-timeout" |
Alex Light | 483208d | 2017-09-26 09:31:17 -0700 | [diff] [blame] | 146 | exit 1 |
| 147 | fi |
| 148 | DEX2OAT_RT_TIMEOUT="$1" |
| 149 | shift |
| 150 | elif [ "x$1" = "x--dex2oat-timeout" ]; then |
| 151 | shift |
| 152 | if [ "x$1" = "x" ]; then |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 153 | error_msg "$0 missing argument to --dex2oat-timeout" |
Alex Light | 483208d | 2017-09-26 09:31:17 -0700 | [diff] [blame] | 154 | exit 1 |
| 155 | fi |
| 156 | DEX2OAT_TIMEOUT="$1" |
| 157 | shift |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 158 | elif [ "x$1" = "x--jvmti" ]; then |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 159 | USE_JVMTI="y" |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 160 | IS_JVMTI_TEST="y" |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 161 | # Secondary images block some tested behavior. |
| 162 | SECONDARY_APP_IMAGE="n" |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 163 | shift |
Alex Light | 280e6c3 | 2020-03-03 13:52:07 -0800 | [diff] [blame] | 164 | elif [ "x$1" = "x--add-libdir-argument" ]; then |
| 165 | ADD_LIBDIR_ARGUMENTS="y" |
| 166 | shift |
Alex Light | faf90b6 | 2016-08-12 14:43:48 -0700 | [diff] [blame] | 167 | elif [ "x$1" = "x-O" ]; then |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 168 | TEST_IS_NDEBUG="y" |
Alex Light | faf90b6 | 2016-08-12 14:43:48 -0700 | [diff] [blame] | 169 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 170 | elif [ "x$1" = "x--lib" ]; then |
| 171 | shift |
| 172 | if [ "x$1" = "x" ]; then |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 173 | error_msg "$0 missing argument to --lib" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 174 | exit 1 |
| 175 | fi |
| 176 | LIB="$1" |
| 177 | shift |
Alex Light | 97acf19 | 2016-03-17 09:59:38 -0700 | [diff] [blame] | 178 | elif [ "x$1" = "x--gc-stress" ]; then |
David Srbecky | 7021c13 | 2019-10-04 12:56:22 +0100 | [diff] [blame] | 179 | # Give an extra 20 mins if we are gc-stress. |
| 180 | TIME_OUT_EXTRA=$((${TIME_OUT_EXTRA} + 1200)) |
Alex Light | 97acf19 | 2016-03-17 09:59:38 -0700 | [diff] [blame] | 181 | shift |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 182 | elif [ "x$1" = "x--testlib" ]; then |
| 183 | shift |
| 184 | if [ "x$1" = "x" ]; then |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 185 | error_msg "$0 missing argument to --testlib" |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 186 | exit 1 |
| 187 | fi |
Mathieu Chartier | de286fd | 2015-09-03 18:10:29 -0700 | [diff] [blame] | 188 | ARGS="${ARGS} $1" |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 189 | shift |
David Srbecky | 5288611 | 2016-01-22 13:56:47 +0000 | [diff] [blame] | 190 | elif [ "x$1" = "x--args" ]; then |
| 191 | shift |
| 192 | if [ "x$1" = "x" ]; then |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 193 | error_msg "$0 missing argument to --args" |
David Srbecky | 5288611 | 2016-01-22 13:56:47 +0000 | [diff] [blame] | 194 | exit 1 |
| 195 | fi |
| 196 | ARGS="${ARGS} $1" |
| 197 | shift |
Alex Light | e2ddce3 | 2019-05-22 17:08:35 +0000 | [diff] [blame] | 198 | elif [ "x$1" = "x--compiler-only-option" ]; then |
| 199 | shift |
| 200 | option="$1" |
| 201 | COMPILE_FLAGS="${COMPILE_FLAGS} $option" |
| 202 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 203 | elif [ "x$1" = "x-Xcompiler-option" ]; then |
| 204 | shift |
| 205 | option="$1" |
| 206 | FLAGS="${FLAGS} -Xcompiler-option $option" |
| 207 | COMPILE_FLAGS="${COMPILE_FLAGS} $option" |
| 208 | shift |
Alex Light | 8d94ddd | 2019-12-18 11:13:03 -0800 | [diff] [blame] | 209 | elif [ "x$1" = "x--create-runner" ]; then |
| 210 | CREATE_RUNNER="y" |
| 211 | shift |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 212 | elif [ "x$1" = "x--android-runtime-option" ]; then |
| 213 | shift |
| 214 | option="$1" |
| 215 | ANDROID_FLAGS="${ANDROID_FLAGS} $option" |
| 216 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 217 | elif [ "x$1" = "x--runtime-option" ]; then |
| 218 | shift |
| 219 | option="$1" |
| 220 | FLAGS="${FLAGS} $option" |
Martin Stjernholm | cb497cf | 2019-09-27 18:42:55 +0100 | [diff] [blame] | 221 | if [ "x$option" = "x-Xmethod-trace" ]; then |
Martin Stjernholm | 3067710 | 2019-10-01 12:54:10 +0100 | [diff] [blame] | 222 | # Method tracing can slow some tests down a lot, in particular |
| 223 | # 530-checker-lse2. |
| 224 | TIME_OUT_EXTRA=$((${TIME_OUT_EXTRA} + 1200)) |
Martin Stjernholm | cb497cf | 2019-09-27 18:42:55 +0100 | [diff] [blame] | 225 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 226 | shift |
| 227 | elif [ "x$1" = "x--boot" ]; then |
| 228 | shift |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 229 | BOOT_IMAGE="$1" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 230 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 231 | elif [ "x$1" = "x--relocate" ]; then |
| 232 | RELOCATE="y" |
| 233 | shift |
| 234 | elif [ "x$1" = "x--no-relocate" ]; then |
| 235 | RELOCATE="n" |
| 236 | shift |
| 237 | elif [ "x$1" = "x--prebuild" ]; then |
| 238 | PREBUILD="y" |
| 239 | shift |
Mathieu Chartier | dcd56c9 | 2017-11-20 20:30:24 -0800 | [diff] [blame] | 240 | elif [ "x$1" = "x--compact-dex-level" ]; then |
| 241 | shift |
| 242 | COMPILE_FLAGS="${COMPILE_FLAGS} --compact-dex-level=$1" |
| 243 | shift |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 244 | elif [ "x$1" = "x--jvmti-redefine-stress" ]; then |
| 245 | # APP_IMAGE doesn't really work with jvmti redefine stress |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 246 | USE_JVMTI="y" |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 247 | APP_IMAGE="n" |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 248 | SECONDARY_APP_IMAGE="n" |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 249 | JVMTI_STRESS="y" |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 250 | JVMTI_REDEFINE_STRESS="y" |
| 251 | shift |
Alex Light | c38c369 | 2017-06-27 15:45:14 -0700 | [diff] [blame] | 252 | elif [ "x$1" = "x--jvmti-step-stress" ]; then |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 253 | USE_JVMTI="y" |
Alex Light | c38c369 | 2017-06-27 15:45:14 -0700 | [diff] [blame] | 254 | JVMTI_STRESS="y" |
| 255 | JVMTI_STEP_STRESS="y" |
| 256 | shift |
Alex Light | 43e935d | 2017-06-19 15:40:40 -0700 | [diff] [blame] | 257 | elif [ "x$1" = "x--jvmti-field-stress" ]; then |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 258 | USE_JVMTI="y" |
Alex Light | 43e935d | 2017-06-19 15:40:40 -0700 | [diff] [blame] | 259 | JVMTI_STRESS="y" |
| 260 | JVMTI_FIELD_STRESS="y" |
| 261 | shift |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 262 | elif [ "x$1" = "x--jvmti-trace-stress" ]; then |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 263 | USE_JVMTI="y" |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 264 | JVMTI_STRESS="y" |
| 265 | JVMTI_TRACE_STRESS="y" |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 266 | shift |
Calin Juravle | 857f058 | 2016-12-20 14:36:59 +0000 | [diff] [blame] | 267 | elif [ "x$1" = "x--no-app-image" ]; then |
| 268 | APP_IMAGE="n" |
| 269 | shift |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 270 | elif [ "x$1" = "x--no-secondary-app-image" ]; then |
| 271 | SECONDARY_APP_IMAGE="n" |
| 272 | shift |
| 273 | elif [ "x$1" = "x--secondary-class-loader-context" ]; then |
| 274 | shift |
| 275 | SECONDARY_CLASS_LOADER_CONTEXT="$1" |
| 276 | shift |
| 277 | elif [ "x$1" = "x--no-secondary-compilation" ]; then |
| 278 | SECONDARY_COMPILATION="n" |
| 279 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 280 | elif [ "x$1" = "x--host" ]; then |
| 281 | HOST="y" |
Roland Levillain | b59f5fb | 2020-02-19 16:22:48 +0000 | [diff] [blame] | 282 | ANDROID_ROOT="${ANDROID_HOST_OUT}" |
| 283 | ANDROID_ART_ROOT="${ANDROID_HOST_OUT}/com.android.art" |
| 284 | ANDROID_I18N_ROOT="${ANDROID_HOST_OUT}/com.android.i18n" |
| 285 | ANDROID_TZDATA_ROOT="${ANDROID_HOST_OUT}/com.android.tzdata" |
Nicolas Geoffray | b0c6cb5 | 2020-04-20 15:12:42 +0100 | [diff] [blame] | 286 | # On host, we default to using the symlink, as the PREFER_32BIT |
| 287 | # configuration is the only configuration building a 32bit version of |
| 288 | # dex2oat. |
| 289 | DEX2OAT_DEBUG_BINARY="dex2oatd" |
| 290 | DEX2OAT_NDEBUG_BINARY="dex2oat" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 291 | shift |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 292 | elif [ "x$1" = "x--bionic" ]; then |
| 293 | BIONIC="y" |
| 294 | # We need to create an ANDROID_ROOT because currently we cannot create |
| 295 | # the frameworks/libcore with linux_bionic so we need to use the normal |
| 296 | # host ones which are in a different location. |
| 297 | CREATE_ANDROID_ROOT="y" |
| 298 | shift |
Alex Light | 6f342dd | 2019-03-27 17:15:42 +0000 | [diff] [blame] | 299 | elif [ "x$1" = "x--runtime-extracted-zipapex" ]; then |
| 300 | shift |
| 301 | USE_EXTRACTED_ZIPAPEX="y" |
| 302 | EXTRACTED_ZIPAPEX_LOC="$1" |
| 303 | shift |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 304 | elif [ "x$1" = "x--runtime-zipapex" ]; then |
| 305 | shift |
| 306 | USE_ZIPAPEX="y" |
| 307 | ZIPAPEX_LOC="$1" |
Alex Light | 907001d | 2019-01-17 00:16:04 +0000 | [diff] [blame] | 308 | # TODO (b/119942078): Currently apex does not support |
| 309 | # symlink_preferred_arch so we will not have a dex2oatd to execute and |
| 310 | # need to manually provide |
| 311 | # dex2oatd64. |
| 312 | DEX2OAT_DEBUG_BINARY="dex2oatd64" |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 313 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 314 | elif [ "x$1" = "x--no-prebuild" ]; then |
| 315 | PREBUILD="n" |
| 316 | shift |
| 317 | elif [ "x$1" = "x--no-image" ]; then |
| 318 | HAVE_IMAGE="n" |
| 319 | shift |
Jeff Hao | 207a37d | 2014-10-29 17:24:25 -0700 | [diff] [blame] | 320 | elif [ "x$1" = "x--secondary" ]; then |
| 321 | SECONDARY_DEX=":$DEX_LOCATION/$TEST_NAME-ex.jar" |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 322 | # Enable cfg-append to make sure we get the dump for both dex files. |
| 323 | # (otherwise the runtime compilation of the secondary dex will overwrite |
Roland Levillain | b0103ca | 2016-11-01 14:48:47 +0000 | [diff] [blame] | 324 | # the dump of the first one). |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 325 | FLAGS="${FLAGS} -Xcompiler-option --dump-cfg-append" |
| 326 | COMPILE_FLAGS="${COMPILE_FLAGS} --dump-cfg-append" |
Jeff Hao | 207a37d | 2014-10-29 17:24:25 -0700 | [diff] [blame] | 327 | shift |
Alex Light | 0e151e7 | 2017-10-25 10:50:35 -0700 | [diff] [blame] | 328 | elif [ "x$1" = "x--with-agent" ]; then |
| 329 | shift |
| 330 | USE_JVMTI="y" |
Alex Light | 54dabfb | 2018-09-19 16:29:09 -0700 | [diff] [blame] | 331 | WITH_AGENT+=("$1") |
Alex Light | 0e151e7 | 2017-10-25 10:50:35 -0700 | [diff] [blame] | 332 | shift |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 333 | elif [ "x$1" = "x--debug-wrap-agent" ]; then |
| 334 | WRAP_DEBUGGER_AGENT="y" |
| 335 | shift |
| 336 | elif [ "x$1" = "x--debug-agent" ]; then |
| 337 | shift |
| 338 | DEBUGGER="agent" |
| 339 | USE_JVMTI="y" |
| 340 | DEBUGGER_AGENT="$1" |
| 341 | TIME_OUT="n" |
| 342 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 343 | elif [ "x$1" = "x--debug" ]; then |
Alex Light | fc58809 | 2020-01-23 15:39:08 -0800 | [diff] [blame] | 344 | USE_JVMTI="y" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 345 | DEBUGGER="y" |
Brian Carlstrom | 93d6ce5 | 2014-11-04 22:31:35 -0800 | [diff] [blame] | 346 | TIME_OUT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 347 | shift |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 348 | elif [ "x$1" = "x--gdbserver-port" ]; then |
| 349 | shift |
| 350 | GDBSERVER_PORT=$1 |
| 351 | shift |
| 352 | elif [ "x$1" = "x--gdbserver-bin" ]; then |
| 353 | shift |
| 354 | GDBSERVER_HOST=$1 |
| 355 | GDBSERVER_DEVICE=$1 |
| 356 | shift |
| 357 | elif [ "x$1" = "x--gdbserver" ]; then |
| 358 | USE_GDBSERVER="y" |
| 359 | DEV_MODE="y" |
| 360 | TIME_OUT="n" |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 361 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 362 | elif [ "x$1" = "x--gdb" ]; then |
| 363 | USE_GDB="y" |
| 364 | DEV_MODE="y" |
Brian Carlstrom | 93d6ce5 | 2014-11-04 22:31:35 -0800 | [diff] [blame] | 365 | TIME_OUT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 366 | shift |
Mathieu Chartier | c0a8a80 | 2014-10-17 15:58:01 -0700 | [diff] [blame] | 367 | elif [ "x$1" = "x--gdb-arg" ]; then |
| 368 | shift |
| 369 | gdb_arg="$1" |
| 370 | GDB_ARGS="${GDB_ARGS} $gdb_arg" |
| 371 | shift |
Stelios Ioannou | 816b0da | 2021-06-03 13:25:50 +0100 | [diff] [blame] | 372 | elif [ "x$1" = "x--gdb-dex2oat" ]; then |
| 373 | USE_GDB_DEX2OAT="y" |
| 374 | DEV_MODE="y" |
| 375 | TIME_OUT="n" |
| 376 | shift |
| 377 | elif [ "x$1" = "x--gdb-dex2oat-args" ]; then |
| 378 | shift |
| 379 | for arg in $(echo $1 | tr ";" " "); do |
| 380 | GDB_DEX2OAT_ARGS+="$arg " |
| 381 | done |
| 382 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 383 | elif [ "x$1" = "x--zygote" ]; then |
| 384 | ZYGOTE="-Xzygote" |
| 385 | msg "Spawning from zygote" |
| 386 | shift |
| 387 | elif [ "x$1" = "x--dev" ]; then |
| 388 | DEV_MODE="y" |
| 389 | shift |
| 390 | elif [ "x$1" = "x--interpreter" ]; then |
| 391 | INTERPRETER="y" |
| 392 | shift |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 393 | elif [ "x$1" = "x--jit" ]; then |
| 394 | JIT="y" |
| 395 | shift |
Nicolas Geoffray | acc56ac | 2018-10-09 08:45:24 +0100 | [diff] [blame] | 396 | elif [ "x$1" = "x--baseline" ]; then |
| 397 | FLAGS="${FLAGS} -Xcompiler-option --baseline" |
Nicolas Geoffray | 9b195cc | 2019-04-02 08:29:00 +0100 | [diff] [blame] | 398 | COMPILE_FLAGS="${COMPILE_FLAGS} --baseline" |
Nicolas Geoffray | acc56ac | 2018-10-09 08:45:24 +0100 | [diff] [blame] | 399 | shift |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 400 | elif [ "x$1" = "x--jvm" ]; then |
| 401 | USE_JVM="y" |
| 402 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 403 | elif [ "x$1" = "x--invoke-with" ]; then |
| 404 | shift |
| 405 | if [ "x$1" = "x" ]; then |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 406 | error_msg "$0 missing argument to --invoke-with" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 407 | exit 1 |
| 408 | fi |
| 409 | if [ "x$INVOKE_WITH" = "x" ]; then |
| 410 | INVOKE_WITH="$1" |
| 411 | else |
| 412 | INVOKE_WITH="$INVOKE_WITH $1" |
| 413 | fi |
| 414 | shift |
| 415 | elif [ "x$1" = "x--no-verify" ]; then |
| 416 | VERIFY="n" |
| 417 | shift |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 418 | elif [ "x$1" = "x--verify-soft-fail" ]; then |
| 419 | VERIFY="s" |
| 420 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 421 | elif [ "x$1" = "x--no-optimize" ]; then |
| 422 | OPTIMIZE="n" |
| 423 | shift |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 424 | elif [ "x$1" = "x--chroot" ]; then |
| 425 | shift |
| 426 | CHROOT="$1" |
| 427 | shift |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 428 | elif [ "x$1" = "x--android-root" ]; then |
| 429 | shift |
| 430 | ANDROID_ROOT="$1" |
| 431 | shift |
Victor Chang | 6461124 | 2019-07-05 16:32:41 +0100 | [diff] [blame] | 432 | elif [ "x$1" = "x--android-i18n-root" ]; then |
| 433 | shift |
| 434 | ANDROID_I18N_ROOT="$1" |
| 435 | shift |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 436 | elif [ "x$1" = "x--android-art-root" ]; then |
Roland Levillain | 2807614 | 2019-01-10 16:39:25 +0000 | [diff] [blame] | 437 | shift |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 438 | ANDROID_ART_ROOT="$1" |
Roland Levillain | 2807614 | 2019-01-10 16:39:25 +0000 | [diff] [blame] | 439 | shift |
Neil Fuller | 26a5dd6 | 2019-03-13 15:16:35 +0000 | [diff] [blame] | 440 | elif [ "x$1" = "x--android-tzdata-root" ]; then |
| 441 | shift |
| 442 | ANDROID_TZDATA_ROOT="$1" |
| 443 | shift |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 444 | elif [ "x$1" = "x--instruction-set-features" ]; then |
| 445 | shift |
| 446 | INSTRUCTION_SET_FEATURES="$1" |
| 447 | shift |
Mathieu Chartier | 2576be2 | 2016-05-24 10:24:53 -0700 | [diff] [blame] | 448 | elif [ "x$1" = "x--timeout" ]; then |
| 449 | shift |
| 450 | TIME_OUT_VALUE="$1" |
| 451 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 452 | elif [ "x$1" = "x--" ]; then |
| 453 | shift |
| 454 | break |
| 455 | elif [ "x$1" = "x--64" ]; then |
Martin Stjernholm | 0d0f8df | 2021-04-28 16:47:01 +0100 | [diff] [blame] | 456 | SUFFIX64="64" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 457 | ISA="x86_64" |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 458 | GDBSERVER_DEVICE="gdbserver64" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 459 | DALVIKVM="dalvikvm64" |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 460 | LIBRARY_DIRECTORY="lib64" |
Colin Cross | afd3c9e | 2016-09-16 13:47:21 -0700 | [diff] [blame] | 461 | TEST_DIRECTORY="nativetest64" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 462 | ARCHITECTURES_PATTERN="${ARCHITECTURES_64}" |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 463 | GET_DEVICE_ISA_BITNESS_FLAG="--64" |
Nicolas Geoffray | b0c6cb5 | 2020-04-20 15:12:42 +0100 | [diff] [blame] | 464 | DEX2OAT_NDEBUG_BINARY="dex2oat64" |
| 465 | DEX2OAT_DEBUG_BINARY="dex2oatd64" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 466 | shift |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 467 | elif [ "x$1" = "x--experimental" ]; then |
| 468 | if [ "$#" -lt 2 ]; then |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 469 | error_msg "missing --experimental option" |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 470 | exit 1 |
| 471 | fi |
| 472 | EXPERIMENTAL="$EXPERIMENTAL $2" |
| 473 | shift 2 |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 474 | elif [ "x$1" = "x--external-log-tags" ]; then |
| 475 | EXTERNAL_LOG_TAGS="y" |
| 476 | shift |
| 477 | elif [ "x$1" = "x--dry-run" ]; then |
| 478 | DRY_RUN="y" |
| 479 | shift |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 480 | elif [ "x$1" = "x--vdex" ]; then |
| 481 | TEST_VDEX="y" |
| 482 | shift |
Nicolas Geoffray | 327cfcf | 2021-10-12 14:13:25 +0100 | [diff] [blame] | 483 | elif [ "x$1" = "x--dex2oat-dm" ]; then |
| 484 | TEST_DEX2OAT_DM="y" |
| 485 | shift |
| 486 | elif [ "x$1" = "x--runtime-dm" ]; then |
| 487 | TEST_RUNTIME_DM="y" |
Nicolas Geoffray | baeaa9b | 2018-01-26 14:31:17 +0000 | [diff] [blame] | 488 | shift |
Nicolas Geoffray | 7498105 | 2017-01-16 17:54:09 +0000 | [diff] [blame] | 489 | elif [ "x$1" = "x--vdex-filter" ]; then |
| 490 | shift |
| 491 | option="$1" |
David Brazdil | feb2282 | 2019-02-13 21:25:57 +0000 | [diff] [blame] | 492 | VDEX_ARGS="${VDEX_ARGS} --compiler-filter=$option" |
| 493 | shift |
| 494 | elif [ "x$1" = "x--vdex-arg" ]; then |
| 495 | shift |
| 496 | VDEX_ARGS="${VDEX_ARGS} $1" |
Nicolas Geoffray | 7498105 | 2017-01-16 17:54:09 +0000 | [diff] [blame] | 497 | shift |
Igor Murashkin | 271a0f8 | 2017-02-14 21:14:17 +0000 | [diff] [blame] | 498 | elif [ "x$1" = "x--sync" ]; then |
| 499 | SYNC_BEFORE_RUN="y" |
| 500 | shift |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 501 | elif [ "x$1" = "x--profile" ]; then |
| 502 | PROFILE="y" |
| 503 | shift |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 504 | elif [ "x$1" = "x--random-profile" ]; then |
| 505 | RANDOM_PROFILE="y" |
| 506 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 507 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 508 | error_msg "unknown $0 option: $1" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 509 | exit 1 |
| 510 | else |
| 511 | break |
| 512 | fi |
| 513 | done |
| 514 | |
Roland Levillain | b59f5fb | 2020-02-19 16:22:48 +0000 | [diff] [blame] | 515 | # HACK: Force the use of `signal_dumper` on host. |
Roland Levillain | 505e56b | 2019-11-20 08:49:24 +0000 | [diff] [blame] | 516 | if [[ "$HOST" = "y" ]]; then |
| 517 | TIME_OUT="timeout" |
| 518 | fi |
| 519 | |
Andreas Gampe | 6ad30a2 | 2019-09-12 15:12:36 -0700 | [diff] [blame] | 520 | # If you change this, update the timeout in testrunner.py as well. |
| 521 | if [ -z "$TIME_OUT_VALUE" ] ; then |
| 522 | # 10 minutes is the default. |
| 523 | TIME_OUT_VALUE=600 |
| 524 | |
| 525 | # For sanitized builds use a larger base. |
| 526 | # TODO: Consider sanitized target builds? |
| 527 | if [ "x$SANITIZE_HOST" != "x" ] ; then |
| 528 | TIME_OUT_VALUE=1500 # 25 minutes. |
| 529 | fi |
| 530 | |
Martin Stjernholm | cb497cf | 2019-09-27 18:42:55 +0100 | [diff] [blame] | 531 | TIME_OUT_VALUE=$((${TIME_OUT_VALUE} + ${TIME_OUT_EXTRA})) |
Andreas Gampe | 6ad30a2 | 2019-09-12 15:12:36 -0700 | [diff] [blame] | 532 | fi |
| 533 | |
Andreas Gampe | 29bfb0c | 2019-09-12 15:17:43 -0700 | [diff] [blame] | 534 | # Escape hatch for slow hosts or devices. Accept an environment variable as a timeout factor. |
| 535 | if [ ! -z "$ART_TIME_OUT_MULTIPLIER" ] ; then |
Martin Stjernholm | 82e61e9 | 2019-09-30 02:43:18 +0000 | [diff] [blame] | 536 | TIME_OUT_VALUE=$((${TIME_OUT_VALUE} * ${ART_TIME_OUT_MULTIPLIER})) |
Andreas Gampe | 29bfb0c | 2019-09-12 15:17:43 -0700 | [diff] [blame] | 537 | fi |
| 538 | |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 539 | # The DEX_LOCATION with the chroot prefix, if any. |
| 540 | CHROOT_DEX_LOCATION="$CHROOT$DEX_LOCATION" |
| 541 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 542 | # If running on device, determine the ISA of the device. |
Roland Levillain | b7724c4 | 2020-04-21 16:51:54 +0100 | [diff] [blame] | 543 | if [ "$HOST" = "n" -a "$USE_JVM" = "n" ]; then |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 544 | ISA=$("$ANDROID_BUILD_TOP/art/test/utils/get-device-isa" "$GET_DEVICE_ISA_BITNESS_FLAG") |
| 545 | fi |
| 546 | |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 547 | if [ "$USE_JVM" = "n" ]; then |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 548 | FLAGS="${FLAGS} ${ANDROID_FLAGS}" |
Alex Light | baac7e4 | 2018-06-08 15:30:11 +0000 | [diff] [blame] | 549 | # we don't want to be trying to get adbconnections since the plugin might |
| 550 | # not have been built. |
| 551 | FLAGS="${FLAGS} -XjdwpProvider:none" |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 552 | for feature in ${EXPERIMENTAL}; do |
Alex Light | fa02285 | 2015-10-28 09:13:20 -0700 | [diff] [blame] | 553 | FLAGS="${FLAGS} -Xexperimental:${feature} -Xcompiler-option --runtime-arg -Xcompiler-option -Xexperimental:${feature}" |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 554 | COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xexperimental:${feature}" |
| 555 | done |
| 556 | fi |
| 557 | |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 558 | if [ "$CREATE_ANDROID_ROOT" = "y" ]; then |
| 559 | ANDROID_ROOT=$DEX_LOCATION/android-root |
| 560 | fi |
| 561 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 562 | if [ "x$1" = "x" ] ; then |
| 563 | MAIN="Main" |
| 564 | else |
| 565 | MAIN="$1" |
Andreas Gampe | f2fdc73 | 2014-06-11 08:20:47 -0700 | [diff] [blame] | 566 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 567 | fi |
| 568 | |
| 569 | if [ "$ZYGOTE" = "" ]; then |
| 570 | if [ "$OPTIMIZE" = "y" ]; then |
| 571 | if [ "$VERIFY" = "y" ]; then |
| 572 | DEX_OPTIMIZE="-Xdexopt:verified" |
| 573 | else |
| 574 | DEX_OPTIMIZE="-Xdexopt:all" |
| 575 | fi |
| 576 | msg "Performing optimizations" |
| 577 | else |
| 578 | DEX_OPTIMIZE="-Xdexopt:none" |
| 579 | msg "Skipping optimizations" |
| 580 | fi |
| 581 | |
| 582 | if [ "$VERIFY" = "y" ]; then |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 583 | JVM_VERIFY_ARG="-Xverify:all" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 584 | msg "Performing verification" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 585 | elif [ "$VERIFY" = "s" ]; then |
| 586 | JVM_VERIFY_ARG="Xverify:all" |
| 587 | DEX_VERIFY="-Xverify:softfail" |
| 588 | msg "Forcing verification to be soft fail" |
| 589 | else # VERIFY = "n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 590 | DEX_VERIFY="-Xverify:none" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 591 | JVM_VERIFY_ARG="-Xverify:none" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 592 | msg "Skipping verification" |
| 593 | fi |
| 594 | fi |
| 595 | |
| 596 | msg "------------------------------" |
| 597 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 598 | if [ "$DEBUGGER" = "y" ]; then |
| 599 | # Use this instead for ddms and connect by running 'ddms': |
Alex Light | fc58809 | 2020-01-23 15:39:08 -0800 | [diff] [blame] | 600 | # DEBUGGER_OPTS="-XjdwpOptions=server=y,suspend=y -XjdwpProvider:adbconnection" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 601 | # TODO: add a separate --ddms option? |
| 602 | |
| 603 | PORT=12345 |
| 604 | msg "Waiting for jdb to connect:" |
| 605 | if [ "$HOST" = "n" ]; then |
| 606 | msg " adb forward tcp:$PORT tcp:$PORT" |
| 607 | fi |
| 608 | msg " jdb -attach localhost:$PORT" |
Alex Light | 264a486 | 2018-01-31 16:47:58 +0000 | [diff] [blame] | 609 | if [ "$USE_JVM" = "n" ]; then |
Alex Light | fc58809 | 2020-01-23 15:39:08 -0800 | [diff] [blame] | 610 | # Use the default libjdwp agent. Use --debug-agent to use a custom one. |
| 611 | DEBUGGER_OPTS="-agentpath:libjdwp.so=transport=dt_socket,address=$PORT,server=y,suspend=y -XjdwpProvider:internal" |
Alex Light | 264a486 | 2018-01-31 16:47:58 +0000 | [diff] [blame] | 612 | else |
| 613 | DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y" |
| 614 | fi |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 615 | elif [ "$DEBUGGER" = "agent" ]; then |
| 616 | PORT=12345 |
| 617 | # TODO Support ddms connection and support target. |
| 618 | if [ "$HOST" = "n" ]; then |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 619 | error_msg "--debug-agent not supported yet for target!" |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 620 | exit 1 |
| 621 | fi |
| 622 | AGENTPATH=${DEBUGGER_AGENT} |
| 623 | if [ "$WRAP_DEBUGGER_AGENT" = "y" ]; then |
| 624 | WRAPPROPS="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}/libwrapagentpropertiesd.so" |
| 625 | if [ "$TEST_IS_NDEBUG" = "y" ]; then |
| 626 | WRAPPROPS="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}/libwrapagentproperties.so" |
| 627 | fi |
| 628 | AGENTPATH="${WRAPPROPS}=${ANDROID_BUILD_TOP}/art/tools/libjdwp-compat.props,${AGENTPATH}" |
| 629 | fi |
| 630 | msg "Connect to localhost:$PORT" |
| 631 | DEBUGGER_OPTS="-agentpath:${AGENTPATH}=transport=dt_socket,address=$PORT,server=y,suspend=y" |
| 632 | fi |
| 633 | |
Alex Light | 54dabfb | 2018-09-19 16:29:09 -0700 | [diff] [blame] | 634 | for agent in "${WITH_AGENT[@]}"; do |
| 635 | FLAGS="${FLAGS} -agentpath:${agent}" |
| 636 | done |
Alex Light | 0e151e7 | 2017-10-25 10:50:35 -0700 | [diff] [blame] | 637 | |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 638 | if [ "$USE_JVMTI" = "y" ]; then |
| 639 | if [ "$USE_JVM" = "n" ]; then |
| 640 | plugin=libopenjdkjvmtid.so |
| 641 | if [[ "$TEST_IS_NDEBUG" = "y" ]]; then |
| 642 | plugin=libopenjdkjvmti.so |
| 643 | fi |
Alex Light | 2ce6fc8 | 2017-12-18 16:42:36 -0800 | [diff] [blame] | 644 | # We used to add flags here that made the runtime debuggable but that is not |
| 645 | # needed anymore since the plugin can do it for us now. |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 646 | FLAGS="${FLAGS} -Xplugin:${plugin}" |
Mythri Alle | f0d8b44 | 2021-11-03 17:28:24 +0000 | [diff] [blame^] | 647 | |
| 648 | # For jvmti tests, set the threshold of compilation to 0, so we jit on the first |
| 649 | # use to provide better test coverage for jvmti + jit. This means we won't run |
| 650 | # the default --jit configuration but it is not too important test scenario for |
| 651 | # jvmti tests. This is art specific flag, so don't use it with jvm. |
| 652 | FLAGS="${FLAGS} -Xjitthreshold:0" |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 653 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 654 | fi |
| 655 | |
Alex Light | 280e6c3 | 2020-03-03 13:52:07 -0800 | [diff] [blame] | 656 | # Add the libdir to the argv passed to the main function. |
| 657 | if [ "$ADD_LIBDIR_ARGUMENTS" = "y" ]; then |
| 658 | if [[ "$HOST" = "y" ]]; then |
| 659 | ARGS="${ARGS} ${ANDROID_HOST_OUT}/${TEST_DIRECTORY}/" |
| 660 | else |
| 661 | ARGS="${ARGS} /data/${TEST_DIRECTORY}/art/${ISA}/" |
| 662 | fi |
| 663 | fi |
Alex Light | fba89fe | 2017-01-12 16:11:02 -0800 | [diff] [blame] | 664 | if [ "$IS_JVMTI_TEST" = "y" ]; then |
Alex Light | fba89fe | 2017-01-12 16:11:02 -0800 | [diff] [blame] | 665 | agent=libtiagentd.so |
| 666 | lib=tiagentd |
| 667 | if [[ "$TEST_IS_NDEBUG" = "y" ]]; then |
| 668 | agent=libtiagent.so |
Alex Light | fba89fe | 2017-01-12 16:11:02 -0800 | [diff] [blame] | 669 | lib=tiagent |
| 670 | fi |
| 671 | |
| 672 | ARGS="${ARGS} ${lib}" |
| 673 | if [[ "$USE_JVM" = "y" ]]; then |
| 674 | FLAGS="${FLAGS} -agentpath:${ANDROID_HOST_OUT}/nativetest64/${agent}=${TEST_NAME},jvm" |
| 675 | else |
Martin Stjernholm | 0d0f8df | 2021-04-28 16:47:01 +0100 | [diff] [blame] | 676 | FLAGS="${FLAGS} -agentpath:${agent}=${TEST_NAME},art" |
Alex Light | fba89fe | 2017-01-12 16:11:02 -0800 | [diff] [blame] | 677 | fi |
| 678 | fi |
| 679 | |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 680 | if [[ "$JVMTI_STRESS" = "y" ]]; then |
Alex Light | 42151c0 | 2017-04-20 15:54:25 -0700 | [diff] [blame] | 681 | agent=libtistressd.so |
| 682 | if [[ "$TEST_IS_NDEBUG" = "y" ]]; then |
| 683 | agent=libtistress.so |
Alex Light | 42151c0 | 2017-04-20 15:54:25 -0700 | [diff] [blame] | 684 | fi |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 685 | |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 686 | # Just give it a default start so we can always add ',' to it. |
| 687 | agent_args="jvmti-stress" |
| 688 | if [[ "$JVMTI_REDEFINE_STRESS" = "y" ]]; then |
| 689 | # We really cannot do this on RI so don't both passing it in that case. |
| 690 | if [[ "$USE_JVM" = "n" ]]; then |
Alex Light | ceae954 | 2017-09-07 13:28:00 -0700 | [diff] [blame] | 691 | agent_args="${agent_args},redefine" |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 692 | fi |
| 693 | fi |
Alex Light | 43e935d | 2017-06-19 15:40:40 -0700 | [diff] [blame] | 694 | if [[ "$JVMTI_FIELD_STRESS" = "y" ]]; then |
| 695 | agent_args="${agent_args},field" |
| 696 | fi |
Alex Light | c38c369 | 2017-06-27 15:45:14 -0700 | [diff] [blame] | 697 | if [[ "$JVMTI_STEP_STRESS" = "y" ]]; then |
| 698 | agent_args="${agent_args},step" |
| 699 | fi |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 700 | if [[ "$JVMTI_TRACE_STRESS" = "y" ]]; then |
| 701 | agent_args="${agent_args},trace" |
| 702 | fi |
| 703 | # In the future add onto this; |
Alex Light | 42151c0 | 2017-04-20 15:54:25 -0700 | [diff] [blame] | 704 | if [[ "$USE_JVM" = "y" ]]; then |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 705 | FLAGS="${FLAGS} -agentpath:${ANDROID_HOST_OUT}/nativetest64/${agent}=${agent_args}" |
Alex Light | 42151c0 | 2017-04-20 15:54:25 -0700 | [diff] [blame] | 706 | else |
Martin Stjernholm | 0d0f8df | 2021-04-28 16:47:01 +0100 | [diff] [blame] | 707 | FLAGS="${FLAGS} -agentpath:${agent}=${agent_args}" |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 708 | fi |
| 709 | fi |
| 710 | |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 711 | if [ "$USE_JVM" = "y" ]; then |
Alex Light | 9c20a14 | 2016-08-23 15:05:12 -0700 | [diff] [blame] | 712 | export LD_LIBRARY_PATH=${ANDROID_HOST_OUT}/lib64 |
Alex Light | 47d49b8 | 2017-07-25 14:06:34 -0700 | [diff] [blame] | 713 | # Some jvmti tests are flaky without -Xint on the RI. |
| 714 | if [ "$IS_JVMTI_TEST" = "y" ]; then |
| 715 | FLAGS="${FLAGS} -Xint" |
| 716 | fi |
Mathieu Chartier | a61894d | 2015-04-23 16:32:54 -0700 | [diff] [blame] | 717 | # Xmx is necessary since we don't pass down the ART flags to JVM. |
Vladimir Marko | c5798bf | 2016-12-09 10:20:54 +0000 | [diff] [blame] | 718 | # We pass the classes2 path whether it's used (src-multidex) or not. |
| 719 | cmdline="${JAVA} ${DEBUGGER_OPTS} ${JVM_VERIFY_ARG} -Xmx256m -classpath classes:classes2 ${FLAGS} $MAIN $@ ${ARGS}" |
Andreas Gampe | 3f1dc56 | 2015-05-18 15:52:22 -0700 | [diff] [blame] | 720 | if [ "$DEV_MODE" = "y" ]; then |
| 721 | echo $cmdline |
| 722 | fi |
Alex Light | 8d94ddd | 2019-12-18 11:13:03 -0800 | [diff] [blame] | 723 | if [ "$CREATE_RUNNER" = "y" ]; then |
| 724 | echo "#!/bin/bash" > runit.sh |
| 725 | echo "export LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"" |
Roland Levillain | b15e879 | 2020-10-28 12:20:59 +0000 | [diff] [blame] | 726 | echo $cmdline >> runit.sh |
Alex Light | 8d94ddd | 2019-12-18 11:13:03 -0800 | [diff] [blame] | 727 | chmod u+x runit.sh |
| 728 | echo "Runnable test script written to $PWD/runit.sh" |
| 729 | else |
| 730 | $cmdline |
| 731 | fi |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 732 | exit |
| 733 | fi |
| 734 | |
Vladimir Marko | 0ace563 | 2018-12-14 11:11:47 +0000 | [diff] [blame] | 735 | # Note: This must start with the CORE_IMG_JARS in Android.common_path.mk |
David Srbecky | 6355d69 | 2020-03-26 14:10:26 +0000 | [diff] [blame] | 736 | # because that's what we use for compiling the boot.art image. |
Vladimir Marko | 0ace563 | 2018-12-14 11:11:47 +0000 | [diff] [blame] | 737 | # It may contain additional modules from TEST_CORE_JARS. |
Victor Chang | d20e51d | 2020-05-05 16:01:19 +0100 | [diff] [blame] | 738 | bpath_modules="core-oj core-libart okhttp bouncycastle apache-xml core-icu4j conscrypt" |
Nicolas Geoffray | 31e0dc2 | 2020-03-20 15:48:09 +0000 | [diff] [blame] | 739 | bpath="" |
| 740 | bpath_locations="" |
| 741 | bpath_separator="" |
David Srbecky | 928d28e | 2020-04-01 17:50:51 +0100 | [diff] [blame] | 742 | bpath_prefix="" |
| 743 | bpath_location_prefix="" |
Ulya Trafimovich | 5439f05 | 2020-07-29 10:03:46 +0100 | [diff] [blame] | 744 | if [ "${HOST}" = "y" ]; then |
David Srbecky | 928d28e | 2020-04-01 17:50:51 +0100 | [diff] [blame] | 745 | bpath_prefix="${ANDROID_HOST_OUT}" |
| 746 | if [ "${ANDROID_HOST_OUT:0:${#ANDROID_BUILD_TOP}+1}" = "${ANDROID_BUILD_TOP}/" ]; then |
| 747 | bpath_location_prefix="${ANDROID_HOST_OUT:${#ANDROID_BUILD_TOP}+1}" |
| 748 | else |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 749 | error_msg "ANDROID_BUILD_TOP/ is not a prefix of ANDROID_HOST_OUT"\ |
| 750 | "\nANDROID_BUILD_TOP=${ANDROID_BUILD_TOP}"\ |
| 751 | "\nANDROID_HOST_OUT=${ANDROID_HOST_OUT}" |
David Srbecky | 928d28e | 2020-04-01 17:50:51 +0100 | [diff] [blame] | 752 | exit |
| 753 | fi |
Vladimir Marko | 7a85e70 | 2018-12-03 18:47:23 +0000 | [diff] [blame] | 754 | fi |
David Srbecky | 928d28e | 2020-04-01 17:50:51 +0100 | [diff] [blame] | 755 | for bpath_module in ${bpath_modules}; do |
| 756 | apex_module="com.android.art" |
| 757 | case "$bpath_module" in |
| 758 | (conscrypt) apex_module="com.android.conscrypt";; |
| 759 | (core-icu4j) apex_module="com.android.i18n";; |
| 760 | (*) apex_module="com.android.art";; |
| 761 | esac |
| 762 | bpath_jar="/apex/${apex_module}/javalib/${bpath_module}.jar" |
| 763 | bpath+="${bpath_separator}${bpath_prefix}${bpath_jar}" |
| 764 | bpath_locations+="${bpath_separator}${bpath_location_prefix}${bpath_jar}" |
| 765 | bpath_separator=":" |
| 766 | done |
Vladimir Marko | 7a85e70 | 2018-12-03 18:47:23 +0000 | [diff] [blame] | 767 | # Pass down the bootclasspath |
| 768 | FLAGS="${FLAGS} -Xbootclasspath:${bpath}" |
| 769 | FLAGS="${FLAGS} -Xbootclasspath-locations:${bpath_locations}" |
| 770 | COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xbootclasspath:${bpath}" |
| 771 | COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xbootclasspath-locations:${bpath_locations}" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 772 | |
| 773 | if [ "$HAVE_IMAGE" = "n" ]; then |
Andreas Gampe | 1078d15 | 2017-11-07 18:00:54 -0800 | [diff] [blame] | 774 | # Disable image dex2oat - this will forbid the runtime to patch or compile an image. |
| 775 | FLAGS="${FLAGS} -Xnoimage-dex2oat" |
| 776 | |
| 777 | # We'll abuse a second flag here to test different behavior. If --relocate, use the |
| 778 | # existing image - relocation will fail as patching is disallowed. If --no-relocate, |
| 779 | # pass a non-existent image - compilation will fail as dex2oat is disallowed. |
| 780 | if [ "${RELOCATE}" = "y" ] ; then |
| 781 | DALVIKVM_BOOT_OPT="-Ximage:${BOOT_IMAGE}" |
| 782 | else |
David Srbecky | 6355d69 | 2020-03-26 14:10:26 +0000 | [diff] [blame] | 783 | DALVIKVM_BOOT_OPT="-Ximage:/system/non-existent/boot.art" |
Andreas Gampe | 1078d15 | 2017-11-07 18:00:54 -0800 | [diff] [blame] | 784 | fi |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 785 | else |
| 786 | DALVIKVM_BOOT_OPT="-Ximage:${BOOT_IMAGE}" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 787 | fi |
| 788 | |
Stelios Ioannou | 816b0da | 2021-06-03 13:25:50 +0100 | [diff] [blame] | 789 | if [ "$USE_GDB_DEX2OAT" = "y" ]; then |
| 790 | if [ "$HOST" = "n" ]; then |
| 791 | echo "The --gdb-dex2oat option is not yet implemented for target." >&2 |
| 792 | exit 1 |
| 793 | fi |
| 794 | fi |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 795 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 796 | if [ "$USE_GDB" = "y" ]; then |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 797 | if [ "$USE_GDBSERVER" = "y" ]; then |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 798 | error_msg "Cannot pass both --gdb and --gdbserver at the same time!" |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 799 | exit 1 |
| 800 | elif [ "$HOST" = "n" ]; then |
Alex Light | 219420e | 2019-12-05 10:20:26 -0800 | [diff] [blame] | 801 | # We might not have any hostname resolution if we are using a chroot. |
| 802 | GDB="$GDBSERVER_DEVICE --no-startup-with-shell 127.0.0.1$GDBSERVER_PORT" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 803 | else |
| 804 | if [ `uname` = "Darwin" ]; then |
| 805 | GDB=lldb |
Mathieu Chartier | c0a8a80 | 2014-10-17 15:58:01 -0700 | [diff] [blame] | 806 | GDB_ARGS="$GDB_ARGS -- $DALVIKVM" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 807 | DALVIKVM= |
| 808 | else |
| 809 | GDB=gdb |
Mathieu Chartier | c0a8a80 | 2014-10-17 15:58:01 -0700 | [diff] [blame] | 810 | GDB_ARGS="$GDB_ARGS --args $DALVIKVM" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 811 | # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line. |
| 812 | # gdbargs="--annotate=3 $gdbargs" |
| 813 | fi |
| 814 | fi |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 815 | elif [ "$USE_GDBSERVER" = "y" ]; then |
| 816 | if [ "$HOST" = "n" ]; then |
Alex Light | 219420e | 2019-12-05 10:20:26 -0800 | [diff] [blame] | 817 | # We might not have any hostname resolution if we are using a chroot. |
| 818 | GDB="$GDBSERVER_DEVICE --no-startup-with-shell 127.0.0.1$GDBSERVER_PORT" |
| 819 | else |
| 820 | GDB="$GDBSERVER_HOST $GDBSERVER_PORT" |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 821 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 822 | fi |
| 823 | |
| 824 | if [ "$INTERPRETER" = "y" ]; then |
Nicolas Geoffray | a5ca8eb | 2018-08-24 13:39:13 +0100 | [diff] [blame] | 825 | INT_OPTS="${INT_OPTS} -Xint" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 826 | fi |
| 827 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 828 | if [ "$JIT" = "y" ]; then |
Nicolas Geoffray | a5ca8eb | 2018-08-24 13:39:13 +0100 | [diff] [blame] | 829 | INT_OPTS="${INT_OPTS} -Xusejit:true" |
Nicolas Geoffray | a5ca8eb | 2018-08-24 13:39:13 +0100 | [diff] [blame] | 830 | else |
| 831 | INT_OPTS="${INT_OPTS} -Xusejit:false" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 832 | fi |
| 833 | |
Nicolas Geoffray | c76fbf0 | 2021-04-06 08:59:17 +0100 | [diff] [blame] | 834 | if [ "$INTERPRETER" = "y" ] || [ "$JIT" = "y" ]; then |
| 835 | if [ "$VERIFY" = "y" ] ; then |
| 836 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=verify" |
| 837 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify" |
| 838 | elif [ "$VERIFY" = "s" ]; then |
| 839 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=extract" |
| 840 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=extract" |
| 841 | DEX_VERIFY="${DEX_VERIFY} -Xverify:softfail" |
| 842 | else # VERIFY = "n" |
| 843 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=assume-verified" |
| 844 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=assume-verified" |
| 845 | DEX_VERIFY="${DEX_VERIFY} -Xverify:none" |
| 846 | fi |
| 847 | fi |
| 848 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 849 | JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni" |
| 850 | |
Richard Uhler | 020c0f3 | 2017-03-14 16:23:17 +0000 | [diff] [blame] | 851 | COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xnorelocate" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 852 | if [ "$RELOCATE" = "y" ]; then |
Richard Uhler | c52f303 | 2017-03-02 13:45:45 +0000 | [diff] [blame] | 853 | FLAGS="${FLAGS} -Xrelocate" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 854 | else |
| 855 | FLAGS="$FLAGS -Xnorelocate" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 856 | fi |
| 857 | |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 858 | if [ "$BIONIC" = "y" ]; then |
| 859 | # This is the location that soong drops linux_bionic builds. Despite being |
| 860 | # called linux_bionic-x86 the build is actually amd64 (x86_64) only. |
| 861 | if [ ! -e "$OUT_DIR/soong/host/linux_bionic-x86" ]; then |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 862 | error_msg "linux_bionic-x86 target doesn't seem to have been built!" |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 863 | exit 1 |
| 864 | fi |
Andreas Gampe | 148c160 | 2019-06-10 16:47:46 -0700 | [diff] [blame] | 865 | # Set TIMEOUT_DUMPER manually so it works even with apex's |
| 866 | TIMEOUT_DUMPER=$OUT_DIR/soong/host/linux_bionic-x86/bin/signal_dumper |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 867 | fi |
| 868 | |
Wojciech Staszkiewicz | e663653 | 2016-09-23 10:59:55 -0700 | [diff] [blame] | 869 | # Prevent test from silently falling back to interpreter in no-prebuild mode. This happens |
| 870 | # when DEX_LOCATION path is too long, because vdex/odex filename is constructed by taking |
| 871 | # full path to dex, stripping leading '/', appending '@classes.vdex' and changing every |
| 872 | # remaining '/' into '@'. |
| 873 | if [ "$HOST" = "y" ]; then |
| 874 | max_filename_size=$(getconf NAME_MAX $DEX_LOCATION) |
| 875 | else |
Roland Levillain | 2ae376f | 2018-01-30 11:35:11 +0000 | [diff] [blame] | 876 | # There is no getconf on device, fallback to standard value. |
| 877 | # See NAME_MAX in kernel <linux/limits.h> |
Wojciech Staszkiewicz | e663653 | 2016-09-23 10:59:55 -0700 | [diff] [blame] | 878 | max_filename_size=255 |
| 879 | fi |
| 880 | # Compute VDEX_NAME. |
| 881 | DEX_LOCATION_STRIPPED="${DEX_LOCATION#/}" |
| 882 | VDEX_NAME="${DEX_LOCATION_STRIPPED//\//@}@$TEST_NAME.jar@classes.vdex" |
| 883 | if [ ${#VDEX_NAME} -gt $max_filename_size ]; then |
Nicolas Geoffray | bea3e31 | 2017-03-07 09:59:05 +0000 | [diff] [blame] | 884 | echo "Dex location path too long:" |
Stelios Ioannou | 3a014e3 | 2021-06-25 15:15:32 +0100 | [diff] [blame] | 885 | error_msg "$VDEX_NAME is ${#VDEX_NAME} character long, and the limit is $max_filename_size." |
Wojciech Staszkiewicz | e663653 | 2016-09-23 10:59:55 -0700 | [diff] [blame] | 886 | exit 1 |
| 887 | fi |
| 888 | |
Ulya Trafimovich | 5439f05 | 2020-07-29 10:03:46 +0100 | [diff] [blame] | 889 | if [ "$HOST" = "y" ]; then |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 890 | # On host, run binaries (`dex2oat(d)`, `dalvikvm`, `profman`) from the `bin` |
| 891 | # directory under the "Android Root" (usually `out/host/linux-x86`). |
| 892 | # |
| 893 | # TODO(b/130295968): Adjust this if/when ART host artifacts are installed |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 894 | # under the ART root (usually `out/host/linux-x86/com.android.art`). |
| 895 | ANDROID_ART_BIN_DIR=$ANDROID_ROOT/bin |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 896 | else |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 897 | # On target, run binaries (`dex2oat(d)`, `dalvikvm`, `profman`) from the ART |
| 898 | # APEX's `bin` directory. This means the linker will observe the ART APEX |
| 899 | # linker configuration file (`/apex/com.android.art/etc/ld.config.txt`) for |
| 900 | # these binaries. |
| 901 | ANDROID_ART_BIN_DIR=$ANDROID_ART_ROOT/bin |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 902 | fi |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 903 | |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 904 | profman_cmdline="true" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 905 | dex2oat_cmdline="true" |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 906 | vdex_cmdline="true" |
Nicolas Geoffray | baeaa9b | 2018-01-26 14:31:17 +0000 | [diff] [blame] | 907 | dm_cmdline="true" |
Andreas Gampe | b09abb2 | 2018-05-03 11:51:22 -0700 | [diff] [blame] | 908 | mkdir_locations="${DEX_LOCATION}/dalvik-cache/$ISA" |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 909 | strip_cmdline="true" |
Igor Murashkin | 271a0f8 | 2017-02-14 21:14:17 +0000 | [diff] [blame] | 910 | sync_cmdline="true" |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 911 | linkroot_cmdline="true" |
| 912 | linkroot_overlay_cmdline="true" |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 913 | setupapex_cmdline="true" |
| 914 | installapex_cmdline="true" |
Alex Light | 5e1ffcd | 2021-03-31 16:46:02 -0700 | [diff] [blame] | 915 | installapex_test_cmdline="true" |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 916 | |
| 917 | linkdirs() { |
| 918 | find "$1" -maxdepth 1 -mindepth 1 -type d | xargs -i ln -sf '{}' "$2" |
Nicolas Geoffray | ea55f3d | 2021-09-07 12:16:56 +0100 | [diff] [blame] | 919 | # Also create a link for the boot image. |
| 920 | ln -sf $ANDROID_HOST_OUT/apex/art_boot_images "$2" |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 921 | } |
| 922 | |
| 923 | if [ "$CREATE_ANDROID_ROOT" = "y" ]; then |
| 924 | mkdir_locations="${mkdir_locations} ${ANDROID_ROOT}" |
| 925 | linkroot_cmdline="linkdirs ${ANDROID_HOST_OUT} ${ANDROID_ROOT}" |
| 926 | if [ "${BIONIC}" = "y" ]; then |
| 927 | # TODO Make this overlay more generic. |
| 928 | linkroot_overlay_cmdline="linkdirs $OUT_DIR/soong/host/linux_bionic-x86 ${ANDROID_ROOT}" |
| 929 | fi |
Nicolas Geoffray | ea55f3d | 2021-09-07 12:16:56 +0100 | [diff] [blame] | 930 | # Replace the boot image to a location expected by the runtime. |
| 931 | DALVIKVM_BOOT_OPT="-Ximage:${ANDROID_ROOT}/art_boot_images/javalib/boot.art" |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 932 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 933 | |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 934 | if [ "$USE_ZIPAPEX" = "y" ]; then |
| 935 | # TODO Currently this only works for linux_bionic zipapexes because those are |
| 936 | # stripped and so small enough that the ulimit doesn't kill us. |
| 937 | mkdir_locations="${mkdir_locations} $DEX_LOCATION/zipapex" |
| 938 | zip_options="-qq" |
| 939 | if [ "$DEV_MODE" = "y" ]; then |
| 940 | zip_options="" |
| 941 | fi |
Alex Light | fc52ffc | 2019-01-31 15:48:18 -0800 | [diff] [blame] | 942 | setupapex_cmdline="unzip -o -u ${zip_options} ${ZIPAPEX_LOC} apex_payload.zip -d ${DEX_LOCATION}" |
| 943 | installapex_cmdline="unzip -o -u ${zip_options} ${DEX_LOCATION}/apex_payload.zip -d ${DEX_LOCATION}/zipapex" |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 944 | ANDROID_ART_BIN_DIR=$DEX_LOCATION/zipapex/bin |
Alex Light | 6f342dd | 2019-03-27 17:15:42 +0000 | [diff] [blame] | 945 | elif [ "$USE_EXTRACTED_ZIPAPEX" = "y" ]; then |
| 946 | # Just symlink the zipapex binaries |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 947 | ANDROID_ART_BIN_DIR=$DEX_LOCATION/zipapex/bin |
Alex Light | 6f342dd | 2019-03-27 17:15:42 +0000 | [diff] [blame] | 948 | # Force since some tests manually run this file twice. |
| 949 | ln_options="" |
| 950 | if [ "$DEV_MODE" = "y" ]; then |
| 951 | ln_options="--verbose" |
| 952 | fi |
Alex Light | 5e1ffcd | 2021-03-31 16:46:02 -0700 | [diff] [blame] | 953 | # If the ${RUN} is executed multiple times we don't need to recreate the link |
| 954 | installapex_test_cmdline="test -L ${DEX_LOCATION}/zipapex" |
Alex Light | 6f342dd | 2019-03-27 17:15:42 +0000 | [diff] [blame] | 955 | installapex_cmdline="ln -s -f ${ln_options} ${EXTRACTED_ZIPAPEX_LOC} ${DEX_LOCATION}/zipapex" |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 956 | fi |
| 957 | |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 958 | # PROFILE takes precedence over RANDOM_PROFILE, since PROFILE tests require a |
| 959 | # specific profile to run properly. |
| 960 | if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 961 | profman_cmdline="$ANDROID_ART_BIN_DIR/profman \ |
Nicolas Geoffray | 0b6a638 | 2017-03-10 09:38:35 +0000 | [diff] [blame] | 962 | --apk=$DEX_LOCATION/$TEST_NAME.jar \ |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 963 | --dex-location=$DEX_LOCATION/$TEST_NAME.jar" |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 964 | if [ -f "$TEST_NAME-ex.jar" ] && [ "$SECONDARY_COMPILATION" = "y" ] ; then |
Calin Juravle | 6df62f7 | 2017-04-28 19:58:01 -0700 | [diff] [blame] | 965 | profman_cmdline="${profman_cmdline} \ |
| 966 | --apk=$DEX_LOCATION/$TEST_NAME-ex.jar \ |
| 967 | --dex-location=$DEX_LOCATION/$TEST_NAME-ex.jar" |
| 968 | fi |
Nicolas Geoffray | 0b6a638 | 2017-03-10 09:38:35 +0000 | [diff] [blame] | 969 | COMPILE_FLAGS="${COMPILE_FLAGS} --profile-file=$DEX_LOCATION/$TEST_NAME.prof" |
| 970 | FLAGS="${FLAGS} -Xcompiler-option --profile-file=$DEX_LOCATION/$TEST_NAME.prof" |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 971 | if [ "$PROFILE" = "y" ]; then |
| 972 | profman_cmdline="${profman_cmdline} --create-profile-from=$DEX_LOCATION/profile \ |
| 973 | --reference-profile-file=$DEX_LOCATION/$TEST_NAME.prof" |
| 974 | else |
| 975 | profman_cmdline="${profman_cmdline} --generate-test-profile=$DEX_LOCATION/$TEST_NAME.prof \ |
| 976 | --generate-test-profile-seed=0" |
| 977 | fi |
Nicolas Geoffray | 0b6a638 | 2017-03-10 09:38:35 +0000 | [diff] [blame] | 978 | fi |
| 979 | |
Stelios Ioannou | 816b0da | 2021-06-03 13:25:50 +0100 | [diff] [blame] | 980 | function get_prebuilt_lldb_path { |
| 981 | local CLANG_BASE="prebuilts/clang/host" |
| 982 | local CLANG_VERSION="$("$ANDROID_BUILD_TOP/build/soong/scripts/get_clang_version.py")" |
| 983 | case "$(uname -s)" in |
| 984 | Darwin) |
| 985 | local PREBUILT_NAME="darwin-x86" |
| 986 | ;; |
| 987 | Linux) |
| 988 | local PREBUILT_NAME="linux-x86" |
| 989 | ;; |
| 990 | *) |
| 991 | >&2 echo "Unknown host $(uname -s). Unsupported for debugging dex2oat with LLDB." |
| 992 | return |
| 993 | ;; |
| 994 | esac |
| 995 | local CLANG_PREBUILT_HOST_PATH="$ANDROID_BUILD_TOP/$CLANG_BASE/$PREBUILT_NAME/$CLANG_VERSION" |
| 996 | # If the clang prebuilt directory exists and the reported clang version |
| 997 | # string does not, then it is likely that the clang version reported by the |
| 998 | # get_clang_version.py script does not match the expected directory name. |
| 999 | if [ -d "${ANDROID_BUILD_TOP}/${CLANG_BASE}/${PREBUILT_NAME}" ] && \ |
| 1000 | [ ! -d "${CLANG_PREBUILT_HOST_PATH}" ]; then |
| 1001 | error_msg "The prebuilt clang directory exists, but the specific clang"\ |
| 1002 | "\nversion reported by get_clang_version.py does not exist in that path."\ |
| 1003 | "\nPlease make sure that the reported clang version resides in the"\ |
| 1004 | "\nprebuilt clang directory!" |
| 1005 | exit 1 |
| 1006 | fi |
| 1007 | |
| 1008 | # The lldb-server binary is a dependency of lldb. |
| 1009 | export LLDB_DEBUGSERVER_PATH="${CLANG_PREBUILT_HOST_PATH}/runtimes_ndk_cxx/x86_64/lldb-server" |
| 1010 | |
| 1011 | # Set the current terminfo directory to TERMINFO so that LLDB can read the |
| 1012 | # termcap database. |
| 1013 | local terminfo_regexp_path='\/.*\/*terminfo\/' |
| 1014 | if [[ $(infocmp) =~ $terminfo_regexp_path ]] ; then |
| 1015 | export TERMINFO="${BASH_REMATCH[0]}" |
| 1016 | fi |
| 1017 | |
| 1018 | prebuilt_lldb_path="$CLANG_PREBUILT_HOST_PATH/bin/lldb.sh" |
| 1019 | } |
| 1020 | |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1021 | function write_dex2oat_cmdlines { |
| 1022 | local name="$1" |
David Srbecky | b0ec679 | 2020-02-06 20:18:17 +0000 | [diff] [blame] | 1023 | |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1024 | local class_loader_context="" |
| 1025 | local enable_app_image=false |
Calin Juravle | 857f058 | 2016-12-20 14:36:59 +0000 | [diff] [blame] | 1026 | if [ "$APP_IMAGE" = "y" ]; then |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1027 | enable_app_image=true |
Calin Juravle | 857f058 | 2016-12-20 14:36:59 +0000 | [diff] [blame] | 1028 | fi |
| 1029 | |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1030 | # If the name ends in -ex then this is a secondary dex file |
| 1031 | if [ "${name:${#name}-3}" = "-ex" ]; then |
| 1032 | # Lazily realize the default value in case DEX_LOCATION/TEST_NAME change |
Vladimir Marko | ae96c82 | 2021-10-13 13:02:26 +0100 | [diff] [blame] | 1033 | if [ "x$SECONDARY_CLASS_LOADER_CONTEXT" = "x" ]; then |
| 1034 | if [ "x$SECONDARY_DEX" = "x" ]; then |
| 1035 | # Tests without `--secondary` load the "-ex" jar in a separate PathClassLoader |
| 1036 | # that is a child of the main PathClassLoader. If the class loader is constructed |
| 1037 | # in any other way, the test needs to specify the secondary CLC explicitly. |
| 1038 | SECONDARY_CLASS_LOADER_CONTEXT="PCL[];PCL[$DEX_LOCATION/$TEST_NAME.jar]" |
| 1039 | else |
| 1040 | # Tests with `--secondary` load the `-ex` jar a part of the main PathClassLoader. |
| 1041 | SECONDARY_CLASS_LOADER_CONTEXT="PCL[$DEX_LOCATION/$TEST_NAME.jar]" |
| 1042 | fi |
| 1043 | fi |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1044 | class_loader_context="'--class-loader-context=$SECONDARY_CLASS_LOADER_CONTEXT'" |
| 1045 | $enable_app_image && [ "$SECONDARY_APP_IMAGE" = "y" ] || enable_app_image=false |
| 1046 | fi |
| 1047 | |
| 1048 | local app_image="" |
| 1049 | $enable_app_image && app_image="--app-image-file=$DEX_LOCATION/oat/$ISA/$name.art --resolve-startup-const-strings=true" |
| 1050 | |
Stelios Ioannou | 816b0da | 2021-06-03 13:25:50 +0100 | [diff] [blame] | 1051 | if [ "$USE_GDB_DEX2OAT" = "y" ]; then |
| 1052 | get_prebuilt_lldb_path |
| 1053 | GDB_DEX2OAT="$prebuilt_lldb_path -f" |
| 1054 | GDB_DEX2OAT_ARGS+=" -- " |
| 1055 | fi |
| 1056 | |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1057 | local dex2oat_binary |
Alex Light | 907001d | 2019-01-17 00:16:04 +0000 | [diff] [blame] | 1058 | dex2oat_binary=${DEX2OAT_DEBUG_BINARY} |
Roland Levillain | 6c3af16 | 2017-04-27 11:18:56 +0100 | [diff] [blame] | 1059 | if [[ "$TEST_IS_NDEBUG" = "y" ]]; then |
Alex Light | 907001d | 2019-01-17 00:16:04 +0000 | [diff] [blame] | 1060 | dex2oat_binary=${DEX2OAT_NDEBUG_BINARY} |
Roland Levillain | 6c3af16 | 2017-04-27 11:18:56 +0100 | [diff] [blame] | 1061 | fi |
Stelios Ioannou | 816b0da | 2021-06-03 13:25:50 +0100 | [diff] [blame] | 1062 | dex2oat_cmdline="$INVOKE_WITH $GDB_DEX2OAT \ |
| 1063 | $ANDROID_ART_BIN_DIR/$dex2oat_binary \ |
| 1064 | $GDB_DEX2OAT_ARGS \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1065 | $COMPILE_FLAGS \ |
Nicolas Geoffray | 68e25eb | 2014-10-29 23:02:11 +0000 | [diff] [blame] | 1066 | --boot-image=${BOOT_IMAGE} \ |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1067 | --dex-file=$DEX_LOCATION/$name.jar \ |
| 1068 | --oat-file=$DEX_LOCATION/oat/$ISA/$name.odex \ |
| 1069 | "$app_image" \ |
David Srbecky | 87712da | 2020-01-17 15:50:02 +0000 | [diff] [blame] | 1070 | --generate-mini-debug-info \ |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1071 | --instruction-set=$ISA \ |
| 1072 | $class_loader_context" |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 1073 | if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then |
| 1074 | dex2oat_cmdline="${dex2oat_cmdline} --instruction-set-features=${INSTRUCTION_SET_FEATURES}" |
| 1075 | fi |
Andreas Gampe | 2ea7b70 | 2015-08-07 08:07:16 -0700 | [diff] [blame] | 1076 | |
| 1077 | # Add in a timeout. This is important for testing the compilation/verification time of |
Stelios Ioannou | 816b0da | 2021-06-03 13:25:50 +0100 | [diff] [blame] | 1078 | # pathological cases. We do not append a timeout when debugging dex2oat because we |
| 1079 | # do not want it to exit while debugging. |
Andreas Gampe | 2ea7b70 | 2015-08-07 08:07:16 -0700 | [diff] [blame] | 1080 | # Note: as we don't know how decent targets are (e.g., emulator), only do this on the host for |
| 1081 | # now. We should try to improve this. |
| 1082 | # The current value is rather arbitrary. run-tests should compile quickly. |
Alex Light | 483208d | 2017-09-26 09:31:17 -0700 | [diff] [blame] | 1083 | # Watchdog timeout is in milliseconds so add 3 '0's to the dex2oat timeout. |
Stelios Ioannou | 816b0da | 2021-06-03 13:25:50 +0100 | [diff] [blame] | 1084 | if [ "$HOST" != "n" ] && [ "$USE_GDB_DEX2OAT" != "y" ]; then |
Andreas Gampe | 2ea7b70 | 2015-08-07 08:07:16 -0700 | [diff] [blame] | 1085 | # Use SIGRTMIN+2 to try to dump threads. |
| 1086 | # Use -k 1m to SIGKILL it a minute later if it hasn't ended. |
Alex Light | 483208d | 2017-09-26 09:31:17 -0700 | [diff] [blame] | 1087 | dex2oat_cmdline="timeout -k ${DEX2OAT_TIMEOUT}s -s SIGRTMIN+2 ${DEX2OAT_RT_TIMEOUT}s ${dex2oat_cmdline} --watchdog-timeout=${DEX2OAT_TIMEOUT}000" |
Andreas Gampe | 2ea7b70 | 2015-08-07 08:07:16 -0700 | [diff] [blame] | 1088 | fi |
Nicolas Geoffray | fbc4f11 | 2017-04-27 21:45:35 +0100 | [diff] [blame] | 1089 | if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1090 | vdex_cmdline="${dex2oat_cmdline} ${VDEX_ARGS} --input-vdex=$DEX_LOCATION/oat/$ISA/$name.vdex --output-vdex=$DEX_LOCATION/oat/$ISA/$name.vdex" |
Nicolas Geoffray | fbc4f11 | 2017-04-27 21:45:35 +0100 | [diff] [blame] | 1091 | elif [ "$TEST_VDEX" = "y" ]; then |
Nicolas Geoffray | c6c6a15 | 2021-03-01 13:51:22 +0000 | [diff] [blame] | 1092 | if [ "$VDEX_ARGS" = "" ]; then |
| 1093 | # If no arguments need to be passed, just delete the odex file so that the runtime only picks up the vdex file. |
| 1094 | vdex_cmdline="rm $DEX_LOCATION/oat/$ISA/$name.odex" |
| 1095 | else |
| 1096 | vdex_cmdline="${dex2oat_cmdline} ${VDEX_ARGS} --input-vdex=$DEX_LOCATION/oat/$ISA/$name.vdex" |
| 1097 | fi |
Nicolas Geoffray | 327cfcf | 2021-10-12 14:13:25 +0100 | [diff] [blame] | 1098 | elif [ "$TEST_DEX2OAT_DM" = "y" ]; then |
| 1099 | vdex_cmdline="${dex2oat_cmdline} ${VDEX_ARGS} --dump-timings --dm-file=$DEX_LOCATION/oat/$ISA/$name.dm" |
Calin Juravle | 046cecf | 2020-12-07 18:31:28 -0800 | [diff] [blame] | 1100 | dex2oat_cmdline="${dex2oat_cmdline} --copy-dex-files=false --output-vdex=$DEX_LOCATION/oat/$ISA/primary.vdex" |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1101 | dm_cmdline="zip -qj $DEX_LOCATION/oat/$ISA/$name.dm $DEX_LOCATION/oat/$ISA/primary.vdex" |
Nicolas Geoffray | 327cfcf | 2021-10-12 14:13:25 +0100 | [diff] [blame] | 1102 | elif [ "$TEST_RUNTIME_DM" = "y" ]; then |
| 1103 | dex2oat_cmdline="${dex2oat_cmdline} --copy-dex-files=false --output-vdex=$DEX_LOCATION/oat/$ISA/primary.vdex" |
| 1104 | dm_cmdline="zip -qj $DEX_LOCATION/$name.dm $DEX_LOCATION/oat/$ISA/primary.vdex" |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1105 | fi |
| 1106 | } |
| 1107 | |
| 1108 | # Enable mini-debug-info for JIT (if JIT is used). |
| 1109 | FLAGS="$FLAGS -Xcompiler-option --generate-mini-debug-info" |
| 1110 | |
| 1111 | if [ "$PREBUILD" = "y" ]; then |
| 1112 | mkdir_locations="${mkdir_locations} ${DEX_LOCATION}/oat/$ISA" |
| 1113 | |
| 1114 | # "Primary". |
| 1115 | write_dex2oat_cmdlines "$TEST_NAME" |
| 1116 | dex2oat_cmdline=$(echo $dex2oat_cmdline) |
| 1117 | dm_cmdline=$(echo $dm_cmdline) |
| 1118 | vdex_cmdline=$(echo $vdex_cmdline) |
| 1119 | |
| 1120 | # Enable mini-debug-info for JIT (if JIT is used). |
| 1121 | FLAGS="$FLAGS -Xcompiler-option --generate-mini-debug-info" |
| 1122 | |
| 1123 | if [ -f "$TEST_NAME-ex.jar" ] && [ "$SECONDARY_COMPILATION" = "y" ] ; then |
| 1124 | # "Secondary" for test coverage. |
| 1125 | |
| 1126 | # Store primary values. |
| 1127 | base_dex2oat_cmdline="$dex2oat_cmdline" |
| 1128 | base_dm_cmdline="$dm_cmdline" |
| 1129 | base_vdex_cmdline="$vdex_cmdline" |
| 1130 | |
| 1131 | write_dex2oat_cmdlines "$TEST_NAME-ex" |
| 1132 | dex2oat_cmdline=$(echo $dex2oat_cmdline) |
| 1133 | dm_cmdline=$(echo $dm_cmdline) |
| 1134 | vdex_cmdline=$(echo $vdex_cmdline) |
| 1135 | |
| 1136 | # Concatenate. |
| 1137 | dex2oat_cmdline="$base_dex2oat_cmdline && $dex2oat_cmdline" |
| 1138 | dm_cmdline="$base_dm_cmdline" # Only use primary dm. |
| 1139 | vdex_cmdline="$base_vdex_cmdline && $vdex_cmdline" |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 1140 | fi |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 1141 | fi |
| 1142 | |
Igor Murashkin | 271a0f8 | 2017-02-14 21:14:17 +0000 | [diff] [blame] | 1143 | if [ "$SYNC_BEFORE_RUN" = "y" ]; then |
| 1144 | sync_cmdline="sync" |
| 1145 | fi |
| 1146 | |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 1147 | DALVIKVM_ISA_FEATURES_ARGS="" |
| 1148 | if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then |
| 1149 | DALVIKVM_ISA_FEATURES_ARGS="-Xcompiler-option --instruction-set-features=${INSTRUCTION_SET_FEATURES}" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1150 | fi |
| 1151 | |
Nicolas Geoffray | c525604 | 2015-12-26 19:41:37 +0000 | [diff] [blame] | 1152 | # java.io.tmpdir can only be set at launch time. |
| 1153 | TMP_DIR_OPTION="" |
| 1154 | if [ "$HOST" = "n" ]; then |
| 1155 | TMP_DIR_OPTION="-Djava.io.tmpdir=/data/local/tmp" |
| 1156 | fi |
| 1157 | |
Alex Light | b801210 | 2019-11-13 01:41:04 +0000 | [diff] [blame] | 1158 | # The build servers have an ancient version of bash so we cannot use @Q. |
| 1159 | if [ "$USE_GDBSERVER" == "y" ]; then |
| 1160 | printf -v QUOTED_DALVIKVM_BOOT_OPT "%q" "$DALVIKVM_BOOT_OPT" |
| 1161 | else |
| 1162 | QUOTED_DALVIKVM_BOOT_OPT="$DALVIKVM_BOOT_OPT" |
| 1163 | fi |
| 1164 | |
Nicolas Geoffray | 6ee4971 | 2018-03-30 14:39:05 +0000 | [diff] [blame] | 1165 | # We set DumpNativeStackOnSigQuit to false to avoid stressing libunwind. |
| 1166 | # b/27185632 |
| 1167 | # b/24664297 |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 1168 | dalvikvm_cmdline="$INVOKE_WITH $GDB $ANDROID_ART_BIN_DIR/$DALVIKVM \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1169 | $GDB_ARGS \ |
| 1170 | $FLAGS \ |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 1171 | $DEX_VERIFY \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1172 | -XXlib:$LIB \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1173 | $DEX2OAT \ |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 1174 | $DALVIKVM_ISA_FEATURES_ARGS \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1175 | $ZYGOTE \ |
| 1176 | $JNI_OPTS \ |
| 1177 | $INT_OPTS \ |
| 1178 | $DEBUGGER_OPTS \ |
Alex Light | b801210 | 2019-11-13 01:41:04 +0000 | [diff] [blame] | 1179 | ${QUOTED_DALVIKVM_BOOT_OPT} \ |
Nicolas Geoffray | c525604 | 2015-12-26 19:41:37 +0000 | [diff] [blame] | 1180 | $TMP_DIR_OPTION \ |
Nicolas Geoffray | 6ee4971 | 2018-03-30 14:39:05 +0000 | [diff] [blame] | 1181 | -XX:DumpNativeStackOnSigQuit:false \ |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 1182 | -cp $DEX_LOCATION/$TEST_NAME.jar$SECONDARY_DEX $MAIN $ARGS" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1183 | |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1184 | sanitize_dex2oat_cmdline() { |
| 1185 | local args=() |
| 1186 | for arg in "$@"; do |
| 1187 | if [ "$arg" = "--class-loader-context=&" ]; then |
| 1188 | arg="--class-loader-context=\&" |
| 1189 | fi |
| 1190 | args+=("$arg") |
| 1191 | done |
| 1192 | echo -n "${args[@]}" |
| 1193 | } |
| 1194 | |
Andreas Gampe | 3ad5d5e | 2015-02-03 18:26:55 -0800 | [diff] [blame] | 1195 | # Remove whitespace. |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1196 | dex2oat_cmdline=$(sanitize_dex2oat_cmdline $(echo $dex2oat_cmdline)) |
Andreas Gampe | 3ad5d5e | 2015-02-03 18:26:55 -0800 | [diff] [blame] | 1197 | dalvikvm_cmdline=$(echo $dalvikvm_cmdline) |
Nicolas Geoffray | baeaa9b | 2018-01-26 14:31:17 +0000 | [diff] [blame] | 1198 | dm_cmdline=$(echo $dm_cmdline) |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1199 | vdex_cmdline=$(sanitize_dex2oat_cmdline $(echo $vdex_cmdline)) |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 1200 | profman_cmdline=$(echo $profman_cmdline) |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1201 | |
Andreas Gampe | b31a8e7 | 2017-05-16 10:30:24 -0700 | [diff] [blame] | 1202 | # Use an empty ASAN_OPTIONS to enable defaults. |
| 1203 | # Note: this is required as envsetup right now exports detect_leaks=0. |
| 1204 | RUN_TEST_ASAN_OPTIONS="" |
| 1205 | |
Andreas Gampe | 5840839 | 2017-05-16 10:45:46 -0700 | [diff] [blame] | 1206 | # Multiple shutdown leaks. b/38341789 |
| 1207 | if [ "x$RUN_TEST_ASAN_OPTIONS" != "x" ] ; then |
| 1208 | RUN_TEST_ASAN_OPTIONS="${RUN_TEST_ASAN_OPTIONS}:" |
| 1209 | fi |
| 1210 | RUN_TEST_ASAN_OPTIONS="${RUN_TEST_ASAN_OPTIONS}detect_leaks=0" |
| 1211 | |
Vladimir Marko | a497a39 | 2018-09-26 10:52:50 +0100 | [diff] [blame] | 1212 | # For running, we must turn off logging when dex2oat is missing. Otherwise we use |
Nicolas Geoffray | f39f04c | 2018-03-05 15:42:11 +0000 | [diff] [blame] | 1213 | # the same defaults as for prebuilt: everything when --dev, otherwise errors and above only. |
| 1214 | if [ "$EXTERNAL_LOG_TAGS" = "n" ]; then |
| 1215 | if [ "$DEV_MODE" = "y" ]; then |
| 1216 | export ANDROID_LOG_TAGS='*:d' |
Nicolas Geoffray | f39f04c | 2018-03-05 15:42:11 +0000 | [diff] [blame] | 1217 | elif [ "$HAVE_IMAGE" = "n" ]; then |
| 1218 | # All tests would log the error of missing image. Be silent here and only log fatal |
| 1219 | # events. |
| 1220 | export ANDROID_LOG_TAGS='*:s' |
| 1221 | else |
| 1222 | # We are interested in LOG(ERROR) output. |
| 1223 | export ANDROID_LOG_TAGS='*:e' |
| 1224 | fi |
| 1225 | fi |
| 1226 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1227 | if [ "$HOST" = "n" ]; then |
| 1228 | adb root > /dev/null |
| 1229 | adb wait-for-device |
| 1230 | if [ "$QUIET" = "n" ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1231 | adb shell rm -rf $CHROOT_DEX_LOCATION |
| 1232 | adb shell mkdir -p $CHROOT_DEX_LOCATION |
| 1233 | adb push $TEST_NAME.jar $CHROOT_DEX_LOCATION |
| 1234 | adb push $TEST_NAME-ex.jar $CHROOT_DEX_LOCATION |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 1235 | if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1236 | adb push profile $CHROOT_DEX_LOCATION |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 1237 | fi |
David Brazdil | 7d2ec61 | 2018-01-19 14:19:59 +0000 | [diff] [blame] | 1238 | # Copy resource folder |
| 1239 | if [ -d res ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1240 | adb push res $CHROOT_DEX_LOCATION |
David Brazdil | 7d2ec61 | 2018-01-19 14:19:59 +0000 | [diff] [blame] | 1241 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1242 | else |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1243 | adb shell rm -rf $CHROOT_DEX_LOCATION >/dev/null 2>&1 |
| 1244 | adb shell mkdir -p $CHROOT_DEX_LOCATION >/dev/null 2>&1 |
| 1245 | adb push $TEST_NAME.jar $CHROOT_DEX_LOCATION >/dev/null 2>&1 |
| 1246 | adb push $TEST_NAME-ex.jar $CHROOT_DEX_LOCATION >/dev/null 2>&1 |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 1247 | if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1248 | adb push profile $CHROOT_DEX_LOCATION >/dev/null 2>&1 |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 1249 | fi |
David Brazdil | 7d2ec61 | 2018-01-19 14:19:59 +0000 | [diff] [blame] | 1250 | # Copy resource folder |
| 1251 | if [ -d res ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1252 | adb push res $CHROOT_DEX_LOCATION >/dev/null 2>&1 |
David Brazdil | 7d2ec61 | 2018-01-19 14:19:59 +0000 | [diff] [blame] | 1253 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1254 | fi |
| 1255 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1256 | # Populate LD_LIBRARY_PATH. |
| 1257 | LD_LIBRARY_PATH= |
Nicolas Geoffray | eb441dd | 2014-10-31 15:34:50 +0000 | [diff] [blame] | 1258 | if [ "$ANDROID_ROOT" != "/system" ]; then |
| 1259 | # Current default installation is dalvikvm 64bits and dex2oat 32bits, |
| 1260 | # so we can only use LD_LIBRARY_PATH when testing on a local |
| 1261 | # installation. |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1262 | LD_LIBRARY_PATH="$ANDROID_ROOT/$LIBRARY_DIRECTORY" |
Nicolas Geoffray | eb441dd | 2014-10-31 15:34:50 +0000 | [diff] [blame] | 1263 | fi |
Martin Stjernholm | 0d0f8df | 2021-04-28 16:47:01 +0100 | [diff] [blame] | 1264 | |
| 1265 | # This adds libarttest(d).so to the default linker namespace when dalvikvm |
| 1266 | # is run from /apex/com.android.art/bin. Since that namespace is essentially |
| 1267 | # an alias for the com_android_art namespace, that gives libarttest(d).so |
| 1268 | # full access to the internal ART libraries. |
| 1269 | LD_LIBRARY_PATH="/data/$TEST_DIRECTORY/com.android.art/lib${SUFFIX64}:$LD_LIBRARY_PATH" |
| 1270 | if [ "$TEST_IS_NDEBUG" = "y" ]; then dlib=""; else dlib="d"; fi |
| 1271 | art_test_internal_libraries=( |
| 1272 | libartagent${dlib}.so |
| 1273 | libarttest${dlib}.so |
| 1274 | libtiagent${dlib}.so |
| 1275 | libtistress${dlib}.so |
| 1276 | ) |
| 1277 | art_test_internal_libraries="${art_test_internal_libraries[*]}" |
| 1278 | NATIVELOADER_DEFAULT_NAMESPACE_LIBS="${art_test_internal_libraries// /:}" |
| 1279 | dlib= |
| 1280 | art_test_internal_libraries= |
| 1281 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1282 | # Needed to access the test's Odex files. |
| 1283 | LD_LIBRARY_PATH="$DEX_LOCATION/oat/$ISA:$LD_LIBRARY_PATH" |
| 1284 | # Needed to access the test's native libraries (see e.g. 674-hiddenapi, |
| 1285 | # which generates `libhiddenapitest_*.so` libraries in `$DEX_LOCATION`). |
| 1286 | LD_LIBRARY_PATH="$DEX_LOCATION:$LD_LIBRARY_PATH" |
Nicolas Geoffray | eb441dd | 2014-10-31 15:34:50 +0000 | [diff] [blame] | 1287 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1288 | # Prepend directories to the path on device. |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 1289 | PREPEND_TARGET_PATH=$ANDROID_ART_BIN_DIR |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1290 | if [ "$ANDROID_ROOT" != "/system" ]; then |
| 1291 | PREPEND_TARGET_PATH="$PREPEND_TARGET_PATH:$ANDROID_ROOT/bin" |
| 1292 | fi |
| 1293 | |
Andreas Gampe | 975d70b | 2019-09-11 11:00:18 -0700 | [diff] [blame] | 1294 | timeout_dumper_cmd= |
Andreas Gampe | a613808 | 2019-09-11 11:08:23 -0700 | [diff] [blame] | 1295 | |
| 1296 | # Check whether signal_dumper is available. |
| 1297 | if [ "$TIMEOUT_DUMPER" = signal_dumper ] ; then |
Andreas Gampe | 5d775eb | 2019-09-13 09:54:55 -0700 | [diff] [blame] | 1298 | # Chroot? Use as prefix for tests. |
| 1299 | TIMEOUT_DUMPER_PATH_PREFIX= |
| 1300 | if [ -n "$CHROOT" ]; then |
| 1301 | TIMEOUT_DUMPER_PATH_PREFIX="$CHROOT/" |
| 1302 | fi |
| 1303 | |
Roland Levillain | 52b4dc9 | 2019-09-12 11:56:52 +0100 | [diff] [blame] | 1304 | # Testing APEX? |
Andreas Gampe | 5aae3db | 2019-09-13 10:24:57 -0700 | [diff] [blame] | 1305 | if adb shell "test -x ${TIMEOUT_DUMPER_PATH_PREFIX}/apex/com.android.art/bin/signal_dumper" ; then |
Andreas Gampe | 5d775eb | 2019-09-13 09:54:55 -0700 | [diff] [blame] | 1306 | TIMEOUT_DUMPER="/apex/com.android.art/bin/signal_dumper" |
| 1307 | # Is it in /system/bin? |
Andreas Gampe | 5aae3db | 2019-09-13 10:24:57 -0700 | [diff] [blame] | 1308 | elif adb shell "test -x ${TIMEOUT_DUMPER_PATH_PREFIX}/system/bin/signal_dumper" ; then |
Andreas Gampe | 5d775eb | 2019-09-13 09:54:55 -0700 | [diff] [blame] | 1309 | TIMEOUT_DUMPER="/system/bin/signal_dumper" |
Andreas Gampe | a613808 | 2019-09-11 11:08:23 -0700 | [diff] [blame] | 1310 | else |
Andreas Gampe | 5d775eb | 2019-09-13 09:54:55 -0700 | [diff] [blame] | 1311 | TIMEOUT_DUMPER= |
Andreas Gampe | a613808 | 2019-09-11 11:08:23 -0700 | [diff] [blame] | 1312 | fi |
| 1313 | else |
| 1314 | TIMEOUT_DUMPER= |
| 1315 | fi |
| 1316 | |
Andreas Gampe | 975d70b | 2019-09-11 11:00:18 -0700 | [diff] [blame] | 1317 | if [ ! -z "$TIMEOUT_DUMPER" ] ; then |
| 1318 | # Use "-l" to dump to logcat. That is convenience for the build bot crash symbolization. |
Andreas Gampe | 38a2818 | 2019-09-13 11:36:11 -0700 | [diff] [blame] | 1319 | # Use exit code 124 for toybox timeout (b/141007616). |
| 1320 | timeout_dumper_cmd="${TIMEOUT_DUMPER} -l -s 15 -e 124" |
Andreas Gampe | 975d70b | 2019-09-11 11:00:18 -0700 | [diff] [blame] | 1321 | fi |
| 1322 | |
| 1323 | timeout_prefix= |
| 1324 | if [ "$TIME_OUT" = "timeout" ]; then |
| 1325 | # Add timeout command if time out is desired. |
| 1326 | # |
| 1327 | # Note: We first send SIGTERM (the timeout default, signal 15) to the signal dumper, which |
| 1328 | # will induce a full thread dump before killing the process. To ensure any issues in |
| 1329 | # dumping do not lead to a deadlock, we also use the "-k" option to definitely kill the |
| 1330 | # child. |
| 1331 | # Note: Using "--foreground" to not propagate the signal to children, i.e., the runtime. |
David Srbecky | a49b04f | 2019-09-16 14:53:15 +0000 | [diff] [blame] | 1332 | timeout_prefix="timeout --foreground -k 120s ${TIME_OUT_VALUE}s ${timeout_dumper_cmd} $cmdline" |
Andreas Gampe | 975d70b | 2019-09-11 11:00:18 -0700 | [diff] [blame] | 1333 | fi |
| 1334 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1335 | # Create a script with the command. The command can get longer than the longest |
| 1336 | # allowed adb command and there is no way to get the exit status from a adb shell |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 1337 | # command. Dalvik cache is cleaned before running to make subsequent executions |
| 1338 | # of the script follow the same runtime path. |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1339 | cmdline="cd $DEX_LOCATION && \ |
Andreas Gampe | b31a8e7 | 2017-05-16 10:30:24 -0700 | [diff] [blame] | 1340 | export ASAN_OPTIONS=$RUN_TEST_ASAN_OPTIONS && \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1341 | export ANDROID_DATA=$DEX_LOCATION && \ |
| 1342 | export DEX_LOCATION=$DEX_LOCATION && \ |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 1343 | export ANDROID_ROOT=$ANDROID_ROOT && \ |
Victor Chang | 6461124 | 2019-07-05 16:32:41 +0100 | [diff] [blame] | 1344 | export ANDROID_I18N_ROOT=$ANDROID_I18N_ROOT && \ |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 1345 | export ANDROID_ART_ROOT=$ANDROID_ART_ROOT && \ |
Neil Fuller | 26a5dd6 | 2019-03-13 15:16:35 +0000 | [diff] [blame] | 1346 | export ANDROID_TZDATA_ROOT=$ANDROID_TZDATA_ROOT && \ |
Nicolas Geoffray | f39f04c | 2018-03-05 15:42:11 +0000 | [diff] [blame] | 1347 | export ANDROID_LOG_TAGS=$ANDROID_LOG_TAGS && \ |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 1348 | rm -rf ${DEX_LOCATION}/dalvik-cache/ && \ |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 1349 | mkdir -p ${mkdir_locations} && \ |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 1350 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH && \ |
Martin Stjernholm | 0d0f8df | 2021-04-28 16:47:01 +0100 | [diff] [blame] | 1351 | export NATIVELOADER_DEFAULT_NAMESPACE_LIBS=$NATIVELOADER_DEFAULT_NAMESPACE_LIBS && \ |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1352 | export PATH=$PREPEND_TARGET_PATH:\$PATH && \ |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 1353 | $profman_cmdline && \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1354 | $dex2oat_cmdline && \ |
Nicolas Geoffray | baeaa9b | 2018-01-26 14:31:17 +0000 | [diff] [blame] | 1355 | $dm_cmdline && \ |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 1356 | $vdex_cmdline && \ |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 1357 | $strip_cmdline && \ |
Igor Murashkin | 271a0f8 | 2017-02-14 21:14:17 +0000 | [diff] [blame] | 1358 | $sync_cmdline && \ |
David Srbecky | a49b04f | 2019-09-16 14:53:15 +0000 | [diff] [blame] | 1359 | $timeout_prefix $dalvikvm_cmdline" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1360 | |
Orion Hodson | ecd94cf | 2020-12-03 13:58:33 +0000 | [diff] [blame] | 1361 | cmdfile=$(mktemp cmd-XXXX --suffix "-$TEST_NAME") |
| 1362 | echo "$cmdline" >> $cmdfile |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1363 | |
| 1364 | if [ "$DEV_MODE" = "y" ]; then |
| 1365 | echo $cmdline |
Alex Light | 219420e | 2019-12-05 10:20:26 -0800 | [diff] [blame] | 1366 | if [ "$USE_GDB" = "y" ] || [ "$USE_GDBSERVER" = "y" ]; then |
| 1367 | echo "Forward ${GDBSERVER_PORT} to local port and connect GDB" |
| 1368 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1369 | fi |
| 1370 | |
| 1371 | if [ "$QUIET" = "n" ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1372 | adb push $cmdfile $CHROOT_DEX_LOCATION/cmdline.sh |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1373 | else |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1374 | adb push $cmdfile $CHROOT_DEX_LOCATION/cmdline.sh >/dev/null 2>&1 |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1375 | fi |
| 1376 | |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1377 | exit_status=0 |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 1378 | if [ "$DRY_RUN" != "y" ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1379 | if [ -n "$CHROOT" ]; then |
| 1380 | adb shell chroot "$CHROOT" sh $DEX_LOCATION/cmdline.sh |
| 1381 | else |
| 1382 | adb shell sh $DEX_LOCATION/cmdline.sh |
| 1383 | fi |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1384 | exit_status=$? |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 1385 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1386 | |
| 1387 | rm -f $cmdfile |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1388 | exit $exit_status |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1389 | else |
Calin Juravle | 24bd3f9 | 2017-05-11 00:36:53 -0700 | [diff] [blame] | 1390 | # Host run. |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1391 | export ANDROID_PRINTF_LOG=brief |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 1392 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1393 | export ANDROID_DATA="$DEX_LOCATION" |
Nicolas Geoffray | 8eedb47 | 2014-10-29 14:05:59 +0000 | [diff] [blame] | 1394 | export ANDROID_ROOT="${ANDROID_ROOT}" |
Victor Chang | 6461124 | 2019-07-05 16:32:41 +0100 | [diff] [blame] | 1395 | export ANDROID_I18N_ROOT="${ANDROID_I18N_ROOT}" |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 1396 | export ANDROID_ART_ROOT="${ANDROID_ART_ROOT}" |
Neil Fuller | 26a5dd6 | 2019-03-13 15:16:35 +0000 | [diff] [blame] | 1397 | export ANDROID_TZDATA_ROOT="${ANDROID_TZDATA_ROOT}" |
Alex Light | 6f342dd | 2019-03-27 17:15:42 +0000 | [diff] [blame] | 1398 | if [ "$USE_ZIPAPEX" = "y" ] || [ "$USE_EXRACTED_ZIPAPEX" = "y" ]; then |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 1399 | # Put the zipapex files in front of the ld-library-path |
Alex Light | f7f3152 | 2019-02-01 11:14:41 -0800 | [diff] [blame] | 1400 | export LD_LIBRARY_PATH="${ANDROID_DATA}/zipapex/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}" |
| 1401 | export DYLD_LIBRARY_PATH="${ANDROID_DATA}/zipapex/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}" |
| 1402 | else |
| 1403 | export LD_LIBRARY_PATH="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}" |
| 1404 | export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}" |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 1405 | fi |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 1406 | export PATH="$PATH:$ANDROID_ART_BIN_DIR" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1407 | |
David Srbecky | c9ede38 | 2015-06-20 06:03:53 +0100 | [diff] [blame] | 1408 | # Temporarily disable address space layout randomization (ASLR). |
| 1409 | # This is needed on the host so that the linker loads core.oat at the necessary address. |
| 1410 | export LD_USE_LOAD_BIAS=1 |
| 1411 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1412 | cmdline="$dalvikvm_cmdline" |
| 1413 | |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1414 | if [ "$TIME_OUT" = "gdb" ]; then |
| 1415 | if [ `uname` = "Darwin" ]; then |
| 1416 | # Fall back to timeout on Mac. |
| 1417 | TIME_OUT="timeout" |
Hiroshi Yamauchi | c823eff | 2015-09-01 16:21:35 -0700 | [diff] [blame] | 1418 | elif [ "$ISA" = "x86" ]; then |
| 1419 | # prctl call may fail in 32-bit on an older (3.2) 64-bit Linux kernel. Fall back to timeout. |
| 1420 | TIME_OUT="timeout" |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1421 | else |
| 1422 | # Check if gdb is available. |
| 1423 | gdb --eval-command="quit" > /dev/null 2>&1 |
| 1424 | if [ $? != 0 ]; then |
| 1425 | # gdb isn't available. Fall back to timeout. |
| 1426 | TIME_OUT="timeout" |
| 1427 | fi |
| 1428 | fi |
| 1429 | fi |
| 1430 | |
| 1431 | if [ "$TIME_OUT" = "timeout" ]; then |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1432 | # Add timeout command if time out is desired. |
Andreas Gampe | 038bb22 | 2015-01-13 19:48:14 -0800 | [diff] [blame] | 1433 | # |
Andreas Gampe | 0df2aba | 2019-06-10 16:53:55 -0700 | [diff] [blame] | 1434 | # Note: We first send SIGTERM (the timeout default, signal 15) to the signal dumper, which |
| 1435 | # will induce a full thread dump before killing the process. To ensure any issues in |
| 1436 | # dumping do not lead to a deadlock, we also use the "-k" option to definitely kill the |
| 1437 | # child. |
Andreas Gampe | 4bdcf5d | 2018-12-14 10:48:53 -0800 | [diff] [blame] | 1438 | # Note: Using "--foreground" to not propagate the signal to children, i.e., the runtime. |
Andreas Gampe | 0df2aba | 2019-06-10 16:53:55 -0700 | [diff] [blame] | 1439 | cmdline="timeout --foreground -k 120s ${TIME_OUT_VALUE}s ${TIMEOUT_DUMPER} -s 15 $cmdline" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1440 | fi |
| 1441 | |
| 1442 | if [ "$DEV_MODE" = "y" ]; then |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 1443 | for var in ANDROID_PRINTF_LOG ANDROID_DATA ANDROID_ROOT ANDROID_I18N_ROOT ANDROID_TZDATA_ROOT ANDROID_ART_ROOT LD_LIBRARY_PATH DYLD_LIBRARY_PATH PATH LD_USE_LOAD_BIAS; do |
Orion Hodson | ee06c5a | 2018-04-23 13:46:24 +0100 | [diff] [blame] | 1444 | echo EXPORT $var=${!var} |
| 1445 | done |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 1446 | echo "$(declare -f linkdirs)" |
Alex Light | 5e1ffcd | 2021-03-31 16:46:02 -0700 | [diff] [blame] | 1447 | echo "mkdir -p ${mkdir_locations} && $setupapex_cmdline && ( $installapex_test_cmdline || $installapex_cmdline ) && $linkroot_cmdline && $linkroot_overlay_cmdline && $profman_cmdline && $dex2oat_cmdline && $dm_cmdline && $vdex_cmdline && $strip_cmdline && $sync_cmdline && $cmdline" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1448 | fi |
| 1449 | |
| 1450 | cd $ANDROID_BUILD_TOP |
| 1451 | |
Calin Juravle | 24bd3f9 | 2017-05-11 00:36:53 -0700 | [diff] [blame] | 1452 | # Make sure we delete any existing compiler artifacts. |
| 1453 | # This enables tests to call the RUN script multiple times in a row |
| 1454 | # without worrying about interference. |
| 1455 | rm -rf ${DEX_LOCATION}/oat |
David Srbecky | 2e4afe8 | 2016-01-27 18:42:06 +0000 | [diff] [blame] | 1456 | rm -rf ${DEX_LOCATION}/dalvik-cache/ |
Calin Juravle | 24bd3f9 | 2017-05-11 00:36:53 -0700 | [diff] [blame] | 1457 | |
Andreas Gampe | b31a8e7 | 2017-05-16 10:30:24 -0700 | [diff] [blame] | 1458 | export ASAN_OPTIONS=$RUN_TEST_ASAN_OPTIONS |
| 1459 | |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 1460 | mkdir -p ${mkdir_locations} || exit 1 |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 1461 | $setupapex_cmdline || { echo "zipapex extraction failed." >&2 ; exit 2; } |
Alex Light | 5e1ffcd | 2021-03-31 16:46:02 -0700 | [diff] [blame] | 1462 | $installapex_test_cmdline || $installapex_cmdline || { echo "zipapex install failed. cmd was: ${installapex_test_cmdline} || ${installapex_cmdline}." >&2; find ${mkdir_locations} -type f >&2; exit 2; } |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 1463 | $linkroot_cmdline || { echo "create symlink android-root failed." >&2 ; exit 2; } |
| 1464 | $linkroot_overlay_cmdline || { echo "overlay android-root failed." >&2 ; exit 2; } |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 1465 | $profman_cmdline || { echo "Profman failed." >&2 ; exit 2; } |
Andreas Gampe | 038a198 | 2020-03-11 23:06:42 +0000 | [diff] [blame] | 1466 | eval "$dex2oat_cmdline" || { echo "Dex2oat failed." >&2 ; exit 2; } |
| 1467 | eval "$dm_cmdline" || { echo "Dex2oat failed." >&2 ; exit 2; } |
| 1468 | eval "$vdex_cmdline" || { echo "Dex2oat failed." >&2 ; exit 2; } |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 1469 | $strip_cmdline || { echo "Strip failed." >&2 ; exit 3; } |
Igor Murashkin | 271a0f8 | 2017-02-14 21:14:17 +0000 | [diff] [blame] | 1470 | $sync_cmdline || { echo "Sync failed." >&2 ; exit 4; } |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 1471 | |
Alex Light | 8d94ddd | 2019-12-18 11:13:03 -0800 | [diff] [blame] | 1472 | if [ "$CREATE_RUNNER" = "y" ]; then |
| 1473 | echo "#!/bin/bash" > ${DEX_LOCATION}/runit.sh |
| 1474 | for var in ANDROID_PRINTF_LOG ANDROID_DATA ANDROID_ROOT ANDROID_I18N_ROOT ANDROID_TZDATA_ROOT ANDROID_ART_ROOT LD_LIBRARY_PATH DYLD_LIBRARY_PATH PATH LD_USE_LOAD_BIAS; do |
| 1475 | echo export $var="${!var}" >> ${DEX_LOCATION}/runit.sh |
| 1476 | done |
Alex Light | 4f915d2 | 2020-01-09 17:51:25 -0800 | [diff] [blame] | 1477 | if [ "$DEV_MODE" = "y" ]; then |
Roland Levillain | b15e879 | 2020-10-28 12:20:59 +0000 | [diff] [blame] | 1478 | echo $cmdline >> ${DEX_LOCATION}/runit.sh |
Alex Light | 4f915d2 | 2020-01-09 17:51:25 -0800 | [diff] [blame] | 1479 | else |
| 1480 | echo 'STDERR=$(mktemp)' >> ${DEX_LOCATION}/runit.sh |
| 1481 | echo 'STDOUT=$(mktemp)' >> ${DEX_LOCATION}/runit.sh |
Roland Levillain | b15e879 | 2020-10-28 12:20:59 +0000 | [diff] [blame] | 1482 | echo $cmdline '>${STDOUT} 2>${STDERR}' >> ${DEX_LOCATION}/runit.sh |
| 1483 | echo 'if diff ${STDOUT} $ANDROID_DATA/expected-stdout.txt; then' \ |
| 1484 | >> ${DEX_LOCATION}/runit.sh |
| 1485 | echo ' rm -f ${STDOUT} ${STDERR}' >> ${DEX_LOCATION}/runit.sh |
| 1486 | echo ' exit 0' >> ${DEX_LOCATION}/runit.sh |
| 1487 | echo 'elif diff ${STDERR} $ANDROID_DATA/expected-stderr.txt; then' \ |
| 1488 | >> ${DEX_LOCATION}/runit.sh |
Alex Light | 4f915d2 | 2020-01-09 17:51:25 -0800 | [diff] [blame] | 1489 | echo ' rm -f ${STDOUT} ${STDERR}' >> ${DEX_LOCATION}/runit.sh |
| 1490 | echo ' exit 0' >> ${DEX_LOCATION}/runit.sh |
| 1491 | echo 'else' >> ${DEX_LOCATION}/runit.sh |
| 1492 | echo ' echo STDOUT:' >> ${DEX_LOCATION}/runit.sh |
| 1493 | echo ' cat ${STDOUT}' >> ${DEX_LOCATION}/runit.sh |
| 1494 | echo ' echo STDERR:' >> ${DEX_LOCATION}/runit.sh |
| 1495 | echo ' cat ${STDERR}' >> ${DEX_LOCATION}/runit.sh |
| 1496 | echo ' rm -f ${STDOUT} ${STDERR}' >> ${DEX_LOCATION}/runit.sh |
| 1497 | echo ' exit 1' >> ${DEX_LOCATION}/runit.sh |
| 1498 | echo 'fi' >> ${DEX_LOCATION}/runit.sh |
| 1499 | fi |
Alex Light | 8d94ddd | 2019-12-18 11:13:03 -0800 | [diff] [blame] | 1500 | chmod u+x $DEX_LOCATION/runit.sh |
| 1501 | echo "Runnable test script written to ${DEX_LOCATION}/runit.sh" |
| 1502 | fi |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 1503 | if [ "$DRY_RUN" = "y" ]; then |
| 1504 | exit 0 |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 1505 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1506 | |
| 1507 | if [ "$USE_GDB" = "y" ]; then |
| 1508 | # When running under gdb, we cannot do piping and grepping... |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 1509 | $cmdline "$@" |
| 1510 | elif [ "$USE_GDBSERVER" = "y" ]; then |
| 1511 | echo "Connect to $GDBSERVER_PORT" |
| 1512 | # When running under gdb, we cannot do piping and grepping... |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 1513 | $cmdline "$@" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1514 | else |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1515 | if [ "$TIME_OUT" != "gdb" ]; then |
| 1516 | trap 'kill -INT -$pid' INT |
Roland Levillain | b15e879 | 2020-10-28 12:20:59 +0000 | [diff] [blame] | 1517 | $cmdline "$@" & pid=$! |
Orion Hodson | 16e7e57 | 2020-10-30 09:40:41 +0000 | [diff] [blame] | 1518 | wait $pid |
| 1519 | exit_value=$? |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1520 | # Add extra detail if time out is enabled. |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1521 | if [ $exit_value = 124 ] && [ "$TIME_OUT" = "timeout" ]; then |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1522 | echo -e "\e[91mTEST TIMED OUT!\e[0m" >&2 |
| 1523 | fi |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1524 | exit $exit_value |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1525 | else |
| 1526 | # With a thread dump that uses gdb if a timeout. |
| 1527 | trap 'kill -INT -$pid' INT |
Roland Levillain | b15e879 | 2020-10-28 12:20:59 +0000 | [diff] [blame] | 1528 | $cmdline "$@" & pid=$! |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1529 | # Spawn a watcher process. |
| 1530 | ( sleep $TIME_OUT_VALUE && \ |
| 1531 | echo "##### Thread dump using gdb on test timeout" && \ |
| 1532 | ( gdb -q -p $pid --eval-command="info thread" --eval-command="thread apply all bt" \ |
| 1533 | --eval-command="call exit(124)" --eval-command=quit || \ |
| 1534 | kill $pid )) 2> /dev/null & watcher=$! |
| 1535 | wait $pid |
| 1536 | test_exit_status=$? |
| 1537 | pkill -P $watcher 2> /dev/null # kill the sleep which will in turn end the watcher as well |
| 1538 | if [ $test_exit_status = 0 ]; then |
| 1539 | # The test finished normally. |
| 1540 | exit 0 |
| 1541 | else |
| 1542 | # The test failed or timed out. |
| 1543 | if [ $test_exit_status = 124 ]; then |
| 1544 | # The test timed out. |
| 1545 | echo -e "\e[91mTEST TIMED OUT!\e[0m" >&2 |
| 1546 | fi |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1547 | exit $test_exit_status |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1548 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1549 | fi |
| 1550 | fi |
| 1551 | fi |