Home | History | Annotate | Download | only in radar-9691614
      1 """
      2 Test that objective-c method returning BOOL works correctly.
      3 """
      4 
      5 import os, time
      6 import unittest2
      7 import lldb
      8 from lldbtest import *
      9 import lldbutil
     10 
     11 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     12 class MethodReturningBOOLTestCase(TestBase):
     13 
     14     mydir = os.path.join("lang", "objc", "radar-9691614")
     15 
     16     @dsym_test
     17     def test_method_ret_BOOL_with_dsym(self):
     18         """Test that objective-c method returning BOOL works correctly."""
     19         d = {'EXE': self.exe_name}
     20         self.buildDsym(dictionary=d)
     21         self.setTearDownCleanup(dictionary=d)
     22         self.objc_method_ret_BOOL(self.exe_name)
     23 
     24     @dwarf_test
     25     def test_method_ret_BOOL_with_dwarf(self):
     26         """Test that objective-c method returning BOOL works correctly."""
     27         d = {'EXE': self.exe_name}
     28         self.buildDwarf(dictionary=d)
     29         self.setTearDownCleanup(dictionary=d)
     30         self.objc_method_ret_BOOL(self.exe_name)
     31 
     32     def setUp(self):
     33         # Call super's setUp().
     34         TestBase.setUp(self)
     35         # We'll use the test method name as the exe_name.
     36         self.exe_name = self.testMethodName
     37         # Find the line number to break inside main().
     38         self.main_source = "main.m"
     39         self.line = line_number(self.main_source, '// Set breakpoint here.')
     40 
     41     def objc_method_ret_BOOL(self, exe_name):
     42         """Test that objective-c method returning BOOL works correctly."""
     43         exe = os.path.join(os.getcwd(), exe_name)
     44         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
     45 
     46         lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
     47 
     48         self.runCmd("run", RUN_SUCCEEDED)
     49         self.expect("process status", STOPPED_DUE_TO_BREAKPOINT,
     50             substrs = [" at %s:%d" % (self.main_source, self.line),
     51                        "stop reason = breakpoint"])
     52 
     53         # rdar://problem/9691614
     54         self.runCmd('p (int)[my isValid]')
     55 
     56         
     57 if __name__ == '__main__':
     58     import atexit
     59     lldb.SBDebugger.Initialize()
     60     atexit.register(lambda: lldb.SBDebugger.Terminate())
     61     unittest2.main()
     62