• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /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
38
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
56function msgfatal() {
57  local message="$*"
58  echo -e "${boldred}Fatal: ${nc}${message}"
59  exit 1
60}
61
62function msgnote() {
63  local message="$*"
64  echo -e "${boldcyan}Note: ${nc}${message}"
65}
66
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
81  SSH_CONFIG=$ANDROID_BUILD_TOP/art/test/testrunner/ssh_config
82  export ART_TEST_CHROOT_BASENAME="art-test-chroot"
83  export ART_TEST_CHROOT="/home/$ART_TEST_SSH_USER/$ART_TEST_CHROOT_BASENAME"
84  export ART_CHROOT_CMD="unshare --user --map-root-user chroot $ART_TEST_CHROOT_BASENAME"
85  export ART_SSH_CMD="ssh -q -F $SSH_CONFIG -p $ART_TEST_SSH_PORT $ART_TEST_SSH_USER@$ART_TEST_SSH_HOST"
86  export ART_SCP_CMD="scp -q -F $SSH_CONFIG -P $ART_TEST_SSH_PORT -p -r"
87  export ART_RSYNC_CMD="rsync -az"
88  export RSYNC_RSH="ssh -q -F $SSH_CONFIG -p $ART_TEST_SSH_PORT" # don't prefix with "ART_", rsync expects this name
89
90  if [[ "$TARGET_ARCH" =~ ^(arm64|riscv64)$ ]]; then
91    export ART_TEST_VM_IMG="ubuntu-23.10-server-cloudimg-$TARGET_ARCH.img"
92    export ART_TEST_VM_DIR="$ANDROID_BUILD_TOP/vm/$TARGET_ARCH"
93    export ART_TEST_VM="$ART_TEST_VM_DIR/$ART_TEST_VM_IMG"
94  else
95    msgfatal "unexpected TARGET_ARCH=$TARGET_ARCH; expected one of {arm64,riscv64}"
96  fi
97fi
98