]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / objc / foundation / TestConstStrings.py
1 """
2 Test that objective-c constant strings are generated correctly by the expression
3 parser.
4 """
5
6 from __future__ import print_function
7
8
9 import os
10 import time
11 import lldb
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 from lldbsuite.test import lldbutil
15
16
17 class ConstStringTestCase(TestBase):
18
19     mydir = TestBase.compute_mydir(__file__)
20     d = {'OBJC_SOURCES': 'const-strings.m'}
21
22     def setUp(self):
23         # Call super's setUp().
24         TestBase.setUp(self)
25         # Find the line number to break inside main().
26         self.main_source = "const-strings.m"
27         self.line = line_number(self.main_source, '// Set breakpoint here.')
28
29     @skipUnlessDarwin
30     def test_break(self):
31         """Test constant string generation amd comparison by the expression parser."""
32         self.build(dictionary=self.d)
33         self.setTearDownCleanup(self.d)
34
35         exe = os.path.join(os.getcwd(), "a.out")
36         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
37
38         lldbutil.run_break_set_by_file_and_line(
39             self,
40             self.main_source,
41             self.line,
42             num_expected_locations=1,
43             loc_exact=True)
44
45         self.runCmd("run", RUN_SUCCEEDED)
46         self.expect("process status", STOPPED_DUE_TO_BREAKPOINT,
47                     substrs=[" at %s:%d" % (self.main_source, self.line),
48                              "stop reason = breakpoint"])
49
50         self.expect('expression (int)[str compare:@"hello"]',
51                     startstr="(int) $0 = 0")
52         self.expect('expression (int)[str compare:@"world"]',
53                     startstr="(int) $1 = -1")
54
55         # Test empty strings, too.
56         self.expect('expression (int)[@"" length]',
57                     startstr="(int) $2 = 0")
58
59         self.expect('expression (int)[@"123" length]',
60                     startstr="(int) $3 = 3")