Mercurial > vim
comparison src/testdir/test_channel.vim @ 13357:179586a64f53 v8.0.1552
patch 8.0.1552: may leak file descriptors when executing job
commit https://github.com/vim/vim/commit/8195247054a659fe5cbc238197634d5e13e8e8e9
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 27 19:10:00 2018 +0100
patch 8.0.1552: may leak file descriptors when executing job
Problem: May leak file descriptors when executing job.
Solution: Close more file descriptors. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/2531)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 27 Feb 2018 19:15:05 +0100 |
parents | c522585ce88d |
children | c0ebd15a0908 |
comparison
equal
deleted
inserted
replaced
13356:2f4f6fc72c1c | 13357:179586a64f53 |
---|---|
19 let s:chopt = {} | 19 let s:chopt = {} |
20 | 20 |
21 " Run "testfunc" after sarting the server and stop the server afterwards. | 21 " Run "testfunc" after sarting the server and stop the server afterwards. |
22 func s:run_server(testfunc, ...) | 22 func s:run_server(testfunc, ...) |
23 call RunServer('test_channel.py', a:testfunc, a:000) | 23 call RunServer('test_channel.py', a:testfunc, a:000) |
24 endfunc | |
25 | |
26 " Return a list of open files. | |
27 " Can be used to make sure no resources leaked. | |
28 " Returns an empty list on systems where this is not supported. | |
29 func s:get_resources() | |
30 let pid = getpid() | |
31 | |
32 if has('mac') | |
33 return systemlist('lsof -p ' . pid . ' | awk ''$4~/^[0-9]*[rwu]$/&&$5=="REG"{print$NF}''') | |
34 elseif isdirectory('/proc/' . pid . '/fd/') | |
35 return systemlist('readlink /proc/' . pid . '/fd/* | grep -v ''^/dev/''') | |
36 else | |
37 return [] | |
38 endif | |
24 endfunc | 39 endfunc |
25 | 40 |
26 let g:Ch_responseMsg = '' | 41 let g:Ch_responseMsg = '' |
27 func Ch_requestHandler(handle, msg) | 42 func Ch_requestHandler(handle, msg) |
28 let g:Ch_responseHandle = a:handle | 43 let g:Ch_responseHandle = a:handle |
618 call ch_sendraw(handle, "double this\n") | 633 call ch_sendraw(handle, "double this\n") |
619 call WaitFor('len(readfile("Xoutput")) > 2') | 634 call WaitFor('len(readfile("Xoutput")) > 2') |
620 call assert_equal(['line one', 'line two', 'this', 'AND this'], readfile('Xoutput')) | 635 call assert_equal(['line one', 'line two', 'this', 'AND this'], readfile('Xoutput')) |
621 finally | 636 finally |
622 call Stop_g_job() | 637 call Stop_g_job() |
638 call assert_equal(-1, match(s:get_resources(), '\(^\|/\)Xoutput$')) | |
623 call delete('Xoutput') | 639 call delete('Xoutput') |
624 endtry | 640 endtry |
625 endfunc | 641 endfunc |
626 | 642 |
627 func Test_nl_write_err_file() | 643 func Test_nl_write_err_file() |
661 call ch_sendraw(handle, "doubleerr that\n") | 677 call ch_sendraw(handle, "doubleerr that\n") |
662 call WaitFor('len(readfile("Xoutput")) > 5') | 678 call WaitFor('len(readfile("Xoutput")) > 5') |
663 call assert_equal(['line one', 'line two', 'this', 'AND this', 'that', 'AND that'], readfile('Xoutput')) | 679 call assert_equal(['line one', 'line two', 'this', 'AND this', 'that', 'AND that'], readfile('Xoutput')) |
664 finally | 680 finally |
665 call Stop_g_job() | 681 call Stop_g_job() |
682 call assert_equal(-1, match(s:get_resources(), '\(^\|/\)Xoutput$')) | |
666 call delete('Xoutput') | 683 call delete('Xoutput') |
667 endtry | 684 endtry |
668 endfunc | 685 endfunc |
669 | 686 |
670 func BufCloseCb(ch) | 687 func BufCloseCb(ch) |
1660 bwipe! | 1677 bwipe! |
1661 split Xtestwrite | 1678 split Xtestwrite |
1662 call assert_equal("asdf\nasdf", getline(1)) | 1679 call assert_equal("asdf\nasdf", getline(1)) |
1663 call assert_equal("xxx\n", getline(2)) | 1680 call assert_equal("xxx\n", getline(2)) |
1664 call assert_equal("\nyyy", getline(3)) | 1681 call assert_equal("\nyyy", getline(3)) |
1682 call assert_equal(-1, match(s:get_resources(), '\(^\|/\)Xtestwrite$')) | |
1665 | 1683 |
1666 call delete('Xtestwrite') | 1684 call delete('Xtestwrite') |
1667 bwipe! | 1685 bwipe! |
1668 endfunc | 1686 endfunc |
1669 | 1687 |