adb: add `adb shell exit 42` stress test.

Add a test to hammer on `adb shell exit $n` for flakiness.

Bug: http://b/74616284
Test: python test_device.py
Change-Id: I6a842960f5b55ff739044698f5c9683992fc42f1
This commit is contained in:
Josh Gao 2018-03-19 15:35:11 -07:00
parent ecb96ac04d
commit c970aefada
1 changed files with 24 additions and 0 deletions

View File

@ -31,6 +31,7 @@ import string
import subprocess
import sys
import tempfile
import threading
import time
import unittest
@ -493,6 +494,29 @@ class ShellTest(DeviceTest):
stdout, _ = self.device.shell(["cat", log_path])
self.assertEqual(stdout.strip(), "SIGHUP")
def test_exit_stress(self):
"""Hammer `adb shell exit 42` with multiple threads."""
thread_count = 48
result = dict()
def hammer(thread_idx, thread_count, result):
success = True
for i in range(thread_idx, 240, thread_count):
ret = subprocess.call(['adb', 'shell', 'exit {}'.format(i)])
if ret != i % 256:
success = False
break
result[thread_idx] = success
threads = []
for i in range(thread_count):
thread = threading.Thread(target=hammer, args=(i, thread_count, result))
thread.start()
threads.append(thread)
for thread in threads:
thread.join()
for i, success in result.iteritems():
self.assertTrue(success)
class ArgumentEscapingTest(DeviceTest):
def test_shell_escaping(self):