xref: /llvm-project/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py (revision 99451b4453688a94c6014cac233d371ab4cc342d)
1"""Test the lldb public C++ api when doing multiple debug sessions simultaneously."""
2
3from __future__ import print_function
4
5
6import os
7
8import lldb
9from lldbsuite.test.decorators import *
10from lldbsuite.test.lldbtest import *
11from lldbsuite.test import lldbutil
12
13
14class TestMultipleSimultaneousDebuggers(TestBase):
15
16    mydir = TestBase.compute_mydir(__file__)
17
18    # This test case fails non-deterministically.
19    @skipIfNoSBHeaders
20    @expectedFailureAll(bugnumber="llvm.org/pr20282")
21    def test_multiple_debuggers(self):
22        env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
23
24        self.driver_exe = self.getBuildArtifact("multi-process-driver")
25        self.buildDriver('multi-process-driver.cpp', self.driver_exe)
26        self.addTearDownHook(lambda: os.remove(self.driver_exe))
27        self.signBinary(self.driver_exe)
28
29        self.inferior_exe = self.getBuildArtifact("testprog")
30        self.buildDriver('testprog.cpp', self.inferior_exe)
31        self.addTearDownHook(lambda: os.remove(self.inferior_exe))
32
33# check_call will raise a CalledProcessError if multi-process-driver doesn't return
34# exit code 0 to indicate success.  We can let this exception go - the test harness
35# will recognize it as a test failure.
36
37        if self.TraceOn():
38            print("Running test %s" % self.driver_exe)
39            check_call([self.driver_exe, self.inferior_exe], env=env)
40        else:
41            with open(os.devnull, 'w') as fnull:
42                check_call([self.driver_exe, self.inferior_exe],
43                           env=env, stdout=fnull, stderr=fnull)
44