Author: Michael Buch Date: 2025-07-07T08:39:47+01:00 New Revision: b7d4735a0e2a65c27aa74a56e19020a34de790fe
URL: https://github.com/llvm/llvm-project/commit/b7d4735a0e2a65c27aa74a56e19020a34de790fe DIFF: https://github.com/llvm/llvm-project/commit/b7d4735a0e2a65c27aa74a56e19020a34de790fe.diff LOG: [lldb][test] Combine libstdc++ and libc++ vector<bool> tests into generic test (#147137) The libc++ and libstdc++ tests were pretty much an exact copy of each other. This test moves the libc++ test into generic removes it from libstdc++. I moved the `GLIBCXX_DEBUG` case over from libstdcxx. For some reason the libstdcxx test was skipped, but it passes on my Linux machine. So I unskipped it for now. Split out from https://github.com/llvm/llvm-project/pull/146740 Added: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterStdVBool.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/main.cpp Modified: Removed: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/main.cpp ################################################################################ diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/Makefile similarity index 75% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/Makefile index d87cf7d402787..65e9dd2fa9e33 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/Makefile @@ -1,4 +1,4 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 + include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterStdVBool.py similarity index 81% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterStdVBool.py index f3371bc014b17..56c86d1edde25 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterStdVBool.py @@ -2,8 +2,6 @@ Test lldb data formatter subsystem. """ - -from typing import Optional import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -17,19 +15,8 @@ def setUp(self): # Find the line number to break at. self.line = line_number("main.cpp", "// Set break point at this line.") - @skip - @add_test_categories(["libstdcxx"]) - def test_with_run_command(self): - self.with_run_command() - - @add_test_categories(["libstdcxx"]) - def test_with_run_command_debug(self): - build_args = {"CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"} - self.with_run_command(build_args) - - def with_run_command(self, dictionary: Optional[dict] = None): + def do_test(self): """Test that that file and class static variables display correctly.""" - self.build(dictionary=dictionary) self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( @@ -52,6 +39,7 @@ def cleanup(): self.runCmd("type summary clear", check=False) self.runCmd("type filter clear", check=False) self.runCmd("type synth clear", check=False) + self.runCmd("settings set target.max-children-count 24", check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -83,3 +71,20 @@ def cleanup(): "[48] = true", ], ) + + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() + + @add_test_categories(["libstdcxx"]) + def test_libstdcxx_debug(self): + self.build( + dictionary={"USE_LIBSTDCPP": 1, "CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"} + ) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/main.cpp new file mode 100644 index 0000000000000..22fc6c89ca8a2 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/main.cpp @@ -0,0 +1,65 @@ +#include <cstdio> +#include <string> +#include <vector> + +int main() { + std::vector<bool> vBool; + + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(false); + vBool.push_back(true); + vBool.push_back(true); + + std::puts("// Set break point at this line."); + return 0; +} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py deleted file mode 100644 index 24dddee62e1e7..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py +++ /dev/null @@ -1,76 +0,0 @@ -""" -Test lldb data formatter subsystem. -""" - - -import lldb -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class LibcxxVBoolDataFormatterTestCase(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.") - - @add_test_categories(["libc++"]) - def test_with_run_command(self): - """Test that that file and class static variables display correctly.""" - self.build() - self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) - - lldbutil.run_break_set_by_file_and_line( - self, "main.cpp", self.line, num_expected_locations=-1 - ) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect( - "thread list", - STOPPED_DUE_TO_BREAKPOINT, - substrs=["stopped", "stop reason = breakpoint"], - ) - - # This is the function to remove the custom formats in order to have a - # clean slate for the next test case. - def cleanup(): - self.runCmd("type format clear", check=False) - self.runCmd("type summary clear", check=False) - self.runCmd("type filter clear", check=False) - self.runCmd("type synth clear", check=False) - self.runCmd("settings set target.max-children-count 24", check=False) - - # Execute the cleanup function during test case tear down. - self.addTearDownHook(cleanup) - - self.expect( - "frame variable -A vBool", - substrs=[ - "size=49", - "[0] = false", - "[1] = true", - "[18] = false", - "[27] = true", - "[36] = false", - "[47] = true", - "[48] = true", - ], - ) - - self.expect( - "expr -A -- vBool", - substrs=[ - "size=49", - "[0] = false", - "[1] = true", - "[18] = false", - "[27] = true", - "[36] = false", - "[47] = true", - "[48] = true", - ], - ) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp deleted file mode 100644 index 026cfc863f2c0..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include <string> -#include <vector> - -int main() -{ - std::vector<bool> vBool; - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(true); - - printf ("size: %d", (int) vBool.size()); // Set break point at this line. - return 0; -} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/Makefile deleted file mode 100644 index c825977b1a5dc..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -CXX_SOURCES := main.cpp - -CFLAGS_EXTRAS := -O0 -USE_LIBSTDCPP := 1 - -include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/main.cpp deleted file mode 100644 index 73956dd3fda31..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include <vector> - -int main() -{ - std::vector<bool> vBool; - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(false); - vBool.push_back(true); - vBool.push_back(true); - - return 0; // Set break point at this line. -} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits