]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / data-formatter / data-formatter-proper-plurals / TestFormattersOneIsSingular.py
1 """
2 Test lldb data formatter subsystem.
3 """
4
5 from __future__ import print_function
6
7
8
9 import datetime
10 import os, time
11 import lldb
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 from lldbsuite.test import lldbutil
15
16 class DataFormatterOneIsSingularTestCase(TestBase):
17
18     mydir = TestBase.compute_mydir(__file__)
19
20     @skipUnlessDarwin
21     def test_one_is_singular_with_run_command(self):
22         """Test that 1 item is not as reported as 1 items."""
23         self.build()
24         self.oneness_data_formatter_commands()
25
26     def setUp(self):
27         # Call super's setUp().
28         TestBase.setUp(self)
29         # Find the line number to break at.
30         self.line = line_number('main.m', '// Set break point at this line.')
31
32     def oneness_data_formatter_commands(self):
33         """Test that 1 item is not as reported as 1 items."""
34         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
35
36         lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
37
38         self.runCmd("run", RUN_SUCCEEDED)
39
40         # The stop reason of the thread should be breakpoint.
41         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
42             substrs = ['stopped',
43                        'stop reason = breakpoint'])
44
45         # This is the function to remove the custom formats in order to have a
46         # clean slate for the next test case.
47         def cleanup():
48             self.runCmd('type format clear', check=False)
49             self.runCmd('type summary clear', check=False)
50             self.runCmd('type synth clear', check=False)
51
52         # Execute the cleanup function during test case tear down.
53         self.addTearDownHook(cleanup)
54
55         # Now check that we are displaying Cocoa classes correctly
56         self.expect('frame variable key',
57                     substrs = ['@"1 element"'])
58         self.expect('frame variable key', matching=False,
59                     substrs = ['1 elements'])
60         self.expect('frame variable value',
61                     substrs = ['@"1 element"'])
62         self.expect('frame variable value', matching=False,
63                     substrs = ['1 elements'])
64         self.expect('frame variable dict',
65                     substrs = ['1 key/value pair'])
66         self.expect('frame variable dict', matching=False,
67                     substrs = ['1 key/value pairs'])
68         self.expect('frame variable imset',
69                     substrs = ['1 index'])
70         self.expect('frame variable imset', matching=False,
71                     substrs = ['1 indexes'])
72         self.expect('frame variable binheap_ref',
73                     substrs = ['@"1 item"'])
74         self.expect('frame variable binheap_ref', matching=False,
75                     substrs = ['1 items'])
76         self.expect('frame variable immutableData',
77                     substrs = ['1 byte'])
78         self.expect('frame variable immutableData', matching=False,
79                     substrs = ['1 bytes'])