blob: 516d991939620d76c7a7b0ad5bcedbccfca17cb6 [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')
42
43 " This test takes a bit longer
44 call TermWait(buf, 200)
Christian Brabandtdb510ca2023-09-03 09:23:12 +020045
46 " clean up
Christian Brabandtfc682992023-09-03 20:20:52 +020047 call delete('Xerr')
Christian Brabandte1dc9a62023-09-02 14:40:13 +020048 exe buf .. "bw!"
49
Christian Brabandtdb510ca2023-09-03 09:23:12 +020050 sp X_crash1_result.txt
Christian Brabandtfc682992023-09-03 20:20:52 +020051
52 let expected = [
53 \ 'crash 1: [OK]',
54 \ 'crash 2: [OK]',
55 \ 'crash 3: [OK]',
56 \ 'crash 4: [OK]',
57 \ ]
58
59 call assert_equal(expected, getline(1, '$'))
Christian Brabandtdb510ca2023-09-03 09:23:12 +020060 bw!
Christian Brabandte1dc9a62023-09-02 14:40:13 +020061
Christian Brabandtdb510ca2023-09-03 09:23:12 +020062 call delete('X_crash1_result.txt')
Christian Brabandte1dc9a62023-09-02 14:40:13 +020063endfunc
64
Christian Brabandtced2c732023-09-02 21:15:52 +020065func Test_crash2()
66 " The following used to crash Vim
67 let opts = #{wait_for_ruler: 0, rows: 20}
68 let args = ' -u NONE -i NONE -n -e -s -S '
69 let buf = RunVimInTerminal(args .. ' crash/vim_regsub_both', opts)
70 call VerifyScreenDump(buf, 'Test_crash_01', {})
71 exe buf .. "bw!"
72endfunc
73
Christian Brabandte1dc9a62023-09-02 14:40:13 +020074" vim: shiftwidth=2 sts=2 expandtab