Refactor tests to consistently wait for login prompt to show up after logout.
This CL refactors the autotest suite to consistently check for the login prompt
visibility whenever the session manager is killed. This ensures that the Window
Manager can depend on being fully initialized prior to being killed.
BUG=chromium-os:18919
TEST=Ran trybot run with VM tests.
Change-Id: I1747bc55c66c3eeae10e2cafa2dfc8219d758874
Reviewed-on: http://gerrit.chromium.org/gerrit/8184
Commit-Ready: David James <davidjames@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
diff --git a/client/bin/site_utils.py b/client/bin/site_utils.py
index 0935c2a..55e0429 100644
--- a/client/bin/site_utils.py
+++ b/client/bin/site_utils.py
@@ -2,13 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import logging, os, platform, re, tempfile, time
+import logging, os, platform, re, signal, tempfile, time
from autotest_lib.client.common_lib import error
from autotest_lib.client.common_lib import utils
class TimeoutError(error.TestError):
"""Error raised when we time out when waiting on a condition."""
+ pass
class Crossystem(object):
@@ -43,6 +44,18 @@
return lambda : self.cros_system_data[name]
+def nuke_process_by_name(name, with_prejudice=False):
+ try:
+ pid = int(utils.system_output('pgrep -o ^%s$' % name).split()[0])
+ except Exception as e:
+ logging.error(e)
+ return
+ if with_prejudice:
+ utils.nuke_pid(pid, [signal.SIGKILL])
+ else:
+ utils.nuke_pid(pid)
+
+
def poll_for_condition(
condition, exception=None, timeout=10, sleep_interval=0.1, desc=None):
"""Poll until a condition becomes true.