Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / lang / c / modules / TestCModules.py
blobec78eb6fb27f4309f16cdc2cb1778af9acde3e1e
1 """Test that importing modules in C works as expected."""
4 import os
6 import lldb
7 from lldbsuite.test.decorators import *
8 from lldbsuite.test.lldbtest import *
9 from lldbsuite.test import lldbutil
12 class CModulesTestCase(TestBase):
13 @expectedFailureAll(
14 oslist=["freebsd", "linux"],
15 bugnumber="http://llvm.org/pr23456 'fopen' has unknown return type",
17 @expectedFailureAll(
18 oslist=["windows"],
19 bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows",
21 @skipIf(macos_version=["<", "10.12"])
22 @expectedFailureNetBSD
23 def test_expr(self):
24 self.build()
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.
36 self.expect(
37 "thread list",
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)
49 self.expect(
50 "expr -l objc++ -- @import Darwin; 3",
51 VARIABLES_DISPLAYED_CORRECTLY,
52 substrs=["int", "3"],
55 # This expr command imports __sFILE with definition
56 # (FILE is a typedef to __sFILE.)
57 self.expect(
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.
64 f = open(log_file)
65 log_lines = f.readlines()
66 f.close()
67 os.remove(log_file)
68 self.assertEqual(" ".join(log_lines).count("struct __sFILE definition"), 1)
70 self.expect(
71 "expr *myFile", VARIABLES_DISPLAYED_CORRECTLY, substrs=["a", "5", "b", "9"]
74 self.expect(
75 "expr MIN((uint64_t)2, (uint64_t)3)",
76 VARIABLES_DISPLAYED_CORRECTLY,
77 substrs=["uint64_t", "2"],
80 self.expect(
81 "expr stdin", VARIABLES_DISPLAYED_CORRECTLY, substrs=["(FILE *)", "0x"]
84 def setUp(self):
85 # Call super's setUp().
86 TestBase.setUp(self)
87 # Find the line number to break inside main().
88 self.line = line_number("main.c", "// Set breakpoint 0 here.")