chrome_binary_test - Add nuke_chrome decorator.
The video_decode_accelerator_unittest is going to be a full-screen application.
https://codereview.chromium.org/271593010/
Due to http://crbug/270064, we cannot have two full-screen apps on ARM platforms.
So nuke chrome while the test is running.
BUG=None
TEST=Run the test on peach-pit
Change-Id: If7f43fc6b72c2905b8eae66d05a47485c0677a9e
Reviewed-on: https://chromium-review.googlesource.com/202109
Reviewed-by: Yuli Huang <yuli@chromium.org>
Reviewed-by: Rohit Makasana <rohitbm@chromium.org>
Commit-Queue: Owen Lin <owenlin@chromium.org>
Tested-by: Owen Lin <owenlin@chromium.org>
diff --git a/client/cros/chrome_binary_test.py b/client/cros/chrome_binary_test.py
index da478f7..41b8dfd 100755
--- a/client/cros/chrome_binary_test.py
+++ b/client/cros/chrome_binary_test.py
@@ -4,9 +4,9 @@
import os, shutil, tempfile
-import cros_ui
-from autotest_lib.client.bin import test
+from autotest_lib.client.bin import test, utils
from autotest_lib.client.common_lib import error
+from autotest_lib.client.cros import constants, cros_ui
class ChromeBinaryTest(test.test):
@@ -63,3 +63,21 @@
cros_ui.xsystem(cmd)
except error.CmdError as e:
raise error.TestFail('%s failed! %s' % (binary_to_run, e))
+
+
+def nuke_chrome(func):
+ """Decorator to nuke the Chrome browser processes."""
+
+ def wrapper(*args, **kargs):
+ open(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE, 'w').close()
+ try:
+ try:
+ utils.nuke_process_by_name(
+ name=constants.BROWSER, with_prejudice=True)
+ except error.AutoservPidAlreadyDeadError:
+ pass
+ return func(*args, **kargs)
+ finally:
+ # Allow chrome to be restarted again later.
+ os.unlink(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)
+ return wrapper