blob: c88c1abc64ef6387329f66e4754b4fc4d69b2515 [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"]
17
18 @skipIfi386
Enrico Granatad2657c52014-10-16 23:02:45 +000019 @skipIfNoSBHeaders
Todd Fiala57cacb012014-07-10 20:52:08 +000020 @expectedFailureDarwin("llvm.org/pr20282") # intermittent
Ed Maste8abef692014-07-12 15:21:55 +000021 @expectedFailureFreeBSD("llvm.org/pr20282")
Todd Fiala57cacb012014-07-10 20:52:08 +000022 @expectedFailureLinux("llvm.org/pr20282")
Jason Molenda91c2a992014-07-10 09:55:19 +000023 def test_multiple_debuggers(self):
Enrico Granatad2657c52014-10-16 23:02:45 +000024 env = {self.dylibPath : self.getLLDBLibraryEnvVal()}
Jason Molenda8c0740152014-07-10 02:17:31 +000025
26 self.driver_exe = os.path.join(os.getcwd(), "multi-process-driver")
27 self.buildDriver('multi-process-driver.cpp', self.driver_exe)
28 self.addTearDownHook(lambda: os.remove(self.driver_exe))
Oleksiy Vyalov49b71c62015-01-22 20:03:21 +000029 self.signBinary(self.driver_exe)
Jason Molenda8c0740152014-07-10 02:17:31 +000030
31 self.inferior_exe = os.path.join(os.getcwd(), "testprog")
32 self.buildDriver('testprog.cpp', self.inferior_exe)
33 self.addTearDownHook(lambda: os.remove(self.inferior_exe))
34
Jason Molenda8c0740152014-07-10 02:17:31 +000035# check_call will raise a CalledProcessError if multi-process-driver doesn't return
36# exit code 0 to indicate success. We can let this exception go - the test harness
37# will recognize it as a test failure.
38
39 if self.TraceOn():
40 print "Running test %s" % self.driver_exe
41 check_call([self.driver_exe, self.inferior_exe], env=env)
42 else:
43 with open(os.devnull, 'w') as fnull:
44 check_call([self.driver_exe, self.inferior_exe], env=env, stdout=fnull, stderr=fnull)
45
46if __name__ == '__main__':
47 import atexit
48 lldb.SBDebugger.Initialize()
49 atexit.register(lambda: lldb.SBDebugger.Terminate())
50 unittest2.main()