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 common 6from autotest_lib.client.common_lib import error 7from autotest_lib.server import test 8 9 10class brillo_NVRAM(test.test): 11 """Test Access-Controlled NVRAM HAL functionality.""" 12 version = 1 13 14 TEST_EXECUTABLE = '/data/nativetest/nvram_hal_test/nvram_hal_test' 15 16 def _get_prop(self, host, property_name): 17 """Returns the value of a system property. 18 19 @param host: A host object representing the DUT. 20 @param property_name: A string holding the property name. 21 22 @return: A string holding the property value. 23 """ 24 return host.run_output('getprop %s' % property_name).strip() 25 26 27 def run_once(self, host=None): 28 """Runs the test. 29 30 @param host: A host object representing the DUT. 31 32 @raise TestFail: The test executable returned an error. 33 """ 34 try: 35 if self._get_prop(host, 'ro.hardware.nvram') == 'testing': 36 raise error.TestFail('NVRAM HAL is not hardware-backed') 37 host.run(self.TEST_EXECUTABLE) 38 except error.GenericHostRunError as run_error: 39 raise error.TestFail(run_error) 40