1# Lint as: python2, python3 2# Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import os, time 7 8from autotest_lib.client.bin import test 9from autotest_lib.client.common_lib import error 10from autotest_lib.client.common_lib.cros import chrome 11from autotest_lib.client.cros.power import power_suspend, power_utils 12 13 14class stub_IdleSuspend(test.test): 15 """ 16 This is not a complete test. It is a stub test that must be run in parallel 17 with power_SuspendStress(method='idle') to control powerd idle values and 18 perform a login. 19 """ 20 version = 1 21 22 _IDLE_TIMINGS = { 23 'disable_idle_suspend': 0, 24 'ignore_external_policy': 1, 25 'unplugged_dim_ms': 8000, 26 'unplugged_off_ms': 12000, 27 'unplugged_suspend_ms': 8000, 28 'plugged_dim_ms': 8000, 29 'plugged_off_ms': 12000, 30 'plugged_suspend_ms': 8000, 31 } 32 33 # Don't wait longer than this to start... if power_SuspendStress died before 34 # creating the HWCLOCK_FILE, we might otherwise wait forever 35 _TEST_START_TIMEOUT = 70 36 37 def run_once(self): 38 with chrome.Chrome(): 39 # Just idle while power_SuspendStress does all the work. Existence 40 # of the HWCLOCK_FILE tells us when it starts and when it's done. 41 for _ in range(self._TEST_START_TIMEOUT): 42 time.sleep(1) 43 if os.path.exists(power_suspend.Suspender.HWCLOCK_FILE): 44 break 45 else: 46 raise error.TestError("Parallel test didn't create Suspender.") 47 48 # These must not be enabled too soon, or the system might suspend 49 # before a wakeup is scheduled. They must not be disabled too late 50 # either, or we might suspend again after the parallel test is done. 51 power_prefs = power_utils.PowerPrefChanger(self._IDLE_TIMINGS) 52 53 while os.path.exists(power_suspend.Suspender.HWCLOCK_FILE): 54 time.sleep(1) 55 56 power_prefs.finalize() 57