Loading fs_mgr/tests/adb-remount-test.sh +39 −11 Original line number Original line Diff line number Diff line Loading @@ -62,7 +62,8 @@ inAdb() { Returns: true if the command succeeded" ] Returns: true if the command succeeded" ] adb_sh() { adb_sh() { args= args= for i in ${@}; do for i in "${@}"; do [ -z "${args}" ] || args="${args} " if [ X"${i}" != X"${i#\'}" ]; then if [ X"${i}" != X"${i#\'}" ]; then args="${args}${i}" args="${args}${i}" elif [ X"${i}" != X"${i#* }" ]; then elif [ X"${i}" != X"${i#* }" ]; then Loading @@ -71,7 +72,7 @@ adb_sh() { args="${args}${i}" args="${args}${i}" fi fi done done adb shell ${args} adb shell "${args}" } } [ "USAGE: adb_date >/dev/stdout [ "USAGE: adb_date >/dev/stdout Loading Loading @@ -332,6 +333,12 @@ fi # Do something # 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 echo "${GREEN}[ RUN ]${NORMAL} Testing kernel support for overlayfs" >&2 overlayfs_supported=true; overlayfs_supported=true; Loading Loading @@ -553,8 +560,8 @@ fi echo "${GREEN}[ RUN ]${NORMAL} push content to /system and /vendor" >&2 echo "${GREEN}[ RUN ]${NORMAL} push content to /system and /vendor" >&2 A="Hello World! $(date)" A="Hello World! $(date)" echo "${A}" | adb_sh "cat - > /system/hello" echo "${A}" | adb_sh cat - ">/system/hello" echo "${A}" | adb_sh "cat - > /vendor/hello" echo "${A}" | adb_sh cat - ">/vendor/hello" B="`adb_cat /system/hello`" || B="`adb_cat /system/hello`" || die "sytem hello" die "sytem hello" check_eq "${A}" "${B}" /system before reboot check_eq "${A}" "${B}" /system before reboot Loading @@ -575,7 +582,7 @@ if ${overlayfs_needed}; then ( echo "${L}" && false ) || ( echo "${L}" && false ) || die -d "overlay takeover failed after reboot" 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 | skip_administrative_mounts | grep -v ' \(squashfs\|ext4\|f2fs\) ' && grep -v ' \(squashfs\|ext4\|f2fs\) ' && echo "${ORANGE}[ WARNING ]${NORMAL} overlay takeover after first stage init" >&2 || echo "${ORANGE}[ WARNING ]${NORMAL} overlay takeover after first stage init" >&2 || Loading Loading @@ -705,17 +712,22 @@ check_eq "cat: /vendor/hello: No such file or directory" "${B}" after flash rm if [ -n "${scratch_partition}" ]; then 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 || adb reboot-fastboot || die "Reboot into fastbootd" 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 && dd if=/dev/zero of=/tmp/adb-remount-test.img bs=4096 count=16 2>/dev/null && fastboot_wait 2m || fastboot_wait 2m || ( rm /tmp/adb-remount-test.img && false) || die "reboot into fastboot" die "reboot into fastboot" fastboot flash --force ${scratch_partition} /tmp/adb-remount-test.img fastboot flash --force ${scratch_partition} /tmp/adb-remount-test.img err=${?} err=${?} rm /tmp/adb-remount-test.img cleanup cleanup() { : } fastboot reboot || fastboot reboot || die "can not reboot out of fastboot" die "can not reboot out of fastboot" [ 0 -eq ${err} ] || [ 0 -eq ${err} ] || Loading @@ -726,6 +738,8 @@ if [ -n "${scratch_partition}" ]; then T=`adb_date` T=`adb_date` D=`adb disable-verity 2>&1` D=`adb disable-verity 2>&1` err=${?} err=${?} adb remount || die "remount failed" echo "${D}" echo "${D}" [ ${err} = 0 ] && [ ${err} = 0 ] && [ X"${D}" = X"${D##*setup failed}" ] && [ X"${D}" = X"${D##*setup failed}" ] && Loading @@ -734,4 +748,18 @@ if [ -n "${scratch_partition}" ]; then die -t ${T} "setup for overlayfs" die -t ${T} "setup for overlayfs" fi 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 echo "${GREEN}[ PASSED ]${NORMAL} adb remount" >&2 Loading
fs_mgr/tests/adb-remount-test.sh +39 −11 Original line number Original line Diff line number Diff line Loading @@ -62,7 +62,8 @@ inAdb() { Returns: true if the command succeeded" ] Returns: true if the command succeeded" ] adb_sh() { adb_sh() { args= args= for i in ${@}; do for i in "${@}"; do [ -z "${args}" ] || args="${args} " if [ X"${i}" != X"${i#\'}" ]; then if [ X"${i}" != X"${i#\'}" ]; then args="${args}${i}" args="${args}${i}" elif [ X"${i}" != X"${i#* }" ]; then elif [ X"${i}" != X"${i#* }" ]; then Loading @@ -71,7 +72,7 @@ adb_sh() { args="${args}${i}" args="${args}${i}" fi fi done done adb shell ${args} adb shell "${args}" } } [ "USAGE: adb_date >/dev/stdout [ "USAGE: adb_date >/dev/stdout Loading Loading @@ -332,6 +333,12 @@ fi # Do something # 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 echo "${GREEN}[ RUN ]${NORMAL} Testing kernel support for overlayfs" >&2 overlayfs_supported=true; overlayfs_supported=true; Loading Loading @@ -553,8 +560,8 @@ fi echo "${GREEN}[ RUN ]${NORMAL} push content to /system and /vendor" >&2 echo "${GREEN}[ RUN ]${NORMAL} push content to /system and /vendor" >&2 A="Hello World! $(date)" A="Hello World! $(date)" echo "${A}" | adb_sh "cat - > /system/hello" echo "${A}" | adb_sh cat - ">/system/hello" echo "${A}" | adb_sh "cat - > /vendor/hello" echo "${A}" | adb_sh cat - ">/vendor/hello" B="`adb_cat /system/hello`" || B="`adb_cat /system/hello`" || die "sytem hello" die "sytem hello" check_eq "${A}" "${B}" /system before reboot check_eq "${A}" "${B}" /system before reboot Loading @@ -575,7 +582,7 @@ if ${overlayfs_needed}; then ( echo "${L}" && false ) || ( echo "${L}" && false ) || die -d "overlay takeover failed after reboot" 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 | skip_administrative_mounts | grep -v ' \(squashfs\|ext4\|f2fs\) ' && grep -v ' \(squashfs\|ext4\|f2fs\) ' && echo "${ORANGE}[ WARNING ]${NORMAL} overlay takeover after first stage init" >&2 || echo "${ORANGE}[ WARNING ]${NORMAL} overlay takeover after first stage init" >&2 || Loading Loading @@ -705,17 +712,22 @@ check_eq "cat: /vendor/hello: No such file or directory" "${B}" after flash rm if [ -n "${scratch_partition}" ]; then 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 || adb reboot-fastboot || die "Reboot into fastbootd" 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 && dd if=/dev/zero of=/tmp/adb-remount-test.img bs=4096 count=16 2>/dev/null && fastboot_wait 2m || fastboot_wait 2m || ( rm /tmp/adb-remount-test.img && false) || die "reboot into fastboot" die "reboot into fastboot" fastboot flash --force ${scratch_partition} /tmp/adb-remount-test.img fastboot flash --force ${scratch_partition} /tmp/adb-remount-test.img err=${?} err=${?} rm /tmp/adb-remount-test.img cleanup cleanup() { : } fastboot reboot || fastboot reboot || die "can not reboot out of fastboot" die "can not reboot out of fastboot" [ 0 -eq ${err} ] || [ 0 -eq ${err} ] || Loading @@ -726,6 +738,8 @@ if [ -n "${scratch_partition}" ]; then T=`adb_date` T=`adb_date` D=`adb disable-verity 2>&1` D=`adb disable-verity 2>&1` err=${?} err=${?} adb remount || die "remount failed" echo "${D}" echo "${D}" [ ${err} = 0 ] && [ ${err} = 0 ] && [ X"${D}" = X"${D##*setup failed}" ] && [ X"${D}" = X"${D##*setup failed}" ] && Loading @@ -734,4 +748,18 @@ if [ -n "${scratch_partition}" ]; then die -t ${T} "setup for overlayfs" die -t ${T} "setup for overlayfs" fi 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 echo "${GREEN}[ PASSED ]${NORMAL} adb remount" >&2