diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh index 6cb7502ca..7a0019452 100755 --- a/fs_mgr/tests/adb-remount-test.sh +++ b/fs_mgr/tests/adb-remount-test.sh @@ -52,11 +52,27 @@ adb_sh() { adb shell "${@}" } +[ "USAGE: adb_date >/dev/stdout + +Returns: report device epoch time (suitable for logcat -t)" ] +adb_date() { + adb_sh date +%s.%N /dev/stdout + +Returns: the logcat output" ] +adb_logcat() { + adb logcat "${@}" Returns the property value" ] get_property() { - adb_sh getprop ${1} 2>&1 /dev/null &1 && + adb root >/dev/null /dev/null && sleep 1 && adb_wait && sleep 1 } +[ "USAGE: die [-t ] [message] >/dev/stderr + +If -t argument is supplied, dump logcat. + +Returns: exit failure, report status" ] die() { + if [ X"-t" = X"${1}" -a -n "${2}" ]; then + adb_logcat -b all -v nsec -t ${2} >&2 + shift 2 + fi echo "${RED}[ FAILED ]${NORMAL} ${@}" >&2 exit 1 } @@ -214,7 +239,7 @@ adb_root && reboot=false OVERLAYFS_BACKING="cache mnt/scratch" for d in ${OVERLAYFS_BACKING}; do - if adb_sh ls -d /${d}/overlay /dev/null 2>&1; then + if adb_sh ls -d /${d}/overlay /dev/null 2>/dev/null; then echo "${ORANGE}[ WARNING ]${NORMAL} /${d}/overlay is setup, wiping" >&2 adb_sh rm -rf /${d}/overlay &2 || echo "${GREEN}[ OK ]${NORMAL} no overlay present before setup" >&2 +adb_sh df -k `adb_sh cat /proc/mounts | + skip_administrative_mounts | + cut -s -d' ' -f1` -D=`adb disable-verity 2>&1` || - die "setup for overlay ${D}" +T=`adb_date` +D=`adb disable-verity 2>&1` +err=${?} echo "${D}" +if [ ${err} != 0 -o X"${D}" != X"${D##*setup failed}" ]; then + die -t ${T} "setup for overlay" +fi if [ X"${D}" != X"${D##*using overlayfs}" ]; then echo "${GREEN}[ OK ]${NORMAL} using overlayfs" >&2 fi @@ -254,11 +286,12 @@ adb_reboot && echo "${D}" | grep "^overlay .* /system\$" >/dev/null || echo "${ORANGE}[ WARNING ]${NORMAL} overlay takeover before remount not complete" >&2 +T=`adb_date` adb_root && adb_wait && adb remount && D=`adb_sh df -k /dev/null; then echo "${ORANGE}[ INFO ]${NORMAL} using scratch dynamic partition for overrides" >&2 H=`adb_sh cat /proc/mounts | sed -n 's@\([^ ]*\) /mnt/scratch \([^ ]*\) .*@\2 on \1@p'` @@ -266,7 +299,7 @@ if echo "${D}" | grep " /mnt/scratch" >/dev/null; then echo "${ORANGE}[ INFO ]${NORMAL} scratch filesystem ${H}" fi for d in ${OVERLAYFS_BACKING}; do - if adb_sh ls -d /${d}/overlay/system/upper /dev/null 2>&1; then + if adb_sh ls -d /${d}/overlay/system/upper /dev/null 2>/dev/null; then echo "${ORANGE}[ INFO ]${NORMAL} /${d}/overlay is setup" >&2 fi done @@ -316,8 +349,9 @@ adb reboot-fastboot && fastboot flash vendor && fastboot reboot || die "fastbootd flash vendor" -adb_wait && - adb_root && +adb_wait 2m || + die "did not reboot after flash" +adb_root && adb_wait && D=`adb_sh df -k /dev/null || true ) && adb_sh rm /system/hello