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() |
Christian Brabandt | d2a08ba | 2023-09-05 07:45:04 +0200 | [diff] [blame] | 8 | CheckNotBSD |
Philip H | 1690ec6 | 2023-09-06 20:20:07 +0200 | [diff] [blame] | 9 | CheckExecutable dash |
Christian Brabandt | d2a08ba | 2023-09-05 07:45:04 +0200 | [diff] [blame] | 10 | |
Christian Brabandt | e1dc9a6 | 2023-09-02 14:40:13 +0200 | [diff] [blame] | 11 | " The following used to crash Vim |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 12 | let opts = #{cmd: 'sh'} |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 13 | let vim = GetVimProg() |
| 14 | |
Christian Brabandt | fc68299 | 2023-09-03 20:20:52 +0200 | [diff] [blame] | 15 | let buf = RunVimInTerminal('sh', opts) |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 16 | |
| 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 Brabandt | fc68299 | 2023-09-03 20:20:52 +0200 | [diff] [blame] | 21 | \ ' && echo "crash 1: [OK]" > X_crash1_result.txt' .. "\<cr>") |
| 22 | call TermWait(buf, 50) |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 23 | |
| 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 Brabandt | fc68299 | 2023-09-03 20:20:52 +0200 | [diff] [blame] | 28 | call TermWait(buf, 50) |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 29 | |
| 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 Brabandt | fc68299 | 2023-09-03 20:20:52 +0200 | [diff] [blame] | 34 | call TermWait(buf, 100) |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 35 | |
Christian Brabandt | fc68299 | 2023-09-03 20:20:52 +0200 | [diff] [blame] | 36 | 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 Brabandt | fc68299 | 2023-09-03 20:20:52 +0200 | [diff] [blame] | 42 | " This test takes a bit longer |
Christian Brabandt | 623ba31 | 2023-09-04 22:09:12 +0200 | [diff] [blame] | 43 | call TermWait(buf, 1000) |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 44 | |
Christian Brabandt | ee9166e | 2023-09-03 21:24:33 +0200 | [diff] [blame] | 45 | let file = 'crash/poc_tagfunc.vim' |
| 46 | let args = printf(cmn_args, vim, file) |
Christian Brabandt | f6d28fe | 2023-09-05 20:18:06 +0200 | [diff] [blame] | 47 | " using || because this poc causes vim to exit with exitstatus != 0 |
Christian Brabandt | ee9166e | 2023-09-03 21:24:33 +0200 | [diff] [blame] | 48 | call term_sendkeys(buf, args .. |
| 49 | \ ' || echo "crash 5: [OK]" >> X_crash1_result.txt' .. "\<cr>") |
| 50 | |
| 51 | call TermWait(buf, 100) |
| 52 | |
Christian Brabandt | 6e60cf4 | 2023-09-03 21:43:46 +0200 | [diff] [blame] | 53 | let file = 'crash/bt_quickfix1_poc' |
| 54 | let args = printf(cmn_args, vim, file) |
| 55 | call term_sendkeys(buf, args .. |
| 56 | \ ' && echo "crash 6: [OK]" >> X_crash1_result.txt' .. "\<cr>") |
| 57 | " clean up |
| 58 | call delete('X') |
Christian Brabandt | 59adcb4 | 2023-09-04 22:42:55 +0200 | [diff] [blame] | 59 | call TermWait(buf, 3000) |
Christian Brabandt | 6e60cf4 | 2023-09-03 21:43:46 +0200 | [diff] [blame] | 60 | |
Christian Brabandt | f6d28fe | 2023-09-05 20:18:06 +0200 | [diff] [blame] | 61 | let file = 'crash/vim_regsub_both_poc' |
| 62 | let args = printf(cmn_args, vim, file) |
Christian Brabandt | f6d28fe | 2023-09-05 20:18:06 +0200 | [diff] [blame] | 63 | call term_sendkeys(buf, args .. |
| 64 | \ ' && echo "crash 7: [OK]" >> X_crash1_result.txt' .. "\<cr>") |
Philip H | 1690ec6 | 2023-09-06 20:20:07 +0200 | [diff] [blame] | 65 | call TermWait(buf, 3000) |
Christian Brabandt | f6d28fe | 2023-09-05 20:18:06 +0200 | [diff] [blame] | 66 | |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 67 | " clean up |
Christian Brabandt | e1dc9a6 | 2023-09-02 14:40:13 +0200 | [diff] [blame] | 68 | exe buf .. "bw!" |
| 69 | |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 70 | sp X_crash1_result.txt |
Christian Brabandt | fc68299 | 2023-09-03 20:20:52 +0200 | [diff] [blame] | 71 | |
| 72 | let expected = [ |
| 73 | \ 'crash 1: [OK]', |
| 74 | \ 'crash 2: [OK]', |
| 75 | \ 'crash 3: [OK]', |
| 76 | \ 'crash 4: [OK]', |
Christian Brabandt | ee9166e | 2023-09-03 21:24:33 +0200 | [diff] [blame] | 77 | \ 'crash 5: [OK]', |
Christian Brabandt | 6e60cf4 | 2023-09-03 21:43:46 +0200 | [diff] [blame] | 78 | \ 'crash 6: [OK]', |
Christian Brabandt | f6d28fe | 2023-09-05 20:18:06 +0200 | [diff] [blame] | 79 | \ 'crash 7: [OK]', |
Christian Brabandt | fc68299 | 2023-09-03 20:20:52 +0200 | [diff] [blame] | 80 | \ ] |
| 81 | |
| 82 | call assert_equal(expected, getline(1, '$')) |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 83 | bw! |
Christian Brabandt | e1dc9a6 | 2023-09-02 14:40:13 +0200 | [diff] [blame] | 84 | |
Christian Brabandt | db510ca | 2023-09-03 09:23:12 +0200 | [diff] [blame] | 85 | call delete('X_crash1_result.txt') |
Christian Brabandt | e1dc9a6 | 2023-09-02 14:40:13 +0200 | [diff] [blame] | 86 | endfunc |
| 87 | |
Christian Brabandt | ced2c73 | 2023-09-02 21:15:52 +0200 | [diff] [blame] | 88 | func Test_crash2() |
| 89 | " The following used to crash Vim |
| 90 | let opts = #{wait_for_ruler: 0, rows: 20} |
| 91 | let args = ' -u NONE -i NONE -n -e -s -S ' |
| 92 | let buf = RunVimInTerminal(args .. ' crash/vim_regsub_both', opts) |
| 93 | call VerifyScreenDump(buf, 'Test_crash_01', {}) |
| 94 | exe buf .. "bw!" |
| 95 | endfunc |
| 96 | |
Christian Brabandt | e1dc9a6 | 2023-09-02 14:40:13 +0200 | [diff] [blame] | 97 | " vim: shiftwidth=2 sts=2 expandtab |