blob: 5cd07e2a3f0b53a0ec5b766a6f86b1f29fab18e7 [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 Brabandtced2c732023-09-02 21:15:52 +0200113func Test_crash2()
114 " The following used to crash Vim
115 let opts = #{wait_for_ruler: 0, rows: 20}
116 let args = ' -u NONE -i NONE -n -e -s -S '
117 let buf = RunVimInTerminal(args .. ' crash/vim_regsub_both', opts)
118 call VerifyScreenDump(buf, 'Test_crash_01', {})
119 exe buf .. "bw!"
120endfunc
121
Christian Brabandte1dc9a62023-09-02 14:40:13 +0200122" vim: shiftwidth=2 sts=2 expandtab