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

Unified Diff: client/site_tests/platform_ProcessPrivileges/platform_ProcessPrivileges.py

Issue 1534001: switch to autox.py and robustify login/logout code (Closed)
Patch Set: merge with head Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/site_tests/login_LogoutProcessCleanup/login_LogoutProcessCleanup.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/site_tests/platform_ProcessPrivileges/platform_ProcessPrivileges.py
diff --git a/client/site_tests/platform_ProcessPrivileges/platform_ProcessPrivileges.py b/client/site_tests/platform_ProcessPrivileges/platform_ProcessPrivileges.py
index a4d99273c6f11492bb228cd937bcd1743e5e405b..8cbbc02096ecd4f3a89999e6079967444570b558 100644
--- a/client/site_tests/platform_ProcessPrivileges/platform_ProcessPrivileges.py
+++ b/client/site_tests/platform_ProcessPrivileges/platform_ProcessPrivileges.py
@@ -3,15 +3,13 @@
# found in the LICENSE file.
import time
-from autotest_lib.client.bin import site_login, test, utils
+from autotest_lib.client.bin import site_login, site_ui_test, utils
from autotest_lib.client.common_lib import error
-class platform_ProcessPrivileges(test.test):
+class platform_ProcessPrivileges(site_ui_test.UITest):
version = 1
- def setup(self):
- site_login.setup_autox(self)
-
+ auto_login = False
def run_once(self, process='X', user=None, run_as_root=False,
do_login=False, any=False):
@@ -24,67 +22,58 @@ class platform_ProcessPrivileges(test.test):
do_login: login before getting process information?
any: Test succeeds if any of processes satisfy the conditions.
"""
- logged_in = site_login.logged_in()
-
- if do_login and not logged_in:
- # Test account information embedded into json file.
- site_login.attempt_login(self, 'autox_script.json')
+ if do_login:
+ self.login()
# Wait for processes for user-session are started.
time.sleep(10)
- try:
- # Get the process information
- pscmd = 'ps -o f,euser,ruser,suser,fuser,comm -C %s --no-headers'
- ps = utils.system_output(pscmd % process, retain_output=True)
-
- pslines = ps.splitlines()
+ # Get the process information
+ pscmd = 'ps -o f,euser,ruser,suser,fuser,comm -C %s --no-headers'
+ ps = utils.system_output(pscmd % process, retain_output=True)
- # Fail if process is not running
- if not len(pslines):
- raise error.TestFail('Process %s is not running' % process)
+ pslines = ps.splitlines()
- # Check all instances of the process
- for psline in pslines:
- ps = psline.split()
+ # Fail if process is not running
+ if not len(pslines):
+ raise error.TestFail('Process %s is not running' % process)
- # Assume process meets conditions until proven otherwise
- user_satisfied = True
- run_as_root_satisfied = True
+ # Check all instances of the process
+ for psline in pslines:
+ ps = psline.split()
- # Fail if not running as the specified user
- if user is not None:
- for uid in ps[1:5]:
- if uid != user:
- if any:
- user_satisfied = False
- break
- raise error.TestFail(
- 'Process %s running as %s; expected %s' %
- (process, uid, user))
+ # Assume process meets conditions until proven otherwise
+ user_satisfied = True
+ run_as_root_satisfied = True
- # Check if process has super-user privileges
- if not run_as_root:
- # TODO(yusukes): Uncomment this once issue 2253 is resolved
- # if int(ps[0]) & 0x04:
- # raise error.TestFail(
- # 'Process %s running with super-user flag' %
- # process)
- if 'root' in ps:
+ # Fail if not running as the specified user
+ if user is not None:
+ for uid in ps[1:5]:
+ if uid != user:
if any:
- run_as_root_satisfied = False
- continue
+ user_satisfied = False
+ break
raise error.TestFail(
- 'Process %s running as root' % process)
-
- # Check if conditions are met for "any" mode.
- if any and user_satisfied and run_as_root_satisfied:
- break
- else:
- if any:
+ 'Process %s running as %s; expected %s' %
+ (process, uid, user))
+
+ # Check if process has super-user privileges
+ if not run_as_root:
+ # TODO(yusukes): Uncomment this once issue 2253 is resolved
+ # if int(ps[0]) & 0x04:
+ # raise error.TestFail(
+ # 'Process %s running with super-user flag' %
+ # process)
+ if 'root' in ps:
+ if any:
+ run_as_root_satisfied = False
+ continue
raise error.TestFail(
- 'Conditions are not met for any process %s' % process)
-
- finally:
- # If we started logged out, log back out.
- if do_login and not logged_in:
- site_login.attempt_logout()
+ 'Process %s running as root' % process)
+
+ # Check if conditions are met for "any" mode.
+ if any and user_satisfied and run_as_root_satisfied:
+ break
+ else:
+ if any:
+ raise error.TestFail(
+ 'Conditions are not met for any process %s' % process)
« 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