2 Test whether a process started by lldb has no extra file descriptors open.
7 from lldbsuite
.test
import lldbutil
8 from lldbsuite
.test
.lldbtest
import *
9 from lldbsuite
.test
.decorators
import *
12 class AvoidsFdLeakTestCase(TestBase
):
13 NO_DEBUG_INFO_TESTCASE
= True
15 # The check for descriptor leakage needs to be implemented differently
18 @skipIfTargetAndroid() # Android have some other file descriptors open by the shell
19 @skipIfDarwinEmbedded # <rdar://problem/33888742> # debugserver on ios has an extra fd open on launch
20 def test_fd_leak_basic(self
):
23 # The check for descriptor leakage needs to be implemented differently
26 @skipIfTargetAndroid() # Android have some other file descriptors open by the shell
27 @skipIfDarwinEmbedded # <rdar://problem/33888742> # debugserver on ios has an extra fd open on launch
28 def test_fd_leak_log(self
):
29 self
.do_test(["log enable -f '/dev/null' lldb commands"])
31 def do_test(self
, commands
):
33 exe
= self
.getBuildArtifact("a.out")
38 target
= self
.dbg
.CreateTarget(exe
)
40 process
= target
.LaunchSimple(None, None, self
.get_process_working_directory())
41 self
.assertTrue(process
, PROCESS_IS_VALID
)
44 process
.GetState(), lldb
.eStateExited
, "Process should have exited."
47 process
.GetExitStatus(),
49 "Process returned non-zero status. Were incorrect file descriptors passed?",
52 # The check for descriptor leakage needs to be implemented differently
55 @skipIfTargetAndroid() # Android have some other file descriptors open by the shell
56 @skipIfDarwinEmbedded # <rdar://problem/33888742> # debugserver on ios has an extra fd open on launch
57 def test_fd_leak_multitarget(self
):
59 exe
= self
.getBuildArtifact("a.out")
61 target
= self
.dbg
.CreateTarget(exe
)
62 breakpoint
= target
.BreakpointCreateBySourceRegex(
63 "Set breakpoint here", lldb
.SBFileSpec("main.c", False)
65 self
.assertTrue(breakpoint
, VALID_BREAKPOINT
)
67 process1
= target
.LaunchSimple(None, None, self
.get_process_working_directory())
68 self
.assertTrue(process1
, PROCESS_IS_VALID
)
70 process1
.GetState(), lldb
.eStateStopped
, "Process should have been stopped."
73 target2
= self
.dbg
.CreateTarget(exe
)
74 process2
= target2
.LaunchSimple(
75 None, None, self
.get_process_working_directory()
77 self
.assertTrue(process2
, PROCESS_IS_VALID
)
80 process2
.GetState(), lldb
.eStateExited
, "Process should have exited."
83 process2
.GetExitStatus(),
85 "Process returned non-zero status. Were incorrect file descriptors passed?",