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 # If your test case doesn't stress debug info, then 15 # set this to true. That way it won't be run once for 16 # each debug info format. 17 NO_DEBUG_INFO_TESTCASE = True 18 19 def test_sample_rename_this(self): 20 """There can be many tests in a test case - describe this test here.""" 21 self.build() 22 self.main_source_file = lldb.SBFileSpec("main.c") 23 self.sample_test() 24 25 def setUp(self): 26 # Call super's setUp(). 27 TestBase.setUp(self) 28 # Set up your test case here. If your test doesn't need any set up then 29 # remove this method from your TestCase class. 30 31 def sample_test(self): 32 """You might use the test implementation in several ways, say so here.""" 33 34 # This function starts a process, "a.out" by default, sets a source 35 # breakpoint, runs to it, and returns the thread, process & target. 36 # It optionally takes an SBLaunchOption argument if you want to pass 37 # arguments or environment variables. 38 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, 39 "Set a breakpoint here", self.main_source_file) 40 41 frame = thread.GetFrameAtIndex(0) 42 test_var = frame.FindVariable("test_var") 43 self.assertSuccess(test_var.GetError(), "Failed to fetch test_var") 44 test_value = test_var.GetValueAsUnsigned() 45 self.assertEqual(test_value, 10, "Got the right value for test_var") 46 47 def sample_test_no_launch(self): 48 """ Same as above but doesn't launch a process.""" 49 50 target = self.createTestTarget() 51 self.expect_expr("global_test_var", result_value="10") 52