From 7b126377b22859b115481e4ceae409aa2178b0f8 Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang Date: Sat, 27 Aug 2022 14:02:07 +0800 Subject: [PATCH] adb-remount-test: Refactor remount -R & disable-verity test Since remount -R and disable-verity -R have similar expectations, group them together and reuse each other's test code. Remove the redundant "remount -R" test at end of file. Total test runtime reduced by one reboot. Bug: 243116800 Test: adb-remount-test Change-Id: I510a9de39f94b73450df9abf82a55496df96bea1 --- fs_mgr/tests/adb-remount-test.sh | 143 +++++++++++-------------------- 1 file changed, 49 insertions(+), 94 deletions(-) diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh index 617ba2692..a1e94ddc1 100755 --- a/fs_mgr/tests/adb-remount-test.sh +++ b/fs_mgr/tests/adb-remount-test.sh @@ -1049,36 +1049,7 @@ if ! wait_for_screen && ${screen_wait}; then LOG WARNING "not healthy, no launcher, skipping wait for screen" fi -# Can we test remount -R command? -if [ "orange" = "$(get_property ro.boot.verifiedbootstate)" ] && - [ "2" = "$(get_property partition.system.verified)" ]; then - - LOG RUN "Testing adb shell su root remount -R command" - - avc_check - T=`adb_date` - adb_su remount -R system &1) -err="${?}" -echo "${H}" >&2 +adb_su disable-verity -R >&2 || + die -t "${T}" "disable-verity -R failed" +sleep 2 +adb_wait "${ADB_WAIT}" || + die "lost device after adb disable-verity -R $(usb_status)" -if [ "${err}" != 0 ]; then - die -t "${T}" "disable-verity -R" +if [ "2" = "$(get_property partition.system.verified)" ]; then + LOG ERROR "partition.system.verified=$(get_property partition.system.verified)" + die "verity not disabled after adb disable-verity -R" fi - -# Fuzzy search for a line that contains "overlay" and "fail". Informational only. -if echo "${H}" | grep -i "overlay" | grep -iq "fail"; then - LOG WARNING "overlayfs setup whined" -fi - -adb_wait "${ADB_WAIT}" && - adb_root || - die "lost device after adb shell su root disable-verity -R $(usb_status)" - if ${overlayfs_needed}; then - if ! is_overlayfs_mounted; then - die "no overlay being setup after disable-verity -R" - fi + is_overlayfs_mounted || + die "no overlay takeover after adb disable-verity -R" + LOG OK "overlay takeover after adb disable-verity -R" fi +LOG OK "adb disable-verity -R" + + +LOG RUN "Testing adb remount -R" + +if surgically_wipe_overlayfs; then + adb_reboot && + adb_wait "${ADB_WAIT}" || + die "lost device after reboot after overlay wipe $(usb_status)" +fi +is_overlayfs_mounted && + die "overlay takeover unexpected at this phase" + +T=$(adb_date) +adb_su remount -R &2 || + die -t "${T}" "adb remount -R failed" +sleep 2 +adb_wait "${ADB_WAIT}" || + die "lost device after adb remount -R $(usb_status)" + +if [ "2" = "$(get_property partition.system.verified)" ]; then + LOG ERROR "partition.system.verified=$(get_property partition.system.verified)" + die "verity not disabled after adb remount -R" +fi +if ${overlayfs_needed}; then + is_overlayfs_mounted || + die "no overlay takeover after adb remount -R" + LOG OK "overlay takeover after adb remount -R" +fi +LOG OK "adb remount -R" + LOG RUN "remount" @@ -1165,12 +1161,10 @@ ret=${?} echo "${D}" >&2 [ ${ret} != 0 ] || [ X"${D}" = X"${D##*remount failed}" ] || - ( [ -n "${L}" ] && echo "${L}" && false ) >&2 || die -t "${T}" "adb remount failed" D=`adb_sh df -k &2 + D=`echo "${D}" | skip_unrelated_mounts | grep "^overlay "` ret=${?} uses_dynamic_scratch=false scratch_partition= @@ -1310,7 +1304,6 @@ if ${overlayfs_needed}; then D=`adb_su df -k &2 || die -d "overlay takeover failed after reboot" adb_su sed -n '1,/overlay \/system/p' /proc/mounts