1 """Test that importing modules in C works as expected."""
7 from lldbsuite
.test
.decorators
import *
8 from lldbsuite
.test
.lldbtest
import *
9 from lldbsuite
.test
import lldbutil
12 class CModulesTestCase(TestBase
):
14 oslist
=["freebsd", "linux"],
15 bugnumber
="http://llvm.org/pr23456 'fopen' has unknown return type",
19 bugnumber
="llvm.org/pr24489: Name lookup not working correctly on Windows",
21 @skipIf(macos_version
=["<", "10.12"])
22 @expectedFailureNetBSD
25 exe
= self
.getBuildArtifact("a.out")
26 self
.runCmd("file " + exe
, CURRENT_EXECUTABLE_SET
)
28 # Break inside the foo function which takes a bar_ptr argument.
29 lldbutil
.run_break_set_by_file_and_line(
30 self
, "main.c", self
.line
, num_expected_locations
=1, loc_exact
=True
33 self
.runCmd("run", RUN_SUCCEEDED
)
35 # The stop reason of the thread should be breakpoint.
38 STOPPED_DUE_TO_BREAKPOINT
,
39 substrs
=["stopped", "stop reason = breakpoint"],
42 # The breakpoint should have a hit count of 1.
43 lldbutil
.check_breakpoint(self
, bpno
=1, expected_hit_count
=1)
45 # Enable logging of the imported AST.
46 log_file
= self
.getBuildArtifact("lldb-ast-log.txt")
47 self
.runCmd("log enable lldb ast -f '%s'" % log_file
)
50 "expr -l objc++ -- @import Darwin; 3",
51 VARIABLES_DISPLAYED_CORRECTLY
,
55 # This expr command imports __sFILE with definition
56 # (FILE is a typedef to __sFILE.)
58 'expr *fopen("/dev/zero", "w")',
59 VARIABLES_DISPLAYED_CORRECTLY
,
60 substrs
=["FILE", "_close"],
63 # Check that the AST log contains exactly one definition of __sFILE.
65 log_lines
= f
.readlines()
68 self
.assertEqual(" ".join(log_lines
).count("struct __sFILE definition"), 1)
71 "expr *myFile", VARIABLES_DISPLAYED_CORRECTLY
, substrs
=["a", "5", "b", "9"]
75 "expr MIN((uint64_t)2, (uint64_t)3)",
76 VARIABLES_DISPLAYED_CORRECTLY
,
77 substrs
=["uint64_t", "2"],
81 "expr stdin", VARIABLES_DISPLAYED_CORRECTLY
, substrs
=["(FILE *)", "0x"]
85 # Call super's setUp().
87 # Find the line number to break inside main().
88 self
.line
= line_number("main.c", "// Set breakpoint 0 here.")