blob: adbf8dd5dcb74c359b1159f45bfd0c350af198d5 [file] [log] [blame]
Ulya Trafimovich95977482021-11-09 14:05:14 +00001#! /bin/bash
2#
3# Copyright (C) 2021 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# Utilities for buildbot. This script is sourced by other buildbot-*.sh scripts.
18
19if [ -t 1 ]; then
20 # Color sequences if terminal is a tty.
21
22 red='\033[0;31m'
23 green='\033[0;32m'
24 yellow='\033[0;33m'
25 blue='\033[0;34m'
26 magenta='\033[0;35m'
27 cyan='\033[0;36m'
28
29 boldred='\033[1;31m'
30 boldgreen='\033[1;32m'
31 boldyellow='\033[1;33m'
32 boldblue='\033[1;34m'
33 boldmagenta='\033[1;95m'
34 boldcyan='\033[1;36m'
35
36 nc='\033[0m'
37fi
Ulya Trafimovich5298bcd2021-11-09 14:46:22 +000038
39function msginfo() {
40 local heading="$1"
41 shift
42 local message="$*"
43 echo -e "${green}${heading}${nc} ${message}"
44}
45
46function msgwarning() {
47 local message="$*"
48 echo -e "${boldmagenta}Warning: ${nc}${message}"
49}
50
51function msgerror() {
52 local message="$*"
53 echo -e "${boldred}Error: ${nc}${message}"
54}
55
Ulya Trafimovich513801a2023-01-19 18:26:43 +000056function msgfatal() {
57 local message="$*"
58 echo -e "${boldred}Fatal: ${nc}${message}"
59 exit 1
60}
61
Ulya Trafimovich5298bcd2021-11-09 14:46:22 +000062function msgnote() {
63 local message="$*"
64 echo -e "${boldcyan}Note: ${nc}${message}"
65}
Ulya Trafimovich513801a2023-01-19 18:26:43 +000066
67export TARGET_ARCH=$(build/soong/soong_ui.bash --dumpvar-mode TARGET_ARCH)
68
69# Do some checks and prepare environment for tests that run on Linux (not on Android).
70if [[ -n "$ART_TEST_ON_VM" ]]; then
71 if [[ -z $ANDROID_BUILD_TOP ]]; then
72 msgfatal "ANDROID_BUILD_TOP is not set"
73 elif [[ -z "$ART_TEST_SSH_USER" ]]; then
74 msgfatal "ART_TEST_SSH_USER not set"
75 elif [[ -z "$ART_TEST_SSH_HOST" ]]; then
76 msgfatal "ART_TEST_SSH_HOST not set"
77 elif [[ -z "$ART_TEST_SSH_PORT" ]]; then
78 msgfatal "ART_TEST_SSH_PORT not set"
79 fi
80
Jaeheon Yib45b07a2023-06-06 10:59:19 -070081 export ART_TEST_CHROOT_BASENAME="art-test-chroot"
82 export ART_TEST_CHROOT="/home/$ART_TEST_SSH_USER/$ART_TEST_CHROOT_BASENAME"
83 export ART_CHROOT_CMD="unshare --user --map-root-user chroot $ART_TEST_CHROOT_BASENAME"
Ulya Trafimovich1cff8442023-04-11 16:07:50 +010084 export ART_SSH_CMD="ssh -q -p $ART_TEST_SSH_PORT $ART_TEST_SSH_USER@$ART_TEST_SSH_HOST -o IdentityAgent=none"
85 export ART_SCP_CMD="scp -P $ART_TEST_SSH_PORT -p -r -o IdentityAgent=none"
Ulya Trafimovich513801a2023-01-19 18:26:43 +000086 export ART_RSYNC_CMD="rsync -az"
Ulya Trafimovich1cff8442023-04-11 16:07:50 +010087 export RSYNC_RSH="ssh -p $ART_TEST_SSH_PORT -o IdentityAgent=none" # don't prefix with "ART_", rsync expects this name
Ulya Trafimovich513801a2023-01-19 18:26:43 +000088
89 if [[ "$TARGET_ARCH" =~ ^(arm64|riscv64)$ ]]; then
90 export ART_TEST_VM_IMG="ubuntu-22.04-server-cloudimg-$TARGET_ARCH.img"
91 export ART_TEST_VM_DIR="$ANDROID_BUILD_TOP/vm/$TARGET_ARCH"
92 export ART_TEST_VM="$ART_TEST_VM_DIR/$ART_TEST_VM_IMG"
93 else
94 msgfatal "unexpected TARGET_ARCH=$TARGET_ARCH; expected one of {arm64,riscv64}"
95 fi
96fi