30 lines · python
1"""2Tests that importing ObjC modules in a non-ObjC target doesn't crash LLDB.3"""4 5import lldb6from lldbsuite.test.decorators import *7from lldbsuite.test.lldbtest import *8from lldbsuite.test import lldbutil9 10 11class TestCase(TestBase):12 def test(self):13 self.build()14 lldbutil.run_to_source_breakpoint(15 self, "// break here", lldb.SBFileSpec("main.c")16 )17 18 # Import foundation to get some ObjC types.19 self.expect("expr --lang objc -- @import Foundation")20 # Do something with NSString (which requires special handling when21 # preparing to run in the target). The expression most likely can't22 # be prepared to run in the target but it should at least not crash LLDB.23 self.expect(24 'expr --lang objc -- [NSString stringWithFormat:@"%d", 1];',25 error=True,26 substrs=[27 "Rewriting an Objective-C constant string requires CFStringCreateWithBytes"28 ],29 )30