| OLD | NEW |
| 1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
| 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import gtk | 6 import gtk |
| 7 from gtk import gdk | 7 from gtk import gdk |
| 8 import os | 8 import os |
| 9 import time | 9 import time |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 return status | 39 return status |
| 40 | 40 |
| 41 def check_developer_switch(self): | 41 def check_developer_switch(self): |
| 42 """ Checks if developer switch button is disabled """ | 42 """ Checks if developer switch button is disabled """ |
| 43 return self.read_gpio_uint("developer_switch") == 0 | 43 return self.read_gpio_uint("developer_switch") == 0 |
| 44 | 44 |
| 45 def check_write_protect(self): | 45 def check_write_protect(self): |
| 46 """ Checks if hardware write protection pin is enabled """ | 46 """ Checks if hardware write protection pin is enabled """ |
| 47 return self.read_gpio_uint("write_protect") == 1 | 47 return self.read_gpio_uint("write_protect") == 1 |
| 48 | 48 |
| 49 def check_vboot_state(self): |
| 50 data = utils.system_output("dev_debug_vboot | grep ' OK$'", |
| 51 ignore_status=True) |
| 52 # factory.log(data) |
| 53 if (data.find('Verify firmware B') < 0 or |
| 54 data.find('Test kernel_subkey_b') < 0 or |
| 55 data.find('Test hd_kern_b.') < 0 or |
| 56 data.find('Verify hd_kern_b.blob with kernel_subkey_b') < 0): |
| 57 return False |
| 58 return True |
| 59 |
| 49 def check_required_tests(self): | 60 def check_required_tests(self): |
| 50 """ Checks if all previous tests are passed """ | 61 """ Checks if all previous tests are passed """ |
| 51 # NOTE the real 'required test' check in factory_Verify also checks | 62 # NOTE the real 'required test' check in factory_Verify also checks |
| 52 # "Google Required Tests", which is not verified here. | 63 # "Google Required Tests", which is not verified here. |
| 53 db = factory.TestDatabase(self.test_list) | 64 db = factory.TestDatabase(self.test_list) |
| 54 status_map = factory.StatusMap(self.test_list, self.status_file, db) | 65 status_map = factory.StatusMap(self.test_list, self.status_file, db) |
| 55 if status_map.filter_by_status(ful.FAILED): | 66 if status_map.filter_by_status(ful.FAILED): |
| 56 return False | 67 return False |
| 57 return True | 68 return True |
| 58 | 69 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 74 "系統已準備就緒。 請按空白鍵開始最終程序!") | 85 "系統已準備就緒。 請按空白鍵開始最終程序!") |
| 75 | 86 |
| 76 # list of tasks to be checked in format ('name': 'label') | 87 # list of tasks to be checked in format ('name': 'label') |
| 77 CHECK_TASKS = { | 88 CHECK_TASKS = { |
| 78 'required_tests': ("Verify all required tests are passed\n" | 89 'required_tests': ("Verify all required tests are passed\n" |
| 79 "確認所有必要測試已通過"), | 90 "確認所有必要測試已通過"), |
| 80 'developer_switch': ("Turn off Developer Switch\n" | 91 'developer_switch': ("Turn off Developer Switch\n" |
| 81 "停用開發者開關 (Developer Switch)"), | 92 "停用開發者開關 (Developer Switch)"), |
| 82 'write_protect': ("Enable write protection pin\n" | 93 'write_protect': ("Enable write protection pin\n" |
| 83 "確認硬體寫入保護已開啟"), | 94 "確認硬體寫入保護已開啟"), |
| 95 'vboot_state': ("Keys for verified boot are matched\n" |
| 96 "驗證開機所需各金鑰符合磁碟映像內容"), |
| 84 } | 97 } |
| 85 | 98 |
| 86 def run_verify(self, vector): | 99 def run_verify(self, vector): |
| 87 return getattr(self.verifier, 'check_' + vector)() | 100 return getattr(self.verifier, 'check_' + vector)() |
| 88 | 101 |
| 89 def all_passed(self): | 102 def all_passed(self): |
| 90 assert(self.check_results) | 103 assert(self.check_results) |
| 91 return all(self.check_results) | 104 return all(self.check_results) |
| 92 | 105 |
| 93 def set_task_as_disabled(self, label_widget): | 106 def set_task_as_disabled(self, label_widget): |
| (...skipping 28 matching lines...) Expand all Loading... |
| 122 self.label_status.set_label(self.MSG_PENDING) | 135 self.label_status.set_label(self.MSG_PENDING) |
| 123 | 136 |
| 124 def key_release_callback(self, widget, event): | 137 def key_release_callback(self, widget, event): |
| 125 if event.keyval == ord('f'): | 138 if event.keyval == ord('f'): |
| 126 factory.log("WARNING: Operator manually forced finalization.") | 139 factory.log("WARNING: Operator manually forced finalization.") |
| 127 gtk.main_quit() | 140 gtk.main_quit() |
| 128 elif event.keyval == ord(' '): | 141 elif event.keyval == ord(' '): |
| 129 if self.all_passed(): | 142 if self.all_passed(): |
| 130 gtk.main_quit() | 143 gtk.main_quit() |
| 131 else: | 144 else: |
| 145 if self.last_check and (time.time() < self.last_check + 1): |
| 146 # ignore flooding events in 1 second |
| 147 return True |
| 132 widget.handler_block(self.key_released_handler_id) | 148 widget.handler_block(self.key_released_handler_id) |
| 133 self.update_status() | 149 self.update_status() |
| 134 widget.handler_unblock(self.key_released_handler_id) | 150 widget.handler_unblock(self.key_released_handler_id) |
| 151 self.last_check = time.time() |
| 135 return True | 152 return True |
| 136 | 153 |
| 137 def register_callback(self, window): | 154 def register_callback(self, window): |
| 138 self.key_released_handler_id = window.connect( | 155 self.key_released_handler_id = window.connect( |
| 139 'key-release-event', self.key_release_callback) | 156 'key-release-event', self.key_release_callback) |
| 140 window.add_events(gdk.KEY_RELEASE_MASK) | 157 window.add_events(gdk.KEY_RELEASE_MASK) |
| 141 | 158 |
| 142 def create_disabled_label(self, message): | 159 def create_disabled_label(self, message): |
| 143 return ful.make_label( | 160 return ful.make_label( |
| 144 message, fg=self.COLOR_DISABLED, alignment=(0, 0.5)) | 161 message, fg=self.COLOR_DISABLED, alignment=(0, 0.5)) |
| 145 | 162 |
| 146 def run_once(self, status_file_path=None, test_list=None): | 163 def run_once(self, status_file_path=None, test_list=None): |
| 147 # configure verifier | 164 # configure verifier |
| 148 self.verifier = MiniVerifier() | 165 self.verifier = MiniVerifier() |
| 149 self.verifier.set_test_info(status_file_path, test_list) | 166 self.verifier.set_test_info(status_file_path, test_list) |
| 167 self.last_check = None |
| 150 | 168 |
| 151 self.COLOR_DISABLED = gtk.gdk.Color(0x7000, 0x7000, 0x7000) | 169 self.COLOR_DISABLED = gtk.gdk.Color(0x7000, 0x7000, 0x7000) |
| 152 self.COLOR_PASSED = ful.LIGHT_GREEN | 170 self.COLOR_PASSED = ful.LIGHT_GREEN |
| 153 self.COLOR_ACTIVE = ful.RED | 171 self.COLOR_ACTIVE = ful.RED |
| 154 | 172 |
| 155 # build check list from self.CHECK_TASKS | 173 # build check list from self.CHECK_TASKS |
| 156 self.check_results = [] | 174 self.check_results = [] |
| 157 self.check_labels = [] | 175 self.check_labels = [] |
| 158 for message in self.CHECK_TASKS.values(): | 176 for message in self.CHECK_TASKS.values(): |
| 159 self.check_labels.append(self.create_disabled_label(message)) | 177 self.check_labels.append(self.create_disabled_label(message)) |
| 160 self.check_results.append(False) | 178 self.check_results.append(False) |
| 161 | 179 |
| 162 # build main window | 180 # build main window |
| 163 self.label_status = ful.make_label(self.MSG_START, fg=ful.WHITE) | 181 self.label_status = ful.make_label(self.MSG_START, fg=ful.WHITE) |
| 164 vbox = gtk.VBox() | 182 vbox = gtk.VBox() |
| 165 vbox.set_spacing(20) | 183 vbox.set_spacing(20) |
| 166 vbox.pack_start(self.label_status, False, False) | 184 vbox.pack_start(self.label_status, False, False) |
| 167 for label in self.check_labels: | 185 for label in self.check_labels: |
| 168 vbox.pack_start(label, False, False) | 186 vbox.pack_start(label, False, False) |
| 169 widget = gtk.EventBox() | 187 widget = gtk.EventBox() |
| 170 widget.modify_bg(gtk.STATE_NORMAL, ful.BLACK) | 188 widget.modify_bg(gtk.STATE_NORMAL, ful.BLACK) |
| 171 widget.add(vbox) | 189 widget.add(vbox) |
| 172 | 190 |
| 173 ful.run_test_widget(self.job, widget, | 191 ful.run_test_widget(self.job, widget, |
| 174 window_registration_callback=self.register_callback) | 192 window_registration_callback=self.register_callback) |
| OLD | NEW |