Skip to content

Commit a88e286

Browse files
authored
[lldb][test] Consolidate libstdc++ and libc++ vector formatter tests into generic test (#146885)
The libstdc++ test was a subset of the tests in libc++. This test moves the libc++ test into `generic` and removes the `libstdc++` tests. I retained the `-D_GLIBCXX_DEBUG` test cases though. Split out from #146740
1 parent 34f124b commit a88e286

File tree

7 files changed

+76
-308
lines changed

7 files changed

+76
-308
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
CXX_SOURCES := main.cpp
22

3-
CXXFLAGS := -O0
4-
USE_LIBSTDCPP := 1
5-
63
include Makefile.rules
Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
Test lldb data formatter subsystem.
33
"""
44

5-
65
import lldb
76
from lldbsuite.test.decorators import *
87
from lldbsuite.test.lldbtest import *
98
from lldbsuite.test import lldbutil
109

1110

12-
class LibcxxVectorDataFormatterTestCase(TestBase):
11+
class StdVectorDataFormatterTestCase(TestBase):
1312
def check_numbers(self, var_name, show_ptr=False):
1413
patterns = []
1514
substrs = [
@@ -52,10 +51,8 @@ def check_numbers(self, var_name, show_ptr=False):
5251
self.expect("frame variable " + var_name + "[2]", substrs=["123"])
5352
self.expect("frame variable " + var_name + "[3]", substrs=["1234"])
5453

55-
@add_test_categories(["libc++"])
56-
def test_with_run_command(self):
54+
def do_test(self):
5755
"""Test that that file and class static variables display correctly."""
58-
self.build()
5956
(self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
6057
self, "break here", lldb.SBFileSpec("main.cpp", False)
6158
)
@@ -170,10 +167,25 @@ def cleanup():
170167

171168
self.expect("frame variable strings", substrs=["vector has 0 items"])
172169

170+
@add_test_categories(["libstdcxx"])
171+
def test_libstdcxx(self):
172+
self.build(dictionary={"USE_LIBSTDCPP": 1})
173+
self.do_test()
174+
175+
@add_test_categories(["libstdcxx"])
176+
def test_libstdcxx_debug(self):
177+
self.build(
178+
dictionary={"USE_LIBSTDCPP": 1, "CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"}
179+
)
180+
self.do_test()
181+
173182
@add_test_categories(["libc++"])
174-
def test_ref_and_ptr(self):
183+
def test_libcxx(self):
184+
self.build(dictionary={"USE_LIBCPP": 1})
185+
self.do_test()
186+
187+
def do_test_ref_and_ptr(self):
175188
"""Test that that file and class static variables display correctly."""
176-
self.build()
177189
(self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
178190
self, "Stop here to check by ref", lldb.SBFileSpec("main.cpp", False)
179191
)
@@ -186,3 +198,20 @@ def test_ref_and_ptr(self):
186198
self.expect("frame variable ptr", substrs=["ptr =", " size=7"])
187199

188200
self.expect("expression ptr", substrs=["$", "size=7"])
201+
202+
@add_test_categories(["libstdcxx"])
203+
def test_ref_and_ptr_libstdcxx(self):
204+
self.build(dictionary={"USE_LIBSTDCPP": 1})
205+
self.do_test_ref_and_ptr()
206+
207+
@add_test_categories(["libstdcxx"])
208+
def test_ref_and_ptr_libstdcxx_debug(self):
209+
self.build(
210+
dictionary={"USE_LIBSTDCPP": 1, "CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"}
211+
)
212+
self.do_test_ref_and_ptr()
213+
214+
@add_test_categories(["libc++"])
215+
def test_ref_and_ptr_libcxx(self):
216+
self.build(dictionary={"USE_LIBCPP": 1})
217+
self.do_test_ref_and_ptr()
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <stdio.h>
2+
#include <string>
3+
#include <vector>
4+
typedef std::vector<int> int_vect;
5+
typedef std::vector<std::string> string_vect;
6+
7+
template <class T>
8+
void by_ref_and_ptr(std::vector<T> &ref, std::vector<T> *ptr) {
9+
// Stop here to check by ref
10+
return;
11+
}
12+
13+
int main() {
14+
int_vect numbers;
15+
numbers.push_back(1); // break here
16+
numbers.push_back(12); // break here
17+
numbers.push_back(123);
18+
numbers.push_back(1234);
19+
numbers.push_back(12345); // break here
20+
numbers.push_back(123456);
21+
numbers.push_back(1234567);
22+
by_ref_and_ptr(numbers, &numbers);
23+
24+
printf("break here");
25+
numbers.clear();
26+
27+
numbers.push_back(7); // break here
28+
29+
string_vect strings;
30+
strings.push_back(std::string("goofy"));
31+
strings.push_back(std::string("is"));
32+
strings.push_back(std::string("smart"));
33+
printf("break here");
34+
strings.push_back(std::string("!!!"));
35+
36+
printf("break here");
37+
strings.clear();
38+
39+
return 0; // break here
40+
}

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/Makefile

Lines changed: 0 additions & 6 deletions
This file was deleted.

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/main.cpp

Lines changed: 0 additions & 41 deletions
This file was deleted.

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py

Lines changed: 0 additions & 220 deletions
This file was deleted.

0 commit comments

Comments
 (0)