Home | History | Annotate | Download | only in signed_types
      1 """
      2 Test that variables with signed types display correctly.
      3 """
      4 
      5 import os, time
      6 import re
      7 import unittest2
      8 import lldb
      9 from lldbtest import *
     10 import lldbutil
     11 
     12 class UnsignedTypesTestCase(TestBase):
     13 
     14     mydir = os.path.join("lang", "cpp", "signed_types")
     15 
     16     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     17     @dsym_test
     18     def test_with_dsym(self):
     19         """Test that variables with signed types display correctly."""
     20         self.buildDsym()
     21         self.signed_types()
     22 
     23     @dwarf_test
     24     def test_with_dwarf(self):
     25         """Test that variables with signed types display correctly."""
     26         self.buildDwarf()
     27         self.signed_types()
     28 
     29     def setUp(self):
     30         # Call super's setUp().
     31         TestBase.setUp(self)
     32         # Find the line number to break inside main().
     33         self.line = line_number('main.cpp', '// Set break point at this line.')
     34 
     35     def signed_types(self):
     36         """Test that variables with signed types display correctly."""
     37         exe = os.path.join(os.getcwd(), "a.out")
     38         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
     39 
     40         # Break on line 22 in main() aftre the variables are assigned values.
     41         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
     42 
     43         self.runCmd("run", RUN_SUCCEEDED)
     44 
     45         # The stop reason of the thread should be breakpoint.
     46         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
     47             substrs = ['stopped', 'stop reason = breakpoint'])
     48 
     49         # The breakpoint should have a hit count of 1.
     50         self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
     51             substrs = [' resolved, hit count = 1'])
     52 
     53         # Execute the assignment statement.
     54         self.runCmd("thread step-over")
     55 
     56         # Test that signed types display correctly.
     57         self.expect("frame variable --show-types --no-args", VARIABLES_DISPLAYED_CORRECTLY,
     58             patterns = ["\((short int|short)\) the_signed_short = 99",
     59                        "\((signed char|char)\) the_signed_char = 'c'"],
     60             substrs = ["(int) the_signed_int = 99",
     61                        "(long) the_signed_long = 99",
     62                        "(long long) the_signed_long_long = 99"])
     63 
     64 
     65 if __name__ == '__main__':
     66     import atexit
     67     lldb.SBDebugger.Initialize()
     68     atexit.register(lambda: lldb.SBDebugger.Terminate())
     69     unittest2.main()
     70