From b3c0074917f791ca4bd79fa780b46312883521fc Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Wed, 2 Jan 2019 10:09:42 -0800 Subject: [PATCH] fs_mgr: overlayfs test fix adb_sh Some commands like 'adb_sh grep " rw," /proc/mounts' do not preserve the embedded spaces when transferred to the device and thus do not entirely behave as expected. There are several commands issued this way throughout the test that are similarly broken. To add consistency, pass any arguments that are not explicitly (double) quoted and contain embedded spaces as quoted to preserve. Also devices that report the kernel internal device /dev/root in /proc/mounts should be suppressed when investigating whether overlayfs is needed. If /dev/root is reported, then we should assume that the mount point / represents it for the following df command when trying to determine if the partition is right-sized. When there is only one device attached, and a serial number is not specified, correctly determine this condition to progress to the testing. Test: adb_remount_test.sh Bug: 122231184 Change-Id: I913e297dd272d6691110bb5d7a7c7f54321b6833 --- fs_mgr/tests/adb-remount-test.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh index 9e211e3bf..160e07651 100755 --- a/fs_mgr/tests/adb-remount-test.sh +++ b/fs_mgr/tests/adb-remount-test.sh @@ -49,7 +49,7 @@ inFastboot() { Returns: true if device is in adb mode" ] inAdb() { adb devices | - grep -v 'List of devices attached' | + grep -v -e 'List of devices attached' -e '^$' | if [ -n "${ANDROID_SERIAL}" ]; then grep "^${ANDROID_SERIAL}[${SPACE}${TAB}]" > /dev/null else @@ -61,7 +61,17 @@ inAdb() { Returns: true if the command succeeded" ] adb_sh() { - adb shell "${@}" + args= + for i in ${@}; do + if [ X"${i}" != X"${i#\'}" ]; then + args="${args} ${i}" + elif [ X"${i}" != X"${i#* }" ]; then + args="${args} '${i}'" + else + args="${args} ${i}" + fi + done + adb shell ${args} } [ "USAGE: adb_date >/dev/stdout @@ -92,7 +102,7 @@ get_property() { Returns: true if device is (likely) a debug build" ] isDebuggable() { - if inAdb && [ 1 -ne "`get_property ro.debuggable`" ]; then + if inAdb && [ 1 != "`get_property ro.debuggable`" ]; then false fi } @@ -363,8 +373,12 @@ D=`adb_sh df -k &2 overlayfs_needed=true D=`adb_sh cat /proc/mounts /dev/null; then + D=`echo / / + echo "${D}" | grep -v /dev/root` +fi +D=`echo "${D}" | cut -s -d' ' -f1` D=`adb_sh df -k ${D}