blob: b6ae4d215301e924d31e351d149a2a110e5059e6 [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 Brabandtd2a08ba2023-09-05 07:45:04 +02008 CheckNotBSD
Philip H1690ec62023-09-06 20:20:07 +02009 CheckExecutable dash
Christian Brabandtd2a08ba2023-09-05 07:45:04 +020010
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
Christian Brabandt623ba312023-09-04 22:09:12 +020043 call TermWait(buf, 1000)
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)
Christian Brabandtf6d28fe2023-09-05 20:18:06 +020047 " using || because this poc causes vim to exit with exitstatus != 0
Christian Brabandtee9166e2023-09-03 21:24:33 +020048 call term_sendkeys(buf, args ..
49 \ ' || echo "crash 5: [OK]" >> X_crash1_result.txt' .. "\<cr>")
50
51 call TermWait(buf, 100)
52
Christian Brabandt6e60cf42023-09-03 21:43:46 +020053 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 Brabandt59adcb42023-09-04 22:42:55 +020059 call TermWait(buf, 3000)
Christian Brabandt6e60cf42023-09-03 21:43:46 +020060
Christian Brabandtf6d28fe2023-09-05 20:18:06 +020061 let file = 'crash/vim_regsub_both_poc'
62 let args = printf(cmn_args, vim, file)
Christian Brabandtf6d28fe2023-09-05 20:18:06 +020063 call term_sendkeys(buf, args ..
64 \ ' && echo "crash 7: [OK]" >> X_crash1_result.txt' .. "\<cr>")
Philip H1690ec62023-09-06 20:20:07 +020065 call TermWait(buf, 3000)
Christian Brabandtf6d28fe2023-09-05 20:18:06 +020066
Christian Brabandtdb510ca2023-09-03 09:23:12 +020067 " clean up
Christian Brabandte1dc9a62023-09-02 14:40:13 +020068 exe buf .. "bw!"
69
Christian Brabandtdb510ca2023-09-03 09:23:12 +020070 sp X_crash1_result.txt
Christian Brabandtfc682992023-09-03 20:20:52 +020071
72 let expected = [
73 \ 'crash 1: [OK]',
74 \ 'crash 2: [OK]',
75 \ 'crash 3: [OK]',
76 \ 'crash 4: [OK]',
Christian Brabandtee9166e2023-09-03 21:24:33 +020077 \ 'crash 5: [OK]',
Christian Brabandt6e60cf42023-09-03 21:43:46 +020078 \ 'crash 6: [OK]',
Christian Brabandtf6d28fe2023-09-05 20:18:06 +020079 \ 'crash 7: [OK]',
Christian Brabandtfc682992023-09-03 20:20:52 +020080 \ ]
81
82 call assert_equal(expected, getline(1, '$'))
Christian Brabandtdb510ca2023-09-03 09:23:12 +020083 bw!
Christian Brabandte1dc9a62023-09-02 14:40:13 +020084
Christian Brabandtdb510ca2023-09-03 09:23:12 +020085 call delete('X_crash1_result.txt')
Christian Brabandte1dc9a62023-09-02 14:40:13 +020086endfunc
87
Christian Brabandtced2c732023-09-02 21:15:52 +020088func 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!"
95endfunc
96
Christian Brabandte1dc9a62023-09-02 14:40:13 +020097" vim: shiftwidth=2 sts=2 expandtab