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

Side by Side Diff: chrome/test/mini_installer/process_verifier.py

Issue 23814002: Remove psutil from the mini_installer test framework. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address mathp's comments. Created 7 years, 3 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 | « chrome/test/mini_installer/chrome_helper.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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium 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 psutil 5 import chrome_helper
6
7 import path_resolver 6 import path_resolver
8 7
9 8
10 def VerifyProcesses(processes): 9 def VerifyProcesses(processes):
11 """Verifies that the running processes match the expectation dictionaries. 10 """Verifies that the running processes match the expectation dictionaries.
12 11
13 This method will throw an AssertionError if process state doesn't match the 12 This method will throw an AssertionError if process state doesn't match the
14 provided expectation. 13 provided expectation.
15 14
16 Args: 15 Args:
17 processes: A dictionary whose keys are paths to processes and values are 16 processes: A dictionary whose keys are paths to processes and values are
18 expectation dictionaries. An expectation dictionary is a dictionary with 17 expectation dictionaries. An expectation dictionary is a dictionary with
19 the following key and value: 18 the following key and value:
20 'running' a boolean indicating whether the process should be 19 'running' a boolean indicating whether the process should be
21 running. 20 running.
22 """ 21 """
23 # Create a list of paths of all running processes. 22 # Create a list of paths of all running processes.
24 running_process_paths = [] 23 running_process_paths = [path for (_, path) in
25 for process in psutil.process_iter(): 24 chrome_helper.GetProcessIDAndPathPairs()]
26 try:
27 running_process_paths.append(process.exe)
28 except psutil.AccessDenied:
29 pass
30 25
31 for process_path, expectation in processes.iteritems(): 26 for process_path, expectation in processes.iteritems():
32 process_resolved_path = path_resolver.ResolvePath(process_path) 27 process_resolved_path = path_resolver.ResolvePath(process_path)
33 is_running = process_resolved_path in running_process_paths 28 is_running = process_resolved_path in running_process_paths
34 assert expectation['running'] == is_running, \ 29 assert expectation['running'] == is_running, \
35 ('Process %s is running' % process_path) if is_running else \ 30 ('Process %s is running' % process_path) if is_running else \
36 ('Process %s is not running' % process_path) 31 ('Process %s is not running' % process_path)
OLDNEW
« no previous file with comments | « chrome/test/mini_installer/chrome_helper.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698