1# Test that LLDB correctly allows scripted commands to set immediate output to
2# a file.
3
4# RUN: echo "READ" > %t.read.txt
5# RUN: echo "WRITE" > %t.write.txt
6# RUN: echo "APPEND" > %t.append.txt
7# RUN: echo "READ PLUS" > %t.read_plus.txt
8# RUN: echo "WRITE PLUS" > %t.write_plus.txt
9# RUN: echo "APPEND PLUS" > %t.append_plus.txt
10
11# RUN: %lldb -s %s \
12# RUN:   -o 'command script import %S/Inputs/custom_command.py' \
13# RUN:   -o 'command script add -f custom_command.write_file mywrite' \
14# RUN:   -o 'mywrite %t.read.txt r' \
15# RUN:   -o 'mywrite %t.write.txt w' \
16# RUN:   -o 'mywrite %t.append.txt a' \
17# RUN:   -o 'mywrite %t.write_plus.txt w+' \
18# RUN:   -o 'mywrite %t.read_plus.txt r+' \
19# RUN:   -o 'mywrite %t.append_plus.txt a+' \
20# RUN:   -o 'command script delete mywrite'
21
22# RUN: cat %t.read.txt | FileCheck %s --check-prefix READ
23# READ: READ
24# READ-NOT: writing to file with mode
25
26# RUN: cat %t.write.txt | FileCheck %s --check-prefix WRITE
27# WRITE-NOT: WRITE
28# WRITE: writing to file with mode: w
29
30# RUN: cat %t.append.txt | FileCheck %s --check-prefix APPEND
31# APPEND: APPEND
32# APPEND-NEXT: writing to file with mode: a
33
34# RUN: cat %t.write_plus.txt | FileCheck %s --check-prefix WRITEPLUS
35# WRITEPLUS-NOT: WRITE PLUS
36# WRITEPLUS: writing to file with mode: w+
37
38# RUN: cat %t.read_plus.txt | FileCheck %s --check-prefix READPLUS
39# READPLUS-NOT: READ PLUS
40# READPLUS: writing to file with mode: r+
41
42# RUN: cat %t.append_plus.txt | FileCheck %s --check-prefix APPENDPLUS
43# APPENDPLUS: APPEND PLUS
44# APPENDPLUS-NEXT: writing to file with mode: a+
45
46# RUN: rm %t.read.txt
47# RUN: rm %t.write.txt
48# RUN: rm %t.append.txt
49# RUN: rm %t.write_plus.txt
50# RUN: rm %t.read_plus.txt
51# RUN: rm %t.append_plus.txt
52