From da144dc216dd98885f4f9b9b5ac1376039033611 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Thu, 9 May 2013 01:04:59 +0000 Subject: [PATCH] Changing the std::map test case to use source breakpoints instead of relying on the nexting always "getting it right" to stop at the locations of interest This should make us more robust in the face of changing compiler line tables and other library modifications llvm-svn: 181497 --- .../libcxx/map/TestDataFormatterLibccMap.py | 35 +++++++--------- .../data-formatter-stl/libcxx/map/main.cpp | 40 ++++++++++++++----- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py index d3630d721a15..d339b7b90520 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py @@ -29,14 +29,12 @@ class LibcxxMapDataFormatterTestCase(TestBase): def setUp(self): # Call super's setUp(). TestBase.setUp(self) - # Find the line number to break at. - self.line = line_number('main.cpp', '// Set break point at this line.') def data_formatter_commands(self): """Test that that file and class static variables display correctly.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1) + lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") self.runCmd("run", RUN_SUCCEEDED) @@ -67,7 +65,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): substrs = ['map has 0 items', '{}']) - self.runCmd("n");self.runCmd("n"); + self.runCmd("continue"); self.expect('frame variable ii', substrs = ['map has 2 items', @@ -78,7 +76,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): 'first = 1', 'second = 1']) - self.runCmd("n");self.runCmd("n"); + self.runCmd("continue"); self.expect('frame variable ii', substrs = ['map has 4 items', @@ -89,9 +87,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): 'first = 3', 'second = 1']) - self.runCmd("n");self.runCmd("n"); - self.runCmd("n");self.runCmd("n"); - self.runCmd("frame select 0") + self.runCmd("continue"); self.expect("frame variable ii", substrs = ['map has 8 items', @@ -130,7 +126,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): #self.expect("expression ii[8]", matching=False, error=True, # substrs = ['1234567']) - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0') + self.runCmd("continue"); self.expect('frame variable ii', substrs = ['map has 0 items', @@ -142,7 +138,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): substrs = ['map has 0 items', '{}']) - self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0') + self.runCmd("continue"); self.expect('frame variable si', substrs = ['map has 1 items', @@ -150,9 +146,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): 'first = \"zero\"', 'second = 0']) - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n") - self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0') + self.runCmd("continue"); self.expect("frame variable si", substrs = ['map has 4 items', @@ -200,20 +194,20 @@ class LibcxxMapDataFormatterTestCase(TestBase): #self.expect("expression si[0]", matching=False, error=True, # substrs = ['first = ', 'zero']) - self.runCmd("n");self.runCmd("n"); + self.runCmd("continue"); self.expect('frame variable si', substrs = ['map has 0 items', '{}']) - self.runCmd("n") + self.runCmd("continue"); self.runCmd("frame variable is --show-types") self.expect('frame variable is', substrs = ['map has 0 items', '{}']) - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); + self.runCmd("continue"); self.expect("frame variable is", substrs = ['map has 4 items', @@ -261,21 +255,20 @@ class LibcxxMapDataFormatterTestCase(TestBase): #self.expect("expression is[0]", matching=False, error=True, # substrs = ['first = ', 'goofy']) - self.runCmd("n") + self.runCmd("continue"); self.expect('frame variable is', substrs = ['map has 0 items', '{}']) - self.runCmd("n");self.runCmd("n"); + self.runCmd("continue"); self.runCmd("frame variable ss --show-types") self.expect('frame variable ss', substrs = ['map has 0 items', '{}']) - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0') + self.runCmd("continue"); self.expect("frame variable ss", substrs = ['map has 3 items', @@ -316,7 +309,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): #self.expect("expression ss[3]", matching=False, error=True, # substrs = ['gatto']) - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0') + self.runCmd("continue"); self.expect('frame variable ss', substrs = ['map has 0 items', diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp index 704d17d52119..6e40b43d810f 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp +++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp @@ -10,6 +10,17 @@ #define intstr_map std::map #define strstr_map std::map +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) +{ + if (arg < 0) + arg = 0; + if (!arg) + arg = 1; + g_the_foo += arg; + return g_the_foo; +} int main() { @@ -17,43 +28,54 @@ int main() ii[0] = 0; // Set break point at this line. ii[1] = 1; + thefoo_rw(1); // Set break point at this line. ii[2] = 0; ii[3] = 1; - ii[4] = 0; + thefoo_rw(1); // Set break point at this line. + ii[4] = 0; ii[5] = 1; ii[6] = 0; ii[7] = 1; + thefoo_rw(1); // Set break point at this line. ii[85] = 1234567; - + ii.clear(); strint_map si; - + thefoo_rw(1); // Set break point at this line. + si["zero"] = 0; + thefoo_rw(1); // Set break point at this line. si["one"] = 1; si["two"] = 2; si["three"] = 3; + thefoo_rw(1); // Set break point at this line. si["four"] = 4; si.clear(); - + thefoo_rw(1); // Set break point at this line. + intstr_map is; - + thefoo_rw(1); // Set break point at this line. is[85] = "goofy"; is[1] = "is"; is[2] = "smart"; is[3] = "!!!"; - + thefoo_rw(1); // Set break point at this line. + is.clear(); - + thefoo_rw(1); // Set break point at this line. + strstr_map ss; - + thefoo_rw(1); // Set break point at this line. + ss["ciao"] = "hello"; ss["casa"] = "house"; ss["gatto"] = "cat"; + thefoo_rw(1); // Set break point at this line. ss["a Mac.."] = "..is always a Mac!"; ss.clear(); - + thefoo_rw(1); // Set break point at this line. return 0; } \ No newline at end of file