diff options
author | Ryan Brown <ribrdb@google.com> | 2015-11-05 00:24:36 +0000 |
---|---|---|
committer | Ryan Brown <ribrdb@google.com> | 2015-11-05 00:24:36 +0000 |
commit | 2dd84882fcd412d99c4aa199891b08e0f13cdee9 (patch) | |
tree | 05cbfc4483ade1c18b548db470da1f0f2682b171 /lldb/packages/Python/lldbsuite/test | |
parent | 51148e9f942ed4dc959f0dc462c8259c57f1487e (diff) | |
download | bcm5719-llvm-2dd84882fcd412d99c4aa199891b08e0f13cdee9.tar.gz bcm5719-llvm-2dd84882fcd412d99c4aa199891b08e0f13cdee9.zip |
Add go data formatters.
Differential Revision: http://reviews.llvm.org/D13878
llvm-svn: 252109
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py | 66 | ||||
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lang/go/formatters/main.go | 9 |
2 files changed, 75 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py b/lldb/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py new file mode 100644 index 00000000000..d14d512506d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py @@ -0,0 +1,66 @@ +"""Test the Go Data Formatter Plugin.""" + +import os, time +import unittest2 +import lldb +import lldbutil +from lldbtest import * + +class TestGoLanguage(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @python_api_test + @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/lldb/packages/Python/lldbsuite/test/lang/go/formatters/main.go b/lldb/packages/Python/lldbsuite/test/lang/go/formatters/main.go new file mode 100644 index 00000000000..7956ad66bcb --- /dev/null +++ b/lldb/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 |