blob: eb3c0a37fbc6bf1ca521b421d1d34a90309cadbd [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()
8 " The following used to crash Vim
Christian Brabandtdb510ca2023-09-03 09:23:12 +02009 " let opts = #{wait_for_ruler: 0, rows: 20, cmd: 'sh'}
10 let opts = #{cmd: 'sh'}
11 let args = 'bash'
12 let vim = GetVimProg()
13
14 let buf = RunVimInTerminal(args, opts)
15
16 let file = 'crash/poc_huaf1'
17 let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
18 let args = printf(cmn_args, vim, file)
19 call term_sendkeys(buf, args ..
20 \ ' && echo "crash 1: [OK]" >> X_crash1_result.txt' .. "\<cr>")
21
22 let file = 'crash/poc_huaf2'
23 let args = printf(cmn_args, vim, file)
24 call term_sendkeys(buf, args ..
25 \ ' && echo "crash 2: [OK]" >> X_crash1_result.txt' .. "\<cr>")
26
27 let file = 'crash/poc_huaf3'
28 let args = printf(cmn_args, vim, file)
29 call term_sendkeys(buf, args ..
30 \ ' && echo "crash 3: [OK]" >> X_crash1_result.txt' .. "\<cr>")
31
32 call TermWait(buf, 50)
33
34 " clean up
Christian Brabandte1dc9a62023-09-02 14:40:13 +020035 exe buf .. "bw!"
36
Christian Brabandtdb510ca2023-09-03 09:23:12 +020037 sp X_crash1_result.txt
38 call assert_equal(['crash 1: [OK]', 'crash 2: [OK]', 'crash 3: [OK]'],
39 \ getline(1, '$'))
40 bw!
Christian Brabandte1dc9a62023-09-02 14:40:13 +020041
Christian Brabandtdb510ca2023-09-03 09:23:12 +020042 call delete('X_crash1_result.txt')
Christian Brabandte1dc9a62023-09-02 14:40:13 +020043endfunc
44
Christian Brabandtced2c732023-09-02 21:15:52 +020045func Test_crash2()
46 " The following used to crash Vim
47 let opts = #{wait_for_ruler: 0, rows: 20}
48 let args = ' -u NONE -i NONE -n -e -s -S '
49 let buf = RunVimInTerminal(args .. ' crash/vim_regsub_both', opts)
50 call VerifyScreenDump(buf, 'Test_crash_01', {})
51 exe buf .. "bw!"
52endfunc
53
Christian Brabandte1dc9a62023-09-02 14:40:13 +020054" vim: shiftwidth=2 sts=2 expandtab