Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / lang / c / unions / TestUnionMembers.py
blobd9acc00f8269efa22b049dcdbde9c3e1c4cc6d45
1 import lldb
2 from lldbsuite.test.lldbtest import *
3 import lldbsuite.test.lldbutil as lldbutil
6 class TestUnionMembers(TestBase):
7 def test_union_members(self):
8 self._load_exe()
10 # Set breakpoints
11 bp = self.target.BreakpointCreateBySourceRegex("Break here", self.src_file_spec)
12 self.assertTrue(bp.IsValid() and bp.GetNumLocations() >= 1, VALID_BREAKPOINT)
14 # Launch the process
15 self.process = self.target.LaunchSimple(
16 None, None, self.get_process_working_directory()
18 self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
19 self.assertEqual(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
21 thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint)
22 self.assertTrue(thread.IsValid())
23 frame = thread.GetSelectedFrame()
24 self.assertTrue(frame.IsValid())
26 val = frame.EvaluateExpression("u")
27 self.assertTrue(val.IsValid())
28 val = frame.EvaluateExpression("u.s")
29 self.assertTrue(val.IsValid())
30 self.assertEqual(val.GetNumChildren(), 2)
32 def _load_exe(self):
33 self.build()
35 src_file = os.path.join(self.getSourceDir(), "main.c")
36 self.src_file_spec = lldb.SBFileSpec(src_file)
37 self.assertTrue(self.src_file_spec.IsValid(), "breakpoint file")
39 # Get the path of the executable
40 exe_path = self.getBuildArtifact("a.out")
42 # Load the executable
43 self.target = self.dbg.CreateTarget(exe_path)
44 self.assertTrue(self.target.IsValid(), VALID_TARGET)