OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2010 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 |
| 6 import time |
| 7 |
| 8 from autotest_lib.client.bin import factory |
| 9 from autotest_lib.client.bin import factory_ui_lib as ful |
| 10 from autotest_lib.client.bin import test, utils |
| 11 from autotest_lib.client.common_lib import error |
| 12 |
| 13 |
| 14 GPIO_ROOT = '/home/gpio' |
| 15 GOOGLE_REQUIRED_TESTS = [ 'GRT_HWComponents', 'GRT_DevRec' ] |
| 16 |
| 17 |
| 18 def init_gpio(gpio_root=GPIO_ROOT): |
| 19 """ initializes GPIO in GPIO_ROOT """ |
| 20 if os.path.exists(gpio_root): |
| 21 utils.system("rm -rf '%s'" % gpio_root) |
| 22 utils.system("mkdir '%s'" % (gpio_root)) |
| 23 utils.system("/usr/sbin/gpio_setup") |
| 24 |
| 25 |
| 26 class factory_Verify(test.test): |
| 27 version = 1 |
| 28 |
| 29 def alert_bypassed(self, target, times=3): |
| 30 """ Alerts user that a required test is bypassed. """ |
| 31 for i in range(times, 0, -1): |
| 32 factory.log(('WARNING: Factory Final Verify: <%s> IS BYPASSED. ' + |
| 33 'THIS DEVICE CANNOT BE QUALIFIED. ' + |
| 34 '(continue in %d seconds)') % (target, i)) |
| 35 time.sleep(1) |
| 36 |
| 37 def check_developer_switch(self, do_check): |
| 38 """ Checks if developer switch button is in disabled state """ |
| 39 if not do_check: |
| 40 self.alert_bypassed("DEVELOPER SWITCH BUTTON") |
| 41 return |
| 42 |
| 43 init_gpio() |
| 44 status = open(os.path.join(GPIO_ROOT, "developer_switch")).read() |
| 45 status_val = int(status) |
| 46 if status_val != 0: |
| 47 raise error.TestFail('Developer Switch Button is enabled') |
| 48 |
| 49 def check_flashrom_write_protect(self, do_check): |
| 50 """ Enables and checks write protection for flashrom """ |
| 51 if not do_check: |
| 52 self.alert_bypassed("FLASHROM WRITE PROTECTION") |
| 53 return |
| 54 |
| 55 factory.log('enable write protect (factory_EnableWriteProtect)') |
| 56 self.job.run_test('factory_EnableWriteProtect') |
| 57 |
| 58 # verify if write protection range is properly fixed, |
| 59 # and all bits in RW is writable. |
| 60 factory.log('verify write protect (hardware_EepromWriteProtect)') |
| 61 if not self.job.run_test('hardware_EepromWriteProtect'): |
| 62 raise error.TestFail('Flashrom write protection test failed.') |
| 63 |
| 64 def check_google_required_tests(self, do_check, status_file, test_list): |
| 65 """ Checks if all previous and Google Required Tests are passed. """ |
| 66 if not do_check: |
| 67 self.alert_bypassed('REQUIRED TESTS') |
| 68 return |
| 69 |
| 70 # check if all previous tests are passed. |
| 71 status_map = factory.StatusMap(test_list, status_file) |
| 72 db = status_map.test_db |
| 73 failed_list = status_map.filter(ful.FAILED) |
| 74 if failed_list: |
| 75 failed = ','.join([db.get_unique_details(t) for t in failed_list]) |
| 76 raise error.TestFail('Some previous tests failed: %s' % |
| 77 failed) |
| 78 |
| 79 # check if all Google Required Tests are passed |
| 80 missing = [] |
| 81 for g in GOOGLE_REQUIRED_TESTS: |
| 82 t = db.get_test_by_unique_name(g) |
| 83 if status_map.lookup_status(t) != ful.PASSED: |
| 84 missing.append('%s(%s)' % (g, db.get_unique_details(t))) |
| 85 if missing: |
| 86 missing_msg = ', '.join(missing) |
| 87 raise error.TestFail('You need to execute following ' + |
| 88 'Google Required Tests: %s' % missing_msg) |
| 89 |
| 90 def run_once(self, |
| 91 check_required_tests=True, |
| 92 check_developer_switch=True, |
| 93 check_and_enable_write_protect=True, |
| 94 status_file_path=None, |
| 95 test_list=None): |
| 96 |
| 97 # apply each final tests |
| 98 self.check_google_required_tests(check_required_tests, |
| 99 status_file_path, |
| 100 test_list) |
| 101 self.check_developer_switch(check_developer_switch) |
| 102 self.check_flashrom_write_protect(check_and_enable_write_protect) |
OLD | NEW |