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

Side by Side Diff: client/site_tests/platform_ProcessPrivileges/platform_ProcessPrivileges.py

Issue 1565001: test: Clean up site_login.py a bit. (Closed)
Patch Set: update one more call to attempt_logout() Created 10 years, 9 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
« no previous file with comments | « client/site_tests/login_LogoutProcessCleanup/login_LogoutProcessCleanup.py ('k') | no next file » | 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) 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 time 5 import time
6 from autotest_lib.client.bin import site_login, test, utils 6 from autotest_lib.client.bin import site_login, test, utils
7 from autotest_lib.client.common_lib import error 7 from autotest_lib.client.common_lib import error
8 8
9 class platform_ProcessPrivileges(test.test): 9 class platform_ProcessPrivileges(test.test):
10 version = 1 10 version = 1
11 11
12 def setup(self): 12 def setup(self):
13 site_login.setup_autox(self) 13 site_login.setup_autox(self)
14 14
15 15
16 def run_once(self, process='X', user=None, run_as_root=False, 16 def run_once(self, process='X', user=None, run_as_root=False,
17 do_login=False): 17 do_login=False):
18 """Check if the process is running as the specified user / root. 18 """Check if the process is running as the specified user / root.
19 19
20 Args: 20 Args:
21 process: Process name to check. 21 process: Process name to check.
22 user: User process must run as; ignored if None. 22 user: User process must run as; ignored if None.
23 run_as_root: Is process allowed to run as root? 23 run_as_root: Is process allowed to run as root?
24 do_login: login before getting process information? 24 do_login: login before getting process information?
25 """ 25 """
26 logged_in = site_login.logged_in() 26 logged_in = site_login.logged_in()
27 27
28 if do_login and not logged_in: 28 if do_login and not logged_in:
29 # Test account information embedded into json file. 29 # Test account information embedded into json file.
30 if not site_login.attempt_login(self, 'autox_script.json'): 30 site_login.attempt_login(self, 'autox_script.json')
31 raise error.TestFail('Could not login')
32 # Wait for processes for user-session are started. 31 # Wait for processes for user-session are started.
33 time.sleep(10) 32 time.sleep(10)
34 33
35 try: 34 try:
36 # Get the process information 35 # Get the process information
37 pscmd = 'ps -o f,euser,ruser,suser,fuser,comm -C %s --no-headers' 36 pscmd = 'ps -o f,euser,ruser,suser,fuser,comm -C %s --no-headers'
38 ps = utils.system_output(pscmd % process, retain_output=True) 37 ps = utils.system_output(pscmd % process, retain_output=True)
39 38
40 pslines = ps.splitlines() 39 pslines = ps.splitlines()
41 40
(...skipping 20 matching lines...) Expand all
62 # raise error.TestFail( 61 # raise error.TestFail(
63 # 'Process %s running with super-user flag' % 62 # 'Process %s running with super-user flag' %
64 # process) 63 # process)
65 if 'root' in ps: 64 if 'root' in ps:
66 raise error.TestFail( 65 raise error.TestFail(
67 'Process %s running as root' % process) 66 'Process %s running as root' % process)
68 finally: 67 finally:
69 # If we started logged out, log back out. 68 # If we started logged out, log back out.
70 if do_login and not logged_in: 69 if do_login and not logged_in:
71 site_login.attempt_logout() 70 site_login.attempt_logout()
OLDNEW
« no previous file with comments | « client/site_tests/login_LogoutProcessCleanup/login_LogoutProcessCleanup.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698