Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / functionalities / avoids-fd-leak / TestFdLeak.py
blobe4f5cd3a03f8668dd99ad53d93c4adfe60ee4a68
1 """
2 Test whether a process started by lldb has no extra file descriptors open.
3 """
6 import lldb
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
16 # here.
17 @skipIfWindows
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):
21 self.do_test([])
23 # The check for descriptor leakage needs to be implemented differently
24 # here.
25 @skipIfWindows
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):
32 self.build()
33 exe = self.getBuildArtifact("a.out")
35 for c in commands:
36 self.runCmd(c)
38 target = self.dbg.CreateTarget(exe)
40 process = target.LaunchSimple(None, None, self.get_process_working_directory())
41 self.assertTrue(process, PROCESS_IS_VALID)
43 self.assertEqual(
44 process.GetState(), lldb.eStateExited, "Process should have exited."
46 self.assertEqual(
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
53 # here.
54 @skipIfWindows
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):
58 self.build()
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)
69 self.assertEqual(
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)
79 self.assertEqual(
80 process2.GetState(), lldb.eStateExited, "Process should have exited."
82 self.assertEqual(
83 process2.GetExitStatus(),
85 "Process returned non-zero status. Were incorrect file descriptors passed?",