xref: /aosp_15_r20/external/libbpf/ci/vmtest/helpers.sh (revision f7c14bbac8cf49633f2740db462ea43457973ec4)
1*f7c14bbaSAndroid Build Coastguard Worker# shellcheck shell=bash
2*f7c14bbaSAndroid Build Coastguard Worker
3*f7c14bbaSAndroid Build Coastguard Worker# $1 - start or end
4*f7c14bbaSAndroid Build Coastguard Worker# $2 - fold identifier, no spaces
5*f7c14bbaSAndroid Build Coastguard Worker# $3 - fold section description
6*f7c14bbaSAndroid Build Coastguard Workerfoldable() {
7*f7c14bbaSAndroid Build Coastguard Worker  local YELLOW='\033[1;33m'
8*f7c14bbaSAndroid Build Coastguard Worker  local NOCOLOR='\033[0m'
9*f7c14bbaSAndroid Build Coastguard Worker  if [ $1 = "start" ]; then
10*f7c14bbaSAndroid Build Coastguard Worker    line="::group::$2"
11*f7c14bbaSAndroid Build Coastguard Worker    if [ ! -z "${3:-}" ]; then
12*f7c14bbaSAndroid Build Coastguard Worker      line="$line - ${YELLOW}$3${NOCOLOR}"
13*f7c14bbaSAndroid Build Coastguard Worker    fi
14*f7c14bbaSAndroid Build Coastguard Worker  else
15*f7c14bbaSAndroid Build Coastguard Worker    line="::endgroup::"
16*f7c14bbaSAndroid Build Coastguard Worker  fi
17*f7c14bbaSAndroid Build Coastguard Worker  echo -e "$line"
18*f7c14bbaSAndroid Build Coastguard Worker}
19*f7c14bbaSAndroid Build Coastguard Worker
20*f7c14bbaSAndroid Build Coastguard Worker__print() {
21*f7c14bbaSAndroid Build Coastguard Worker  local TITLE=""
22*f7c14bbaSAndroid Build Coastguard Worker  if [[ -n $2 ]]; then
23*f7c14bbaSAndroid Build Coastguard Worker      TITLE=" title=$2"
24*f7c14bbaSAndroid Build Coastguard Worker  fi
25*f7c14bbaSAndroid Build Coastguard Worker  echo "::$1${TITLE}::$3"
26*f7c14bbaSAndroid Build Coastguard Worker}
27*f7c14bbaSAndroid Build Coastguard Worker
28*f7c14bbaSAndroid Build Coastguard Worker# $1 - title
29*f7c14bbaSAndroid Build Coastguard Worker# $2 - message
30*f7c14bbaSAndroid Build Coastguard Workerprint_error() {
31*f7c14bbaSAndroid Build Coastguard Worker  __print error $1 $2
32*f7c14bbaSAndroid Build Coastguard Worker}
33*f7c14bbaSAndroid Build Coastguard Worker
34*f7c14bbaSAndroid Build Coastguard Worker# $1 - title
35*f7c14bbaSAndroid Build Coastguard Worker# $2 - message
36*f7c14bbaSAndroid Build Coastguard Workerprint_notice() {
37*f7c14bbaSAndroid Build Coastguard Worker  __print notice $1 $2
38*f7c14bbaSAndroid Build Coastguard Worker}
39