1 """Test SBValue::Persist"""
5 from lldbsuite
.test
.decorators
import *
6 from lldbsuite
.test
.lldbtest
import *
7 from lldbsuite
.test
import lldbutil
10 class SBValuePersistTestCase(TestBase
):
11 NO_DEBUG_INFO_TESTCASE
= True
13 @expectedFailureAll(oslist
=["windows"], bugnumber
="llvm.org/pr24772")
15 """Test SBValue::Persist"""
17 self
.setTearDownCleanup()
18 self
.runCmd("file " + self
.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET
)
20 lldbutil
.run_break_set_by_source_regexp(self
, "break here")
22 self
.runCmd("run", RUN_SUCCEEDED
)
24 # The stop reason of the thread should be breakpoint.
27 STOPPED_DUE_TO_BREAKPOINT
,
28 substrs
=["stopped", "stop reason = breakpoint"],
31 # This is the function to remove the custom formats in order to have a
32 # clean slate for the next test case.
34 self
.runCmd("type format clear", check
=False)
35 self
.runCmd("type summary clear", check
=False)
36 self
.runCmd("type filter clear", check
=False)
37 self
.runCmd("type synthetic clear", check
=False)
39 # Execute the cleanup function during test case tear down.
40 self
.addTearDownHook(cleanup
)
42 foo
= self
.frame().FindVariable("foo")
43 bar
= self
.frame().FindVariable("bar")
44 baz
= self
.frame().FindVariable("baz")
46 self
.assertTrue(foo
.IsValid(), "foo is not valid")
47 self
.assertTrue(bar
.IsValid(), "bar is not valid")
48 self
.assertTrue(baz
.IsValid(), "baz is not valid")
50 fooPersist
= foo
.Persist()
51 barPersist
= bar
.Persist()
52 bazPersist
= baz
.Persist()
54 self
.assertTrue(fooPersist
.IsValid(), "fooPersist is not valid")
55 self
.assertTrue(barPersist
.IsValid(), "barPersist is not valid")
56 self
.assertTrue(bazPersist
.IsValid(), "bazPersist is not valid")
58 self
.assertEqual(fooPersist
.GetValueAsUnsigned(0), 10, "fooPersist != 10")
59 self
.assertEqual(barPersist
.GetPointeeData().sint32
[0], 4, "barPersist != 4")
60 self
.assertEquals(bazPersist
.GetSummary(), '"85"', "bazPersist != 85")
62 self
.runCmd("continue")
64 self
.assertTrue(fooPersist
.IsValid(), "fooPersist is not valid")
65 self
.assertTrue(barPersist
.IsValid(), "barPersist is not valid")
66 self
.assertTrue(bazPersist
.IsValid(), "bazPersist is not valid")
68 self
.assertEqual(fooPersist
.GetValueAsUnsigned(0), 10, "fooPersist != 10")
69 self
.assertEqual(barPersist
.GetPointeeData().sint32
[0], 4, "barPersist != 4")
70 self
.assertEquals(bazPersist
.GetSummary(), '"85"', "bazPersist != 85")
72 self
.expect("expr *(%s)" % (barPersist
.GetName()), substrs
=["= 4"])