diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-05-12 14:42:02 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-05-12 14:42:02 +0200 |
commit | 48a687148c4649f6f55b36a1f4111041e7207235 (patch) | |
tree | c36291ac765ffc2fd28529bf23e9c999db8a42e4 | |
parent | c3fd98cf8e43d48a322402d08fa83444c2b0a4a6 (diff) |
patch 8.2.0742: handling of a TERM signal not testedv8.2.0742
Problem: Handling of a TERM signal not tested.
Solution: Add a test for SIGTERM. (Dominique Pelle, closes #6055)
-rw-r--r-- | src/testdir/test_signals.vim | 46 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/testdir/test_signals.vim b/src/testdir/test_signals.vim index 7a2be899f6..cb84f5e1aa 100644 --- a/src/testdir/test_signals.vim +++ b/src/testdir/test_signals.vim @@ -106,3 +106,49 @@ func Test_signal_INT() call StopVimInTerminal(buf) endfunc + +" Test a deadly signal. +" +" There are several deadly signals: SISEGV, SIBUS, SIGTERM... +" Test uses signal SIGTERM as it does not create a core +" dump file unlike SIGSEGV, SIGBUS, etc. See "man 7 signals. +" +" Vim should exit with a deadly signal and unsaved changes +" should be recoverable from the swap file preserved as a +" result of the deadly signal handler. +func Test_deadly_signal_TERM() + if !HasSignal('TERM') + throw 'Skipped: TERM signal not supported' + endif + if !CanRunVimInTerminal() + throw 'Skipped: cannot run vim in terminal' + endif + let cmd = GetVimCommand() + if cmd =~ 'valgrind' + throw 'Skipped: cannot test signal TERM with valgrind' + endif + + let buf = RunVimInTerminal('Xsig_TERM', {'rows': 6}) + let pid_vim = term_getjob(buf)->job_info().process + + call term_sendkeys(buf, ":call setline(1, 'foo')\n") + call WaitForAssert({-> assert_equal('foo', term_getline(buf, 1))}) + + call assert_false(filereadable('Xsig_TERM')) + exe 'silent !kill -s TERM ' .. pid_vim + call WaitForAssert({-> assert_equal('Vim: Caught deadly signal TERM', term_getline(buf, 1))}) + call WaitForAssert({-> assert_match('Vim: preserving files\.\.\.$', term_getline(buf, 2))}) + call WaitForAssert({-> assert_true(filereadable('.Xsig_TERM.swp'))}) + + " Don't call StopVimInTerminal() as it expects job to be still running. + call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))}) + + new + silent recover .Xsig_TERM.swp + call assert_equal(['foo'], getline(1, '$')) + + %bwipe! + call delete('.Xsig_TERM.swp') +endfunc + +" vim: ts=8 sw=2 sts=2 tw=80 fdm=marker diff --git a/src/version.c b/src/version.c index f71d1c4fb3..41f857f638 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 742, +/**/ 741, /**/ 740, |