Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c970aefa authored by Josh Gao's avatar Josh Gao
Browse files

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
parent ecb96ac0
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -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):