adb: fix race condition in test_non_interactive_sigint.

Fix race condition in the test_non_interactive_sigint test by
looping for a while.

Bug: http://b/32336914
Test: python test_device.py
Change-Id: Ie65a762ad6f04815231add5444762c4c0ffd31cb
This commit is contained in:
Josh Gao 2016-10-21 12:40:42 -07:00
parent 094004bf42
commit e76b9f3dde
1 changed files with 6 additions and 2 deletions

View File

@ -473,8 +473,12 @@ class ShellTest(DeviceTest):
self.device.shell(proc_query)
os.kill(sleep_proc.pid, signal.SIGINT)
sleep_proc.communicate()
self.assertEqual(1, self.device.shell_nocheck(proc_query)[0],
'subprocess failed to terminate')
# It can take some time for the process to receive the signal and die.
end_time = time.time() + 3
while self.device.shell_nocheck(proc_query)[0] != 1:
self.assertFalse(time.time() > end_time,
'subprocess failed to terminate in time')
def test_non_interactive_stdin(self):
"""Tests that non-interactive shells send stdin."""