Add a new test in api/multiple-debuggers which tries to create 50
debug sessions simultaneously to expose race conditoin/locking
issues.
This directory has an inferior program, testprog.cpp that has a
couple of functions we can put breakpoints on.
It has a driver program, multi-process-driver.cpp, which links
against the LLDB solib and uses the SB APIs. It creates 50 pthreads,
creates a debugger on all of them, launches a debug session of the
inferior testprog, hits a couple breakpoints, walks the stack,
continues, etc., and then kills the inferior and ends the debug
session.
A pass is if all fifty debug sessions complete successfully
in the alloted time (~60 seconds).
We may need to tweak this one to work correctly on different
platforms/targets but I wanted to get it checked in to start.
llvm-svn: 212671
diff --git a/lldb/test/api/multiple-debuggers/TestMultipleDebuggers.py b/lldb/test/api/multiple-debuggers/TestMultipleDebuggers.py
new file mode 100644
index 0000000..0ea227c
--- /dev/null
+++ b/lldb/test/api/multiple-debuggers/TestMultipleDebuggers.py
@@ -0,0 +1,46 @@
+"""Test the lldb public C++ api when doing multiple debug sessions simultaneously."""
+
+import os, re, StringIO
+import unittest2
+from lldbtest import *
+import lldbutil
+import lldb
+import subprocess
+
+class TestMultipleSimultaneousDebuggers(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ TestBase.setUp(self)
+ self.lib_dir = os.environ["LLDB_LIB_DIR"]
+
+ @skipIfi386
+ def test_whatever(self):
+
+ self.driver_exe = os.path.join(os.getcwd(), "multi-process-driver")
+ self.buildDriver('multi-process-driver.cpp', self.driver_exe)
+ self.addTearDownHook(lambda: os.remove(self.driver_exe))
+
+ self.inferior_exe = os.path.join(os.getcwd(), "testprog")
+ self.buildDriver('testprog.cpp', self.inferior_exe)
+ self.addTearDownHook(lambda: os.remove(self.inferior_exe))
+
+ env = {self.dylibPath : self.getLLDBLibraryEnvVal()}
+
+# check_call will raise a CalledProcessError if multi-process-driver doesn't return
+# exit code 0 to indicate success. We can let this exception go - the test harness
+# will recognize it as a test failure.
+
+ if self.TraceOn():
+ print "Running test %s" % self.driver_exe
+ check_call([self.driver_exe, self.inferior_exe], env=env)
+ else:
+ with open(os.devnull, 'w') as fnull:
+ check_call([self.driver_exe, self.inferior_exe], env=env, stdout=fnull, stderr=fnull)
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()