1""" 2Describe the purpose of the test class here. 3""" 4 5 6 7import lldb 8import lldbsuite.test.lldbutil as lldbutil 9from lldbsuite.test.lldbtest import * 10 11 12class RenameThisSampleTestTestCase(TestBase): 13 14 mydir = TestBase.compute_mydir(__file__) 15 16 # If your test case doesn't stress debug info, the 17 # set this to true. That way it won't be run once for 18 # each debug info format. 19 NO_DEBUG_INFO_TESTCASE = True 20 21 def test_sample_rename_this(self): 22 """There can be many tests in a test case - describe this test here.""" 23 self.build() 24 self.main_source_file = lldb.SBFileSpec("main.c") 25 self.sample_test() 26 27 def setUp(self): 28 # Call super's setUp(). 29 TestBase.setUp(self) 30 # Set up your test case here. If your test doesn't need any set up then 31 # remove this method from your TestCase class. 32 33 def sample_test(self): 34 """You might use the test implementation in several ways, say so here.""" 35 36 # This function starts a process, "a.out" by default, sets a source 37 # breakpoint, runs to it, and returns the thread, process & target. 38 # It optionally takes an SBLaunchOption argument if you want to pass 39 # arguments or environment variables. 40 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, 41 "Set a breakpoint here", self.main_source_file) 42 43 frame = thread.GetFrameAtIndex(0) 44 test_var = frame.FindVariable("test_var") 45 self.assertTrue(test_var.GetError().Success(), "Failed to fetch test_var") 46 test_value = test_var.GetValueAsUnsigned() 47 self.assertEqual(test_value, 10, "Got the right value for test_var") 48 49