Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: client/cros/cros_ui_test.py

Issue 6825028: [autotest] Ensure that ownership state is properly cleaned during test setup (Closed) Base URL: http://git.chromium.org/git/autotest.git@master
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/cros/cros_ui.py ('k') | client/site_tests/suite_Smoke/control » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2011 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 dbus, logging, os, re, shutil, socket, sys 5 import dbus, logging, os, re, shutil, socket, sys
6 import common 6 import common
7 import auth_server, constants, cryptohome, dns_server 7 import auth_server, constants, cryptohome, dns_server
8 import cros_logging, cros_ui, login, ownership 8 import cros_logging, cros_ui, login, ownership
9 from autotest_lib.client.bin import test, utils 9 from autotest_lib.client.bin import test, utils
10 from autotest_lib.client.common_lib import error 10 from autotest_lib.client.common_lib import error
11 from dbus.mainloop.glib import DBusGMainLoop 11 from dbus.mainloop.glib import DBusGMainLoop
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 # Mark /var/log/messages now; we'll run through all subsequent 162 # Mark /var/log/messages now; we'll run through all subsequent
163 # log messages at the end of the test and log info about processes that 163 # log messages at the end of the test and log info about processes that
164 # crashed. 164 # crashed.
165 self._log_reader = cros_logging.LogReader() 165 self._log_reader = cros_logging.LogReader()
166 self._log_reader.set_start_by_current() 166 self._log_reader.set_start_by_current()
167 167
168 if creds: 168 if creds:
169 self.start_authserver() 169 self.start_authserver()
170 170
171 # Fake ownership unless the test is explicitly testing owner creation.
172 if not is_creating_owner and not os.access(
173 constants.OWNER_KEY_FILE, os.F_OK):
174 logging.info('Owner credentials not found. Faking ownership...')
175 self.__fake_ownership()
176 self.fake_owner = True
177
178 if login.logged_in(): 171 if login.logged_in():
179 login.attempt_logout() 172 login.attempt_logout()
180 173
174 # The UI must be taken down to ensure that no stale state persists.
175 cros_ui.stop()
181 (self.username, self.password) = self.__resolve_creds(creds) 176 (self.username, self.password) = self.__resolve_creds(creds)
182 # Ensure there's no stale cryptohome from previous tests. 177 # Ensure there's no stale cryptohome from previous tests.
183 try: 178 try:
184 cryptohome.remove_vault(self.username) 179 cryptohome.remove_vault(self.username)
185 except cryptohome.ChromiumOSError as err: 180 except cryptohome.ChromiumOSError as err:
186 logging.error(err) 181 logging.error(err)
187 182
188 if is_creating_owner: 183 # Fake ownership unless the test is explicitly testing owner creation.
184 if not is_creating_owner:
185 logging.info('Faking ownership...')
186 self.__fake_ownership()
187 self.fake_owner = True
188 else:
189 logging.info('Erasing stale owner state.') 189 logging.info('Erasing stale owner state.')
190 ownership.clear_ownership() 190 ownership.clear_ownership()
191 self.fake_owner = False 191 self.fake_owner = False
192 cros_ui.start()
192 193
193 login.refresh_login_screen() 194 login.refresh_login_screen()
194 if self.auto_login: 195 if self.auto_login:
195 self.login(self.username, self.password) 196 self.login(self.username, self.password)
196 if is_creating_owner: 197 if is_creating_owner:
197 login.wait_for_ownership() 198 login.wait_for_ownership()
198 199
199 def __fake_ownership(self): 200 def __fake_ownership(self):
200 """Fake ownership by generating the necessary magic files.""" 201 """Fake ownership by generating the necessary magic files."""
201 # Determine the module directory. 202 # Determine the module directory.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 385
385 self.stop_authserver() 386 self.stop_authserver()
386 self.__log_crashed_processes(self.crash_blacklist) 387 self.__log_crashed_processes(self.crash_blacklist)
387 388
388 389
389 def get_auth_endpoint_misses(self): 390 def get_auth_endpoint_misses(self):
390 if hasattr(self, '_authServer'): 391 if hasattr(self, '_authServer'):
391 return self._authServer.get_endpoint_misses() 392 return self._authServer.get_endpoint_misses()
392 else: 393 else:
393 return {} 394 return {}
OLDNEW
« no previous file with comments | « client/cros/cros_ui.py ('k') | client/site_tests/suite_Smoke/control » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698