• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 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 logging
6import os
7
8import common
9from autotest_lib.client.common_lib import error
10from autotest_lib.server import test
11
12class brillo_PowerMgmtInterfaces(test.test):
13    """Verify presence of required power management kernel interfaces."""
14    version = 1
15
16    def check_cpuidle(self, host):
17        cpuidle_driver = host.run_output('cat /sys/devices/system/cpu/cpuidle/current_driver')
18
19        if cpuidle_driver == 'none' or cpuidle_driver == '':
20            raise error.testFail('no cpuidle driver registered')
21
22    def check_cpufreq(self, host):
23        cpufreq_governors = host.run_output('cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors')
24
25        if cpufreq_governors == '':
26            raise error.testFail('no cpufreq governors registered')
27
28    def check_wakelocks(self, host):
29        wakelock_ls = host.run_output('ls /sys/power/wake_lock')
30
31    def check_suspend(self, host):
32        pm_states = host.run_output('cat /sys/power/state')
33        if pm_states.find("mem") == -1:
34            raise error.testFail('suspend-to-mem not supported')
35
36    def run_once(self, host):
37        """Run the Brillo power management kernel interfaces presence test.
38
39        @param host: a host object representing the DUT.
40
41        """
42        self.check_cpuidle(host)
43        self.check_cpufreq(host)
44        self.check_wakelocks(host)
45        self.check_suspend(host)
46