| OLD | NEW |
| 1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2009 The Chromium OS 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 logging, time, utils | 5 import logging, os, time, utils |
| 6 from autotest_lib.client.bin import test | 6 from autotest_lib.client.bin import site_utils, test |
| 7 from autotest_lib.client.common_lib import error | 7 from autotest_lib.client.common_lib import error |
| 8 | 8 |
| 9 class desktopui_KillRestart(test.test): | 9 class desktopui_KillRestart(test.test): |
| 10 version = 1 | 10 version = 1 |
| 11 | 11 |
| 12 def run_once(self, binary = 'chrome'): | 12 def run_once(self, binary = 'chrome'): |
| 13 # Try to kill all running instances of the binary. | 13 # Try to kill all running instances of the binary. |
| 14 try: | 14 try: |
| 15 utils.system('pkill -KILL %s' % binary) | 15 utils.system('pkill -KILL %s' % binary) |
| 16 except error.CmdError, e: | 16 except error.CmdError, e: |
| 17 logging.debug(e) | 17 logging.debug(e) |
| 18 raise error.TestFail('%s is not running before kill' % binary) | 18 raise error.TestFail('%s is not running before kill' % binary) |
| 19 | 19 |
| 20 # Give the system a chance to restart the binary. | 20 # Check if the binary is running again (using os.system(), since it |
| 21 time.sleep(3) | 21 # doesn't raise an exception if the command fails). |
| 22 | 22 site_utils.poll_for_condition( |
| 23 # Check if the binary is running again. | 23 lambda: os.system('pgrep %s' % binary) == 0, |
| 24 try: | 24 error.TestFail('%s is not running after kill' % binary)) |
| 25 utils.system('pgrep %s' % binary) | |
| 26 except error.CmdError, e: | |
| 27 logging.debug(e) | |
| 28 raise error.TestFail('%s is not running after kill' % binary) | |
| OLD | NEW |