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