| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 import time | 6 import time |
| 7 | 7 |
| 8 from autotest_lib.client.bin import factory | 8 from autotest_lib.client.bin import factory |
| 9 from autotest_lib.client.bin import factory_ui_lib as ful | 9 from autotest_lib.client.bin import factory_ui_lib as ful |
| 10 from autotest_lib.client.bin import test, utils | 10 from autotest_lib.client.bin import test, utils |
| 11 from autotest_lib.client.bin import factory_error as error | 11 from autotest_lib.client.bin import factory_error as error |
| 12 | 12 |
| 13 | 13 |
| 14 GPIO_ROOT = '/home/gpio' | 14 GPIO_ROOT = '/home/gpio' |
| 15 GOOGLE_REQUIRED_TESTS = [ 'GRT_HWComponents', 'GRT_DevRec' ] | 15 GOOGLE_REQUIRED_TESTS = [ 'GRT_HWComponents', 'GRT_DevRec' ] |
| 16 | 16 |
| 17 | 17 |
| 18 def init_gpio(gpio_root=GPIO_ROOT): | 18 def init_gpio(gpio_root=GPIO_ROOT): |
| 19 """ initializes GPIO in GPIO_ROOT """ | 19 """ initializes GPIO in GPIO_ROOT """ |
| 20 if os.path.exists(gpio_root): | 20 if os.path.exists(gpio_root): |
| 21 utils.system("rm -rf '%s'" % gpio_root) | 21 utils.system("rm -rf '%s'" % gpio_root) |
| 22 utils.system("mkdir '%s'" % (gpio_root)) | 22 utils.system("mkdir '%s'" % (gpio_root)) |
| 23 utils.system("/usr/sbin/gpio_setup") | 23 utils.system("/usr/sbin/gpio_setup") |
| 24 | 24 |
| 25 | 25 |
| 26 class factory_Verify(test.test): | 26 class factory_Verify(test.test): |
| 27 version = 1 | 27 version = 2 |
| 28 | 28 |
| 29 def alert_bypassed(self, target, times=3): | 29 def alert_bypassed(self, target, times=3): |
| 30 """ Alerts user that a required test is bypassed. """ | 30 """ Alerts user that a required test is bypassed. """ |
| 31 for i in range(times, 0, -1): | 31 for i in range(times, 0, -1): |
| 32 factory.log(('WARNING: Factory Final Verify: <%s> IS BYPASSED. ' + | 32 factory.log(('WARNING: Factory Final Verify: <%s> IS BYPASSED. ' + |
| 33 'THIS DEVICE CANNOT BE QUALIFIED. ' + | 33 'THIS DEVICE CANNOT BE QUALIFIED. ' + |
| 34 '(continue in %d seconds)') % (target, i)) | 34 '(continue in %d seconds)') % (target, i)) |
| 35 time.sleep(1) | 35 time.sleep(1) |
| 36 | 36 |
| 37 def check_developer_switch(self, do_check): | 37 def check_developer_switch(self, do_check): |
| 38 """ Checks if developer switch button is in disabled state """ | 38 """ Checks if developer switch button is in disabled state """ |
| 39 if not do_check: | 39 if not do_check: |
| 40 self.alert_bypassed("DEVELOPER SWITCH BUTTON") | 40 self.alert_bypassed("DEVELOPER SWITCH BUTTON") |
| 41 return | 41 return |
| 42 | 42 |
| 43 init_gpio() | 43 init_gpio() |
| 44 status = open(os.path.join(GPIO_ROOT, "developer_switch")).read() | 44 status = open(os.path.join(GPIO_ROOT, "developer_switch")).read() |
| 45 status_val = int(status) | 45 status_val = int(status) |
| 46 if status_val != 0: | 46 if status_val != 0: |
| 47 raise error.TestFail('Developer Switch Button is enabled') | 47 raise error.TestFail('Developer Switch Button is enabled') |
| 48 | 48 |
| 49 def check_flashrom_write_protect(self, do_check): | 49 def check_flashrom_write_protect(self, do_check, subtest_tag): |
| 50 """ Enables and checks write protection for flashrom """ | 50 """ Enables and checks write protection for flashrom """ |
| 51 if not do_check: | 51 if not do_check: |
| 52 self.alert_bypassed("FLASHROM WRITE PROTECTION") | 52 self.alert_bypassed("FLASHROM WRITE PROTECTION") |
| 53 return | 53 return |
| 54 | 54 |
| 55 factory.log('enable write protect (factory_EnableWriteProtect)') | 55 # this is an important message, so print it several times to alert user |
| 56 self.job.run_test('factory_EnableWriteProtect') | 56 for i in range(3): |
| 57 | 57 factory.log('ENABLE WRITE PROTECTION (factory_EnableWriteProtect)') |
| 58 # verify if write protection range is properly fixed, | 58 if not self.job.run_test('factory_EnableWriteProtect', tag=subtest_tag): |
| 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.') | 59 raise error.TestFail('Flashrom write protection test failed.') |
| 63 | 60 |
| 64 def check_google_required_tests(self, do_check, status_file, test_list): | 61 def check_google_required_tests(self, do_check, status_file, test_list): |
| 65 """ Checks if all previous and Google Required Tests are passed. """ | 62 """ Checks if all previous and Google Required Tests are passed. """ |
| 66 if not do_check: | 63 if not do_check: |
| 67 self.alert_bypassed('REQUIRED TESTS') | 64 self.alert_bypassed('REQUIRED TESTS') |
| 68 return | 65 return |
| 69 | 66 |
| 70 # check if all previous tests are passed. | 67 # check if all previous tests are passed. |
| 71 db = factory.TestDatabase(test_list) | 68 db = factory.TestDatabase(test_list) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 83 missing.append('%s(%s)' % (g, db.get_unique_id_str(t))) | 80 missing.append('%s(%s)' % (g, db.get_unique_id_str(t))) |
| 84 if missing: | 81 if missing: |
| 85 missing_msg = ', '.join(missing) | 82 missing_msg = ', '.join(missing) |
| 86 raise error.TestFail('You need to execute following ' + | 83 raise error.TestFail('You need to execute following ' + |
| 87 'Google Required Tests: %s' % missing_msg) | 84 'Google Required Tests: %s' % missing_msg) |
| 88 | 85 |
| 89 def run_once(self, | 86 def run_once(self, |
| 90 check_required_tests=True, | 87 check_required_tests=True, |
| 91 check_developer_switch=True, | 88 check_developer_switch=True, |
| 92 check_and_enable_write_protect=True, | 89 check_and_enable_write_protect=True, |
| 90 subtest_tag=None, |
| 93 status_file_path=None, | 91 status_file_path=None, |
| 94 test_list=None): | 92 test_list=None): |
| 95 | 93 |
| 96 # apply each final tests | 94 # apply each final tests |
| 97 self.check_google_required_tests(check_required_tests, | 95 self.check_google_required_tests(check_required_tests, |
| 98 status_file_path, | 96 status_file_path, |
| 99 test_list) | 97 test_list) |
| 100 self.check_developer_switch(check_developer_switch) | 98 self.check_developer_switch(check_developer_switch) |
| 101 self.check_flashrom_write_protect(check_and_enable_write_protect) | 99 self.check_flashrom_write_protect(check_and_enable_write_protect, |
| 100 subtest_tag) |
| OLD | NEW |