summaryrefslogtreecommitdiffstats
path: root/lldb/test/Shell/Commands
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-10-09 19:22:02 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-10-09 19:22:02 +0000
commit87aa9c9e4d41ed881453e2fab85b3d25f648bb55 (patch)
tree63efe79832bf3de4f63e4e81c62e73923947b882 /lldb/test/Shell/Commands
parentfd18e94697c987d5f24e25aa4e27adaffff3cce4 (diff)
downloadbcm5719-llvm-87aa9c9e4d41ed881453e2fab85b3d25f648bb55.tar.gz
bcm5719-llvm-87aa9c9e4d41ed881453e2fab85b3d25f648bb55.zip
Re-land "[test] Split LLDB tests into API, Shell & Unit"
The original patch got reverted because it broke `check-lldb` on a clean build. This fixes that. llvm-svn: 374201
Diffstat (limited to 'lldb/test/Shell/Commands')
-rw-r--r--lldb/test/Shell/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputConsole.test11
-rw-r--r--lldb/test/Shell/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputFile.test51
-rw-r--r--lldb/test/Shell/Commands/CommandScriptImmediateOutput/Inputs/custom_command.py22
-rw-r--r--lldb/test/Shell/Commands/CommandScriptImmediateOutput/lit.local.cfg2
-rw-r--r--lldb/test/Shell/Commands/Inputs/frame.py2
-rw-r--r--lldb/test/Shell/Commands/Inputs/main.c2
-rw-r--r--lldb/test/Shell/Commands/command-backtrace.test12
-rw-r--r--lldb/test/Shell/Commands/command-regex-delete.test14
-rw-r--r--lldb/test/Shell/Commands/command-regex-unalias.test11
-rw-r--r--lldb/test/Shell/Commands/command-script-import.test13
-rw-r--r--lldb/test/Shell/Commands/command-source.test12
11 files changed, 152 insertions, 0 deletions
diff --git a/lldb/test/Shell/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputConsole.test b/lldb/test/Shell/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputConsole.test
new file mode 100644
index 00000000000..c928a44afb7
--- /dev/null
+++ b/lldb/test/Shell/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputConsole.test
@@ -0,0 +1,11 @@
+# Test that LLDB correctly allows scripted commands to set immediate output to
+# the console.
+
+# RUN: %lldb -s %s \
+# RUN: -o 'command script import %S/Inputs/custom_command.py' \
+# RUN: -o 'command script add -f custom_command.command_function mycommand' \
+# RUN: -o 'mycommand' \
+# RUN: -o 'command script delete mycommand' \
+# RUN: 2>&1 | FileCheck %s
+
+# CHECK: this is a test string, just a test string
diff --git a/lldb/test/Shell/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputFile.test b/lldb/test/Shell/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputFile.test
new file mode 100644
index 00000000000..a653b74200d
--- /dev/null
+++ b/lldb/test/Shell/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputFile.test
@@ -0,0 +1,51 @@
+# Test that LLDB correctly allows scripted commands to set immediate output to
+# a file.
+
+# RUN: echo "READ" > %t.read.txt
+# RUN: echo "WRITE" > %t.write.txt
+# RUN: echo "APPEND" > %t.append.txt
+# RUN: echo "READ PLUS" > %t.read_plus.txt
+# RUN: echo "WRITE PLUS" > %t.write_plus.txt
+# RUN: echo "APPEND PLUS" > %t.append_plus.txt
+
+# RUN: %lldb -s %s \
+# RUN: -o 'command script import %S/Inputs/custom_command.py' \
+# RUN: -o 'command script add -f custom_command.write_file mywrite' \
+# RUN: -o 'mywrite %t.read.txt r' \
+# RUN: -o 'mywrite %t.write.txt w' \
+# RUN: -o 'mywrite %t.append.txt a' \
+# RUN: -o 'mywrite %t.write_plus.txt w+' \
+# RUN: -o 'mywrite %t.read_plus.txt r+' \
+# RUN: -o 'mywrite %t.append_plus.txt a+' \
+# RUN: -o 'command script delete mywrite'
+
+# RUN: cat %t.read.txt | FileCheck %s --check-prefix READ
+# READ: READ
+# READ-NOT: writing to file with mode
+
+# RUN: cat %t.write.txt | FileCheck %s --check-prefix WRITE
+# WRITE-NOT: WRITE
+# WRITE: writing to file with mode: w
+
+# RUN: cat %t.append.txt | FileCheck %s --check-prefix APPEND
+# APPEND: APPEND
+# APPEND-NEXT: writing to file with mode: a
+
+# RUN: cat %t.write_plus.txt | FileCheck %s --check-prefix WRITEPLUS
+# WRITEPLUS-NOT: WRITE PLUS
+# WRITEPLUS: writing to file with mode: w+
+
+# RUN: cat %t.read_plus.txt | FileCheck %s --check-prefix READPLUS
+# READPLUS-NOT: READ PLUS
+# READPLUS: writing to file with mode: r+
+
+# RUN: cat %t.append_plus.txt | FileCheck %s --check-prefix APPENDPLUS
+# APPENDPLUS: APPEND PLUS
+# APPENDPLUS-NEXT: writing to file with mode: a+
+
+# RUN: rm %t.read.txt
+# RUN: rm %t.write.txt
+# RUN: rm %t.append.txt
+# RUN: rm %t.write_plus.txt
+# RUN: rm %t.read_plus.txt
+# RUN: rm %t.append_plus.txt
diff --git a/lldb/test/Shell/Commands/CommandScriptImmediateOutput/Inputs/custom_command.py b/lldb/test/Shell/Commands/CommandScriptImmediateOutput/Inputs/custom_command.py
new file mode 100644
index 00000000000..14add9943dc
--- /dev/null
+++ b/lldb/test/Shell/Commands/CommandScriptImmediateOutput/Inputs/custom_command.py
@@ -0,0 +1,22 @@
+from __future__ import print_function
+
+import sys
+
+
+def split(command):
+ command = command.strip()
+ return command.rsplit(' ', 1)
+
+def command_function(debugger, command, exe_ctx, result, internal_dict):
+ result.SetImmediateOutputFile(sys.__stdout__)
+ print('this is a test string, just a test string', file=result)
+
+
+def write_file(debugger, command, exe_ctx, result, internal_dict):
+ args = split(command)
+ path = args[0]
+ mode = args[1]
+ with open(path, mode) as f:
+ result.SetImmediateOutputFile(f)
+ if not mode in ['r']:
+ print('writing to file with mode: ' + mode, file=result)
diff --git a/lldb/test/Shell/Commands/CommandScriptImmediateOutput/lit.local.cfg b/lldb/test/Shell/Commands/CommandScriptImmediateOutput/lit.local.cfg
new file mode 100644
index 00000000000..d880a5f420b
--- /dev/null
+++ b/lldb/test/Shell/Commands/CommandScriptImmediateOutput/lit.local.cfg
@@ -0,0 +1,2 @@
+if not "python" in config.available_features:
+ config.unsupported = True
diff --git a/lldb/test/Shell/Commands/Inputs/frame.py b/lldb/test/Shell/Commands/Inputs/frame.py
new file mode 100644
index 00000000000..40591742839
--- /dev/null
+++ b/lldb/test/Shell/Commands/Inputs/frame.py
@@ -0,0 +1,2 @@
+import lldb
+print("frame.py: {}".format(lldb.frame))
diff --git a/lldb/test/Shell/Commands/Inputs/main.c b/lldb/test/Shell/Commands/Inputs/main.c
new file mode 100644
index 00000000000..c029ddd96cd
--- /dev/null
+++ b/lldb/test/Shell/Commands/Inputs/main.c
@@ -0,0 +1,2 @@
+int foo() { return 0; }
+int main() { return foo(); }
diff --git a/lldb/test/Shell/Commands/command-backtrace.test b/lldb/test/Shell/Commands/command-backtrace.test
new file mode 100644
index 00000000000..2816f5f2e33
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-backtrace.test
@@ -0,0 +1,12 @@
+# Check basic functionality of command bt.
+# RUN: %lldb -s %s 2>&1 | FileCheck %s
+
+# Make sure this is not rejected by the parser as invalid syntax.
+# Blank characters after the '1' are important, as we're testing the parser.
+bt 1
+# CHECK: error: invalid target
+
+# Make sure this is not rejected by the parser as invalid syntax.
+# Blank characters after the 'all' are important, as we're testing the parser.
+bt all
+# CHECK: error: invalid target
diff --git a/lldb/test/Shell/Commands/command-regex-delete.test b/lldb/test/Shell/Commands/command-regex-delete.test
new file mode 100644
index 00000000000..ddc6259a9c9
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-regex-delete.test
@@ -0,0 +1,14 @@
+# Check basic functionality of command regex.
+# RUN: %lldb -s %s 2>&1 | FileCheck %s
+
+command regex 'Help__'
+# CHECK: Enter one or more sed substitution commands in the form
+# We need to leave a new line after to end the regex.
+s/^$/help/
+
+Help__
+# CHECK: Debugger commands:
+
+command delete Help__
+Help__
+# CHECK: error: 'Help__' is not a valid command
diff --git a/lldb/test/Shell/Commands/command-regex-unalias.test b/lldb/test/Shell/Commands/command-regex-unalias.test
new file mode 100644
index 00000000000..94f1a14ae00
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-regex-unalias.test
@@ -0,0 +1,11 @@
+# Check that commands created with command regex cannot be unaliased
+# RUN: %lldb -s %s 2>&1 | FileCheck %s
+
+command regex 'Help__'
+# CHECK: Enter one or more sed substitution commands in the form
+# We need to leave a new line after to end the regex.
+s/^$/help/
+
+command unalias Help__
+Help__
+# CHECK: error: 'Help__' is not an alias
diff --git a/lldb/test/Shell/Commands/command-script-import.test b/lldb/test/Shell/Commands/command-script-import.test
new file mode 100644
index 00000000000..18a043b4940
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-script-import.test
@@ -0,0 +1,13 @@
+# REQUIRES: python
+# RUN: echo 'b main' > %t.in
+# RUN: echo 'run' >> %t.in
+# RUN: echo 'command script import %S/Inputs/frame.py' >> %t.in
+
+# RUN: %clang -g -O0 %S/Inputs/main.c -o %t.out
+# RUN: %lldb -b -s %t.in -o 'script print("script: {}".format(lldb.frame))' %t.out | FileCheck %s
+
+# Make sure that we don't have access to lldb.frame from the Python script.
+# CHECK: frame.py: None
+
+# Make sure that we do have access to lldb.frame from the script command.
+# CHECK: script: frame #0
diff --git a/lldb/test/Shell/Commands/command-source.test b/lldb/test/Shell/Commands/command-source.test
new file mode 100644
index 00000000000..d8218850c32
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-source.test
@@ -0,0 +1,12 @@
+# Check that stop command source on error.
+
+# RUN: %lldb -x -b -o "command source -e 1 %s" 2>&1 | FileCheck %s --check-prefix STOP
+# RUN: %lldb -x -b -o "command source -e 0 %s" 2>&1 | FileCheck %s --check-prefix CONTINUE
+# RUN: %lldb -x -b -o 'settings set interpreter.stop-command-source-on-error true' -o "command source %s" 2>&1 | FileCheck %s --check-prefix STOP
+# RUN: %lldb -x -b -o 'settings set interpreter.stop-command-source-on-error false' -o "command source %s" 2>&1 | FileCheck %s --check-prefix CONTINUE
+
+bogus
+p 10+1
+
+# CONTINUE: $0 = 11
+# STOP-NOT: $0 = 11
OpenPOWER on IntegriCloud