Skip to content

Commit c9a69b1

Browse files
author
Mark Salyzyn
committed
fs_mgr: adb-remount-test.sh: use 24-bit forground colors
This allows colors to rendor according to user preferences in terminal emulator settings. Signed-off-by: Mark Salyzyn <[email protected]> Bug: 161454607 Test: make sure colors make sense Change-Id: Ie2749dcce66954deddbca2863dadfa270cc6633e
1 parent d88715a commit c9a69b1

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

fs_mgr/tests/adb-remount-test.sh

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ TAB="`echo | tr '\n' '\t'`"
5050
ESCAPE="`echo | tr '\n' '\033'`"
5151
# A _real_ embedded carriage return character
5252
CR="`echo | tr '\n' '\r'`"
53-
GREEN="${ESCAPE}[38;5;40m"
54-
RED="${ESCAPE}[38;5;196m"
55-
ORANGE="${ESCAPE}[38;5;255:165:0m"
56-
BLUE="${ESCAPE}[35m"
53+
GREEN="${ESCAPE}[32m"
54+
RED="${ESCAPE}[31m"
55+
YELLOW="${ESCAPE}[33m"
56+
BLUE="${ESCAPE}[34m"
5757
NORMAL="${ESCAPE}[0m"
5858
TMPDIR=${TMPDIR:-/tmp}
5959
print_time=false
@@ -164,7 +164,7 @@ avc_check() {
164164
if [ -z "${L}" ]; then
165165
return
166166
fi
167-
echo "${ORANGE}[ WARNING ]${NORMAL} unlabeled sepolicy violations:" >&2
167+
echo "${YELLOW}[ WARNING ]${NORMAL} unlabeled sepolicy violations:" >&2
168168
echo "${L}" | sed "s/^/${INDENT}/" >&2
169169
}
170170

