blob: 8c79d3abd6a1721ce439e801889bd304a64baca7 [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 Brabandtfc682992023-09-03 20:20:52 +02008 if !executable('sh')
9 throw 'Skipped: sh not executable!'
10 endif
Christian Brabandte1dc9a62023-09-02 14:40:13 +020011 " The following used to crash Vim
Christian Brabandtdb510ca2023-09-03 09:23:12 +020012 let opts = #{cmd: 'sh'}
Christian Brabandtdb510ca2023-09-03 09:23:12 +020013 let vim = GetVimProg()
14
Christian Brabandtfc682992023-09-03 20:20:52 +020015 let buf = RunVimInTerminal('sh', opts)
Christian Brabandtdb510ca2023-09-03 09:23:12 +020016
17 let file = 'crash/poc_huaf1'
18 let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
19 let args = printf(cmn_args, vim, file)
20 call term_sendkeys(buf, args ..
Christian Brabandtfc682992023-09-03 20:20:52 +020021 \ ' && echo "crash 1: [OK]" > X_crash1_result.txt' .. "\<cr>")
22 call TermWait(buf, 50)
Christian Brabandtdb510ca2023-09-03 09:23:12 +020023
24 let file = 'crash/poc_huaf2'
25 let args = printf(cmn_args, vim, file)
26 call term_sendkeys(buf, args ..
27 \ ' && echo "crash 2: [OK]" >> X_crash1_result.txt' .. "\<cr>")
Christian Brabandtfc682992023-09-03 20:20:52 +020028 call TermWait(buf, 50)
Christian Brabandtdb510ca2023-09-03 09:23:12 +020029
30 let file = 'crash/poc_huaf3'
31 let args = printf(cmn_args, vim, file)
32 call term_sendkeys(buf, args ..
33 \ ' && echo "crash 3: [OK]" >> X_crash1_result.txt' .. "\<cr>")
Christian Brabandtfc682992023-09-03 20:20:52 +020034 call TermWait(buf, 100)
Christian Brabandtdb510ca2023-09-03 09:23:12 +020035
Christian Brabandtfc682992023-09-03 20:20:52 +020036 let file = 'crash/bt_quickfix_poc'
37 let args = printf(cmn_args, vim, file)
38 call term_sendkeys(buf, args ..
39 \ ' && echo "crash 4: [OK]" >> X_crash1_result.txt' .. "\<cr>")
40 " clean up
41 call delete('Xerr')
Christian Brabandtfc682992023-09-03 20:20:52 +020042 " This test takes a bit longer
Christian Brabandt623ba312023-09-04 22:09:12 +020043 call TermWait(buf, 1000)
Christian Brabandtdb510ca2023-09-03 09:23:12 +020044
Christian Brabandtee9166e2023-09-03 21:24:33 +020045 let file = 'crash/poc_tagfunc.vim'
46 let args = printf(cmn_args, vim, file)
47 call term_sendkeys(buf, args ..
48 \ ' || echo "crash 5: [OK]" >> X_crash1_result.txt' .. "\<cr>")
49
50 call TermWait(buf, 100)
51
Christian Brabandt6e60cf42023-09-03 21:43:46 +020052 let file = 'crash/bt_quickfix1_poc'
53 let args = printf(cmn_args, vim, file)
54 call term_sendkeys(buf, args ..
55 \ ' && echo "crash 6: [OK]" >> X_crash1_result.txt' .. "\<cr>")
56 " clean up
57 call delete('X')
Christian Brabandt623ba312023-09-04 22:09:12 +020058 call TermWait(buf, 1000)
Christian Brabandt6e60cf42023-09-03 21:43:46 +020059
Christian Brabandtdb510ca2023-09-03 09:23:12 +020060 " clean up
Christian Brabandte1dc9a62023-09-02 14:40:13 +020061 exe buf .. "bw!"
62
Christian Brabandtdb510ca2023-09-03 09:23:12 +020063 sp X_crash1_result.txt
Christian Brabandtfc682992023-09-03 20:20:52 +020064
65 let expected = [
66 \ 'crash 1: [OK]',
67 \ 'crash 2: [OK]',
68 \ 'crash 3: [OK]',
69 \ 'crash 4: [OK]',
Christian Brabandtee9166e2023-09-03 21:24:33 +020070 \ 'crash 5: [OK]',
Christian Brabandt6e60cf42023-09-03 21:43:46 +020071 \ 'crash 6: [OK]',
Christian Brabandtfc682992023-09-03 20:20:52 +020072 \ ]
73
74 call assert_equal(expected, getline(1, '$'))
Christian Brabandtdb510ca2023-09-03 09:23:12 +020075 bw!
Christian Brabandte1dc9a62023-09-02 14:40:13 +020076
Christian Brabandtdb510ca2023-09-03 09:23:12 +020077 call delete('X_crash1_result.txt')
Christian Brabandte1dc9a62023-09-02 14:40:13 +020078endfunc
79
Christian Brabandtced2c732023-09-02 21:15:52 +020080func Test_crash2()
81 " The following used to crash Vim
82 let opts = #{wait_for_ruler: 0, rows: 20}
83 let args = ' -u NONE -i NONE -n -e -s -S '
84 let buf = RunVimInTerminal(args .. ' crash/vim_regsub_both', opts)
85 call VerifyScreenDump(buf, 'Test_crash_01', {})
86 exe buf .. "bw!"
87endfunc
88
Christian Brabandte1dc9a62023-09-02 14:40:13 +020089" vim: shiftwidth=2 sts=2 expandtab