1""" 2Test basic std::weak_ptr functionality. 3""" 4 5from lldbsuite.test.decorators import * 6from lldbsuite.test.lldbtest import * 7from lldbsuite.test import lldbutil 8 9 10class TestSharedPtr(TestBase): 11 @add_test_categories(["libc++"]) 12 @skipIf(compiler=no_match("clang")) 13 def test(self): 14 self.build() 15 16 lldbutil.run_to_source_breakpoint( 17 self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp") 18 ) 19 20 self.runCmd("settings set target.import-std-module true") 21 22 self.expect_expr( 23 "w", 24 result_type="std::weak_ptr<int>", 25 result_summary="3 strong=1 weak=2", 26 result_children=[ValueCheck(name="__ptr_")], 27 ) 28 self.expect_expr("*w.lock()", result_type="element_type", result_value="3") 29 self.expect_expr("*w.lock() = 5", result_type="element_type", result_value="5") 30 self.expect_expr("*w.lock()", result_type="element_type", result_value="5") 31 self.expect_expr("w.use_count()", result_type="long", result_value="1") 32 self.expect("expr w.reset()") 33 self.expect_expr("w.use_count()", result_type="long", result_value="0") 34