@@ -303,7 +303,7 @@ adb_wait() {
303303
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
304304
local active_slot=`get_active_slot`
305305
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
306-
echo "${ORANGE}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}" >&2
306+
echo "${YELLOW}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}" >&2
307307
fi
308308
fi
309309
local end=`date +%s`
@@ -406,7 +406,7 @@ fastboot_wait() {
406406
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
407407
local active_slot=`get_active_slot`
408408
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
409-
echo "${ORANGE}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
409+
echo "${YELLOW}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
410410
fi >&2
411411
fi
412412
return ${ret}
@@ -431,7 +431,7 @@ recovery_wait() {
431431
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
432432
local active_slot=`get_active_slot`
433433
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
434-
echo "${ORANGE}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
434+
echo "${YELLOW}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
435435
fi >&2
436436
fi
437437
return ${ret}
@@ -839,7 +839,7 @@ done
839839
if ! ${color}; then
840840
GREEN=""
841841
RED=""
842-
ORANGE=""
842+
YELLOW=""
843843
BLUE=""
844844
NORMAL=""
845845
fi
@@ -851,14 +851,14 @@ fi
851851
inFastboot && die "device in fastboot mode"
852852
inRecovery && die "device in recovery mode"
853853
if ! inAdb; then
854-
echo "${ORANGE}[ WARNING ]${NORMAL} device not in adb mode" >&2
854+
echo "${YELLOW}[ WARNING ]${NORMAL} device not in adb mode" >&2
855855
adb_wait ${ADB_WAIT}
856856
fi
857857
inAdb || die "specified device not in adb mode"
858858
isDebuggable || die "device not a debug build"
859859
enforcing=true
860860
if ! adb_su getenforce </dev/null | grep 'Enforcing' >/dev/null; then
861-
echo "${ORANGE}[ WARNING ]${NORMAL} device does not have sepolicy in enforcing mode" >&2
861+
echo "${YELLOW}[ WARNING ]${NORMAL} device does not have sepolicy in enforcing mode" >&2
862862
enforcing=false
863863
fi
864864

@@ -935,11 +935,11 @@ adb_sh ls -l /dev/block/by-name/ /dev/block/mapper/ </dev/null 2>/dev/null |
935935

936936
# If reboot too soon after fresh flash, could trip device update failure logic
937937
if ${screen_wait}; then
938-
echo "${ORANGE}[ WARNING ]${NORMAL} waiting for screen to come up. Consider --no-wait-screen option" >&2
938+
echo "${YELLOW}[ WARNING ]${NORMAL} waiting for screen to come up. Consider --no-wait-screen option" >&2
939939
fi
940940
if ! wait_for_screen && ${screen_wait}; then
941941
screen_wait=false
942-
echo "${ORANGE}[ WARNING ]${NORMAL} not healthy, no launcher, skipping wait for screen" >&2
942+
echo "${YELLOW}[ WARNING ]${NORMAL} not healthy, no launcher, skipping wait for screen" >&2
943943
fi
944944

945945
# Can we test remount -R command?
@@ -988,7 +988,7 @@ else
988988
adb_su remount -R system </dev/null
989989
err=${?}
990990
if [ "${err}" != 0 ]; then
991-
echo "${ORANGE}[ WARNING ]${NORMAL} adb shell su root remount -R system = ${err}, likely did not reboot!" >&2
991+
echo "${YELLOW}[ WARNING ]${NORMAL} adb shell su root remount -R system = ${err}, likely did not reboot!" >&2
992992
T="-t ${T}"
993993
else
994994
# Rebooted, logcat will be meaningless, and last logcat will likely be clear
@@ -1014,7 +1014,7 @@ adb_sh ls -d /sys/module/overlay </dev/null >/dev/null 2>/dev/null ||
10141014
adb_sh grep "nodev${TAB}overlay" /proc/filesystems </dev/null >/dev/null 2>/dev/null &&
10151015
echo "${GREEN}[ OK ]${NORMAL} overlay module present" >&2 ||
10161016
(
1017-
echo "${ORANGE}[ WARNING ]${NORMAL} overlay module not present" >&2 &&
1017+
echo "${YELLOW}[ WARNING ]${NORMAL} overlay module not present" >&2 &&
10181018
false
10191019
) ||
10201020
overlayfs_supported=false
@@ -1023,7 +1023,7 @@ if ${overlayfs_supported}; then
10231023
echo "${GREEN}[ OK ]${NORMAL} overlay module supports override_creds" >&2 ||
10241024
case `adb_sh uname -r </dev/null` in
10251025
4.[456789].* | 4.[1-9][0-9]* | [56789].*)
1026-
echo "${ORANGE}[ WARNING ]${NORMAL} overlay module does not support override_creds" >&2 &&
1026+
echo "${YELLOW}[ WARNING ]${NORMAL} overlay module does not support override_creds" >&2 &&
10271027
overlayfs_supported=false
10281028
;;
10291029
*)
@@ -1045,14 +1045,14 @@ echo "${GREEN}[ RUN ]${NORMAL} Checking current overlayfs status" >&2
10451045
reboot=false
10461046
for d in ${OVERLAYFS_BACKING}; do
10471047
if adb_sh ls -d /${d}/overlay </dev/null >/dev/null 2>/dev/null; then
1048-
echo "${ORANGE}[ WARNING ]${NORMAL} /${d}/overlay is setup, surgically wiping" >&2
1048+
echo "${YELLOW}[ WARNING ]${NORMAL} /${d}/overlay is setup, surgically wiping" >&2
10491049
adb_sh rm -rf /${d}/overlay </dev/null ||
10501050
die "/${d}/overlay wipe"
10511051
reboot=true
10521052
fi
10531053
done
10541054
if ${reboot}; then
1055-
echo "${ORANGE}[ WARNING ]${NORMAL} rebooting before test" >&2
1055+
echo "${YELLOW}[ WARNING ]${NORMAL} rebooting before test" >&2
10561056
adb_reboot &&
10571057
adb_wait ${ADB_WAIT} ||
10581058
die "lost device after reboot after wipe `usb_status`"
@@ -1064,7 +1064,7 @@ D=`adb_sh df -k </dev/null` &&
10641064
D=`echo "${D}" | grep -v " /vendor/..*$" | grep "^overlay "` &&
10651065
echo "${H}" &&
10661066
echo "${D}" &&
1067-
echo "${ORANGE}[ WARNING ]${NORMAL} overlays present before setup" >&2 ||
1067+
echo "${YELLOW}[ WARNING ]${NORMAL} overlays present before setup" >&2 ||
10681068
echo "${GREEN}[ OK ]${NORMAL} no overlay present before setup" >&2
10691069
overlayfs_needed=true
10701070
D=`adb_sh cat /proc/mounts </dev/null |
@@ -1117,7 +1117,7 @@ rebooted=false
11171117
if [ X"${D}" != X"${H}" ]; then
11181118
echo "${H}"
11191119
if [ X"${D}" != X"${D##*setup failed}" ]; then
1120-
echo "${ORANGE}[ WARNING ]${NORMAL} overlayfs setup whined" >&2
1120+
echo "${YELLOW}[ WARNING ]${NORMAL} overlayfs setup whined" >&2
11211121
fi
11221122
D=`adb_sh df -k </dev/null` &&
11231123
H=`echo "${D}" | head -1` &&
@@ -1164,7 +1164,7 @@ if [ X"${D}" != X"${D##*Successfully disabled verity}" ]; then
11641164
elif ${rebooted}; then
11651165
echo "${GREEN}[ OK ]${NORMAL} verity already disabled" >&2
11661166
else
1167-
echo "${ORANGE}[ WARNING ]${NORMAL} verity already disabled" >&2
1167+
echo "${YELLOW}[ WARNING ]${NORMAL} verity already disabled" >&2
11681168
fi
11691169

11701170
echo "${GREEN}[ RUN ]${NORMAL} remount" >&2
@@ -1194,7 +1194,7 @@ if ${overlayfs_needed}; then
11941194
die -t ${T} "overlay takeover failed"
11951195
fi
11961196
echo "${D}" | grep "^overlay .* /system\$" >/dev/null ||
1197-
echo "${ORANGE}[ WARNING ]${NORMAL} overlay takeover not complete" >&2
1197+
echo "${YELLOW}[ WARNING ]${NORMAL} overlay takeover not complete" >&2
11981198
if [ -z "${virtual_ab}" ]; then
11991199
scratch_partition=scratch
12001200
fi
@@ -1326,7 +1326,7 @@ echo "${GREEN}[ RUN ]${NORMAL} reboot to confirm content persistent" >&2
13261326
13271327
fixup_from_recovery() {
13281328
inRecovery || return 1
1329-
echo "${ORANGE}[ ERROR ]${NORMAL} Device in recovery" >&2
1329+
echo "${YELLOW}[ ERROR ]${NORMAL} Device in recovery" >&2
13301330
adb reboot </dev/null
13311331
adb_wait ${ADB_WAIT}
13321332
}
@@ -1346,7 +1346,7 @@ if ${overlayfs_needed}; then
13461346
adb_su sed -n '1,/overlay \/system/p' /proc/mounts </dev/null |
13471347
skip_administrative_mounts |
13481348
grep -v ' \(erofs\|squashfs\|ext4\|f2fs\|vfat\) ' &&
1349-
echo "${ORANGE}[ WARNING ]${NORMAL} overlay takeover after first stage init" >&2 ||
1349+
echo "${YELLOW}[ WARNING ]${NORMAL} overlay takeover after first stage init" >&2 ||
13501350
echo "${GREEN}[ OK ]${NORMAL} overlay takeover in first stage init" >&2
13511351
fi
13521352
@@ -1407,20 +1407,20 @@ is_bootloader_fastboot=false
14071407
is_userspace_fastboot=false
14081408
14091409
if ! ${is_bootloader_fastboot}; then
1410-
echo "${ORANGE}[ WARNING ]${NORMAL} does not support fastboot, skipping"
1410+
echo "${YELLOW}[ WARNING ]${NORMAL} does not support fastboot, skipping"
14111411
elif [ -z "${ANDROID_PRODUCT_OUT}" ]; then
1412-
echo "${ORANGE}[ WARNING ]${NORMAL} build tree not setup, skipping"
1412+
echo "${YELLOW}[ WARNING ]${NORMAL} build tree not setup, skipping"
14131413
elif [ ! -s "${ANDROID_PRODUCT_OUT}/vendor.img" ]; then
1414-
echo "${ORANGE}[ WARNING ]${NORMAL} vendor image missing, skipping"
1414+
echo "${YELLOW}[ WARNING ]${NORMAL} vendor image missing, skipping"
14151415
elif [ "${ANDROID_PRODUCT_OUT}" = "${ANDROID_PRODUCT_OUT%*/${H}}" ]; then
1416-
echo "${ORANGE}[ WARNING ]${NORMAL} wrong vendor image, skipping"
1416+
echo "${YELLOW}[ WARNING ]${NORMAL} wrong vendor image, skipping"
14171417
elif [ -z "${ANDROID_HOST_OUT}" ]; then
1418-
echo "${ORANGE}[ WARNING ]${NORMAL} please run lunch, skipping"
1418+
echo "${YELLOW}[ WARNING ]${NORMAL} please run lunch, skipping"
14191419
elif ! (
14201420
adb_cat /vendor/build.prop |
14211421
cmp -s ${ANDROID_PRODUCT_OUT}/vendor/build.prop
14221422
) >/dev/null 2>/dev/null; then
1423-
echo "${ORANGE}[ WARNING ]${NORMAL} vendor image signature mismatch, skipping"
1423+
echo "${YELLOW}[ WARNING ]${NORMAL} vendor image signature mismatch, skipping"
14241424
else
14251425
wait_for_screen
14261426
avc_check
@@ -1466,7 +1466,7 @@ else
14661466
fi
14671467
fastboot reboot ||
14681468
die "can not reboot out of fastboot"
1469-
echo "${ORANGE}[ WARNING ]${NORMAL} adb after fastboot"
1469+
echo "${YELLOW}[ WARNING ]${NORMAL} adb after fastboot"
14701470
adb_wait ${ADB_WAIT} ||
14711471
fixup_from_recovery ||
14721472
die "did not reboot after formatting ${scratch_partition} `usb_status`"
@@ -1483,8 +1483,8 @@ else
14831483
if ${is_userspace_fastboot}; then
14841484
die "overlay supposed to be minus /vendor takeover after flash vendor"
14851485
else
1486-
echo "${ORANGE}[ WARNING ]${NORMAL} user fastboot missing required to invalidate, ignoring a failure" >&2
1487-
echo "${ORANGE}[ WARNING ]${NORMAL} overlay supposed to be minus /vendor takeover after flash vendor" >&2
1486+
echo "${YELLOW}[ WARNING ]${NORMAL} user fastboot missing required to invalidate, ignoring a failure" >&2
1487+
echo "${YELLOW}[ WARNING ]${NORMAL} overlay supposed to be minus /vendor takeover after flash vendor" >&2
14881488
fi
14891489
fi
14901490
B="`adb_cat /system/hello`"
@@ -1502,7 +1502,7 @@ else
15021502
check_eq "cat: /vendor/hello: No such file or directory" "${B}" \
15031503
vendor content after flash vendor
15041504
else
1505-
echo "${ORANGE}[ WARNING ]${NORMAL} user fastboot missing required to invalidate, ignoring a failure" >&2
1505+
echo "${YELLOW}[ WARNING ]${NORMAL} user fastboot missing required to invalidate, ignoring a failure" >&2
15061506
check_eq "cat: /vendor/hello: No such file or directory" "${B}" \
15071507
--warning vendor content after flash vendor
15081508
fi
@@ -1523,7 +1523,7 @@ err=${?}
15231523
L=
15241524
D="${H%?Now reboot your device for settings to take effect*}"
15251525
if [ X"${H}" != X"${D}" ]; then
1526-
echo "${ORANGE}[ WARNING ]${NORMAL} adb remount requires a reboot after partial flash (legacy avb)"
1526+
echo "${YELLOW}[ WARNING ]${NORMAL} adb remount requires a reboot after partial flash (legacy avb)"
15271527
L=`adb_logcat -b all -v nsec -t ${T} 2>&1`
15281528
adb_reboot &&
15291529
adb_wait ${ADB_WAIT} &&
@@ -1581,7 +1581,7 @@ if ${is_bootloader_fastboot} && [ -n "${scratch_partition}" ]; then
15811581
err=${?}
15821582
if [ X"${D}" != "${D%?Now reboot your device for settings to take effect*}" ]
15831583
then
1584-
echo "${ORANGE}[ WARNING ]${NORMAL} adb disable-verity requires a reboot after partial flash"
1584+
echo "${YELLOW}[ WARNING ]${NORMAL} adb disable-verity requires a reboot after partial flash"
15851585
adb_reboot &&
15861586
adb_wait ${ADB_WAIT} &&
15871587
adb_root ||
@@ -1614,9 +1614,9 @@ fixup_from_fastboot() {
16141614
if [ -n "${ACTIVE_SLOT}" ]; then
16151615
local active_slot=`get_active_slot`
16161616
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
1617-
echo "${ORANGE}[ ERROR ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
1617+
echo "${YELLOW}[ ERROR ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
16181618
else
1619-
echo "${ORANGE}[ ERROR ]${NORMAL} Active slot to be set to ${ACTIVE_SLOT}"
1619+
echo "${YELLOW}[ ERROR ]${NORMAL} Active slot to be set to ${ACTIVE_SLOT}"
16201620
fi >&2
16211621
fastboot --set-active=${ACTIVE_SLOT}
16221622
fi

0 commit comments

Comments
 (0)