Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (C) 2018 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | |
| 18 | # Run Android Runtime APEX tests. |
| 19 | |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 20 | # Status of whole test script. |
| 21 | exit_status=0 |
| 22 | # Status of current test suite. |
| 23 | test_status=0 |
| 24 | |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 25 | function say { |
| 26 | echo "$0: $*" |
| 27 | } |
| 28 | |
| 29 | function die { |
| 30 | echo "$0: $*" |
| 31 | exit 1 |
| 32 | } |
| 33 | |
| 34 | which guestmount >/dev/null && which guestunmount >/dev/null && which virt-filesystems >/dev/null \ |
| 35 | || die "This script requires 'guestmount', 'guestunmount', |
| 36 | and 'virt-filesystems' from libguestfs. On Debian-based systems, these tools |
| 37 | can be installed with: |
| 38 | |
| 39 | sudo apt-get install libguestfs-tools |
| 40 | " |
Pete Bentley | f34e743 | 2018-12-11 18:12:25 +0000 | [diff] [blame] | 41 | |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 42 | [[ -n "$ANDROID_PRODUCT_OUT" ]] \ |
| 43 | || die "You need to source and lunch before you can use this script." |
| 44 | |
| 45 | # Fail early. |
| 46 | set -e |
| 47 | |
| 48 | build_apex_p=true |
| 49 | list_image_files_p=false |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 50 | print_image_tree_p=false |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 51 | |
| 52 | function usage { |
| 53 | cat <<EOF |
| 54 | Usage: $0 [OPTION] |
| 55 | Build (optional) and run tests on Android Runtime APEX package (on host). |
| 56 | |
| 57 | -s, --skip-build skip the build step |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 58 | -l, --list-files list the contents of the ext4 image using `find` |
| 59 | -t, --print-tree list the contents of the ext4 image using `tree` |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 60 | -h, --help display this help and exit |
| 61 | |
| 62 | EOF |
| 63 | exit |
| 64 | } |
| 65 | |
| 66 | while [[ $# -gt 0 ]]; do |
| 67 | case "$1" in |
| 68 | (-s|--skip-build) build_apex_p=false;; |
| 69 | (-l|--list-files) list_image_files_p=true;; |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 70 | (-t|--print-tree) print_image_tree_p=true;; |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 71 | (-h|--help) usage;; |
| 72 | (*) die "Unknown option: '$1' |
| 73 | Try '$0 --help' for more information.";; |
| 74 | esac |
| 75 | shift |
| 76 | done |
| 77 | |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 78 | if $print_image_tree_p; then |
| 79 | which tree >/dev/null || die "This script requires the 'tree' tool. |
| 80 | On Debian-based systems, this can be installed with: |
| 81 | |
| 82 | sudo apt-get install tree |
| 83 | " |
| 84 | fi |
| 85 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 86 | |
| 87 | # build_apex APEX_MODULE |
| 88 | # ---------------------- |
| 89 | # Build APEX package APEX_MODULE. |
| 90 | function build_apex { |
| 91 | if $build_apex_p; then |
| 92 | local apex_module=$1 |
| 93 | say "Building package $apex_module" && make "$apex_module" || die "Cannot build $apex_module" |
| 94 | fi |
| 95 | } |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 96 | |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 97 | # maybe_list_apex_contents MOUNT_POINT |
| 98 | # ------------------------------------ |
| 99 | # If any listing/printing option was used, honor them and display the contents |
| 100 | # of the APEX payload at MOUNT_POINT. |
| 101 | function maybe_list_apex_contents { |
| 102 | local mount_point=$1 |
| 103 | |
| 104 | # List the contents of the mounted image using `find` (optional). |
| 105 | if $list_image_files_p; then |
| 106 | say "Listing image files" && find "$mount_point" |
| 107 | fi |
| 108 | |
| 109 | # List the contents of the mounted image using `tree` (optional). |
| 110 | if $print_image_tree_p; then |
| 111 | say "Printing image tree" && ls -ld "$mount_point" && tree -aph --du "$mount_point" |
| 112 | fi |
| 113 | } |
| 114 | |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 115 | function fail_check { |
| 116 | echo "$0: FAILED: $*" |
| 117 | test_status=1 |
| 118 | exit_status=1 |
| 119 | } |
| 120 | |
| 121 | function check_file { |
| 122 | [[ -f "$mount_point/$1" ]] || fail_check "Cannot find file '$1' in mounted image" |
| 123 | } |
| 124 | |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 125 | function check_binary { |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 126 | [[ -x "$mount_point/bin/$1" ]] || fail_check "Cannot find binary '$1' in mounted image" |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | function check_multilib_binary { |
| 130 | # TODO: Use $TARGET_ARCH (e.g. check whether it is "arm" or "arm64") to improve |
| 131 | # the precision of this test? |
Alex Light | 572a096 | 2019-01-18 14:48:37 -0800 | [diff] [blame] | 132 | if ! [[ -L "$mount_point/bin/${1}" ]]; then |
| 133 | fail_check "Cannot find symlink for multilib binary '$1' in mounted image" |
| 134 | fi |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 135 | [[ -x "$mount_point/bin/${1}32" ]] || [[ -x "$mount_point/bin/${1}64" ]] \ |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 136 | || fail_check "Cannot find binary '$1' in mounted image" |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | function check_binary_symlink { |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 140 | [[ -h "$mount_point/bin/$1" ]] || fail_check "Cannot find symbolic link '$1' in mounted image" |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | function check_library { |
| 144 | # TODO: Use $TARGET_ARCH (e.g. check whether it is "arm" or "arm64") to improve |
| 145 | # the precision of this test? |
| 146 | [[ -f "$mount_point/lib/$1" ]] || [[ -f "$mount_point/lib64/$1" ]] \ |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 147 | || fail_check "Cannot find library '$1' in mounted image" |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 148 | } |
| 149 | |
Nicolas Geoffray | cc64d08 | 2019-01-25 09:43:18 +0000 | [diff] [blame] | 150 | function check_java_library { |
| 151 | [[ -x "$mount_point/javalib/$1" ]] || fail_check "Cannot find java library '$1' in mounted image" |
| 152 | } |
| 153 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 154 | # Check contents of APEX payload located in `$mount_point`. |
| 155 | function check_release_contents { |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 156 | # Check that the mounted image contains an APEX manifest. |
| 157 | check_file apex_manifest.json |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 158 | |
| 159 | # Check that the mounted image contains ART base binaries. |
| 160 | check_multilib_binary dalvikvm |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 161 | # TODO: Does not work yet (b/119942078). |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 162 | : check_binary_symlink dalvikvm |
| 163 | check_binary dex2oat |
| 164 | check_binary dexoptanalyzer |
| 165 | check_binary profman |
| 166 | |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 167 | # oatdump is only in device apex's due to build rules |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 168 | # TODO: Check for it when it is also built for host. |
| 169 | : check_binary oatdump |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 170 | |
Roland Levillain | 8d3d491 | 2019-01-07 15:19:50 +0000 | [diff] [blame] | 171 | # Check that the mounted image contains Android Runtime libraries. |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 172 | check_library libart-compiler.so |
Roland Levillain | 8d3d491 | 2019-01-07 15:19:50 +0000 | [diff] [blame] | 173 | check_library libart-dexlayout.so |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 174 | check_library libart.so |
Roland Levillain | 8d3d491 | 2019-01-07 15:19:50 +0000 | [diff] [blame] | 175 | check_library libartbase.so |
| 176 | check_library libdexfile.so |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 177 | check_library libopenjdkjvm.so |
| 178 | check_library libopenjdkjvmti.so |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 179 | check_library libprofile.so |
Roland Levillain | 8d3d491 | 2019-01-07 15:19:50 +0000 | [diff] [blame] | 180 | # Check that the mounted image contains Android Core libraries. |
Pete Bentley | 51ffdbe | 2019-01-11 15:25:40 +0000 | [diff] [blame] | 181 | check_library "libexpat${host_suffix}.so" |
| 182 | check_library libjavacore.so |
| 183 | check_library libjavacrypto.so |
Roland Levillain | cb82d09 | 2018-11-02 18:50:15 +0000 | [diff] [blame] | 184 | check_library libopenjdk.so |
Pete Bentley | 51ffdbe | 2019-01-11 15:25:40 +0000 | [diff] [blame] | 185 | check_library "libz${host_suffix}.so" |
| 186 | check_library libziparchive.so |
Roland Levillain | 8d3d491 | 2019-01-07 15:19:50 +0000 | [diff] [blame] | 187 | # Check that the mounted image contains additional required libraries. |
| 188 | check_library libadbconnection.so |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 189 | |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 190 | # TODO: Should we check for other libraries, such as: |
| 191 | # |
| 192 | # libbacktrace.so |
| 193 | # libbase.so |
| 194 | # liblog.so |
| 195 | # libsigchain.so |
| 196 | # libtombstoned_client.so |
| 197 | # libunwindstack.so |
| 198 | # libvixl.so |
| 199 | # libvixld.so |
| 200 | # ... |
| 201 | # |
| 202 | # ? |
Nicolas Geoffray | cc64d08 | 2019-01-25 09:43:18 +0000 | [diff] [blame] | 203 | |
Alex Light | a6ea602 | 2019-01-29 11:02:03 -0800 | [diff] [blame^] | 204 | check_java_library core-oj.jar |
| 205 | check_java_library core-libart.jar |
| 206 | check_java_library okhttp.jar |
| 207 | check_java_library bouncycastle.jar |
| 208 | check_java_library apache-xml.jar |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 211 | # Check debug contents of APEX payload located in `$mount_point`. |
| 212 | function check_debug_contents { |
| 213 | # Check that the mounted image contains ART tools binaries. |
| 214 | check_binary dexdiag |
| 215 | check_binary dexdump |
| 216 | check_binary dexlist |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 217 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 218 | # Check that the mounted image contains ART debug binaries. |
| 219 | check_binary dex2oatd |
| 220 | check_binary dexoptanalyzerd |
| 221 | check_binary profmand |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 222 | |
Roland Levillain | 8d3d491 | 2019-01-07 15:19:50 +0000 | [diff] [blame] | 223 | # Check that the mounted image contains Android Runtime debug libraries. |
| 224 | check_library libartbased.so |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 225 | check_library libartd-compiler.so |
Roland Levillain | 8d3d491 | 2019-01-07 15:19:50 +0000 | [diff] [blame] | 226 | check_library libartd-dexlayout.so |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 227 | check_library libartd.so |
Roland Levillain | 8d3d491 | 2019-01-07 15:19:50 +0000 | [diff] [blame] | 228 | check_library libdexfiled.so |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 229 | check_library libopenjdkjvmd.so |
| 230 | check_library libopenjdkjvmtid.so |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 231 | check_library libprofiled.so |
Roland Levillain | cb82d09 | 2018-11-02 18:50:15 +0000 | [diff] [blame] | 232 | # Check that the mounted image contains Android Core debug libraries. |
| 233 | check_library libopenjdkd.so |
| 234 | # Check that the mounted image contains additional required debug libraries. |
Roland Levillain | 8d3d491 | 2019-01-07 15:19:50 +0000 | [diff] [blame] | 235 | check_library libadbconnectiond.so |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | # Testing target (device) APEX packages. |
| 239 | # ====================================== |
| 240 | |
| 241 | # Clean-up. |
| 242 | function cleanup_target { |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 243 | guestunmount "$mount_point" |
| 244 | rm -rf "$work_dir" |
| 245 | } |
| 246 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 247 | # Garbage collection. |
| 248 | function finish_target { |
| 249 | # Don't fail early during cleanup. |
| 250 | set +e |
| 251 | cleanup_target |
| 252 | } |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 253 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 254 | # setup_target_apex APEX_MODULE MOUNT_POINT |
| 255 | # ----------------------------------------- |
| 256 | # Extract image from target APEX_MODULE and mount it in MOUNT_POINT. |
| 257 | function setup_target_apex { |
| 258 | local apex_module=$1 |
| 259 | local mount_point=$2 |
| 260 | local system_apexdir="$ANDROID_PRODUCT_OUT/system/apex" |
| 261 | local apex_package="$system_apexdir/$apex_module.apex" |
| 262 | |
| 263 | say "Extracting and mounting image" |
| 264 | |
| 265 | # Extract the payload from the Android Runtime APEX. |
| 266 | local image_filename="apex_payload.img" |
| 267 | unzip -q "$apex_package" "$image_filename" -d "$work_dir" |
| 268 | mkdir "$mount_point" |
| 269 | local image_file="$work_dir/$image_filename" |
| 270 | |
| 271 | # Check filesystems in the image. |
| 272 | local image_filesystems="$work_dir/image_filesystems" |
| 273 | virt-filesystems -a "$image_file" >"$image_filesystems" |
| 274 | # We expect a single partition (/dev/sda) in the image. |
| 275 | local partition="/dev/sda" |
| 276 | echo "$partition" | cmp "$image_filesystems" - |
| 277 | |
| 278 | # Mount the image from the Android Runtime APEX. |
Pete Bentley | ca0f7ba | 2019-01-25 16:30:10 +0000 | [diff] [blame] | 279 | guestmount -a "$image_file" -m "$partition" --ro "$mount_point" |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | # Testing release APEX package (com.android.runtime.release). |
| 283 | # ----------------------------------------------------------- |
| 284 | |
| 285 | apex_module="com.android.runtime.release" |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 286 | test_status=0 |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 287 | |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 288 | say "Processing APEX package $apex_module" |
| 289 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 290 | work_dir=$(mktemp -d) |
| 291 | mount_point="$work_dir/image" |
Pete Bentley | 51ffdbe | 2019-01-11 15:25:40 +0000 | [diff] [blame] | 292 | host_suffix="" |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 293 | |
| 294 | trap finish_target EXIT |
| 295 | |
| 296 | # Build the APEX package (optional). |
| 297 | build_apex "$apex_module" |
| 298 | |
| 299 | # Set up APEX package. |
| 300 | setup_target_apex "$apex_module" "$mount_point" |
| 301 | |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 302 | # List the contents of the APEX image (optional). |
| 303 | maybe_list_apex_contents "$mount_point" |
| 304 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 305 | # Run tests on APEX package. |
| 306 | say "Checking APEX package $apex_module" |
Nicolas Geoffray | cc64d08 | 2019-01-25 09:43:18 +0000 | [diff] [blame] | 307 | check_release_contents "$apex_module" |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 308 | |
| 309 | # Clean up. |
| 310 | trap - EXIT |
| 311 | cleanup_target |
| 312 | |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 313 | [[ "$test_status" = 0 ]] && say "$apex_module tests passed" |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 314 | echo |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 315 | |
| 316 | # Testing debug APEX package (com.android.runtime.debug). |
| 317 | # ------------------------------------------------------- |
| 318 | |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 319 | apex_module="com.android.runtime.debug" |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 320 | test_status=0 |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 321 | |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 322 | say "Processing APEX package $apex_module" |
| 323 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 324 | work_dir=$(mktemp -d) |
| 325 | mount_point="$work_dir/image" |
Pete Bentley | 51ffdbe | 2019-01-11 15:25:40 +0000 | [diff] [blame] | 326 | host_suffix="" |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 327 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 328 | trap finish_target EXIT |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 329 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 330 | # Build the APEX package (optional). |
| 331 | build_apex "$apex_module" |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 332 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 333 | # Set up APEX package. |
| 334 | setup_target_apex "$apex_module" "$mount_point" |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 335 | |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 336 | # List the contents of the APEX image (optional). |
| 337 | maybe_list_apex_contents "$mount_point" |
| 338 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 339 | # Run tests on APEX package. |
| 340 | say "Checking APEX package $apex_module" |
Nicolas Geoffray | cc64d08 | 2019-01-25 09:43:18 +0000 | [diff] [blame] | 341 | check_release_contents "$apex_module" |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 342 | check_debug_contents |
| 343 | # Check for files pulled in from debug target-only oatdump. |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 344 | check_binary oatdump |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 345 | check_library libart-disassembler.so |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 346 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 347 | # Clean up. |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 348 | trap - EXIT |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 349 | cleanup_target |
Roland Levillain | 38a938e | 2018-09-21 10:55:51 +0100 | [diff] [blame] | 350 | |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 351 | [[ "$test_status" = 0 ]] && say "$apex_module tests passed" |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 352 | echo |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 353 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 354 | |
| 355 | # Testing host APEX package (com.android.runtime.host). |
| 356 | # ===================================================== |
| 357 | |
| 358 | # Clean-up. |
| 359 | function cleanup_host { |
| 360 | rm -rf "$work_dir" |
| 361 | } |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 362 | |
| 363 | # Garbage collection. |
| 364 | function finish_host { |
| 365 | # Don't fail early during cleanup. |
| 366 | set +e |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 367 | cleanup_host |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 368 | } |
| 369 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 370 | # setup_host_apex APEX_MODULE MOUNT_POINT |
| 371 | # --------------------------------------- |
| 372 | # Extract Zip file from host APEX_MODULE and extract it in MOUNT_POINT. |
| 373 | function setup_host_apex { |
| 374 | local apex_module=$1 |
| 375 | local mount_point=$2 |
| 376 | local system_apexdir="$ANDROID_HOST_OUT/apex" |
| 377 | local apex_package="$system_apexdir/$apex_module.zipapex" |
| 378 | |
| 379 | say "Extracting payload" |
| 380 | |
| 381 | # Extract the payload from the Android Runtime APEX. |
| 382 | local image_filename="apex_payload.zip" |
| 383 | unzip -q "$apex_package" "$image_filename" -d "$work_dir" |
| 384 | mkdir "$mount_point" |
| 385 | local image_file="$work_dir/$image_filename" |
| 386 | |
| 387 | # Unzipping the payload |
| 388 | unzip -q "$image_file" -d "$mount_point" |
| 389 | } |
| 390 | |
| 391 | apex_module="com.android.runtime.host" |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 392 | test_status=0 |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 393 | |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 394 | say "Processing APEX package $apex_module" |
| 395 | |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 396 | work_dir=$(mktemp -d) |
| 397 | mount_point="$work_dir/zip" |
Pete Bentley | 51ffdbe | 2019-01-11 15:25:40 +0000 | [diff] [blame] | 398 | host_suffix="-host" |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 399 | |
| 400 | trap finish_host EXIT |
| 401 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 402 | # Build the APEX package (optional). |
| 403 | build_apex "$apex_module" |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 404 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 405 | # Set up APEX package. |
| 406 | setup_host_apex "$apex_module" "$mount_point" |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 407 | |
Roland Levillain | 04e83d1 | 2018-11-16 15:03:47 +0000 | [diff] [blame] | 408 | # List the contents of the APEX image (optional). |
| 409 | maybe_list_apex_contents "$mount_point" |
| 410 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 411 | # Run tests on APEX package. |
| 412 | say "Checking APEX package $apex_module" |
Nicolas Geoffray | cc64d08 | 2019-01-25 09:43:18 +0000 | [diff] [blame] | 413 | check_release_contents "$apex_module" |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 414 | check_debug_contents |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 415 | |
Roland Levillain | 996f42f | 2018-12-11 15:26:51 +0000 | [diff] [blame] | 416 | # Clean up. |
| 417 | trap - EXIT |
| 418 | cleanup_host |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 419 | |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 420 | [[ "$test_status" = 0 ]] && say "$apex_module tests passed" |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 421 | |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 422 | [[ "$exit_status" = 0 ]] && say "All Android Runtime APEX tests passed" |
Alex Light | da948ce | 2018-12-06 17:05:41 +0000 | [diff] [blame] | 423 | |
Roland Levillain | 43c08d2 | 2019-01-18 18:58:47 +0000 | [diff] [blame] | 424 | exit $exit_status |