Christian Brabandt | e1dc9a6 | 2023-09-02 14:40:13 +0200 | [diff] [blame] | 1 | " Some tests, that used to crash Vim |
| 2 | source check.vim |
| 3 | source screendump.vim |
| 4 | |
| 5 | CheckScreendump |
| 6 | |
| 7 | func Test_crash1() |
| 8 | " The following used to crash Vim |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 9 | " 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 Brabandt | e1dc9a6 | 2023-09-02 14:40:13 +0200 | [diff] [blame] | 35 | exe buf .. "bw!" |
| 36 | |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 37 | sp X_crash1_result.txt |
| 38 | call assert_equal(['crash 1: [OK]', 'crash 2: [OK]', 'crash 3: [OK]'], |
| 39 | \ getline(1, '$')) |
| 40 | bw! |
Christian Brabandt | e1dc9a6 | 2023-09-02 14:40:13 +0200 | [diff] [blame] | 41 | |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 42 | call delete('X_crash1_result.txt') |
Christian Brabandt | e1dc9a6 | 2023-09-02 14:40:13 +0200 | [diff] [blame] | 43 | endfunc |
| 44 | |
Christian Brabandt | ced2c73 | 2023-09-02 21:15:52 +0200 | [diff] [blame] | 45 | func 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!" |
| 52 | endfunc |
| 53 | |
Christian Brabandt | e1dc9a6 | 2023-09-02 14:40:13 +0200 | [diff] [blame] | 54 | " vim: shiftwidth=2 sts=2 expandtab |