| Ulya Trafimovich | 9597748 | 2021-11-09 14:05:14 +0000 | [diff] [blame] | 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 | |
| 19 | if [ -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' |
| 37 | fi |
| Ulya Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 38 | |
| 39 | function msginfo() { |
| 40 | local heading="$1" |
| 41 | shift |
| 42 | local message="$*" |
| 43 | echo -e "${green}${heading}${nc} ${message}" |
| 44 | } |
| 45 | |
| 46 | function msgwarning() { |
| 47 | local message="$*" |
| 48 | echo -e "${boldmagenta}Warning: ${nc}${message}" |
| 49 | } |
| 50 | |
| 51 | function msgerror() { |
| 52 | local message="$*" |
| 53 | echo -e "${boldred}Error: ${nc}${message}" |
| 54 | } |
| 55 | |
| Ulya Trafimovich | 513801a | 2023-01-19 18:26:43 +0000 | [diff] [blame] | 56 | function msgfatal() { |
| 57 | local message="$*" |
| 58 | echo -e "${boldred}Fatal: ${nc}${message}" |
| 59 | exit 1 |
| 60 | } |
| 61 | |
| Ulya Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 62 | function msgnote() { |
| 63 | local message="$*" |
| 64 | echo -e "${boldcyan}Note: ${nc}${message}" |
| 65 | } |
| Ulya Trafimovich | 513801a | 2023-01-19 18:26:43 +0000 | [diff] [blame] | 66 | |
| 67 | export 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). |
| 70 | if [[ -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 | |
| David Srbecky | 67dd186 | 2024-03-04 14:50:18 +0000 | [diff] [blame] | 81 | SSH_CONFIG=$ANDROID_BUILD_TOP/art/test/testrunner/ssh_config |
| Jaeheon Yi | b45b07a | 2023-06-06 10:59:19 -0700 | [diff] [blame] | 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" |
| David Srbecky | 67dd186 | 2024-03-04 14:50:18 +0000 | [diff] [blame] | 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" |
| Ulya Trafimovich | 513801a | 2023-01-19 18:26:43 +0000 | [diff] [blame] | 87 | export ART_RSYNC_CMD="rsync -az" |
| David Srbecky | 67dd186 | 2024-03-04 14:50:18 +0000 | [diff] [blame] | 88 | export RSYNC_RSH="ssh -q -F $SSH_CONFIG -p $ART_TEST_SSH_PORT" # don't prefix with "ART_", rsync expects this name |
| Ulya Trafimovich | 513801a | 2023-01-19 18:26:43 +0000 | [diff] [blame] | 89 | |
| 90 | if [[ "$TARGET_ARCH" =~ ^(arm64|riscv64)$ ]]; then |
| David Srbecky | 1bcc4b6 | 2024-02-21 12:34:27 +0000 | [diff] [blame] | 91 | export ART_TEST_VM_IMG="ubuntu-23.10-server-cloudimg-$TARGET_ARCH.img" |
| Ulya Trafimovich | 513801a | 2023-01-19 18:26:43 +0000 | [diff] [blame] | 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 |
| 97 | fi |