Home | History | Annotate | Download | only in rdar-10642615
      1 """
      2 Test lldb data formatter subsystem.
      3 """
      4 
      5 import os, time
      6 import unittest2
      7 import lldb
      8 from lldbtest import *
      9 import lldbutil
     10 
     11 class Radar10642615DataFormatterTestCase(TestBase):
     12 
     13     # test for rdar://problem/10642615 ()
     14     mydir = os.path.join("functionalities", "data-formatter", "rdar-10642615")
     15 
     16     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     17     @dsym_test
     18     def test_with_dsym_and_run_command(self):
     19         """Test data formatter commands."""
     20         self.buildDsym()
     21         self.data_formatter_commands()
     22 
     23     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     24     @dwarf_test
     25     def test_with_dwarf_and_run_command(self):
     26         """Test data formatter commands."""
     27         self.buildDwarf()
     28         self.data_formatter_commands()
     29 
     30     def setUp(self):
     31         # Call super's setUp().
     32         TestBase.setUp(self)
     33         # Find the line number to break at.
     34         self.line = line_number('main.cpp', '// Set break point at this line.')
     35 
     36     def data_formatter_commands(self):
     37         """Test that that file and class static variables display correctly."""
     38         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
     39 
     40         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
     41 
     42         self.runCmd("run", RUN_SUCCEEDED)
     43 
     44         # The stop reason of the thread should be breakpoint.
     45         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
     46             substrs = ['stopped',
     47                        'stop reason = breakpoint'])
     48 
     49         # This is the function to remove the custom formats in order to have a
     50         # clean slate for the next test case.
     51         def cleanup():
     52             self.runCmd('type summary clear', check=False)
     53 
     54         # Execute the cleanup function during test case tear down.
     55         self.addTearDownHook(cleanup)
     56 
     57         self.expect('frame variable',
     58             substrs = ['(vFloat) valueFL = (1, 0, 4, 0)',
     59                        '(int16_t [8]) valueI16 = (1, 0, 4, 0, 0, 1, 0, 4)',
     60                        '(int32_t [4]) valueI32 = (1, 0, 4, 0)',
     61                        '(vDouble) valueDL = (1, 4)',
     62                        "(vUInt8) valueU8 = ('\\x01', '\\0', '\\x04', '\\0', '\\0', '\\x01', '\\0', '\\x04', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0')",
     63                        '(vUInt16) valueU16 = (1, 0, 4, 0, 0, 1, 0, 4)',
     64                        '(vUInt32) valueU32 = (1, 2, 3, 4)',
     65                        "(vSInt8) valueS8 = ('\\x01', '\\0', '\\x04', '\\0', '\\0', '\\x01', '\\0', '\\x04', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0')",
     66                        '(vSInt16) valueS16 = (1, 0, 4, 0, 0, 1, 0, 4)',
     67                        '(vSInt32) valueS32 = (4, 3, 2, 1)',
     68                        '(vBool32) valueBool32 = (0, 1, 0, 1)'])
     69 
     70 if __name__ == '__main__':
     71     import atexit
     72     lldb.SBDebugger.Initialize()
     73     atexit.register(lambda: lldb.SBDebugger.Terminate())
     74     unittest2.main()
     75