Adding YouTube Flash tests and refactoring YT functions
in a helper class so new tests can reuse the code.
TEST=ran manually
BUG=chromium:265409
Change-Id: I4e28e4cd5be9ee0f6852b9ab5bc1c2ccfdaf9453
Reviewed-on: https://gerrit.chromium.org/gerrit/63598
Reviewed-by: Simran Basi <sbasi@chromium.org>
Reviewed-by: Rohit Makasana <rohitbm@chromium.org>
Tested-by: Rohit Makasana <rohitbm@chromium.org>
Commit-Queue: Rohit Makasana <rohitbm@chromium.org>
diff --git a/client/bin/site_utils.py b/client/bin/site_utils.py
index 679d88f..88e2384 100644
--- a/client/bin/site_utils.py
+++ b/client/bin/site_utils.py
@@ -76,6 +76,41 @@
return int(str_pid)
+def get_process_list(name, command_line=None):
+ """
+ Return the list of pid for matching process |name command_line|.
+
+ on a system running
+ 31475 ? 0:06 /opt/google/chrome/chrome --allow-webui-compositing -
+ 31478 ? 0:00 /opt/google/chrome/chrome-sandbox /opt/google/chrome/
+ 31485 ? 0:00 /opt/google/chrome/chrome --type=zygote --log-level=1
+ 31532 ? 1:05 /opt/google/chrome/chrome --type=renderer
+
+ get_process_list('chrome')
+ would return ['31475', '31485', '31532']
+
+ get_process_list('chrome', '--type=renderer')
+ would return ['31532']
+
+ Arguments:
+ name: process name to search for. If command_line is provided, name is
+ matched against full command line. If command_line is not provided,
+ name is only matched against the process name.
+ command line: when command line is passed, the full process command line
+ is used for matching.
+
+ Returns:
+ list of PIDs of the matching processes.
+
+ """
+ # TODO(rohitbm) crbug.com/268861
+ flag = '-x' if not command_line else '-f'
+ name = '\'%s.*%s\'' % (name, command_line) if command_line else name
+ str_pid = utils.system_output(
+ 'pgrep %s %s' % (flag, name), ignore_status=True).rstrip()
+ return str_pid
+
+
def nuke_process_by_name(name, with_prejudice=False):
try:
pid = get_oldest_pid_by_name(name)