Home | History | Annotate | Download | only in firmware_FastbootReboot
      1 # Copyright (c) 2015 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import logging
      6 import time
      7 
      8 from autotest_lib.client.common_lib import error
      9 from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
     10 
     11 
     12 class firmware_FastbootReboot(FirmwareTest):
     13     """
     14     Reboot testing through Fastboot.
     15     Testing:
     16       fastboot reboot
     17       fastboot reboot-bootloader
     18 
     19     This needs to be only enabled for Android tests.
     20     """
     21     version = 1
     22 
     23     def initialize(self, host, cmdline_args, dev_mode=False):
     24         super(firmware_FastbootReboot, self).initialize(host, cmdline_args)
     25         self.switcher.setup_mode('dev' if dev_mode else 'normal')
     26 
     27     def in_fastboot_mode(self):
     28         # make sure that we're in fastboot mode
     29         result = self.faft_client.host.run_shell_command_get_output(
     30             'fastboot devices')
     31         if not result:
     32             return False
     33         else:
     34             return True
     35 
     36     def run_once(self, dev_mode=False):
     37         if not self.faft_client.system.has_host():
     38             raise error.TestNAError('DUT is not Android device.  Skipping test')
     39 
     40         self.faft_client.host.run_shell_command('adb reboot bootloader')
     41         # make sure that DUT goes offline first
     42         self.switcher.wait_for_client_offline()
     43         self.switcher.wait_for_client_fastboot()
     44 
     45         if not self.in_fastboot_mode():
     46             raise error.TestFail("DUT not in fastboot mode!")
     47 
     48         # try rebooting into OS
     49         logging.info("Testing fastboot reboot")
     50         self.faft_client.host.run_shell_command('fastboot reboot')
     51         # make sure that DUT goes offline first
     52         self.switcher.wait_for_client_offline()
     53         self.switcher.wait_for_client()
     54 
     55         # now reboot into fastboot again
     56         self.faft_client.host.run_shell_command('adb reboot bootloader')
     57         # make sure that DUT goes offline first
     58         self.switcher.wait_for_client_offline()
     59         self.switcher.wait_for_client_fastboot()
     60         if not self.in_fastboot_mode():
     61             raise error.TestFail("DUT not in fastboot mode!")
     62 
     63         logging.info("Testing fastboot reboot-bootloader")
     64         self.faft_client.host.run_shell_command('fastboot reboot-bootloader')
     65         # make sure that DUT goes offline first
     66         self.switcher.wait_for_client_offline()
     67         self.switcher.wait_for_client_fastboot()
     68         if not self.in_fastboot_mode():
     69             raise error.TestFail("DUT not in fastboot mode!")
     70 
     71         self.faft_client.host.run_shell_command('fastboot continue')
     72         self.switcher.wait_for_client()
     73