Add test cases to TestTargetAPI.py to exercise the newly added SBTarget.FindGlobalVariables() API.

llvm-svn: 134109
This commit is contained in:
Johnny Chen 2011-06-29 22:45:06 +00:00
parent 4becb37e34
commit 466c593912
2 changed files with 33 additions and 0 deletions

View File

@ -12,6 +12,19 @@ class TargetAPITestCase(TestBase):
mydir = os.path.join("python_api", "target")
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@python_api_test
def test_find_global_variables_with_dsym(self):
"""Exercise SBTaget.FindGlobalVariables() API."""
self.buildDsym()
self.find_global_variables()
@python_api_test
def test_find_global_variables_with_dwarf(self):
"""Exercise SBTarget.FindGlobalVariables() API."""
self.buildDwarf()
self.find_global_variables()
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@python_api_test
def test_get_description_with_dsym(self):
@ -58,6 +71,24 @@ class TargetAPITestCase(TestBase):
self.line1 = line_number('main.c', '// Find the line number for breakpoint 1 here.')
self.line2 = line_number('main.c', '// Find the line number for breakpoint 2 here.')
def find_global_variables(self):
"""Exercise SBTaget.FindGlobalVariables() API."""
exe = os.path.join(os.getcwd(), "a.out")
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
value_list = target.FindGlobalVariables('my_global_var_of_char_type', 1)
self.assertTrue(value_list.GetSize() == 1)
my_global_var = value_list.GetValueAtIndex(0)
self.expect(my_global_var.GetName(), exe=False,
startstr = "my_global_var_of_char_type")
self.expect(my_global_var.GetTypeName(), exe=False,
startstr = "char")
self.expect(my_global_var.GetValue(), exe=False,
startstr = "'X'")
def get_description(self):
"""Exercise SBTaget.GetDescription() API."""
exe = os.path.join(os.getcwd(), "a.out")

View File

@ -18,6 +18,8 @@
//
// The two symbol context should point to the same symbol, i.e., 'a' function.
char my_global_var_of_char_type = 'X'; // Test SBTarget.FindGlobalVariables(...).
int a(int);
int b(int);
int c(int);