adb-remount-test: Only test mounts that are remounted by us
Right now we assume all RW mounts (minus /data & special FS) are
remounted by us and we apply the remount/overlayfs related checks
on them unconditionally. This would generate false positives when
a partition was RW but not remounted by us.
The test should instead check mounts that were remounted by us
(transitioned from RO to RW after adb-remount), and ignore
partitions that were already RW before running adb-remount.
Bug: 313609600
Test: adb-remount-test
Change-Id: I94e8a35775271f557790a458781657eb3b24a6f5
diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh
index c87e564..7ac7a16 100755
--- a/fs_mgr/tests/adb-remount-test.sh
+++ b/fs_mgr/tests/adb-remount-test.sh
@@ -1233,6 +1233,12 @@
adb_sh grep -q " /vendor [^ ]* rw," /proc/mounts </dev/null &&
die "/vendor is not RO"
+data_device=$(adb_sh awk '$2 == "/data" { print $1; exit }' /proc/mounts)
+RO=$(adb_sh grep " ro," /proc/mounts </dev/null |
+ grep -v "^${data_device}" |
+ skip_administrative_mounts |
+ awk '{ print $1 }')
+
T=$(adb_date)
adb remount >&2 ||
die -t "${T}" "adb remount"
@@ -1241,6 +1247,12 @@
adb_sh grep -q " /vendor [^ ]* rw," /proc/mounts </dev/null ||
die -t "${T}" "/vendor is not RW"
+# Only find mounts that are remounted RO -> RW
+RW=$(adb_sh grep " rw," /proc/mounts </dev/null |
+ grep -v "^${data_device}" |
+ skip_administrative_mounts |
+ grep -E "^($(join_with '|' ${RO})) ")
+
scratch_on_super=false
if ${overlayfs_needed}; then
is_overlayfs_mounted /system ||
@@ -1287,27 +1299,19 @@
fi
done
- data_device=$(adb_sh awk '$2 == "/data" { print $1; exit }' /proc/mounts)
# KISS (we do not support sub-mounts for system partitions currently)
adb_sh grep "^overlay " /proc/mounts </dev/null |
grep -vE "^overlay.* /(apex|system|vendor)/[^ ]" |
grep " overlay ro," &&
die "expected overlay to be RW after remount"
- adb_sh grep -v noatime /proc/mounts </dev/null |
- grep -v "^${data_device}" |
- skip_administrative_mounts |
- grep -v ' ro,' &&
- die "mounts are not noatime"
- D=$(adb_sh grep " rw," /proc/mounts </dev/null |
- grep -v "^${data_device}" |
- skip_administrative_mounts |
+ D=$(echo "${RW}" |
awk '{ print $1 }' |
sed 's|/dev/root|/|' |
sort -u)
if [ -n "${D}" ]; then
adb_sh df -k ${D} </dev/null |
- sed -e 's/^Filesystem /Filesystem (rw) /'
+ sed -e 's/^Filesystem /Filesystem (rw)/'
fi >&2
for d in ${D}; do
if adb_sh tune2fs -l "${d}" </dev/null 2>&1 | grep -q "Filesystem features:.*shared_blocks" ||
@@ -1319,6 +1323,10 @@
is_overlayfs_mounted && die -t "${T}" "unexpected overlay takeover"
fi
+echo -n "${RW}" |
+ grep -v noatime &&
+ die "mounts (rw) are not noatime"
+
LOG OK "adb remount RW"
################################################################################