blob: 00b745c29e98a216768034aba31c3417323c1e59 [file] [log] [blame]
Roland Levillain72f67742019-03-06 15:48:08 +00001#! /bin/bash
Nicolas Geoffrayb745adc2018-10-11 10:30:19 +01002#
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 Levillain72f67742019-03-06 15:48:08 +000017# Push ART artifacts and its dependencies to a chroot directory for on-device testing.
18
Martin Stjernholmaea51b52021-04-24 17:17:39 +010019set -e
20
Orion Hodson5697fab2019-11-19 15:01:02 +000021if [ -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'
28fi
Roland Levillain72f67742019-03-06 15:48:08 +000029
Roland Levillain1d852c32020-02-14 16:38:11 +000030# Setup as root, as some actions performed here require it.
31adb root
Nicolas Geoffrayb745adc2018-10-11 10:30:19 +010032adb wait-for-device
33
Roland Levillain72f67742019-03-06 15:48:08 +000034if [[ -z "$ANDROID_BUILD_TOP" ]]; then
35 echo 'ANDROID_BUILD_TOP environment variable is empty; did you forget to run `lunch`?'
36 exit 1
37fi
38
39if [[ -z "$ANDROID_PRODUCT_OUT" ]]; then
Nicolas Geoffrayb745adc2018-10-11 10:30:19 +010040 echo 'ANDROID_PRODUCT_OUT environment variable is empty; did you forget to run `lunch`?'
41 exit 1
42fi
43
Roland Levillain72f67742019-03-06 15:48:08 +000044if [[ -z "$ART_TEST_CHROOT" ]]; then
45 echo 'ART_TEST_CHROOT environment variable is empty; please set it before running this script.'
Nicolas Geoffrayb745adc2018-10-11 10:30:19 +010046 exit 1
47fi
48
Roland Levillain5d24c3d2020-02-07 11:57:12 +000049
Martin Stjernholme2f97112020-05-21 14:59:42 +010050# Sync relevant product directories
51# ---------------------------------
Roland Levillain5d24c3d2020-02-07 11:57:12 +000052
Martin Stjernholmaea51b52021-04-24 17:17:39 +010053(
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 Stjernholme2f97112020-05-21 14:59:42 +010066
Roland Levillain5d24c3d2020-02-07 11:57:12 +000067# Overwrite the default public.libraries.txt file with a smaller one that
68# contains only the public libraries pushed to the chroot directory.
69adb push "$ANDROID_BUILD_TOP/art/tools/public.libraries.buildbot.txt" \
70 "$ART_TEST_CHROOT/system/etc/public.libraries.txt"
71
Martin Stjernholme2f97112020-05-21 14:59:42 +010072# Create the framework directory if it doesn't exist. Some gtests need it.
73adb shell mkdir -p "$ART_TEST_CHROOT/system/framework"
74
Jooyung Han2d348672020-02-12 15:14:15 +090075# APEX packages activation.
76# -------------------------
77
Martin Stjernholmaea51b52021-04-24 17:17:39 +010078adb shell mkdir -p "$ART_TEST_CHROOT/apex"
79
Jooyung Han2d348672020-02-12 15:14:15 +090080# Manually "activate" the flattened APEX $1 by syncing it to /apex/$2 in the
81# chroot. $2 defaults to $1.
Jooyung Han2d348672020-02-12 15:14:15 +090082activate_apex() {
83 local src_apex=${1}
84 local dst_apex=${2:-${src_apex}}
Martin Stjernholmaea51b52021-04-24 17:17:39 +010085
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 Han2d348672020-02-12 15:14:15 +090097 echo -e "${green}Activating APEX ${src_apex} as ${dst_apex}...${nc}"
Jooyung Han2d348672020-02-12 15:14:15 +090098 adb shell rm -rf "$ART_TEST_CHROOT/apex/${dst_apex}"
Martin Stjernholmaea51b52021-04-24 17:17:39 +010099 adb push $src_apex_path "$ART_TEST_CHROOT/apex/${dst_apex}"
Jooyung Han2d348672020-02-12 15:14:15 +0900100}
101
102# "Activate" the required APEX modules.
103activate_apex com.android.art.testing com.android.art
104activate_apex com.android.i18n
105activate_apex com.android.runtime
106activate_apex com.android.tzdata
107activate_apex com.android.conscrypt
Eric Holk39d529f2021-02-17 12:48:53 -0800108activate_apex com.android.os.statsd