Home | History | Annotate | Download | only in dummy_IdleSuspend
      1 # Copyright (c) 2013 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 os, time
      6 
      7 from autotest_lib.client.bin import test
      8 from autotest_lib.client.common_lib import error
      9 from autotest_lib.client.common_lib.cros import chrome
     10 from autotest_lib.client.cros.power import power_suspend, power_utils
     11 
     12 
     13 class dummy_IdleSuspend(test.test):
     14     """
     15     This is not a complete test. It is a dummy test that must be run in parallel
     16     with power_SuspendStress(method='idle') to control powerd idle values and
     17     perform a login.
     18     """
     19     version = 1
     20 
     21     _IDLE_TIMINGS = {
     22         'disable_idle_suspend': 0,
     23         'ignore_external_policy': 1,
     24         'unplugged_dim_ms': 4000,
     25         'unplugged_off_ms': 6000,
     26         'unplugged_suspend_ms': 8000,
     27         'plugged_dim_ms': 4000,
     28         'plugged_off_ms': 6000,
     29         'plugged_suspend_ms': 8000,
     30     }
     31 
     32     # Don't wait longer than this to start... if power_SuspendStress died before
     33     # creating the HWCLOCK_FILE, we might otherwise wait forever
     34     _TEST_START_TIMEOUT = 70
     35 
     36     def run_once(self):
     37         with chrome.Chrome():
     38             # Just idle while power_SuspendStress does all the work. Existence
     39             # of the HWCLOCK_FILE tells us when it starts and when it's done.
     40             for _ in xrange(self._TEST_START_TIMEOUT):
     41                 time.sleep(1)
     42                 if os.path.exists(power_suspend.Suspender.HWCLOCK_FILE):
     43                     break
     44             else:
     45                 raise error.TestError("Parallel test didn't create Suspender.")
     46 
     47             # These must not be enabled too soon, or the system might suspend
     48             # before a wakeup is scheduled. They must not be disabled too late
     49             # either, or we might suspend again after the parallel test is done.
     50             power_prefs = power_utils.PowerPrefChanger(self._IDLE_TIMINGS)
     51 
     52             while os.path.exists(power_suspend.Suspender.HWCLOCK_FILE):
     53                 time.sleep(1)
     54 
     55             power_prefs.finalize()
     56