blob: d238692a0c09b1bd810443aa602d6bb936ea8e15 [file] [log] [blame]
Jason Molenda8c0740152014-07-10 02:17:31 +00001"""Test the lldb public C++ api when doing multiple debug sessions simultaneously."""
2
3import os, re, StringIO
4import unittest2
5from lldbtest import *
6import lldbutil
7import lldb
8import subprocess
9
10class TestMultipleSimultaneousDebuggers(TestBase):
11
12 mydir = TestBase.compute_mydir(__file__)
13
14 def setUp(self):
15 TestBase.setUp(self)
16 self.lib_dir = os.environ["LLDB_LIB_DIR"]
Adrian McCarthyb016b3c2015-03-27 20:47:35 +000017 self.implib_dir = os.environ["LLDB_IMPLIB_DIR"]
Jason Molenda8c0740152014-07-10 02:17:31 +000018
19 @skipIfi386
Enrico Granatad2657c52014-10-16 23:02:45 +000020 @skipIfNoSBHeaders
Todd Fiala57cacb012014-07-10 20:52:08 +000021 @expectedFailureDarwin("llvm.org/pr20282") # intermittent
Ed Maste8abef692014-07-12 15:21:55 +000022 @expectedFailureFreeBSD("llvm.org/pr20282")
Todd Fiala57cacb012014-07-10 20:52:08 +000023 @expectedFailureLinux("llvm.org/pr20282")
Jason Molenda91c2a992014-07-10 09:55:19 +000024 def test_multiple_debuggers(self):
Enrico Granatad2657c52014-10-16 23:02:45 +000025 env = {self.dylibPath : self.getLLDBLibraryEnvVal()}
Jason Molenda8c0740152014-07-10 02:17:31 +000026
27 self.driver_exe = os.path.join(os.getcwd(), "multi-process-driver")
28 self.buildDriver('multi-process-driver.cpp', self.driver_exe)
29 self.addTearDownHook(lambda: os.remove(self.driver_exe))
Oleksiy Vyalov49b71c62015-01-22 20:03:21 +000030 self.signBinary(self.driver_exe)
Jason Molenda8c0740152014-07-10 02:17:31 +000031
32 self.inferior_exe = os.path.join(os.getcwd(), "testprog")
33 self.buildDriver('testprog.cpp', self.inferior_exe)
34 self.addTearDownHook(lambda: os.remove(self.inferior_exe))
35
Jason Molenda8c0740152014-07-10 02:17:31 +000036# check_call will raise a CalledProcessError if multi-process-driver doesn't return
37# exit code 0 to indicate success. We can let this exception go - the test harness
38# will recognize it as a test failure.
39
40 if self.TraceOn():
41 print "Running test %s" % self.driver_exe
42 check_call([self.driver_exe, self.inferior_exe], env=env)
43 else:
44 with open(os.devnull, 'w') as fnull:
45 check_call([self.driver_exe, self.inferior_exe], env=env, stdout=fnull, stderr=fnull)
46
47if __name__ == '__main__':
48 import atexit
49 lldb.SBDebugger.Initialize()
50 atexit.register(lambda: lldb.SBDebugger.Terminate())
51 unittest2.main()