blob: 5c83e3a2f5ffe366e0d2199edf82a7517410786e [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 Brabandtdb510ca2023-09-03 09:23:12 +020075 " clean up
Christian Brabandte1dc9a62023-09-02 14:40:13 +020076 exe buf .. "bw!"
77
Christian Brabandtdb510ca2023-09-03 09:23:12 +020078 sp X_crash1_result.txt
Christian Brabandtfc682992023-09-03 20:20:52 +020079
80 let expected = [
81 \ 'crash 1: [OK]',
82 \ 'crash 2: [OK]',
83 \ 'crash 3: [OK]',
84 \ 'crash 4: [OK]',
Christian Brabandtee9166e2023-09-03 21:24:33 +020085 \ 'crash 5: [OK]',
Christian Brabandt6e60cf42023-09-03 21:43:46 +020086 \ 'crash 6: [OK]',
Christian Brabandtf6d28fe2023-09-05 20:18:06 +020087 \ 'crash 7: [OK]',
Christian Brabandt3bd7fa12023-10-02 20:59:08 +020088 \ 'crash 8: [OK]',
Christian Brabandtfc682992023-09-03 20:20:52 +020089 \ ]
90
91 call assert_equal(expected, getline(1, '$'))
Christian Brabandtdb510ca2023-09-03 09:23:12 +020092 bw!
Christian Brabandte1dc9a62023-09-02 14:40:13 +020093
Christian Brabandtdb510ca2023-09-03 09:23:12 +020094 call delete('X_crash1_result.txt')
Christian Brabandte1dc9a62023-09-02 14:40:13 +020095endfunc
96
Christian Brabandtced2c732023-09-02 21:15:52 +020097func Test_crash2()
98 " The following used to crash Vim
99 let opts = #{wait_for_ruler: 0, rows: 20}
100 let args = ' -u NONE -i NONE -n -e -s -S '
101 let buf = RunVimInTerminal(args .. ' crash/vim_regsub_both', opts)
102 call VerifyScreenDump(buf, 'Test_crash_01', {})
103 exe buf .. "bw!"
104endfunc
105
Christian Brabandte1dc9a62023-09-02 14:40:13 +0200106" vim: shiftwidth=2 sts=2 expandtab