Avoid using hardcoded line number to break on. Use the line_number() utility

function to get the line number to break on during setUp().

llvm-svn: 116350
This commit is contained in:
Johnny Chen 2010-10-12 22:14:43 +00:00
parent 1a28439b96
commit f389d7290e
2 changed files with 10 additions and 3 deletions

View File

@ -22,14 +22,21 @@ class EnumTypesTestCase(TestBase):
self.buildDwarf()
self.image_lookup_for_enum_type()
def setUp(self):
super(EnumTypesTestCase, self).setUp()
# Find the line number to break inside main().
self.line = line_number('main.c', '// Set break point at this line.')
def image_lookup_for_enum_type(self):
"""Test 'image lookup -t days' and check for correct display."""
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Break inside the main.
self.expect("breakpoint set -f main.c -l 26", BREAKPOINT_CREATED,
startstr = "Breakpoint created: 1: file ='main.c', line = 26, locations = 1")
self.expect("breakpoint set -f main.c -l %d" % self.line,
BREAKPOINT_CREATED,
startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" %
self.line)
self.runCmd("run", RUN_SUCCEEDED)

View File

@ -23,7 +23,7 @@ int main (int argc, char const *argv[])
enum days day;
for (day = Monday - 1; day <= kNumDays + 1; day++)
{
printf("day as int is %i\n", (int)day);
printf("day as int is %i\n", (int)day); // Set break point at this line.
}
return 0;
}