1# coding=utf8 2""" 3Test that the expression parser returns proper Unicode strings. 4""" 5 6 7 8import lldb 9from lldbsuite.test.decorators import * 10from lldbsuite.test.lldbtest import * 11from lldbsuite.test import lldbutil 12 13# this test case fails because of rdar://12991846 14# the expression parser does not deal correctly with Unicode expressions 15# e.g. 16#(lldb) expr L"Hello" 17#(const wchar_t [6]) $0 = { 18# [0] = \0\0\0\0 19# [1] = \0\0\0\0 20# [2] = \0\0\0\0 21# [3] = \0\0\0\0 22# [4] = H\0\0\0 23# [5] = e\0\0\0 24#} 25 26 27class UnicodeLiteralsTestCase(TestBase): 28 29 mydir = TestBase.compute_mydir(__file__) 30 31 def test_expr1(self): 32 """Test that the expression parser returns proper Unicode strings.""" 33 self.build() 34 self.rdar12991846(expr=1) 35 36 def test_expr2(self): 37 """Test that the expression parser returns proper Unicode strings.""" 38 self.build() 39 self.rdar12991846(expr=2) 40 41 def test_expr3(self): 42 """Test that the expression parser returns proper Unicode strings.""" 43 self.build() 44 self.rdar12991846(expr=3) 45 46 def setUp(self): 47 # Call super's setUp(). 48 TestBase.setUp(self) 49 # Find the line number to break for main.cpp. 50 self.source = 'main.cpp' 51 self.line = line_number( 52 self.source, '// Set break point at this line.') 53 54 def rdar12991846(self, expr=None): 55 """Test that the expression parser returns proper Unicode strings.""" 56 if self.getArchitecture() in ['i386']: 57 self.skipTest( 58 "Skipping because this test is known to crash on i386") 59 60 exe = self.getBuildArtifact("a.out") 61 62 # Create a target by the debugger. 63 target = self.dbg.CreateTarget(exe) 64 self.assertTrue(target, VALID_TARGET) 65 66 # Break on the struct declration statement in main.cpp. 67 lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.line) 68 69 # Now launch the process, and do not stop at entry point. 70 process = target.LaunchSimple( 71 None, None, self.get_process_working_directory()) 72 73 if not process: 74 self.fail("SBTarget.Launch() failed") 75 76 if expr == 1: 77 self.expect('expression L"hello"', substrs=['hello']) 78 79 if expr == 2: 80 self.expect('expression u"hello"', substrs=['hello']) 81 82 if expr == 3: 83 self.expect('expression U"hello"', substrs=['hello']) 84