Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1 | #! /bin/bash |
Nicolas Geoffray | b745adc | 2018-10-11 10:30:19 +0100 | [diff] [blame] | 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 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 17 | # Push ART artifacts and its dependencies to a chroot directory for on-device testing. |
| 18 | |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 19 | set -e |
| 20 | |
Orion Hodson | 5697fab | 2019-11-19 15:01:02 +0000 | [diff] [blame] | 21 | if [ -t 1 ]; then |
| 22 | # Color sequences if terminal is a tty. |
| 23 | red='\033[0;31m' |
| 24 | green='\033[0;32m' |
| 25 | yellow='\033[0;33m' |
| 26 | magenta='\033[0;35m' |
| 27 | nc='\033[0m' |
| 28 | fi |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 29 | |
Roland Levillain | 1d852c3 | 2020-02-14 16:38:11 +0000 | [diff] [blame] | 30 | # Setup as root, as some actions performed here require it. |
| 31 | adb root |
Nicolas Geoffray | b745adc | 2018-10-11 10:30:19 +0100 | [diff] [blame] | 32 | adb wait-for-device |
| 33 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 34 | if [[ -z "$ANDROID_BUILD_TOP" ]]; then |
| 35 | echo 'ANDROID_BUILD_TOP environment variable is empty; did you forget to run `lunch`?' |
| 36 | exit 1 |
| 37 | fi |
| 38 | |
| 39 | if [[ -z "$ANDROID_PRODUCT_OUT" ]]; then |
Nicolas Geoffray | b745adc | 2018-10-11 10:30:19 +0100 | [diff] [blame] | 40 | echo 'ANDROID_PRODUCT_OUT environment variable is empty; did you forget to run `lunch`?' |
| 41 | exit 1 |
| 42 | fi |
| 43 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 44 | if [[ -z "$ART_TEST_CHROOT" ]]; then |
| 45 | echo 'ART_TEST_CHROOT environment variable is empty; please set it before running this script.' |
Nicolas Geoffray | b745adc | 2018-10-11 10:30:19 +0100 | [diff] [blame] | 46 | exit 1 |
| 47 | fi |
| 48 | |
Roland Levillain | 5d24c3d | 2020-02-07 11:57:12 +0000 | [diff] [blame] | 49 | |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 50 | # Sync relevant product directories |
| 51 | # --------------------------------- |
Roland Levillain | 5d24c3d | 2020-02-07 11:57:12 +0000 | [diff] [blame] | 52 | |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 53 | ( |
| 54 | cd $ANDROID_PRODUCT_OUT |
| 55 | for dir in system/* linkerconfig data; do |
| 56 | [ -d $dir ] || continue |
| 57 | if [ $dir == system/apex ]; then |
| 58 | # We sync the APEXes later. |
| 59 | continue |
| 60 | fi |
| 61 | echo -e "${green}Syncing $dir directory...${nc}" |
| 62 | adb shell mkdir -p "$ART_TEST_CHROOT/$dir" |
| 63 | adb push $dir "$ART_TEST_CHROOT/$(dirname $dir)" |
| 64 | done |
| 65 | ) |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 66 | |
Roland Levillain | 5d24c3d | 2020-02-07 11:57:12 +0000 | [diff] [blame] | 67 | # Overwrite the default public.libraries.txt file with a smaller one that |
| 68 | # contains only the public libraries pushed to the chroot directory. |
| 69 | adb push "$ANDROID_BUILD_TOP/art/tools/public.libraries.buildbot.txt" \ |
| 70 | "$ART_TEST_CHROOT/system/etc/public.libraries.txt" |
| 71 | |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 72 | # Create the framework directory if it doesn't exist. Some gtests need it. |
| 73 | adb shell mkdir -p "$ART_TEST_CHROOT/system/framework" |
| 74 | |
Jooyung Han | 2d34867 | 2020-02-12 15:14:15 +0900 | [diff] [blame] | 75 | # APEX packages activation. |
| 76 | # ------------------------- |
| 77 | |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 78 | adb shell mkdir -p "$ART_TEST_CHROOT/apex" |
| 79 | |
Jooyung Han | 2d34867 | 2020-02-12 15:14:15 +0900 | [diff] [blame] | 80 | # Manually "activate" the flattened APEX $1 by syncing it to /apex/$2 in the |
| 81 | # chroot. $2 defaults to $1. |
Jooyung Han | 2d34867 | 2020-02-12 15:14:15 +0900 | [diff] [blame] | 82 | activate_apex() { |
| 83 | local src_apex=${1} |
| 84 | local dst_apex=${2:-${src_apex}} |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 85 | |
| 86 | # Unpack the .apex file in the product directory, but if we already see a |
| 87 | # directory we assume buildbot-build.sh has already done it for us and just |
| 88 | # use it. |
| 89 | src_apex_path=$ANDROID_PRODUCT_OUT/system/apex/${src_apex} |
| 90 | if [ ! -d $src_apex_path ]; then |
| 91 | echo -e "${green}Extracting APEX ${src_apex}.apex...${nc}" |
| 92 | mkdir -p $src_apex_path |
| 93 | $ANDROID_HOST_OUT/bin/deapexer --debugfs_path $ANDROID_HOST_OUT/bin/debugfs_static \ |
| 94 | extract ${src_apex_path}.apex $src_apex_path |
| 95 | fi |
| 96 | |
Jooyung Han | 2d34867 | 2020-02-12 15:14:15 +0900 | [diff] [blame] | 97 | echo -e "${green}Activating APEX ${src_apex} as ${dst_apex}...${nc}" |
Jooyung Han | 2d34867 | 2020-02-12 15:14:15 +0900 | [diff] [blame] | 98 | adb shell rm -rf "$ART_TEST_CHROOT/apex/${dst_apex}" |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 99 | adb push $src_apex_path "$ART_TEST_CHROOT/apex/${dst_apex}" |
Jooyung Han | 2d34867 | 2020-02-12 15:14:15 +0900 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | # "Activate" the required APEX modules. |
| 103 | activate_apex com.android.art.testing com.android.art |
| 104 | activate_apex com.android.i18n |
| 105 | activate_apex com.android.runtime |
| 106 | activate_apex com.android.tzdata |
| 107 | activate_apex com.android.conscrypt |
Eric Holk | 39d529f | 2021-02-17 12:48:53 -0800 | [diff] [blame] | 108 | activate_apex com.android.os.statsd |