From cd9b7779f39203c735162b2e5c7b1da2ca22443e Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Tue, 12 Oct 2010 00:09:25 +0000 Subject: [PATCH] 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: 116275 --- lldb/test/bitfields/TestBitfields.py | 13 ++++++++++--- lldb/test/bitfields/main.c | 2 +- lldb/test/lldbtest.py | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lldb/test/bitfields/TestBitfields.py b/lldb/test/bitfields/TestBitfields.py index b5a2f92c5a07..b29b5f9435a6 100644 --- a/lldb/test/bitfields/TestBitfields.py +++ b/lldb/test/bitfields/TestBitfields.py @@ -31,14 +31,21 @@ class BitfieldsTestCase(TestBase): self.buildDwarf() self.bitfields_variable_python() + def setUp(self): + super(BitfieldsTestCase, self).setUp() + # Find the line number to break inside main(). + self.line = line_number('main.c', '// Set break point at this line.') + def bitfields_variable(self): """Test 'frame variable ...' on a variable with bitfields.""" 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 42", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.c', line = 42, 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) @@ -81,7 +88,7 @@ class BitfieldsTestCase(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target.IsValid(), VALID_TARGET) - breakpoint = target.BreakpointCreateByLocation("main.c", 42) + breakpoint = target.BreakpointCreateByLocation("main.c", self.line) self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) self.runCmd("run", RUN_SUCCEEDED, setCookie=False) diff --git a/lldb/test/bitfields/main.c b/lldb/test/bitfields/main.c index ca73cc08cba0..8d4116b2278f 100644 --- a/lldb/test/bitfields/main.c +++ b/lldb/test/bitfields/main.c @@ -39,6 +39,6 @@ int main (int argc, char const *argv[]) bits.b7 = i; //// break $source:$line for (i=0; i<(1<<4); i++) bits.four = i; //// break $source:$line - return 0; //// continue + return 0; //// Set break point at this line. } diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index 915cfd54fe12..97b351cdd696 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -232,7 +232,7 @@ def line_number(filename, string_to_match): for i, line in enumerate(f): if line.find(string_to_match) != -1: # Found our match. - return i + return i+1 return -1 def pointer_size():