brillo: Test required power management interfaces present

Add test brillo_PowerMgmtInterfaces, which verifies the power management
interfaces required by the DPS are present:

* kernel wakelocks: verify the wakelock sysfs interface is present.
  N.B.: It is not possible to build a brillo kernel without support.

* cpufreq: verify CPU 0's cpufreq sysfs interface is present, and has
  at least one scaling governor available.

* cpuidle: verify the cpuidle sysfs interface is present and a cpuidle
  driver is registered.

This test is added to the Brillo BVT, but not smoke tests, as the Brillo
emulator does not meet all of the above requirements.

Bug: 26163706
Change-Id: I21943dcd9412fb37aae57d75e64aed890fd9c057
Reviewed-on: https://chromium-review.googlesource.com/329605
Commit-Ready: Todd Poynor <toddpoynor@google.com>
Tested-by: Todd Poynor <toddpoynor@google.com>
Reviewed-by: Dan Erat <derat@chromium.org>
diff --git a/server/site_tests/brillo_PowerMgmtInterfaces/brillo_PowerMgmtInterfaces.py b/server/site_tests/brillo_PowerMgmtInterfaces/brillo_PowerMgmtInterfaces.py
new file mode 100644
index 0000000..a4d5469
--- /dev/null
+++ b/server/site_tests/brillo_PowerMgmtInterfaces/brillo_PowerMgmtInterfaces.py
@@ -0,0 +1,39 @@
+# Copyright 2016 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+import os
+
+import common
+from autotest_lib.client.common_lib import error
+from autotest_lib.server import test
+
+class brillo_PowerMgmtInterfaces(test.test):
+    """Verify presence of required power management kernel interfaces."""
+    version = 1
+
+    def check_cpuidle(self, host):
+        cpuidle_driver = host.run_output('cat /sys/devices/system/cpu/cpuidle/current_driver')
+
+        if cpuidle_driver == 'none' or cpuidle_driver == '':
+            raise error.testFail('no cpuidle driver registered')
+
+    def check_cpufreq(self, host):
+        cpufreq_governors = host.run_output('cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors')
+
+        if cpufreq_governors == '':
+            raise error.testFail('no cpufreq governors registered')
+
+    def check_wakelocks(self, host):
+        wakelock_ls = host.run_output('ls /sys/power/wake_lock')
+
+    def run_once(self, host):
+        """Run the Brillo power management kernel interfaces presence test.
+
+        @param host: a host object representing the DUT.
+
+        """
+        self.check_cpuidle(host)
+        self.check_cpufreq(host)
+        self.check_wakelocks(host)
diff --git a/server/site_tests/brillo_PowerMgmtInterfaces/control b/server/site_tests/brillo_PowerMgmtInterfaces/control
new file mode 100644
index 0000000..8106683
--- /dev/null
+++ b/server/site_tests/brillo_PowerMgmtInterfaces/control
@@ -0,0 +1,21 @@
+# Copyright 2016 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+AUTHOR = 'toddpoynor'
+NAME = 'brillo_PowerMgmtInterfaces'
+TIME = 'SHORT'
+TEST_CATEGORY = 'Functional'
+TEST_TYPE = 'Server'
+ATTRIBUTES = 'suite:brillo-bvt'
+SUITE = 'brillo-bvt'
+
+DOC = """
+Check power management OS interfaces required for a Brillo starter board are
+present.
+"""
+
+def run(machine):
+    job.run_test(NAME, host=hosts.create_host(machine))
+
+parallel_simple(run, machines)