summaryrefslogtreecommitdiffstats
path: root/packages/Python/lldbsuite/test/lang/go/formatters
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/lang/go/formatters
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/lang/go/formatters')
-rw-r--r--packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py65
-rw-r--r--packages/Python/lldbsuite/test/lang/go/formatters/main.go9
2 files changed, 74 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py b/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py
new file mode 100644
index 0000000..8b869df
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py
@@ -0,0 +1,65 @@
+"""Test the Go Data Formatter Plugin."""
+
+import os, time
+import unittest2
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+class TestGoLanguage(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfFreeBSD # llvm.org/pr24895 triggers assertion failure
+ @skipIfRemote # Not remote test suite ready
+ @no_debug_info_test
+ @skipUnlessGoInstalled
+ def test_go_formatter_plugin(self):
+ """Test go data formatters."""
+ self.buildGo()
+ self.launchProcess()
+ self.check_formatters()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.main_source = "main.go"
+ self.break_line = line_number(self.main_source, '// stop here')
+
+ def launchProcess(self):
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ self.bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line)
+ self.assertTrue(self.bpt, VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple (None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, self.bpt)
+
+ # Make sure we stopped at the first breakpoint.
+ self.assertTrue (len(thread_list) != 0, "No thread stopped at our breakpoint.")
+ self.assertTrue (len(thread_list) == 1, "More than one thread stopped at our breakpoint.")
+
+ frame = thread_list[0].GetFrameAtIndex(0)
+ self.assertTrue (frame, "Got a valid frame 0 frame.")
+
+ def check_formatters(self):
+ a = self.frame().FindVariable('a')
+ self.assertEqual('(string) a = "my string"', str(a))
+ b = self.frame().FindVariable('b')
+ self.assertEqual("([]int) b = (len 2, cap 7) {\n [0] = 0\n [1] = 0\n}", str(b))
+
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
diff --git a/packages/Python/lldbsuite/test/lang/go/formatters/main.go b/packages/Python/lldbsuite/test/lang/go/formatters/main.go
new file mode 100644
index 0000000..7956ad6
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/go/formatters/main.go
@@ -0,0 +1,9 @@
+package main
+
+import "fmt"
+
+func main() {
+ a := "my string"
+ b := make([]int, 2, 7)
+ fmt.Println(a, b) // stop here
+} \ No newline at end of file
OpenPOWER on IntegriCloud