summaryrefslogtreecommitdiffstats
path: root/packages/Python/lldbsuite/test/python_api/sbvalue_persist
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2016-01-06 20:12:03 +0000
committerdim <dim@FreeBSD.org>2016-01-06 20:12:03 +0000
commit78b9749c0a4ea980a8b934645da6ae98fcc665e8 (patch)
treedd2a1ddf0476664c2b823409c36cbccd52662ca7 /packages/Python/lldbsuite/test/python_api/sbvalue_persist
parent60cb593f9d55fa5ca7a5372b731f2330345b4b9a (diff)
downloadFreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.zip
FreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.tar.gz
Vendor import of lldb trunk r256945:
https://llvm.org/svn/llvm-project/lldb/trunk@256945
Diffstat (limited to 'packages/Python/lldbsuite/test/python_api/sbvalue_persist')
-rw-r--r--packages/Python/lldbsuite/test/python_api/sbvalue_persist/Makefile15
-rw-r--r--packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py74
-rw-r--r--packages/Python/lldbsuite/test/python_api/sbvalue_persist/main.cpp14
3 files changed, 103 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/python_api/sbvalue_persist/Makefile b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/Makefile
new file mode 100644
index 0000000..e5c7b91
--- /dev/null
+++ b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/Makefile
@@ -0,0 +1,15 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+# Clean renamed executable on 'make clean'
+clean: OBJECTS+=no_synth
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets. Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py
new file mode 100644
index 0000000..6edbbda
--- /dev/null
+++ b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py
@@ -0,0 +1,74 @@
+"""Test SBValue::Persist"""
+
+from __future__ import print_function
+
+
+
+import os, sys, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class SBValuePersistTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @add_test_categories(['pyapi'])
+ @expectedFailureWindows("llvm.org/pr24772")
+ def test(self):
+ """Test SBValue::Persist"""
+ self.build()
+ self.setTearDownCleanup()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_source_regexp (self, "break here")
+
+ 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 synthetic clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ foo = self.frame().FindVariable("foo")
+ bar = self.frame().FindVariable("bar")
+ baz = self.frame().FindVariable("baz")
+
+ self.assertTrue(foo.IsValid(), "foo is not valid")
+ self.assertTrue(bar.IsValid(), "bar is not valid")
+ self.assertTrue(baz.IsValid(), "baz is not valid")
+
+ fooPersist = foo.Persist()
+ barPersist = bar.Persist()
+ bazPersist = baz.Persist()
+
+ self.assertTrue(fooPersist.IsValid(), "fooPersist is not valid")
+ self.assertTrue(barPersist.IsValid(), "barPersist is not valid")
+ self.assertTrue(bazPersist.IsValid(), "bazPersist is not valid")
+
+ self.assertTrue(fooPersist.GetValueAsUnsigned(0) == 10, "fooPersist != 10")
+ self.assertTrue(barPersist.GetPointeeData().sint32[0] == 4, "barPersist != 4")
+ self.assertTrue(bazPersist.GetSummary() == '"85"', "bazPersist != 85")
+
+ self.runCmd("continue")
+
+ self.assertTrue(fooPersist.IsValid(), "fooPersist is not valid")
+ self.assertTrue(barPersist.IsValid(), "barPersist is not valid")
+ self.assertTrue(bazPersist.IsValid(), "bazPersist is not valid")
+
+ self.assertTrue(fooPersist.GetValueAsUnsigned(0) == 10, "fooPersist != 10")
+ self.assertTrue(barPersist.GetPointeeData().sint32[0] == 4, "barPersist != 4")
+ self.assertTrue(bazPersist.GetSummary() == '"85"', "bazPersist != 85")
+
+ self.expect("expr *(%s)" % (barPersist.GetName()), substrs = ['= 4'])
diff --git a/packages/Python/lldbsuite/test/python_api/sbvalue_persist/main.cpp b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/main.cpp
new file mode 100644
index 0000000..650d87a
--- /dev/null
+++ b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/main.cpp
@@ -0,0 +1,14 @@
+#include <vector>
+#include <string>
+
+void f() {}
+
+int main() {
+ int foo = 10;
+ int *bar = new int(4);
+ std::string baz = "85";
+
+ f(); // break here
+ f(); // break here
+ return 0;
+} \ No newline at end of file
OpenPOWER on IntegriCloud