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