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 5import time 6 7from autotest_lib.server import autotest, test 8 9class system_ColdBoot(test.test): 10 """ 11 Shut down the device gracefully via Linux shell commands, then simulate 12 a power button press and verify that it comes back up correctly. 13 """ 14 version = 1 15 16 # Allowed timeout for graceful shutdown. 17 TIMEOUT_POWEROFF_TRANSITION = 15 18 # Time to sleep to ensure full power off, after OS quits replying to pings. 19 WAIT_TIME_FULL_POWEROFF = 5 20 21 def run_once(self, host): 22 boot_id = host.get_boot_id() 23 24 host.run("poweroff") 25 host.test_wait_for_shutdown(self.TIMEOUT_POWEROFF_TRANSITION) 26 time.sleep(self.WAIT_TIME_FULL_POWEROFF) 27 28 host.servo.power_normal_press() 29 host.test_wait_for_boot(boot_id) 30 31 autotest.Autotest(host).run_test("desktopui_SimpleLogin", 32 exit_without_logout=True) 33