fs_mgr: overlayfs: test: test mount -o rw,remount command
WAI: Using mount -o rw,remount command can only work after the
overlays are setup. After the second 'adb disable-verity' or
'adb remount -R' has been issued; the first only disables
verity and does not setup the backing storage. If mount remount
command is issued after the first on an overlayfs system, it will
report a r/o filesystem.
Add a test that confirms that at least this supported behavior is
working, we do not test the corner case.
In the case of overlayfs, we have declared we will not support the
mount remount operation until then; we would need to modify toybox
to add logic that resides inside adb remount service. toybox is
allowed to be adjusted to compile under Android and bionic, but it
is not supposed to have code that is specific to Android.
Fix last test to before this one to move us back into this state.
Fix the adb_sh command parser to handle properly quoting arguments
as it passes them to adb, since we will need it working for this
added test.
Report the product serial number of build description to aid triage.
Test: adb-remount-test.sh
Bug: 109821005
Bug: 122602260
Bug: 123079041
Change-Id: Ida051dbe2a918182db97f0f22f64b299e3c0a068
diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh
index 42f3f29..ede0122 100755
--- a/fs_mgr/tests/adb-remount-test.sh
+++ b/fs_mgr/tests/adb-remount-test.sh
@@ -62,16 +62,17 @@
Returns: true if the command succeeded" ]
adb_sh() {
args=
- for i in ${@}; do
+ for i in "${@}"; do
+ [ -z "${args}" ] || args="${args} "
if [ X"${i}" != X"${i#\'}" ]; then
- args="${args} ${i}"
+ args="${args}${i}"
elif [ X"${i}" != X"${i#* }" ]; then
- args="${args} '${i}'"
+ args="${args}'${i}'"
else
- args="${args} ${i}"
+ args="${args}${i}"
fi
done
- adb shell ${args}
+ adb shell "${args}"
}
[ "USAGE: adb_date >/dev/stdout
@@ -332,6 +333,12 @@
# Do something
+D=`get_property ro.serialno`
+[ -n "${D}" ] || D=`get_property ro.boot.serialno`
+[ -z "${D}" ] || ANDROID_SERIAL=${D}
+BUILD_DESCRIPTION=`get_property ro.build.description`
+echo "${BLUE}[ INFO ]${NORMAL} ${ANDROID_SERIAL} ${BUILD_DESCRIPTION}" >&2
+
echo "${GREEN}[ RUN ]${NORMAL} Testing kernel support for overlayfs" >&2
overlayfs_supported=true;
@@ -553,8 +560,8 @@
echo "${GREEN}[ RUN ]${NORMAL} push content to /system and /vendor" >&2
A="Hello World! $(date)"
-echo "${A}" | adb_sh "cat - > /system/hello"
-echo "${A}" | adb_sh "cat - > /vendor/hello"
+echo "${A}" | adb_sh cat - ">/system/hello"
+echo "${A}" | adb_sh cat - ">/vendor/hello"
B="`adb_cat /system/hello`" ||
die "sytem hello"
check_eq "${A}" "${B}" /system before reboot
@@ -575,7 +582,7 @@
( echo "${L}" && false ) ||
die -d "overlay takeover failed after reboot"
- adb_su "sed -n '1,/overlay \\/system/p' /proc/mounts" </dev/null |
+ adb_su sed -n '1,/overlay \/system/p' /proc/mounts </dev/null |
skip_administrative_mounts |
grep -v ' \(squashfs\|ext4\|f2fs\) ' &&
echo "${ORANGE}[ WARNING ]${NORMAL} overlay takeover after first stage init" >&2 ||
@@ -705,17 +712,22 @@
if [ -n "${scratch_partition}" ]; then
- echo "${GREEN}[ RUN ]${NORMAL} test fastboot flash to ${scratch_partition}" >&2
+ echo "${GREEN}[ RUN ]${NORMAL} test fastboot flash to ${scratch_partition} recovery" >&2
adb reboot-fastboot ||
die "Reboot into fastbootd"
+ cleanup() {
+ rm /tmp/adb-remount-test.img
+ }
dd if=/dev/zero of=/tmp/adb-remount-test.img bs=4096 count=16 2>/dev/null &&
fastboot_wait 2m ||
- ( rm /tmp/adb-remount-test.img && false) ||
die "reboot into fastboot"
fastboot flash --force ${scratch_partition} /tmp/adb-remount-test.img
err=${?}
- rm /tmp/adb-remount-test.img
+ cleanup
+ cleanup() {
+ :
+ }
fastboot reboot ||
die "can not reboot out of fastboot"
[ 0 -eq ${err} ] ||
@@ -726,6 +738,8 @@
T=`adb_date`
D=`adb disable-verity 2>&1`
err=${?}
+ adb remount ||
+ die "remount failed"
echo "${D}"
[ ${err} = 0 ] &&
[ X"${D}" = X"${D##*setup failed}" ] &&
@@ -734,4 +748,18 @@
die -t ${T} "setup for overlayfs"
fi
+echo "${GREEN}[ RUN ]${NORMAL} test raw remount command" >&2
+
+# prerequisite is a prepped device from above
+adb_reboot &&
+ adb_wait 2m ||
+ die "lost device after reboot to ro state"
+adb_sh grep " /vendor .* rw," /proc/mounts >/dev/null &&
+ die "/vendor is not read-only"
+adb_su mount -o rw,remount /vendor ||
+ die "remount command"
+adb_sh grep " /vendor .* rw," /proc/mounts >/dev/null ||
+ die "/vendor is not read-write"
+echo "${GREEN}[ OK ]${NORMAL} mount -o rw,remount command works" >&2
+
echo "${GREEN}[ PASSED ]${NORMAL} adb remount" >&2