1# encoding: utf-8 2""" 3Test lldb data formatter subsystem. 4""" 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class ObjCDataFormatterTestCase(TestBase): 14 def appkit_tester_impl(self, commands, use_constant_classes): 15 if use_constant_classes: 16 self.build() 17 else: 18 disable_constant_classes = { 19 "CFLAGS_EXTRAS": "-fno-constant-nsnumber-literals " 20 + "-fno-constant-nsarray-literals " 21 + "-fno-constant-nsdictionary-literals", 22 } 23 # FIXME: Remove compiler when flags are available upstream. 24 self.build(dictionary=disable_constant_classes, compiler="xcrun clang") 25 self.appkit_common_data_formatters_command() 26 commands() 27 28 def appkit_common_data_formatters_command(self): 29 """Test formatters for AppKit classes.""" 30 self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( 31 self, "// Set break point at this line.", lldb.SBFileSpec("main.m", False) 32 ) 33 34 # The stop reason of the thread should be breakpoint. 35 self.expect( 36 "thread list", 37 STOPPED_DUE_TO_BREAKPOINT, 38 substrs=["stopped", "stop reason = breakpoint"], 39 ) 40 41 # This is the function to remove the custom formats in order to have a 42 # clean slate for the next test case. 43 def cleanup(): 44 self.runCmd("type format clear", check=False) 45 self.runCmd("type summary clear", check=False) 46 self.runCmd("type synth clear", check=False) 47 48 # Execute the cleanup function during test case tear down. 49 self.addTearDownHook(cleanup) 50