From 3ae19c3c01d5825509eee9e98620fcbec43b720e Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang Date: Thu, 1 Sep 2022 23:10:52 +0800 Subject: [PATCH] adb-remount-test: Miscellaneous fixes - 2nd round * Call adb_wait in adb_reboot, as virtually all adb_reboot callsites are immediately followed by adb_wait. * Remove |data| option from skip_administrative_mounts. The |data| option doesn't really work anyway, because vold & init creates bewildering heirarchy of /data bind-mounts, so it's not feasible to filter /data by mountpoints. It's more sensible to filter by the /data device node name, which should be done by the caller. * Untangle skip_administrative_mounts and skip_unrelated_mounts. I don't know why we need two separate functions that do similar things. Just merge them together. Bug: 243116800 Test: adb-remount-test Change-Id: I847f0b8cc2a952bb4c8656a43da783f312670061 --- fs_mgr/tests/adb-remount-test.sh | 72 ++++++++++---------------------- 1 file changed, 23 insertions(+), 49 deletions(-) diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh index 4b0e899dd..a6bdd6c02 100755 --- a/fs_mgr/tests/adb-remount-test.sh +++ b/fs_mgr/tests/adb-remount-test.sh @@ -250,6 +250,7 @@ adb_reboot() { avc_check adb reboot remount-test |s|m|h|d] @@ -710,7 +711,7 @@ join_with() { echo "${result}" } -[ "USAGE: skip_administrative_mounts [data] < /proc/mounts +[ "USAGE: skip_administrative_mounts < /proc/mounts Filters out all administrative (eg: sysfs) mounts uninteresting to the test" ] skip_administrative_mounts() { @@ -726,29 +727,13 @@ skip_administrative_mounts() { ) local exclude_mount_points=( "\/cache" "\/mnt\/scratch" "\/mnt\/vendor\/persist" "\/persist" - "\/metadata" + "\/metadata" "\/apex\/[^ ]+" ) - if [ "data" = "${1}" ]; then - exclude_mount_points+=("\/data") - fi awk '$1 !~ /^('"$(join_with "|" "${exclude_devices[@]}")"')$/ && $2 !~ /^('"$(join_with "|" "${exclude_mount_points[@]}")"')$/ && $3 !~ /^('"$(join_with "|" "${exclude_filesystems[@]}")"')$/' } -[ "USAGE: skip_unrelated_mounts < /proc/mounts - -or output from df - -Filters out all apex and vendor override administrative overlay mounts -uninteresting to the test" ] -skip_unrelated_mounts() { - grep -vE \ - -e "^overlay.* /(apex|bionic|system|vendor)/[^ ]" \ - -e "^[^ ]+ /apex/[^ ]" \ - -e "[%] /(data_mirror|apex|bionic|system|vendor)/[^ ]+$" -} - [ "USAGE: surgically_wipe_overlayfs Surgically wipe any mounted overlayfs scratch files. @@ -774,8 +759,9 @@ Returns: true if overlayfs is mounted [on mountpoint]" ] is_overlayfs_mounted() { local df_output=$(adb_su df -k &2 if ${reboot}; then - adb_reboot && - adb_wait "${ADB_WAIT}" + adb_reboot fi } @@ -1060,8 +1045,7 @@ adb_root || die "adb root failed" # having to go through enable-verity transition. if surgically_wipe_overlayfs; then LOG WARNING "rebooting before test" - adb_reboot && - adb_wait ${ADB_WAIT} || + adb_reboot || die "lost device after reboot after overlay wipe $(usb_status)" adb_root || die "lost device after elevation to root after wipe `usb_status`" @@ -1070,9 +1054,10 @@ is_overlayfs_mounted && die "overlay takeover unexpected at this phase" overlayfs_needed=true +data_device=$(adb_sh awk '$2 == "/data" { print $1; exit }' /proc/mounts) D=$(adb_sh grep " ro," /proc/mounts /dev/null || die -t "${T}" "expected overlay to takeover /system after remount" + # KISS (we do not support sub-mounts for system partitions currently) adb_sh grep "^overlay " /proc/mounts &2 - bad_rw=false for d in ${D}; do - if adb_sh tune2fs -l $d &1 | - grep "Filesystem features:.*shared_blocks" >/dev/null; then - bad_rw=true - else - d=`adb_sh df -k ${D} &1 | grep -q "Filesystem features:.*shared_blocks" || + adb_sh df -k "${d}" | grep -q " 100% "; then + die "remount overlayfs missed a spot (rw)" fi done - ${bad_rw} && die "remount overlayfs missed a spot (rw)" fi LOG OK "adb remount RW" @@ -1384,8 +1360,7 @@ fixup_from_recovery() { adb_wait ${ADB_WAIT} } -adb_reboot && - adb_wait ${ADB_WAIT} || +adb_reboot || fixup_from_recovery || die "reboot after override content added failed `usb_status`" @@ -1591,7 +1566,6 @@ if ${is_bootloader_fastboot} && [ -n "${scratch_partition}" ]; then then LOG WARNING "adb disable-verity requires a reboot after partial flash" adb_reboot && - adb_wait ${ADB_WAIT} && adb_root || die "failed to reboot" T=`adb_date`