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 16 mydir = TestBase.compute_mydir(__file__) 17 d = {'OBJC_SOURCES': 'const-strings.m'} 18 19 def setUp(self): 20 # Call super's setUp(). 21 TestBase.setUp(self) 22 # Find the line number to break inside main(). 23 self.main_source = "const-strings.m" 24 self.line = line_number(self.main_source, '// Set breakpoint here.') 25 26 @skipUnlessDarwin 27 def test_break(self): 28 """Test constant string generation amd comparison by the expression parser.""" 29 self.build(dictionary=self.d) 30 self.setTearDownCleanup(self.d) 31 32 exe = self.getBuildArtifact("a.out") 33 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 34 35 lldbutil.run_break_set_by_file_and_line( 36 self, 37 self.main_source, 38 self.line, 39 num_expected_locations=1, 40 loc_exact=True) 41 42 self.runCmd("run", RUN_SUCCEEDED) 43 self.expect("process status", STOPPED_DUE_TO_BREAKPOINT, 44 substrs=["stop reason = breakpoint", 45 " at %s:%d" % (self.main_source, self.line)]) 46 47 self.expect('expression (int)[str compare:@"hello"]', 48 startstr="(int) $0 = 0") 49 self.expect('expression (int)[str compare:@"world"]', 50 startstr="(int) $1 = -1") 51 52 # Test empty strings, too. 53 self.expect('expression (int)[@"" length]', 54 startstr="(int) $2 = 0") 55 56 self.expect('expression (int)[@"123" length]', 57 startstr="(int) $3 = 3") 58