summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-10-28 17:43:26 +0000
committerZachary Turner <zturner@google.com>2015-10-28 17:43:26 +0000
commitc432c8f856e0bd84de980a9d9bb2d31b06fa95b1 (patch)
tree4efa528e074a6e2df782345e4cd97f5d85d038c4 /lldb/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
parenta8a3bd210086b50242903ed95048fe5e53897878 (diff)
downloadbcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.tar.gz
bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.zip
Move lldb/test to lldb/packages/Python/lldbsuite/test.
This is the conclusion of an effort to get LLDB's Python code structured into a bona-fide Python package. This has a number of benefits, but most notably the ability to more easily share Python code between different but related pieces of LLDB's Python infrastructure (for example, `scripts` can now share code with `test`). llvm-svn: 251532
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
new file mode 100644
index 00000000000..8bbe552c6d5
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
@@ -0,0 +1,73 @@
+"""
+Test lldb-mi -symbol-xxx commands.
+"""
+
+from __future__ import print_function
+
+import use_lldb_suite
+
+import lldbmi_testcase
+from lldbtest import *
+
+class MiSymbolTestCase(lldbmi_testcase.MiTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ def test_lldbmi_symbol_list_lines_file(self):
+ """Test that 'lldb-mi --interpreter' works for -symbol-list-lines when file exists."""
+
+ self.spawnLldbMi(args = None)
+
+ # Load executable
+ self.runCmd("-file-exec-and-symbols %s" % self.myexe)
+ self.expect("\^done")
+
+ # Run to main
+ self.runCmd("-break-insert -f main")
+ self.expect("\^done,bkpt={number=\"1\"")
+ self.runCmd("-exec-run")
+ self.expect("\^running")
+ self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
+ # Get address of main and its line
+ self.runCmd("-data-evaluate-expression main")
+ self.expect("\^done,value=\"0x[0-9a-f]+ \(a.out`main at main.cpp:[0-9]+\)\"")
+ addr = int(self.child.after.split("\"")[1].split(" ")[0], 16)
+ line = line_number('main.cpp', '// FUNC_main')
+
+ # Test that -symbol-list-lines works on valid data
+ self.runCmd("-symbol-list-lines main.cpp")
+ self.expect("\^done,lines=\[\{pc=\"0x0*%x\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d+\"\})+\]" % (addr, line))
+
+ # Test that -symbol-list-lines doesn't include lines from other sources
+ # by checking the first and last line, and making sure the other lines
+ # are between 30 and 39.
+ sline = line_number('symbol_list_lines_inline_test2.cpp', '// FUNC_gfunc2')
+ eline = line_number('symbol_list_lines_inline_test2.cpp', '// END_gfunc2')
+ self.runCmd("-symbol-list-lines symbol_list_lines_inline_test2.cpp")
+ self.expect("\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*\]" % (sline, eline))
+ ##FIXME: This doesn't work for symbol_list_lines_inline_test.cpp due to clang bug llvm.org/pr24716
+ ##sline = line_number('symbol_list_lines_inline_test.cpp', '// FUNC_gfunc')
+ ##eline = line_number('symbol_list_lines_inline_test.cpp', '// STRUCT_s')
+ ##self.runCmd("-symbol-list-lines symbol_list_lines_inline_test.cpp")
+ ##self.expect("\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}\]" % (sline, eline))
+
+ # Test that -symbol-list-lines fails when file doesn't exist
+ self.runCmd("-symbol-list-lines unknown_file")
+ self.expect("\^error,message=\"warning: No source filenames matched 'unknown_file'\. error: no source filenames matched any command arguments \"")
+
+ # Test that -symbol-list-lines fails when file is specified using relative path
+ self.runCmd("-symbol-list-lines ./main.cpp")
+ self.expect("\^error,message=\"warning: No source filenames matched '\./main\.cpp'\. error: no source filenames matched any command arguments \"")
+
+ # Test that -symbol-list-lines works when file is specified using absolute path
+ import os
+ path = os.path.join(os.getcwd(), "main.cpp")
+ self.runCmd("-symbol-list-lines \"%s\"" % path)
+ self.expect("\^done,lines=\[\{pc=\"0x0*%x\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d+\"\})+\]" % (addr, line))
+
+ # Test that -symbol-list-lines fails when file doesn't exist
+ self.runCmd("-symbol-list-lines unknown_dir/main.cpp")
+ self.expect("\^error,message=\"warning: No source filenames matched 'unknown_dir/main\.cpp'\. error: no source filenames matched any command arguments \"")
OpenPOWER on IntegriCloud