[TableGen] Fix validateOperandClass for non Phyical Reg (#118146)
[llvm-project.git] / lldb / test / API / sample_test / TestSampleTest.py
blobf18a4c0e6bb61e63a3adcace32cb38bd885d6b54
1 """
2 Describe the purpose of the test class here.
3 """
6 import lldb
7 import lldbsuite.test.lldbutil as lldbutil
8 from lldbsuite.test.lldbtest import *
11 class RenameThisSampleTestTestCase(TestBase):
12 # If your test case doesn't stress debug info, then
13 # set this to true. That way it won't be run once for
14 # each debug info format.
15 NO_DEBUG_INFO_TESTCASE = True
17 def test_sample_rename_this(self):
18 """There can be many tests in a test case - describe this test here."""
19 self.build()
20 self.main_source_file = lldb.SBFileSpec("main.c")
21 self.sample_test()
23 def setUp(self):
24 # Call super's setUp().
25 TestBase.setUp(self)
26 # Set up your test case here. If your test doesn't need any set up then
27 # remove this method from your TestCase class.
29 def sample_test(self):
30 """You might use the test implementation in several ways, say so here."""
32 # This function starts a process, "a.out" by default, sets a source
33 # breakpoint, runs to it, and returns the thread, process & target.
34 # It optionally takes an SBLaunchOption argument if you want to pass
35 # arguments or environment variables.
36 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
37 self, "Set a breakpoint here", self.main_source_file
40 frame = thread.GetFrameAtIndex(0)
41 test_var = frame.FindVariable("test_var")
42 self.assertSuccess(test_var.GetError(), "Failed to fetch test_var")
43 test_value = test_var.GetValueAsUnsigned()
44 self.assertEqual(test_value, 10, "Got the right value for test_var")
46 def sample_test_no_launch(self):
47 """Same as above but doesn't launch a process."""
49 target = self.createTestTarget()
50 self.expect_expr("global_test_var", result_value="10")