blob: 8deb79702b88b7c84d1ca0aef9de8083d2453037 [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
43 call TermWait(buf, 200)
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')
58 " This test takes a bit longer
59 call TermWait(buf, 200)
60
Christian Brabandtdb510ca2023-09-03 09:23:12 +020061 " clean up
Christian Brabandte1dc9a62023-09-02 14:40:13 +020062 exe buf .. "bw!"
63
Christian Brabandtdb510ca2023-09-03 09:23:12 +020064 sp X_crash1_result.txt
Christian Brabandtfc682992023-09-03 20:20:52 +020065
66 let expected = [
67 \ 'crash 1: [OK]',
68 \ 'crash 2: [OK]',
69 \ 'crash 3: [OK]',
70 \ 'crash 4: [OK]',
Christian Brabandtee9166e2023-09-03 21:24:33 +020071 \ 'crash 5: [OK]',
Christian Brabandt6e60cf42023-09-03 21:43:46 +020072 \ 'crash 6: [OK]',
Christian Brabandtfc682992023-09-03 20:20:52 +020073 \ ]
74
75 call assert_equal(expected, getline(1, '$'))
Christian Brabandtdb510ca2023-09-03 09:23:12 +020076 bw!
Christian Brabandte1dc9a62023-09-02 14:40:13 +020077
Christian Brabandtdb510ca2023-09-03 09:23:12 +020078 call delete('X_crash1_result.txt')
Christian Brabandte1dc9a62023-09-02 14:40:13 +020079endfunc
80
Christian Brabandtced2c732023-09-02 21:15:52 +020081func Test_crash2()
82 " The following used to crash Vim
83 let opts = #{wait_for_ruler: 0, rows: 20}
84 let args = ' -u NONE -i NONE -n -e -s -S '
85 let buf = RunVimInTerminal(args .. ' crash/vim_regsub_both', opts)
86 call VerifyScreenDump(buf, 'Test_crash_01', {})
87 exe buf .. "bw!"
88endfunc
89
Christian Brabandte1dc9a62023-09-02 14:40:13 +020090" vim: shiftwidth=2 sts=2 expandtab