fs_mgr: test: track device active slot throughout
Report any discrepancy in the active slot. Fix a problem with problematic error propagation for adb_cat() Test: adb-remount-test.sh Bug: 126256072 Change-Id: I8a5d4e364945c5e60d252333886987b8dca0cfb3
This commit is contained in:
parent
5a465412b1
commit
448fc9783c
1 changed files with 50 additions and 13 deletions
|
@ -48,6 +48,7 @@ NORMAL="${ESCAPE}[0m"
|
|||
TMPDIR=${TMPDIR:-/tmp}
|
||||
print_time=false
|
||||
start_time=`date +%s`
|
||||
ACTIVE_SLOT=
|
||||
|
||||
##
|
||||
## Helper Functions
|
||||
|
@ -77,6 +78,7 @@ inAdb() {
|
|||
wc -l | grep '^1$' >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
[ "USAGE: inRecovery
|
||||
|
||||
Returns: true if device is in recovery mode" ]
|
||||
|
@ -221,15 +223,23 @@ format_duration() {
|
|||
|
||||
Returns: waits until the device has returned for adb or optional timeout" ]
|
||||
adb_wait() {
|
||||
local ret
|
||||
if [ -n "${1}" ]; then
|
||||
echo -n ". . . waiting `format_duration ${1}`" ${ANDROID_SERIAL} ${USB_ADDRESS} "${CR}"
|
||||
timeout --preserve-status --signal=KILL ${1} adb wait-for-device 2>/dev/null
|
||||
local ret=${?}
|
||||
ret=${?}
|
||||
echo -n " ${CR}"
|
||||
return ${ret}
|
||||
else
|
||||
adb wait-for-device
|
||||
ret=${?}
|
||||
fi
|
||||
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
|
||||
local active_slot=`get_active_slot`
|
||||
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
|
||||
echo "${ORANGE}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}" >&2
|
||||
fi
|
||||
fi
|
||||
return ${ret}
|
||||
}
|
||||
|
||||
[ "USAGE: usb_status > stdout
|
||||
|
@ -254,33 +264,50 @@ usb_status() {
|
|||
|
||||
Returns: waits until the device has returned for fastboot or optional timeout" ]
|
||||
fastboot_wait() {
|
||||
local ret
|
||||
# fastboot has no wait-for-device, but it does an automatic
|
||||
# wait and requires (even a nonsensical) command to do so.
|
||||
if [ -n "${1}" ]; then
|
||||
echo -n ". . . waiting `format_duration ${1}`" ${ANDROID_SERIAL} ${USB_ADDRESS} "${CR}"
|
||||
timeout --preserve-status --signal=KILL ${1} fastboot wait-for-device >/dev/null 2>/dev/null
|
||||
local ret=${?}
|
||||
ret=${?}
|
||||
echo -n " ${CR}"
|
||||
( exit ${ret} )
|
||||
else
|
||||
fastboot wait-for-device >/dev/null 2>/dev/null
|
||||
fi ||
|
||||
inFastboot
|
||||
ret=${?}
|
||||
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
|
||||
local active_slot=`get_active_slot`
|
||||
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
|
||||
echo "${ORANGE}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}" >&2
|
||||
fi
|
||||
fi
|
||||
return ${ret}
|
||||
}
|
||||
|
||||
[ "USAGE: recovery_wait [timeout]
|
||||
|
||||
Returns: waits until the device has returned for recovery or optional timeout" ]
|
||||
recovery_wait() {
|
||||
local ret
|
||||
if [ -n "${1}" ]; then
|
||||
echo -n ". . . waiting `format_duration ${1}`" ${ANDROID_SERIAL} ${USB_ADDRESS} "${CR}"
|
||||
timeout --preserve-status --signal=KILL ${1} adb wait-for-recovery 2>/dev/null
|
||||
local ret=${?}
|
||||
ret=${?}
|
||||
echo -n " ${CR}"
|
||||
return ${ret}
|
||||
else
|
||||
adb wait-for-recovery
|
||||
ret=${?}
|
||||
fi
|
||||
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
|
||||
local active_slot=`get_active_slot`
|
||||
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
|
||||
echo "${ORANGE}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}" >&2
|
||||
fi
|
||||
fi
|
||||
return ${ret}
|
||||
}
|
||||
|
||||
[ "any_wait [timeout]
|
||||
|
@ -326,7 +353,7 @@ adb_unroot() {
|
|||
[ root != "`adb_sh echo '${USER}' </dev/null`" ]
|
||||
}
|
||||
|
||||
[ "USAGE: fastboot_getvar var expected
|
||||
[ "USAGE: fastboot_getvar var expected >/dev/stderr
|
||||
|
||||
Returns: true if var output matches expected" ]
|
||||
fastboot_getvar() {
|
||||
|
@ -350,6 +377,19 @@ fastboot_getvar() {
|
|||
echo ${O} >&2
|
||||
}
|
||||
|
||||
[ "USAGE: get_active_slot >/dev/stdout
|
||||
|
||||
Returns: with a or b string reporting active slot" ]
|
||||
get_active_slot() {
|
||||
if inAdb || inRecovery; then
|
||||
get_property ro.boot.slot_suffix | tr -d _
|
||||
elif inFastboot; then
|
||||
fastboot_getvar current-slot 2>&1 | sed -n 's/current-slot: //p'
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
[ "USAGE: restore
|
||||
|
||||
Do nothing: should be redefined when necessary. Called after cleanup.
|
||||
|
@ -583,6 +623,9 @@ fi
|
|||
BUILD_DESCRIPTION=`get_property ro.build.description`
|
||||
[ -z "${BUILD_DESCRIPTION}" ] ||
|
||||
echo "${BLUE}[ INFO ]${NORMAL} ${BUILD_DESCRIPTION}" >&2
|
||||
ACTIVE_SLOT=`get_active_slot`
|
||||
[ -z "${ACTIVE_SLOT}" ] ||
|
||||
echo "${BLUE}[ INFO ]${NORMAL} active slot is ${ACTIVE_SLOT}" >&2
|
||||
|
||||
# Report existing partition sizes
|
||||
adb_sh ls -l /dev/block/by-name/ </dev/null 2>/dev/null |
|
||||
|
@ -1031,13 +1074,7 @@ else
|
|||
check_eq "${A}" "${B}" system after flash vendor
|
||||
adb_root ||
|
||||
die "adb root"
|
||||
B="`adb_cat /vendor/hello`" &&
|
||||
if ${is_userspace_fastboot} || ! ${overlayfs_needed}; then
|
||||
die "re-read /vendor/hello after flash vendor"
|
||||
else
|
||||
echo "${ORANGE}[ WARNING ]${NORMAL} user fastboot missing required to invalidate, ignoring a failure" >&2
|
||||
echo "${ORANGE}[ WARNING ]${NORMAL} re-read /vendor/hello after flash vendor" >&2
|
||||
fi
|
||||
B="`adb_cat /vendor/hello`"
|
||||
if ${is_userspace_fastboot} || ! ${overlayfs_needed}; then
|
||||
check_eq "cat: /vendor/hello: No such file or directory" "${B}" \
|
||||
vendor content after flash vendor
|
||||
|
|
Loading…
Reference in a new issue