1 # -*- coding: utf-8 -*- 2 # 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 4 # Use of this source code is governed by a BSD-style license that can be 5 # found in the LICENSE file. 6 7 __author__ = 'nsanders (at] chromium.org (Nick Sanders)' 8 9 import logging, os 10 11 from autotest_lib.client.bin import test, utils 12 from autotest_lib.client.common_lib import error 13 from autotest_lib.client.cros import gpio 14 15 class hardware_GPIOSwitches(test.test): 16 version = 4 17 18 def initialize(self): 19 self._gpio = gpio.Gpio(error.TestError) 20 21 def gpio_read(self, name): 22 try: 23 return self._gpio.read(name) 24 except: 25 raise error.TestError( 26 'Unable to read gpio value "%s"\n' 27 ' gpio "%s"' % (name, name)) 28 29 def run_once(self): 30 self._gpio.setup() 31 keyvals = {} 32 keyvals['level_recovery'] = self.gpio_read('recovery_button') 33 keyvals['level_developer'] = self.gpio_read('developer_switch') 34 keyvals['level_firmware_writeprotect'] = self.gpio_read('write_protect') 35 36 self.write_perf_keyval(keyvals) 37