diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh index 825109fa7..0765f04a2 100755 --- a/fs_mgr/tests/adb-remount-test.sh +++ b/fs_mgr/tests/adb-remount-test.sh @@ -164,12 +164,26 @@ NB: This can be flakey on devices due to USB state Returns: true if device in root state" ] adb_root() { + [ `adb_sh echo '${USER}'` != root ] || return 0 adb root >/dev/null /dev/null sleep 2 adb_wait 2m && [ `adb_sh echo '${USER}'` = root ] } +[ "USAGE: adb_unroot + +NB: This can be flakey on devices due to USB state + +Returns: true if device in un root state" ] +adb_unroot() { + [ `adb_sh echo '${USER}'` = root ] || return 0 + adb unroot >/dev/null /dev/null + sleep 2 + adb_wait 2m && + [ `adb_sh echo '${USER}'` != root ] +} + [ "USAGE: fastboot_getvar var expected Returns: true if var output matches expected" ] @@ -194,6 +208,15 @@ fastboot_getvar() { echo ${O} >&2 } +[ "USAGE: cleanup + +Do nothing: should be redefined when necessary + +Returns: cleans up any latent resources, reverses configurations" ] +cleanup () { + : +} + [ "USAGE: die [-d|-t ] [message] >/dev/stderr If -d, or -t argument is supplied, dump logcat. @@ -212,6 +235,7 @@ die() { shift 2 fi echo "${RED}[ FAILED ]${NORMAL} ${@}" >&2 + cleanup exit 1 } @@ -558,6 +582,7 @@ check_eq "${A}" "${B}" /system after reboot echo "${GREEN}[ OK ]${NORMAL} /system content remains after reboot" >&2 # Only root can read vendor if sepolicy permissions are as expected if ${enforcing}; then + adb_unroot B="`adb_cat /vendor/hello`" && die "re-read /vendor/hello after reboot w/o root" check_eq "cat: /vendor/hello: Permission denied" "${B}" vendor after reboot w/o root