Automatically do 'adb disable-verity' if needed

This also adds 'adb wait-for-device' before 'adb root'
to correctly handle the case that device is not ready yet when
runtest.sh is executed.

Bug: 67326963

Test: run 'adb enable-verify' and 'adb reboot'
    then execute run_test.sh
    observe that 'adb disable-verify' is executed.

Test: run 'adb disable-verify' and 'adb reboot'
    then execute run_test.sh
    observe that 'adb disable-verify' is not executed.

Change-Id: I064a6408fefee13cc3c4882f060e3b5059364d4f
diff --git a/runtests.sh b/runtests.sh
index 9d6701a..7fae183 100755
--- a/runtests.sh
+++ b/runtests.sh
@@ -30,9 +30,21 @@
 
 set -x # print commands
 
+adb wait-for-device
 adb root
 adb wait-for-device
-adb remount
+
+# 'disable-verity' will appear in 'adb remount' output if
+# dm-verity is enabled and needs to be disabled.
+if adb remount | grep 'disable-verity'; then
+  adb disable-verity
+  adb reboot
+  adb wait-for-device
+  adb root
+  adb wait-for-device
+  adb remount
+fi
+
 adb sync
 
 adb shell /data/nativetest/wifilogd_unit_test/wifilogd_unit_test