Author: Michael Buch
Date: 2025-07-07T12:48:15+01:00
New Revision: e14e98290e71abe5d34b1d4724fde1b85b350547

URL: 
https://github.com/llvm/llvm-project/commit/e14e98290e71abe5d34b1d4724fde1b85b350547
DIFF: 
https://github.com/llvm/llvm-project/commit/e14e98290e71abe5d34b1d4724fde1b85b350547.diff

LOG: [lldb][test] Combine libstdc++ and libc++ std::shared_ptr tests into 
generic test (#147141)

This combines the libc++ and libstdc++ test cases. The libstdcpp tests
were a subset of the libc++ test, so this patch moves the libcxx test
into `generic` and removes the libstdcpp test entirely.

Split out from https://github.com/llvm/llvm-project/pull/146740

Added: 
    
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/Makefile
    
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py
    
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/main.cpp

Modified: 
    

Removed: 
    
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/Makefile
    
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
    
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/main.cpp
    
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile
    
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
    
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/main.cpp


################################################################################
diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/Makefile
similarity index 57%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/Makefile
index 654e4b15bd568..99998b20bcb05 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/Makefile
@@ -1,6 +1,3 @@
 CXX_SOURCES := main.cpp
 
-CXXFLAGS := -O0
-USE_LIBSTDCPP := 1
-
 include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py
similarity index 86%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py
index a10ab8e863002..8b641c9643958 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py
@@ -1,5 +1,5 @@
 """
-Test lldb data formatter for libc++ std::shared_ptr.
+Test lldb data formatter for std::shared_ptr.
 """
 
 import lldb
@@ -9,11 +9,8 @@
 
 
 class TestCase(TestBase):
-    @add_test_categories(["libc++"])
-    def test_shared_ptr_variables(self):
+    def do_test(self):
         """Test `frame variable` output for `std::shared_ptr` types."""
-        self.build()
-
         (_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(
             self, "// break here", lldb.SBFileSpec("main.cpp")
         )
@@ -56,16 +53,8 @@ def test_shared_ptr_variables(self):
         self.assertRegex(valobj.summary, r"^10( strong=1)? weak=0$")
         self.assertNotEqual(valobj.child[0].unsigned, 0)
 
-        if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(
-            [">", "16.0"]
-        ):
-            string_type = "std::string"
-        else:
-            string_type = "std::basic_string<char, std::char_traits<char>, 
std::allocator<char> > "
-
         valobj = self.expect_var_path(
             "sp_str",
-            type="std::shared_ptr<" + string_type + ">",
             children=[ValueCheck(name="pointer", summary='"hello"')],
         )
         self.assertRegex(valobj.summary, r'^"hello"( strong=1)? weak=0$')
@@ -73,7 +62,7 @@ def test_shared_ptr_variables(self):
         valobj = self.expect_var_path("sp_user", type="std::shared_ptr<User>")
         self.assertRegex(
             valobj.summary,
-            "^std(::__[^:]*)?::shared_ptr<User>::element_type @ 
0x0*[1-9a-f][0-9a-f]+( strong=1)? weak=0",
+            "element_type @ 0x0*[1-9a-f][0-9a-f]+( strong=1)? weak=0",
         )
         self.assertNotEqual(valobj.child[0].unsigned, 0)
 
@@ -115,3 +104,13 @@ def test_shared_ptr_variables(self):
         self.expect_var_path("ptr_node->next->value", value="2")
         self.expect_var_path("(*ptr_node).value", value="1")
         self.expect_var_path("(*(*ptr_node).next).value", value="2")
+
+    @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()

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/main.cpp
similarity index 100%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/main.cpp
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/main.cpp

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/Makefile
deleted file mode 100644
index c1c8b4a2a0a53..0000000000000
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-CXX_SOURCES := main.cpp
-
-USE_LIBCPP := 1
-
-# We need debug info tuning for lldb in order to emit the preferred name for
-# std::string. See https://reviews.llvm.org/D145803.
-CXXFLAGS_EXTRAS := -std=c++14 -glldb
-include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
deleted file mode 100644
index 785fd03169224..0000000000000
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
+++ /dev/null
@@ -1,53 +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 StdSmartPtrDataFormatterTestCase(TestBase):
-    @add_test_categories(["libstdcxx"])
-    @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
-    def test_with_run_command(self):
-        self.build()
-        self.runCmd("file " + self.getBuildArtifact("a.out"), 
CURRENT_EXECUTABLE_SET)
-
-        lldbutil.run_break_set_by_source_regexp(self, "Set break point at this 
line.")
-        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"],
-        )
-
-        self.expect("frame variable nsp", substrs=["nsp = nullptr"])
-        self.expect("frame variable isp", substrs=["isp = 123"])
-        self.expect("frame variable ssp", substrs=['ssp = "foobar"'])
-
-        self.expect("frame variable nwp", substrs=["nwp = nullptr"])
-        self.expect("frame variable iwp", substrs=["iwp = 123"])
-        self.expect("frame variable swp", substrs=['swp = "foobar"'])
-
-        self.expect("frame variable *nsp", substrs=["*nsp = <parent is NULL>"])
-        self.expect("frame variable *isp", substrs=["*isp = 123"])
-        self.expect("frame variable *ssp", substrs=['*ssp = "foobar"'])
-        self.expect("frame variable *fsp", substrs=["*fsp = (mem = 5)"])
-
-        self.expect("frame variable fsp->mem", substrs=["(int) fsp->mem = 5"])
-
-        self.runCmd("continue")
-
-        self.expect("frame variable nsp", substrs=["nsp = nullptr"])
-        self.expect("frame variable isp", substrs=["isp = nullptr"])
-        self.expect("frame variable ssp", substrs=["ssp = nullptr"])
-
-        self.expect("frame variable nwp", substrs=["nwp = nullptr"])
-
-        # FIXME: these weak_ptr's should also be reset to nullptr.
-        self.expect("frame variable iwp", substrs=["iwp = ", "strong=0 
weak=1"])
-        self.expect("frame variable swp", substrs=["swp = ", "strong=0 
weak=1"])

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/main.cpp
deleted file mode 100644
index 6e4b869e1c8e0..0000000000000
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/main.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <memory>
-#include <string>
-
-struct Foo {
-  int mem = 5;
-};
-
-int
-main()
-{
-    std::shared_ptr<char> nsp;
-    std::shared_ptr<int> isp(new int{123});
-    std::shared_ptr<std::string> ssp = std::make_shared<std::string>("foobar");
-    std::shared_ptr<Foo> fsp = std::make_shared<Foo>();
-
-    std::weak_ptr<char> nwp;
-    std::weak_ptr<int> iwp = isp;
-    std::weak_ptr<std::string> swp = ssp;
-
-    nsp.reset(); // Set break point at this line.
-    isp.reset();
-    ssp.reset();
-    fsp.reset();
-
-    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

Reply via email to