9566af03130929661711616ed1f0aac21a1f12cc
[openbsd] /
1 """
2 Test lldb data formatter subsystem.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class LibcxxUnorderedDataFormatterTestCase(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     def setUp(self):
18         TestBase.setUp(self)
19         ns = 'ndk' if lldbplatformutil.target_is_android() else ''
20         self.namespace = 'std::__' + ns + '1'
21
22     @add_test_categories(["libc++"])
23     def test_with_run_command(self):
24         self.build()
25         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
26
27         lldbutil.run_break_set_by_source_regexp(
28             self, "Set break point at this line.")
29
30         self.runCmd("run", RUN_SUCCEEDED)
31
32         # The stop reason of the thread should be breakpoint.
33         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
34                     substrs=['stopped',
35                              'stop reason = breakpoint'])
36
37         # This is the function to remove the custom formats in order to have a
38         # clean slate for the next test case.
39         def cleanup():
40             self.runCmd('type format clear', check=False)
41             self.runCmd('type summary clear', check=False)
42             self.runCmd('type filter clear', check=False)
43             self.runCmd('type synth clear', check=False)
44             self.runCmd(
45                 "settings set target.max-children-count 256",
46                 check=False)
47
48         # Execute the cleanup function during test case tear down.
49         self.addTearDownHook(cleanup)
50
51         ns = self.namespace
52         self.look_for_content_and_continue(
53             "map", ['%s::unordered_map' %
54                     ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
55
56         self.look_for_content_and_continue(
57             "mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 'second = "this"',
58                      'first = 2', 'second = "hello"'])
59
60         self.look_for_content_and_continue(
61             "iset", ['%s::unordered_set' %
62                      ns, 'size=5 {', '\[\d\] = 5', '\[\d\] = 3', '\[\d\] = 2'])
63
64         self.look_for_content_and_continue(
65             "sset", ['%s::unordered_set' % ns, 'size=5 {', '\[\d\] = "is"', '\[\d\] = "world"',
66                      '\[\d\] = "hello"'])
67
68         self.look_for_content_and_continue(
69             "imset", ['%s::unordered_multiset' % ns, 'size=6 {', '(\[\d\] = 3(\\n|.)+){3}',
70                       '\[\d\] = 2', '\[\d\] = 1'])
71
72         self.look_for_content_and_continue(
73             "smset", ['%s::unordered_multiset' % ns, 'size=5 {', '(\[\d\] = "is"(\\n|.)+){2}',
74                       '(\[\d\] = "world"(\\n|.)+){2}'])
75
76     def look_for_content_and_continue(self, var_name, patterns):
77         self.expect(("frame variable %s" % var_name), patterns=patterns)
78         self.expect(("frame variable %s" % var_name), patterns=patterns)
79         self.runCmd("continue")