blob: eef1731454d9ceb8707e72d50d29672d9968cc74 [file] [log] [blame]
Christian Brabandte1dc9a62023-09-02 14:40:13 +02001" Some tests, that used to crash Vim
2source check.vim
3source screendump.vim
4
5CheckScreendump
6
7func Test_crash1()
Christian Brabandtd2a08ba2023-09-05 07:45:04 +02008 CheckNotBSD
Philip H1690ec62023-09-06 20:20:07 +02009 CheckExecutable dash
Christian Brabandtda200c22023-09-06 21:12:24 +020010 " Test 7 fails on Mac ...
Christian Brabandt5856b072023-09-06 20:53:46 +020011 CheckNotMac
Christian Brabandtd2a08ba2023-09-05 07:45:04 +020012
Christian Brabandte1dc9a62023-09-02 14:40:13 +020013 " The following used to crash Vim
Christian Brabandtdb510ca2023-09-03 09:23:12 +020014 let opts = #{cmd: 'sh'}
Christian Brabandtdb510ca2023-09-03 09:23:12 +020015 let vim = GetVimProg()
16
Christian Brabandtfc682992023-09-03 20:20:52 +020017 let buf = RunVimInTerminal('sh', opts)
Christian Brabandtdb510ca2023-09-03 09:23:12 +020018
19 let file = 'crash/poc_huaf1'
20 let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
21 let args = printf(cmn_args, vim, file)
22 call term_sendkeys(buf, args ..
Christian Brabandtfc682992023-09-03 20:20:52 +020023 \ ' && echo "crash 1: [OK]" > X_crash1_result.txt' .. "\<cr>")
24 call TermWait(buf, 50)
Christian Brabandtdb510ca2023-09-03 09:23:12 +020025
26 let file = 'crash/poc_huaf2'
27 let args = printf(cmn_args, vim, file)
28 call term_sendkeys(buf, args ..
29 \ ' && echo "crash 2: [OK]" >> X_crash1_result.txt' .. "\<cr>")
Christian Brabandtfc682992023-09-03 20:20:52 +020030 call TermWait(buf, 50)
Christian Brabandtdb510ca2023-09-03 09:23:12 +020031
32 let file = 'crash/poc_huaf3'
33 let args = printf(cmn_args, vim, file)
34 call term_sendkeys(buf, args ..
35 \ ' && echo "crash 3: [OK]" >> X_crash1_result.txt' .. "\<cr>")
Christian Brabandtfc682992023-09-03 20:20:52 +020036 call TermWait(buf, 100)
Christian Brabandtdb510ca2023-09-03 09:23:12 +020037
Christian Brabandtfc682992023-09-03 20:20:52 +020038 let file = 'crash/bt_quickfix_poc'
39 let args = printf(cmn_args, vim, file)
40 call term_sendkeys(buf, args ..
41 \ ' && echo "crash 4: [OK]" >> X_crash1_result.txt' .. "\<cr>")
42 " clean up
43 call delete('Xerr')
Christian Brabandtfc682992023-09-03 20:20:52 +020044 " This test takes a bit longer
Christian Brabandt623ba312023-09-04 22:09:12 +020045 call TermWait(buf, 1000)
Christian Brabandtdb510ca2023-09-03 09:23:12 +020046
Christian Brabandtee9166e2023-09-03 21:24:33 +020047 let file = 'crash/poc_tagfunc.vim'
48 let args = printf(cmn_args, vim, file)
Christian Brabandtf6d28fe2023-09-05 20:18:06 +020049 " using || because this poc causes vim to exit with exitstatus != 0
Christian Brabandtee9166e2023-09-03 21:24:33 +020050 call term_sendkeys(buf, args ..
51 \ ' || echo "crash 5: [OK]" >> X_crash1_result.txt' .. "\<cr>")
52
53 call TermWait(buf, 100)
54
Christian Brabandt6e60cf42023-09-03 21:43:46 +020055 let file = 'crash/bt_quickfix1_poc'
56 let args = printf(cmn_args, vim, file)
57 call term_sendkeys(buf, args ..
58 \ ' && echo "crash 6: [OK]" >> X_crash1_result.txt' .. "\<cr>")
59 " clean up
60 call delete('X')
Christian Brabandt59adcb42023-09-04 22:42:55 +020061 call TermWait(buf, 3000)
Christian Brabandt6e60cf42023-09-03 21:43:46 +020062
Christian Brabandtf6d28fe2023-09-05 20:18:06 +020063 let file = 'crash/vim_regsub_both_poc'
64 let args = printf(cmn_args, vim, file)
Christian Brabandtf6d28fe2023-09-05 20:18:06 +020065 call term_sendkeys(buf, args ..
66 \ ' && echo "crash 7: [OK]" >> X_crash1_result.txt' .. "\<cr>")
Philip H1690ec62023-09-06 20:20:07 +020067 call TermWait(buf, 3000)
Christian Brabandtf6d28fe2023-09-05 20:18:06 +020068
Christian Brabandt3bd7fa12023-10-02 20:59:08 +020069 let file = 'crash/vim_msg_trunc_poc'
70 let args = printf(cmn_args, vim, file)
71 call term_sendkeys(buf, args ..
72 \ ' || echo "crash 8: [OK]" >> X_crash1_result.txt' .. "\<cr>")
73 call TermWait(buf, 3000)
74
Christian Brabandt20d161a2023-10-05 22:08:30 +020075 let file = 'crash/crash_scrollbar'
76 let args = printf(cmn_args, vim, file)
77 call term_sendkeys(buf, args ..
78 \ ' && echo "crash 9: [OK]" >> X_crash1_result.txt' .. "\<cr>")
79 call TermWait(buf, 1000)
80
Christian Brabandt41e6f7d2023-10-11 21:08:13 +020081 let file = 'crash/editing_arg_idx_POC_1'
82 let args = printf(cmn_args, vim, file)
83 call term_sendkeys(buf, args ..
84 \ ' || echo "crash 10: [OK]" >> X_crash1_result.txt' .. "\<cr>")
85 call TermWait(buf, 1000)
86 call delete('Xerr')
87 call delete('@')
88
Christian Brabandtdb510ca2023-09-03 09:23:12 +020089 " clean up
Christian Brabandte1dc9a62023-09-02 14:40:13 +020090 exe buf .. "bw!"
91
Christian Brabandtdb510ca2023-09-03 09:23:12 +020092 sp X_crash1_result.txt
Christian Brabandtfc682992023-09-03 20:20:52 +020093
94 let expected = [
95 \ 'crash 1: [OK]',
96 \ 'crash 2: [OK]',
97 \ 'crash 3: [OK]',
98 \ 'crash 4: [OK]',
Christian Brabandtee9166e2023-09-03 21:24:33 +020099 \ 'crash 5: [OK]',
Christian Brabandt6e60cf42023-09-03 21:43:46 +0200100 \ 'crash 6: [OK]',
Christian Brabandtf6d28fe2023-09-05 20:18:06 +0200101 \ 'crash 7: [OK]',
Christian Brabandt3bd7fa12023-10-02 20:59:08 +0200102 \ 'crash 8: [OK]',
Christian Brabandt20d161a2023-10-05 22:08:30 +0200103 \ 'crash 9: [OK]',
Christian Brabandt41e6f7d2023-10-11 21:08:13 +0200104 \ 'crash 10: [OK]',
Christian Brabandtfc682992023-09-03 20:20:52 +0200105 \ ]
106
107 call assert_equal(expected, getline(1, '$'))
Christian Brabandtdb510ca2023-09-03 09:23:12 +0200108 bw!
Christian Brabandte1dc9a62023-09-02 14:40:13 +0200109
Christian Brabandtdb510ca2023-09-03 09:23:12 +0200110 call delete('X_crash1_result.txt')
Christian Brabandte1dc9a62023-09-02 14:40:13 +0200111endfunc
112
Christian Brabandt25aabc22023-11-14 19:31:34 +0100113func Test_crash1_2()
114 CheckNotBSD
115 CheckExecutable dash
116
117 " The following used to crash Vim
118 let opts = #{cmd: 'sh'}
119 let vim = GetVimProg()
120 let result = 'X_crash1_1_result.txt'
121
122 let buf = RunVimInTerminal('sh', opts)
123
124 let file = 'crash/poc1'
125 let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
126 let args = printf(cmn_args, vim, file)
127 call term_sendkeys(buf, args ..
128 \ ' && echo "crash 1: [OK]" > '.. result .. "\<cr>")
129 call TermWait(buf, 150)
130
Christian Brabandteec0c2b2023-11-28 22:03:48 +0100131 let file = 'crash/poc_win_enter_ext'
132 let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
133 let args = printf(cmn_args, vim, file)
134 call term_sendkeys(buf, args ..
135 \ ' && echo "crash 2: [OK]" >> '.. result .. "\<cr>")
136 call TermWait(buf, 350)
137
Christian Brabandt0fb375a2023-11-29 10:23:39 +0100138 let file = 'crash/poc_suggest_trie_walk'
139 let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
140 let args = printf(cmn_args, vim, file)
141 call term_sendkeys(buf, args ..
142 \ ' && echo "crash 3: [OK]" >> '.. result .. "\<cr>")
143 call TermWait(buf, 150)
144
Christian Brabandt25aabc22023-11-14 19:31:34 +0100145 " clean up
146 exe buf .. "bw!"
147
148 exe "sp " .. result
149
150 let expected = [
151 \ 'crash 1: [OK]',
Christian Brabandteec0c2b2023-11-28 22:03:48 +0100152 \ 'crash 2: [OK]',
Christian Brabandt0fb375a2023-11-29 10:23:39 +0100153 \ 'crash 3: [OK]',
Christian Brabandt25aabc22023-11-14 19:31:34 +0100154 \ ]
155
156 call assert_equal(expected, getline(1, '$'))
157 bw!
158
159 call delete(result)
160endfunc
161
Christian Brabandtced2c732023-09-02 21:15:52 +0200162func Test_crash2()
163 " The following used to crash Vim
164 let opts = #{wait_for_ruler: 0, rows: 20}
165 let args = ' -u NONE -i NONE -n -e -s -S '
166 let buf = RunVimInTerminal(args .. ' crash/vim_regsub_both', opts)
167 call VerifyScreenDump(buf, 'Test_crash_01', {})
168 exe buf .. "bw!"
169endfunc
170
Christian Brabandte1dc9a62023-09-02 14:40:13 +0200171" vim: shiftwidth=2 sts=2 expandtab