autotest: add a verifier about setting host's dev mode.

This CL add a verifier to verify whether a host is in dev mode. If it is
in, a repair action which resetting GBB flags will be kicked off.

BUG=chromium:392289
TEST=Run local afe with local DUT. Test 'verify fails' & 'verify
succeeds'.

Change-Id: Iedc42219aba23cf09c2d8364477a2f2530338f80
Reviewed-on: https://chromium-review.googlesource.com/446662
Reviewed-by: Richard Barnette <jrbarnette@google.com>
Commit-Queue: Xixuan Wu <xixuan@chromium.org>
Tested-by: Xixuan Wu <xixuan@chromium.org>
diff --git a/server/hosts/cros_repair.py b/server/hosts/cros_repair.py
index ac96aad..c054362 100644
--- a/server/hosts/cros_repair.py
+++ b/server/hosts/cros_repair.py
@@ -226,6 +226,19 @@
         return 'Python on the host is installed and working'
 
 
+class DevModeVerifier(hosts.Verifier):
+    """Verify that the host is not in dev mode."""
+
+    def verify(self, host):
+        result = host.run('crossystem devsw_boot', ignore_status=True).stdout
+        if result != '0':
+            raise hosts.AutoservVerifyError('The host is in dev mode')
+
+    @property
+    def description(self):
+        return 'The host should not be in dev mode'
+
+
 class ServoSysRqRepair(hosts.RepairAction):
     """
     Repair a Chrome device by sending a system request to the kernel.
@@ -349,6 +362,7 @@
     FirmwareVersionVerifier = cros_firmware.FirmwareVersionVerifier
     verify_dag = [
         (repair.SshVerifier,         'ssh',      []),
+        (DevModeVerifier,            'devmode',  ['ssh']),
         (ACPowerVerifier,            'power',    ['ssh']),
         (EXT4fsErrorVerifier,        'ext4',     ['ssh']),
         (WritableVerifier,           'writable', ['ssh']),
@@ -395,7 +409,7 @@
         # firmware.
         (FirmwareRepair, 'firmware', [], ['ssh', 'fwstatus', 'good_au']),
 
-        (repair.RebootRepair, 'reboot', ['ssh'], ['writable']),
+        (repair.RebootRepair, 'reboot', ['ssh'], ['devmode', 'writable']),
 
         (AutoUpdateRepair, 'au',
                 usb_triggers + powerwash_triggers, au_triggers),
diff --git a/server/hosts/repair.py b/server/hosts/repair.py
index 64a16cd..667380e 100644
--- a/server/hosts/repair.py
+++ b/server/hosts/repair.py
@@ -65,12 +65,13 @@
     """Repair a target device by rebooting it."""
 
     def repair(self, host):
+        host.run('/usr/share/vboot/bin/set_gbb_flags.sh 0')
         host.reboot()
 
 
     @property
     def description(self):
-        return 'Reboot the host'
+        return 'Reset GBB flags and Reboot the host'
 
 
 class RPMCycleRepair(hosts.RepairAction):