Merge "adb-remount-test: Refactor fastboot flash vendor test" am: a219a2337a
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2197003 Change-Id: I3ae8ec64337db21abd4f9365f88911b231705da4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
538a3f0a1f
1 changed files with 64 additions and 85 deletions
|
|
@ -55,7 +55,6 @@ RED="${ESCAPE}[31m"
|
||||||
YELLOW="${ESCAPE}[33m"
|
YELLOW="${ESCAPE}[33m"
|
||||||
BLUE="${ESCAPE}[34m"
|
BLUE="${ESCAPE}[34m"
|
||||||
NORMAL="${ESCAPE}[0m"
|
NORMAL="${ESCAPE}[0m"
|
||||||
TMPDIR=${TMPDIR:-/tmp}
|
|
||||||
print_time=false
|
print_time=false
|
||||||
start_time=`date +%s`
|
start_time=`date +%s`
|
||||||
ACTIVE_SLOT=
|
ACTIVE_SLOT=
|
||||||
|
|
@ -588,22 +587,13 @@ get_active_slot() {
|
||||||
|
|
||||||
[ "USAGE: restore
|
[ "USAGE: restore
|
||||||
|
|
||||||
Do nothing: should be redefined when necessary. Called after cleanup.
|
Do nothing: should be redefined when necessary.
|
||||||
|
|
||||||
Returns: reverses configurations" ]
|
Returns: reverses configurations" ]
|
||||||
restore() {
|
restore() {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "USAGE: cleanup
|
|
||||||
|
|
||||||
Do nothing: should be redefined when necessary
|
|
||||||
|
|
||||||
Returns: cleans up any latent resources" ]
|
|
||||||
cleanup() {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
[ "USAGE: test_duration >/dev/stderr
|
[ "USAGE: test_duration >/dev/stderr
|
||||||
|
|
||||||
Prints the duration of the test
|
Prints the duration of the test
|
||||||
|
|
@ -874,8 +864,10 @@ if ! ${color}; then
|
||||||
NORMAL=""
|
NORMAL=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
TMPDIR=
|
||||||
|
|
||||||
exit_handler() {
|
exit_handler() {
|
||||||
cleanup || true
|
[ -n "${TMPDIR}" ] && rm -rf "${TMPDIR}"
|
||||||
local err=0
|
local err=0
|
||||||
if ! restore; then
|
if ! restore; then
|
||||||
LOG ERROR "restore failed"
|
LOG ERROR "restore failed"
|
||||||
|
|
@ -888,6 +880,8 @@ exit_handler() {
|
||||||
}
|
}
|
||||||
trap 'exit_handler' EXIT
|
trap 'exit_handler' EXIT
|
||||||
|
|
||||||
|
TMPDIR=$(mktemp -d)
|
||||||
|
|
||||||
if ${print_time}; then
|
if ${print_time}; then
|
||||||
LOG INFO "start $(date)"
|
LOG INFO "start $(date)"
|
||||||
fi
|
fi
|
||||||
|
|
@ -1305,19 +1299,15 @@ check_ne "${SYSTEM_INO}" "${VENDOR_INO}" vendor and system inode
|
||||||
|
|
||||||
# Download libc.so, append some garbage, push back, and check if the file
|
# Download libc.so, append some garbage, push back, and check if the file
|
||||||
# is updated.
|
# is updated.
|
||||||
tempdir="`mktemp -d`"
|
adb pull /system/lib/bootstrap/libc.so "${TMPDIR}/libc.so" >/dev/null ||
|
||||||
cleanup() {
|
|
||||||
rm -rf ${tempdir}
|
|
||||||
}
|
|
||||||
adb pull /system/lib/bootstrap/libc.so ${tempdir} >/dev/null ||
|
|
||||||
die "pull libc.so from device"
|
die "pull libc.so from device"
|
||||||
garbage="D105225BBFCB1EB8AB8EBDB7094646F0"
|
garbage="D105225BBFCB1EB8AB8EBDB7094646F0"
|
||||||
echo "${garbage}" >> ${tempdir}/libc.so
|
echo "${garbage}" >>"${TMPDIR}/libc.so"
|
||||||
adb push ${tempdir}/libc.so /system/lib/bootstrap/libc.so >/dev/null ||
|
adb push "${TMPDIR}/libc.so" /system/lib/bootstrap/libc.so >/dev/null ||
|
||||||
die "push libc.so to device"
|
die "push libc.so to device"
|
||||||
adb pull /system/lib/bootstrap/libc.so ${tempdir}/libc.so.fromdevice >/dev/null ||
|
adb pull /system/lib/bootstrap/libc.so "${TMPDIR}/libc.so.fromdevice" >/dev/null ||
|
||||||
die "pull libc.so from device"
|
die "pull libc.so from device"
|
||||||
diff ${tempdir}/libc.so ${tempdir}/libc.so.fromdevice > /dev/null ||
|
diff "${TMPDIR}/libc.so" "${TMPDIR}/libc.so.fromdevice" > /dev/null ||
|
||||||
die "libc.so differ"
|
die "libc.so differ"
|
||||||
|
|
||||||
LOG RUN "reboot to confirm content persistent"
|
LOG RUN "reboot to confirm content persistent"
|
||||||
|
|
@ -1379,87 +1369,85 @@ adb_sh find ${MOUNTS} </dev/null >/dev/null 2>/dev/null || true
|
||||||
|
|
||||||
# Check if the updated libc.so is persistent after reboot.
|
# Check if the updated libc.so is persistent after reboot.
|
||||||
adb_root &&
|
adb_root &&
|
||||||
adb pull /system/lib/bootstrap/libc.so ${tempdir}/libc.so.fromdevice >/dev/null ||
|
adb pull /system/lib/bootstrap/libc.so "${TMPDIR}/libc.so.fromdevice" >/dev/null ||
|
||||||
die "pull libc.so from device"
|
die "pull libc.so from device"
|
||||||
diff ${tempdir}/libc.so ${tempdir}/libc.so.fromdevice > /dev/null || die "libc.so differ"
|
diff "${TMPDIR}/libc.so" "${TMPDIR}/libc.so.fromdevice" > /dev/null || die "libc.so differ"
|
||||||
rm -rf ${tempdir}
|
|
||||||
cleanup() {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
LOG OK "/system/lib/bootstrap/libc.so content remains after reboot"
|
LOG OK "/system/lib/bootstrap/libc.so content remains after reboot"
|
||||||
|
|
||||||
LOG RUN "flash vendor, confirm its content disappears"
|
################################################################################
|
||||||
|
LOG RUN "flash vendor, and confirm vendor override disappears"
|
||||||
|
|
||||||
H=`adb_sh echo '${HOSTNAME}' </dev/null 2>/dev/null`
|
is_bootloader_fastboot=true
|
||||||
is_bootloader_fastboot=false
|
|
||||||
# cuttlefish?
|
# cuttlefish?
|
||||||
[ X"${H}" != X"${H#vsoc}" ] || is_bootloader_fastboot=true
|
[[ "$(get_property ro.product.device)" == vsoc* ]] &&
|
||||||
|
is_bootloader_fastboot=false
|
||||||
is_userspace_fastboot=false
|
is_userspace_fastboot=false
|
||||||
|
|
||||||
if ! ${is_bootloader_fastboot}; then
|
if ! ${is_bootloader_fastboot}; then
|
||||||
LOG WARNING "does not support fastboot, skipping"
|
LOG WARNING "does not support fastboot flash, skipping"
|
||||||
elif [ -z "${ANDROID_PRODUCT_OUT}" ]; then
|
|
||||||
LOG WARNING "build tree not setup, skipping"
|
|
||||||
elif [ ! -s "${ANDROID_PRODUCT_OUT}/vendor.img" ]; then
|
|
||||||
LOG WARNING "vendor image missing, skipping"
|
|
||||||
elif [ "${ANDROID_PRODUCT_OUT}" = "${ANDROID_PRODUCT_OUT%*/${H}}" ]; then
|
|
||||||
LOG WARNING "wrong vendor image, skipping"
|
|
||||||
elif [ -z "${ANDROID_HOST_OUT}" ]; then
|
|
||||||
LOG WARNING "please run lunch, skipping"
|
|
||||||
elif ! (
|
|
||||||
adb_cat /vendor/build.prop |
|
|
||||||
cmp -s ${ANDROID_PRODUCT_OUT}/vendor/build.prop
|
|
||||||
) >/dev/null 2>/dev/null; then
|
|
||||||
LOG WARNING "vendor image signature mismatch, skipping"
|
|
||||||
else
|
else
|
||||||
wait_for_screen
|
wait_for_screen
|
||||||
|
adb_root || die "adb root"
|
||||||
|
|
||||||
|
VENDOR_DEVICE_CANDIDATES=(
|
||||||
|
"/dev/block/mapper/vendor"{_${ACTIVE_SLOT},}
|
||||||
|
"/dev/block/by-name/vendor"{_${ACTIVE_SLOT},}
|
||||||
|
)
|
||||||
|
for b in "${VENDOR_DEVICE_CANDIDATES[@]}"; do
|
||||||
|
if adb_test -e "${b}"; then
|
||||||
|
adb pull "${b}" "${TMPDIR}/vendor.img" || die "adb pull ${b}"
|
||||||
|
LOG INFO "pulled ${b} from device as vendor.img"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[ -f "${TMPDIR}/vendor.img" ] ||
|
||||||
|
die "cannot find block device of vendor partition"
|
||||||
|
|
||||||
avc_check
|
avc_check
|
||||||
adb reboot fastboot </dev/null ||
|
adb reboot fastboot </dev/null ||
|
||||||
die "fastbootd not supported (wrong adb in path?)"
|
die "fastbootd not supported (wrong adb in path?)"
|
||||||
any_wait ${ADB_WAIT} &&
|
any_wait ${ADB_WAIT} &&
|
||||||
inFastboot ||
|
inFastboot ||
|
||||||
die "reboot into fastboot to flash vendor `usb_status` (bad bootloader?)"
|
die "reboot into fastboot to flash vendor `usb_status` (bad bootloader?)"
|
||||||
fastboot flash vendor ||
|
fastboot flash vendor "${TMPDIR}/vendor.img" ||
|
||||||
( fastboot reboot && false) ||
|
( fastboot reboot && false) ||
|
||||||
die "fastboot flash vendor"
|
die "fastboot flash vendor"
|
||||||
|
LOG OK "flashed vendor"
|
||||||
|
|
||||||
fastboot_getvar is-userspace yes &&
|
fastboot_getvar is-userspace yes &&
|
||||||
is_userspace_fastboot=true
|
is_userspace_fastboot=true
|
||||||
|
# check ${scratch_partition} via fastboot
|
||||||
if [ -n "${scratch_partition}" ]; then
|
if [ -n "${scratch_partition}" ]; then
|
||||||
fastboot_getvar partition-type:${scratch_partition} raw ||
|
fastboot_getvar partition-type:${scratch_partition} raw ||
|
||||||
( fastboot reboot && false) ||
|
( fastboot reboot && false) ||
|
||||||
die "fastboot can not see ${scratch_partition} parameters"
|
die "fastboot can not see ${scratch_partition} parameters"
|
||||||
if ${uses_dynamic_scratch}; then
|
if ${uses_dynamic_scratch}; then
|
||||||
# check ${scratch_partition} via fastboot
|
|
||||||
fastboot_getvar has-slot:${scratch_partition} no &&
|
fastboot_getvar has-slot:${scratch_partition} no &&
|
||||||
fastboot_getvar is-logical:${scratch_partition} yes ||
|
fastboot_getvar is-logical:${scratch_partition} yes ||
|
||||||
( fastboot reboot && false) ||
|
( fastboot reboot && false) ||
|
||||||
die "fastboot can not see ${scratch_partition} parameters"
|
die "fastboot can not see ${scratch_partition} parameters"
|
||||||
else
|
|
||||||
fastboot_getvar is-logical:${scratch_partition} no ||
|
|
||||||
( fastboot reboot && false) ||
|
|
||||||
die "fastboot can not see ${scratch_partition} parameters"
|
|
||||||
fi
|
|
||||||
if ! ${uses_dynamic_scratch}; then
|
|
||||||
fastboot reboot-bootloader ||
|
|
||||||
die "Reboot into fastboot"
|
|
||||||
fi
|
|
||||||
if ${uses_dynamic_scratch}; then
|
|
||||||
LOG INFO "expect fastboot erase ${scratch_partition} to fail"
|
LOG INFO "expect fastboot erase ${scratch_partition} to fail"
|
||||||
fastboot erase ${scratch_partition} &&
|
fastboot erase ${scratch_partition} &&
|
||||||
( fastboot reboot || true) &&
|
( fastboot reboot || true) &&
|
||||||
die "fastboot can erase ${scratch_partition}"
|
die "fastboot can erase ${scratch_partition}"
|
||||||
|
else
|
||||||
|
fastboot_getvar is-logical:${scratch_partition} no ||
|
||||||
|
( fastboot reboot && false) ||
|
||||||
|
die "fastboot can not see ${scratch_partition} parameters"
|
||||||
|
fastboot reboot-bootloader ||
|
||||||
|
die "fastboot reboot bootloader"
|
||||||
fi
|
fi
|
||||||
LOG INFO "expect fastboot format ${scratch_partition} to fail"
|
LOG INFO "expect fastboot format ${scratch_partition} to fail"
|
||||||
fastboot format ${scratch_partition} &&
|
fastboot format ${scratch_partition} &&
|
||||||
( fastboot reboot || true) &&
|
( fastboot reboot || true) &&
|
||||||
die "fastboot can format ${scratch_partition}"
|
die "fastboot can format ${scratch_partition}"
|
||||||
fi
|
fi
|
||||||
fastboot reboot ||
|
|
||||||
die "can not reboot out of fastboot"
|
fastboot reboot || die "cannot reboot out of fastboot"
|
||||||
LOG WARNING "adb after fastboot"
|
LOG INFO "reboot from fastboot"
|
||||||
adb_wait ${ADB_WAIT} ||
|
adb_wait ${ADB_WAIT} ||
|
||||||
fixup_from_recovery ||
|
fixup_from_recovery ||
|
||||||
die "did not reboot after formatting ${scratch_partition} `usb_status`"
|
die "cannot reboot after flash vendor $(usb_status)"
|
||||||
if ${overlayfs_needed}; then
|
if ${overlayfs_needed}; then
|
||||||
adb_root &&
|
adb_root &&
|
||||||
D=`adb_sh df -k </dev/null` &&
|
D=`adb_sh df -k </dev/null` &&
|
||||||
|
|
@ -1474,32 +1462,30 @@ else
|
||||||
if ${is_userspace_fastboot}; then
|
if ${is_userspace_fastboot}; then
|
||||||
die "overlay supposed to be minus /vendor takeover after flash vendor"
|
die "overlay supposed to be minus /vendor takeover after flash vendor"
|
||||||
else
|
else
|
||||||
LOG WARNING "user fastboot missing required to invalidate, ignoring a failure"
|
LOG WARNING "fastbootd missing required to invalidate, ignoring a failure"
|
||||||
LOG WARNING "overlay supposed to be minus /vendor takeover after flash vendor"
|
LOG WARNING "overlay supposed to be minus /vendor takeover after flash vendor"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
B="`adb_cat /system/hello`"
|
check_eq "${A}" "$(adb_cat /system/hello)" "/system content after flash vendor"
|
||||||
check_eq "${A}" "${B}" system after flash vendor
|
check_eq "${SYSTEM_INO}" "$(adb_sh stat --format=%i /system/hello </dev/null)" "system inode after flash vendor"
|
||||||
adb_sh ls /system >/dev/null || die "ls /system"
|
adb_sh ls /system >/dev/null || die "ls /system"
|
||||||
adb_test -d /system/priv-app || die "[ -d /system/priv-app ]"
|
adb_test -d /system/priv-app || die "[ -d /system/priv-app ]"
|
||||||
B="`adb_cat /system/priv-app/hello`"
|
check_eq "${A}" "$(adb_cat /system/priv-app/hello)" "/system/priv-app content after flash vendor"
|
||||||
check_eq "${A}" "${B}" system/priv-app after flash vendor
|
adb_root || die "adb root"
|
||||||
adb_root ||
|
if adb_test -e /vendor/hello; then
|
||||||
die "adb root"
|
if ${is_userspace_fastboot} || ! ${overlayfs_needed}; then
|
||||||
if ${is_userspace_fastboot} || ! ${overlayfs_needed}; then
|
|
||||||
adb_test -e /vendor/hello &&
|
|
||||||
die "vendor content after flash vendor"
|
die "vendor content after flash vendor"
|
||||||
else
|
else
|
||||||
LOG WARNING "user fastboot missing required to invalidate, ignoring a failure"
|
LOG WARNING "fastbootd missing required to invalidate, ignoring a failure"
|
||||||
adb_test -e /vendor/hello &&
|
|
||||||
LOG WARNING "vendor content after flash vendor"
|
LOG WARNING "vendor content after flash vendor"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
LOG OK "vendor override destroyed after flash verdor"
|
||||||
check_eq "${SYSTEM_INO}" "`adb_sh stat --format=%i /system/hello </dev/null`" system inode after reboot
|
fi >&2
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
wait_for_screen
|
wait_for_screen
|
||||||
|
|
||||||
|
################################################################################
|
||||||
LOG RUN "remove test content (cleanup)"
|
LOG RUN "remove test content (cleanup)"
|
||||||
|
|
||||||
T=`adb_date`
|
T=`adb_date`
|
||||||
|
|
@ -1541,19 +1527,12 @@ if ${is_bootloader_fastboot} && [ -n "${scratch_partition}" ]; then
|
||||||
avc_check
|
avc_check
|
||||||
adb reboot fastboot </dev/null ||
|
adb reboot fastboot </dev/null ||
|
||||||
die "Reboot into fastbootd"
|
die "Reboot into fastbootd"
|
||||||
img=${TMPDIR}/adb-remount-test-${$}.img
|
img="${TMPDIR}/adb-remount-test-${$}.img"
|
||||||
cleanup() {
|
|
||||||
rm ${img}
|
|
||||||
}
|
|
||||||
dd if=/dev/zero of=${img} bs=4096 count=16 2>/dev/null &&
|
dd if=/dev/zero of=${img} bs=4096 count=16 2>/dev/null &&
|
||||||
fastboot_wait ${FASTBOOT_WAIT} ||
|
fastboot_wait ${FASTBOOT_WAIT} ||
|
||||||
die "reboot into fastboot to flash scratch `usb_status`"
|
die "reboot into fastboot to flash scratch `usb_status`"
|
||||||
fastboot flash --force ${scratch_partition} ${img}
|
fastboot flash --force ${scratch_partition} ${img}
|
||||||
err=${?}
|
err=${?}
|
||||||
cleanup
|
|
||||||
cleanup() {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
fastboot reboot ||
|
fastboot reboot ||
|
||||||
die "can not reboot out of fastboot"
|
die "can not reboot out of fastboot"
|
||||||
[ 0 -eq ${err} ] ||
|
[ 0 -eq ${err} ] ||
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue