diff options
author | 2021-11-09 14:46:22 +0000 | |
---|---|---|
committer | 2021-11-10 17:40:37 +0000 | |
commit | 5298bcd20622df02bf207181ec6d758e0d2bf671 (patch) | |
tree | 0f2894b21159104f2a2aaf093e1d265378b2b6ca | |
parent | cbf71ec69f0ce1bc20418e3ba68430d17f97fed0 (diff) |
buildbot-*.sh scripts: clean up colorful messages.
Add helper functions `msginfo`, `msgwarning`, `msgerror`, `msgnote` and
use them in the buildbot scripts.
Bug: none
Test: ran tests in chroot as described in art/test/README.chroot.md,
observed no changes in the colored output
Change-Id: Ibd577c80ddabef2c04d4f814c46a0d70829f8946
-rwxr-xr-x | tools/buildbot-build.sh | 3 | ||||
-rwxr-xr-x | tools/buildbot-cleanup-device.sh | 8 | ||||
-rwxr-xr-x | tools/buildbot-setup-device.sh | 32 | ||||
-rwxr-xr-x | tools/buildbot-sync.sh | 15 | ||||
-rwxr-xr-x | tools/buildbot-teardown-device.sh | 10 | ||||
-rwxr-xr-x | tools/buildbot-utils.sh | 22 |
6 files changed, 56 insertions, 34 deletions
diff --git a/tools/buildbot-build.sh b/tools/buildbot-build.sh index b08a231124..a93de22985 100755 --- a/tools/buildbot-build.sh +++ b/tools/buildbot-build.sh @@ -389,6 +389,5 @@ EOF rm -rf $linkerconfig_out mkdir -p $linkerconfig_out $ANDROID_HOST_OUT/bin/linkerconfig --target $linkerconfig_out --root $linkerconfig_root --vndk $platform_version - echo -e "${boldcyan}note:${nc} Don't be scared by \"Unable to access VNDK APEX\" message," \ - " it's not fatal" + msgnote "Don't be scared by \"Unable to access VNDK APEX\" message, it's not fatal" fi diff --git a/tools/buildbot-cleanup-device.sh b/tools/buildbot-cleanup-device.sh index 038ddc4fe3..7dee149129 100755 --- a/tools/buildbot-cleanup-device.sh +++ b/tools/buildbot-cleanup-device.sh @@ -28,16 +28,16 @@ if [[ -n "$ART_TEST_CHROOT" ]]; then fi if adb shell test -d "$ART_TEST_CHROOT"; then - echo -e "${green}Remove entire /linkerconfig directory from chroot directory${nc}" + msginfo "Remove entire /linkerconfig directory from chroot directory" adb shell rm -rf "$ART_TEST_CHROOT/linkerconfig" - echo -e "${green}Remove entire /system directory from chroot directory${nc}" + msginfo "Remove entire /system directory from chroot directory" adb shell rm -rf "$ART_TEST_CHROOT/system" - echo -e "${green}Remove entire /data directory from chroot directory${nc}" + msginfo "Remove entire /data directory from chroot directory" adb shell rm -rf "$ART_TEST_CHROOT/data" - echo -e "${green}Remove entire chroot directory${nc}" + msginfo "Remove entire chroot directory" adb shell rmdir "$ART_TEST_CHROOT" || adb shell ls -la "$ART_TEST_CHROOT" fi else diff --git a/tools/buildbot-setup-device.sh b/tools/buildbot-setup-device.sh index d9bada079a..fc306279ea 100755 --- a/tools/buildbot-setup-device.sh +++ b/tools/buildbot-setup-device.sh @@ -29,10 +29,10 @@ fi adb root adb wait-for-device -echo -e "${green}Date on host${nc}" +msginfo "Date on host" date -echo -e "${green}Date on device${nc}" +msginfo "Date on device" adb shell date host_seconds_since_epoch=$(date -u +%s) @@ -48,37 +48,37 @@ seconds_per_hour=3600 # b/187295147 : Disable live-lock kill daemon. # It can confuse long running processes for issues and kill them. # This usually manifests as temporarily lost adb connection. -echo -e "${green}Killing llkd, seen killing adb${nc}" +msginfo "Killing llkd, seen killing adb" adb shell setprop ctl.stop llkd-0 adb shell setprop ctl.stop llkd-1 # Kill logd first, so that when we set the adb buffer size later in this file, # it is brought up again. -echo -e "${green}Killing logd, seen leaking on fugu/N${nc}" -adb shell pkill -9 -U logd logd && echo -e "${green}...logd killed${nc}" +msginfo "Killing logd, seen leaking on fugu/N" +adb shell pkill -9 -U logd logd && msginfo "...logd killed" # Update date on device if the difference with host is more than one hour. if [ $abs_time_difference_in_seconds -gt $seconds_per_hour ]; then - echo -e "${green}Update date on device${nc}" + msginfo "Update date on device" adb shell date -u @$host_seconds_since_epoch fi -echo -e "${green}Turn off selinux${nc}" +msginfo "Turn off selinux" adb shell setenforce 0 $verbose && adb shell getenforce -echo -e "${green}Setting local loopback${nc}" +msginfo "Setting local loopback" adb shell ifconfig lo up $verbose && adb shell ifconfig if $verbose; then - echo -e "${green}List properties${nc}" + msginfo "List properties" adb shell getprop - echo -e "${green}Uptime${nc}" + msginfo "Uptime" adb shell uptime - echo -e "${green}Battery info${nc}" + msginfo "Battery info" adb shell dumpsys battery fi @@ -91,19 +91,19 @@ else buffer_size=32MB fi -echo -e "${green}Setting adb buffer size to ${buffer_size}${nc}" +msginfo "Setting adb buffer size to ${buffer_size}" adb logcat -G ${buffer_size} $verbose && adb logcat -g -echo -e "${green}Removing adb spam filter${nc}" +msginfo "Removing adb spam filter" adb logcat -P "" $verbose && adb logcat -p -echo -e "${green}Kill stalled dalvikvm processes${nc}" +msginfo "Kill stalled dalvikvm processes" # 'ps' on M can sometimes hang. timeout 2s adb shell "ps" >/dev/null if [[ $? == 124 ]] && [[ "$ART_TEST_RUN_ON_ARM_FVP" != true ]]; then - echo -e "${green}Rebooting device to fix 'ps'${nc}" + msginfo "Rebooting device to fix 'ps'" adb reboot adb wait-for-device root else @@ -116,7 +116,7 @@ fi if [[ -n "$ART_TEST_CHROOT" ]]; then # Prepare the chroot dir. - echo -e "${green}Prepare the chroot dir in $ART_TEST_CHROOT${nc}" + msginfo "Prepare the chroot dir in $ART_TEST_CHROOT" # Check that ART_TEST_CHROOT is correctly defined. [[ "x$ART_TEST_CHROOT" = x/* ]] || { echo "$ART_TEST_CHROOT is not an absolute path"; exit 1; } diff --git a/tools/buildbot-sync.sh b/tools/buildbot-sync.sh index 9bc511332d..8c3e8ffd40 100755 --- a/tools/buildbot-sync.sh +++ b/tools/buildbot-sync.sh @@ -25,17 +25,18 @@ adb root adb wait-for-device if [[ -z "$ANDROID_BUILD_TOP" ]]; then - echo 'ANDROID_BUILD_TOP environment variable is empty; did you forget to run `lunch`?' + msgerror 'ANDROID_BUILD_TOP environment variable is empty; did you forget to run `lunch`?' exit 1 fi if [[ -z "$ANDROID_PRODUCT_OUT" ]]; then - echo 'ANDROID_PRODUCT_OUT environment variable is empty; did you forget to run `lunch`?' + msgerror 'ANDROID_PRODUCT_OUT environment variable is empty; did you forget to run `lunch`?' exit 1 fi if [[ -z "$ART_TEST_CHROOT" ]]; then - echo 'ART_TEST_CHROOT environment variable is empty; please set it before running this script.' + msgerror 'ART_TEST_CHROOT environment variable is empty; ' \ + 'please set it before running this script.' exit 1 fi @@ -51,7 +52,7 @@ fi # We sync the APEXes later. continue fi - echo -e "${green}Syncing $dir directory...${nc}" + msginfo "Syncing $dir directory..." adb shell mkdir -p "$ART_TEST_CHROOT/$dir" adb push $dir "$ART_TEST_CHROOT/$(dirname $dir)" done @@ -88,16 +89,16 @@ activate_apex() { src_apex_file="${src_apex_path}.capex" fi if [ -z "${src_apex_file}" ]; then - echo -e "${red}Failed to find .apex or .capex file to extract for ${src_apex_path}${nc}" + msgerror "Failed to find .apex or .capex file to extract for ${src_apex_path}" exit 1 fi - echo -e "${green}Extracting APEX ${src_apex_file}...${nc}" + msginfo "Extracting APEX ${src_apex_file}..." mkdir -p $src_apex_path $ANDROID_HOST_OUT/bin/deapexer --debugfs_path $ANDROID_HOST_OUT/bin/debugfs_static \ extract ${src_apex_file} $src_apex_path fi - echo -e "${green}Activating APEX ${src_apex} as ${dst_apex}...${nc}" + msginfo "Activating APEX ${src_apex} as ${dst_apex}..." adb shell rm -rf "$ART_TEST_CHROOT/apex/${dst_apex}" adb push $src_apex_path "$ART_TEST_CHROOT/apex/${dst_apex}" } diff --git a/tools/buildbot-teardown-device.sh b/tools/buildbot-teardown-device.sh index 511524fcfc..d464e42b8d 100755 --- a/tools/buildbot-teardown-device.sh +++ b/tools/buildbot-teardown-device.sh @@ -30,7 +30,7 @@ if [[ -n "$ART_TEST_CHROOT" ]]; then if adb shell test -d "$ART_TEST_CHROOT"; then # Display users of the chroot dir. - echo -e "${green}List open files under chroot dir $ART_TEST_CHROOT${nc}" + msginfo "List open files under chroot dir $ART_TEST_CHROOT" adb shell lsof | grep "$ART_TEST_CHROOT" # for_all_chroot_process ACTION @@ -60,12 +60,12 @@ if [[ -n "$ART_TEST_CHROOT" ]]; then echo "$cmdline (PID: $pid)" } - echo -e "${green}List processes running from binaries under chroot dir $ART_TEST_CHROOT${nc}" + msginfo "List processes running from binaries under chroot dir $ART_TEST_CHROOT" for_all_chroot_process display_process # Tear down the chroot dir. - echo -e "${green}Tear down the chroot set up in $ART_TEST_CHROOT${nc}" + msginfo "Tear down the chroot set up in $ART_TEST_CHROOT" # remove_filesystem_from_chroot DIR-IN-CHROOT FSTYPE REMOVE-DIR-IN-CHROOT # ----------------------------------------------------------------------- @@ -139,8 +139,8 @@ if [[ -n "$ART_TEST_CHROOT" ]]; then adb shell kill -9 "$pid" } - echo -e "${green}Kill processes still running from binaries under" \ - "chroot dir $ART_TEST_CHROOT (if any)${nc} " + msginfo "Kill processes" \ + "still running from binaries under chroot dir $ART_TEST_CHROOT (if any)" for_all_chroot_process kill_process fi fi diff --git a/tools/buildbot-utils.sh b/tools/buildbot-utils.sh index 899a9a3eb7..32ed234d90 100755 --- a/tools/buildbot-utils.sh +++ b/tools/buildbot-utils.sh @@ -35,3 +35,25 @@ if [ -t 1 ]; then nc='\033[0m' fi + +function msginfo() { + local heading="$1" + shift + local message="$*" + echo -e "${green}${heading}${nc} ${message}" +} + +function msgwarning() { + local message="$*" + echo -e "${boldmagenta}Warning: ${nc}${message}" +} + +function msgerror() { + local message="$*" + echo -e "${boldred}Error: ${nc}${message}" +} + +function msgnote() { + local message="$*" + echo -e "${boldcyan}Note: ${nc}${message}" +} |