From 3f75f25f9c077a284aedab09c5813d887a62f464 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Nov 2022 22:40:10 +0800 Subject: vim-patch:8.2.2945: some buffer related code is not tested Problem: Some buffer related code is not tested. Solution: Add a few more tests. (Yegappan Lakshmanan, closes vim/vim#8320) https://github.com/vim/vim/commit/59b262362f26b3aaea1eeb0078adc33eed59863e Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_recover.vim | 127 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) (limited to 'src/nvim/testdir/test_recover.vim') diff --git a/src/nvim/testdir/test_recover.vim b/src/nvim/testdir/test_recover.vim index 9de4ddc546..61d8684033 100644 --- a/src/nvim/testdir/test_recover.vim +++ b/src/nvim/testdir/test_recover.vim @@ -138,4 +138,131 @@ func Test_nocatch_process_still_running() call delete(swname) endfunc +" Test for :recover with multiple swap files +func Test_recover_multiple_swap_files() + CheckUnix + new Xfile1 + call setline(1, ['a', 'b', 'c']) + preserve + let b = readblob('.Xfile1.swp') + call writefile(b, '.Xfile1.swm') + call writefile(b, '.Xfile1.swn') + call writefile(b, '.Xfile1.swo') + %bw! + call feedkeys(":recover Xfile1\3\q", 'xt') + call assert_equal(['a', 'b', 'c'], getline(1, '$')) + + call delete('.Xfile1.swm') + call delete('.Xfile1.swn') + call delete('.Xfile1.swo') +endfunc + +" Test for :recover using an empty swap file +func Test_recover_empty_swap_file() + CheckUnix + call writefile([], '.Xfile1.swp') + let msg = execute('recover Xfile1') + call assert_match('Unable to read block 0 from .Xfile1.swp', msg) + call assert_equal('Xfile1', @%) + bw! + " :recover from an empty buffer + call assert_fails('recover', 'E305:') + call delete('.Xfile1.swp') +endfunc + +" Test for :recover using a corrupted swap file +func Test_recover_corrupted_swap_file() + CheckUnix + " recover using a partial swap file + call writefile(0z1234, '.Xfile1.swp') + call assert_fails('recover Xfile1', 'E295:') + bw! + + " recover using invalid content in the swap file + call writefile([repeat('1', 2*1024)], '.Xfile1.swp') + call assert_fails('recover Xfile1', 'E307:') + call delete('.Xfile1.swp') + + " :recover using a swap file with a corrupted header + edit Xfile1 + preserve + let sn = swapname('') + let b = readblob(sn) + bw! + " clear the B0_MAGIC_LONG field + let b[1008:1011] = 0z00000000 + call writefile(b, sn) + let msg = execute('recover Xfile1') + call assert_match('the file has been damaged', msg) + bw! + call delete(sn) +endfunc + +" Test for :recover using an encrypted swap file +func Test_recover_encrypted_swap_file() + CheckUnix + + " Recover an encrypted file from the swap file without the original file + new Xfile1 + call feedkeys(":X\vim\vim\", 'xt') + call setline(1, ['aaa', 'bbb', 'ccc']) + preserve + let b = readblob('.Xfile1.swp') + call writefile(b, '.Xfile1.swm') + bw! + call feedkeys(":recover Xfile1\vim\\", 'xt') + call assert_equal(['aaa', 'bbb', 'ccc'], getline(1, '$')) + bw! + call delete('.Xfile1.swm') + + " Recover an encrypted file from the swap file with the original file + new Xfile1 + call feedkeys(":X\vim\vim\", 'xt') + call setline(1, ['aaa', 'bbb', 'ccc']) + update + call setline(1, ['111', '222', '333']) + preserve + let b = readblob('.Xfile1.swp') + call writefile(b, '.Xfile1.swm') + bw! + call feedkeys(":recover Xfile1\vim\\", 'xt') + call assert_equal(['111', '222', '333'], getline(1, '$')) + call assert_true(&modified) + bw! + call delete('.Xfile1.swm') + call delete('Xfile1') +endfunc + +" Test for :recover using a unreadable swap file +func Test_recover_unreadble_swap_file() + CheckUnix + CheckNotRoot + new Xfile1 + let b = readblob('.Xfile1.swp') + call writefile(b, '.Xfile1.swm') + bw! + call setfperm('.Xfile1.swm', '-w-------') + call assert_fails('recover Xfile1', 'E306:') + call delete('.Xfile1.swm') +endfunc + +" Test for using :recover when the original file and the swap file have the +" same contents. +func Test_recover_unmodified_file() + CheckUnix + call writefile(['aaa', 'bbb', 'ccc'], 'Xfile1') + edit Xfile1 + preserve + let b = readblob('.Xfile1.swp') + %bw! + call writefile(b, '.Xfile1.swz') + let msg = execute('recover Xfile1') + call assert_equal(['aaa', 'bbb', 'ccc'], getline(1, '$')) + call assert_false(&modified) + call assert_match('Buffer contents equals file contents', msg) + bw! + call delete('Xfile1') + call delete('.Xfile1.swz') +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 442a7e89b8de0959c41007f42b1a59cf52b814fe Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Nov 2022 22:52:58 +0800 Subject: vim-patch:8.2.2952: recover test fails on big endian systems Problem: Recover test fails on big endian systems. Solution: Disable the failing test on big endian systems. (Yegappan Lakshmanan, closes vim/vim#8335) https://github.com/vim/vim/commit/99285550a9957e2c8669f183557944c6513c4875 Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_recover.vim | 42 +++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'src/nvim/testdir/test_recover.vim') diff --git a/src/nvim/testdir/test_recover.vim b/src/nvim/testdir/test_recover.vim index 61d8684033..ce9de8b87d 100644 --- a/src/nvim/testdir/test_recover.vim +++ b/src/nvim/testdir/test_recover.vim @@ -144,7 +144,7 @@ func Test_recover_multiple_swap_files() new Xfile1 call setline(1, ['a', 'b', 'c']) preserve - let b = readblob('.Xfile1.swp') + let b = readblob(swapname('')) call writefile(b, '.Xfile1.swm') call writefile(b, '.Xfile1.swn') call writefile(b, '.Xfile1.swo') @@ -173,6 +173,7 @@ endfunc " Test for :recover using a corrupted swap file func Test_recover_corrupted_swap_file() CheckUnix + " recover using a partial swap file call writefile(0z1234, '.Xfile1.swp') call assert_fails('recover Xfile1', 'E295:') @@ -188,12 +189,41 @@ func Test_recover_corrupted_swap_file() preserve let sn = swapname('') let b = readblob(sn) + let save_b = copy(b) bw! - " clear the B0_MAGIC_LONG field - let b[1008:1011] = 0z00000000 - call writefile(b, sn) - let msg = execute('recover Xfile1') - call assert_match('the file has been damaged', msg) + " Run these tests only on little-endian systems. These tests fail on a + " big-endian system (IBM S390x system). + if b[1008:1011] == 0z33323130 + \ && b[4096:4097] == 0z7470 + \ && b[8192:8193] == 0z6164 + + " clear the B0_MAGIC_LONG field + let b[1008:1011] = 0z00000000 + call writefile(b, sn) + let msg = execute('recover Xfile1') + call assert_match('the file has been damaged', msg) + bw! + + " clear the pointer ID + let b = copy(save_b) + let b[4096:4097] = 0z0000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E310:') + bw! + + " clear the data block ID + let b = copy(save_b) + let b[8192:8193] = 0z0000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + bw! + + " remove the data block + let b = copy(save_b) + call writefile(b[:8191], sn) + call assert_fails('recover Xfile1', 'E312:') + endif + bw! call delete(sn) endfunc -- cgit From a8f54a94c11d8ff3da299e54de4cbbcfec1fd4ac Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Nov 2022 22:53:40 +0800 Subject: vim-patch:8.2.2960: swap file recovery not sufficiently tested Problem: Swap file recovery not sufficiently tested. Solution: Add a few more tests. (Yegappan Lakshmanan, closes vim/vim#8339) https://github.com/vim/vim/commit/8cf02e5cf8fb14a5009f12e7af0a47617a0ce88d Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_recover.vim | 100 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) (limited to 'src/nvim/testdir/test_recover.vim') diff --git a/src/nvim/testdir/test_recover.vim b/src/nvim/testdir/test_recover.vim index ce9de8b87d..89f894a4bb 100644 --- a/src/nvim/testdir/test_recover.vim +++ b/src/nvim/testdir/test_recover.vim @@ -151,6 +151,16 @@ func Test_recover_multiple_swap_files() %bw! call feedkeys(":recover Xfile1\3\q", 'xt') call assert_equal(['a', 'b', 'c'], getline(1, '$')) + " try using out-of-range number to select a swap file + bw! + call feedkeys(":recover Xfile1\4\q", 'xt') + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) + bw! + call feedkeys(":recover Xfile1\0\q", 'xt') + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) + bw! call delete('.Xfile1.swm') call delete('.Xfile1.swn') @@ -171,6 +181,8 @@ func Test_recover_empty_swap_file() endfunc " Test for :recover using a corrupted swap file +" Refer to the comments in the memline.c file for the swap file headers +" definition. func Test_recover_corrupted_swap_file() CheckUnix @@ -202,6 +214,18 @@ func Test_recover_corrupted_swap_file() call writefile(b, sn) let msg = execute('recover Xfile1') call assert_match('the file has been damaged', msg) + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) + bw! + + " reduce the page size + let b = copy(save_b) + let b[12:15] = 0z00010000 + call writefile(b, sn) + let msg = execute('recover Xfile1') + call assert_match('page size is smaller than minimum value', msg) + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) bw! " clear the pointer ID @@ -209,6 +233,26 @@ func Test_recover_corrupted_swap_file() let b[4096:4097] = 0z0000 call writefile(b, sn) call assert_fails('recover Xfile1', 'E310:') + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) + bw! + + " set the number of pointers in a pointer block to zero + let b = copy(save_b) + let b[4098:4099] = 0z0000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???EMPTY BLOCK'], getline(1, '$')) + bw! + + " set the block number in a pointer entry to a negative number + let b = copy(save_b) + let b[4104:4111] = 0z00000000.00000080 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???LINES MISSING'], getline(1, '$')) bw! " clear the data block ID @@ -216,12 +260,45 @@ func Test_recover_corrupted_swap_file() let b[8192:8193] = 0z0000 call writefile(b, sn) call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???BLOCK MISSING'], getline(1, '$')) + bw! + + " set the number of lines in the data block to zero + let b = copy(save_b) + let b[8208:8211] = 0z00000000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['??? from here until ???END lines may have been inserted/deleted', + \ '???END'], getline(1, '$')) + bw! + + " use an invalid text start for the lines in a data block + let b = copy(save_b) + let b[8216:8219] = 0z00000000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???'], getline(1, '$')) + bw! + + " use an incorrect text end (db_txt_end) for the data block + let b = copy(save_b) + let b[8204:8207] = 0z80000000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['??? from here until ???END lines may be messed up', '', + \ '???END'], getline(1, '$')) bw! " remove the data block let b = copy(save_b) call writefile(b[:8191], sn) call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???MANY LINES MISSING'], getline(1, '$')) endif bw! @@ -295,4 +372,27 @@ func Test_recover_unmodified_file() call delete('.Xfile1.swz') endfunc +" Test for recovering a file when editing a symbolically linked file +func Test_recover_symbolic_link() + CheckUnix + call writefile(['aaa', 'bbb', 'ccc'], 'Xfile1') + silent !ln -s Xfile1 Xfile2 + edit Xfile2 + call assert_equal('.Xfile1.swp', fnamemodify(swapname(''), ':t')) + preserve + let b = readblob('.Xfile1.swp') + %bw! + call writefile([], 'Xfile1') + call writefile(b, '.Xfile1.swp') + silent! recover Xfile2 + call assert_equal(['aaa', 'bbb', 'ccc'], getline(1, '$')) + call assert_true(&modified) + update + %bw! + call assert_equal(['aaa', 'bbb', 'ccc'], readfile('Xfile1')) + call delete('Xfile1') + call delete('Xfile2') + call delete('.Xfile1.swp') +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From f12a45c45eab75578fa18b1c6395f80b8749f7ef Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Nov 2022 22:57:08 +0800 Subject: vim-patch:8.2.2973: fix for recovery and diff mode not tested Problem: Fix for recovery and diff mode not tested. Solution: Add a few more tests. (Yegappan Lakshmanan, closes vim/vim#8352) https://github.com/vim/vim/commit/3044324e8dccd470bd854cf7d9457232cc9c220e Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_recover.vim | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/nvim/testdir/test_recover.vim') diff --git a/src/nvim/testdir/test_recover.vim b/src/nvim/testdir/test_recover.vim index 89f894a4bb..90ee10704c 100644 --- a/src/nvim/testdir/test_recover.vim +++ b/src/nvim/testdir/test_recover.vim @@ -395,4 +395,48 @@ func Test_recover_symbolic_link() call delete('.Xfile1.swp') endfunc +" Test for recovering a file when an autocmd moves the cursor to an invalid +" line. This used to result in an internal error (E315) which is fixed +" by 8.2.2966. +func Test_recover_invalid_cursor_pos() + call writefile([], 'Xfile1') + edit Xfile1 + preserve + let b = readblob('.Xfile1.swp') + bw! + augroup Test + au! + au BufReadPost Xfile1 normal! 3G + augroup END + call writefile(range(1, 3), 'Xfile1') + call writefile(b, '.Xfile1.swp') + try + recover Xfile1 + catch /E308:/ + " this test is for the :E315 internal error. + " ignore the 'E308: Original file may have been changed' error + endtry + redraw! + augroup Test + au! + augroup END + augroup! Test + call delete('Xfile1') + call delete('.Xfile1.swp') +endfunc + +" Test for recovering a buffer without a name +func Test_noname_buffer() + new + call setline(1, ['one', 'two']) + preserve + let sn = swapname('') + let b = readblob(sn) + bw! + call writefile(b, sn) + exe "recover " .. sn + call assert_equal(['one', 'two'], getline(1, '$')) + call delete(sn) +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From fa17dc1e1b893db3320b9b7ae50698c05280df92 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Nov 2022 23:00:25 +0800 Subject: vim-patch:8.2.2981: recovery test is not run on big-endian systems Problem: Recovery test is not run on big-endian systems. Solution: Make it work on big-endian systems. (James McCoy, closes vim/vim#8368) https://github.com/vim/vim/commit/6654ca702ca64c99965efcad3243ea5f95473252 Co-authored-by: James McCoy --- src/nvim/testdir/test_recover.vim | 193 +++++++++++++++++++------------------- 1 file changed, 96 insertions(+), 97 deletions(-) (limited to 'src/nvim/testdir/test_recover.vim') diff --git a/src/nvim/testdir/test_recover.vim b/src/nvim/testdir/test_recover.vim index 90ee10704c..10a9e7b4f3 100644 --- a/src/nvim/testdir/test_recover.vim +++ b/src/nvim/testdir/test_recover.vim @@ -203,103 +203,102 @@ func Test_recover_corrupted_swap_file() let b = readblob(sn) let save_b = copy(b) bw! - " Run these tests only on little-endian systems. These tests fail on a - " big-endian system (IBM S390x system). - if b[1008:1011] == 0z33323130 - \ && b[4096:4097] == 0z7470 - \ && b[8192:8193] == 0z6164 - - " clear the B0_MAGIC_LONG field - let b[1008:1011] = 0z00000000 - call writefile(b, sn) - let msg = execute('recover Xfile1') - call assert_match('the file has been damaged', msg) - call assert_equal('Xfile1', @%) - call assert_equal([''], getline(1, '$')) - bw! - - " reduce the page size - let b = copy(save_b) - let b[12:15] = 0z00010000 - call writefile(b, sn) - let msg = execute('recover Xfile1') - call assert_match('page size is smaller than minimum value', msg) - call assert_equal('Xfile1', @%) - call assert_equal([''], getline(1, '$')) - bw! - - " clear the pointer ID - let b = copy(save_b) - let b[4096:4097] = 0z0000 - call writefile(b, sn) - call assert_fails('recover Xfile1', 'E310:') - call assert_equal('Xfile1', @%) - call assert_equal([''], getline(1, '$')) - bw! - - " set the number of pointers in a pointer block to zero - let b = copy(save_b) - let b[4098:4099] = 0z0000 - call writefile(b, sn) - call assert_fails('recover Xfile1', 'E312:') - call assert_equal('Xfile1', @%) - call assert_equal(['???EMPTY BLOCK'], getline(1, '$')) - bw! - - " set the block number in a pointer entry to a negative number - let b = copy(save_b) - let b[4104:4111] = 0z00000000.00000080 - call writefile(b, sn) - call assert_fails('recover Xfile1', 'E312:') - call assert_equal('Xfile1', @%) - call assert_equal(['???LINES MISSING'], getline(1, '$')) - bw! - - " clear the data block ID - let b = copy(save_b) - let b[8192:8193] = 0z0000 - call writefile(b, sn) - call assert_fails('recover Xfile1', 'E312:') - call assert_equal('Xfile1', @%) - call assert_equal(['???BLOCK MISSING'], getline(1, '$')) - bw! - - " set the number of lines in the data block to zero - let b = copy(save_b) - let b[8208:8211] = 0z00000000 - call writefile(b, sn) - call assert_fails('recover Xfile1', 'E312:') - call assert_equal('Xfile1', @%) - call assert_equal(['??? from here until ???END lines may have been inserted/deleted', - \ '???END'], getline(1, '$')) - bw! - - " use an invalid text start for the lines in a data block - let b = copy(save_b) - let b[8216:8219] = 0z00000000 - call writefile(b, sn) - call assert_fails('recover Xfile1', 'E312:') - call assert_equal('Xfile1', @%) - call assert_equal(['???'], getline(1, '$')) - bw! - - " use an incorrect text end (db_txt_end) for the data block - let b = copy(save_b) - let b[8204:8207] = 0z80000000 - call writefile(b, sn) - call assert_fails('recover Xfile1', 'E312:') - call assert_equal('Xfile1', @%) - call assert_equal(['??? from here until ???END lines may be messed up', '', - \ '???END'], getline(1, '$')) - bw! - - " remove the data block - let b = copy(save_b) - call writefile(b[:8191], sn) - call assert_fails('recover Xfile1', 'E312:') - call assert_equal('Xfile1', @%) - call assert_equal(['???MANY LINES MISSING'], getline(1, '$')) - endif + + " Not all fields are written in a system-independent manner. Detect whether + " the test is running on a little or big-endian system, so the correct + " corruption values can be set. + let little_endian = b[1008:1015] == 0z33323130.00000000 + + " clear the B0_MAGIC_LONG field + let b[1008:1015] = 0z0000000000000000 + call writefile(b, sn) + let msg = execute('recover Xfile1') + call assert_match('the file has been damaged', msg) + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) + bw! + + " reduce the page size + let b = copy(save_b) + let b[12:15] = 0z00010000 + call writefile(b, sn) + let msg = execute('recover Xfile1') + call assert_match('page size is smaller than minimum value', msg) + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) + bw! + + " clear the pointer ID + let b = copy(save_b) + let b[4096:4097] = 0z0000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E310:') + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) + bw! + + " set the number of pointers in a pointer block to zero + let b = copy(save_b) + let b[4098:4099] = 0z0000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???EMPTY BLOCK'], getline(1, '$')) + bw! + + " set the block number in a pointer entry to a negative number + let b = copy(save_b) + let b[4104:4111] = little_endian ? 0z00000000.00000080 : 0z80000000.00000000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???LINES MISSING'], getline(1, '$')) + bw! + + " clear the data block ID + let b = copy(save_b) + let b[8192:8193] = 0z0000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???BLOCK MISSING'], getline(1, '$')) + bw! + + " set the number of lines in the data block to zero + let b = copy(save_b) + let b[8208:8215] = 0z00000000.00000000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['??? from here until ???END lines may have been inserted/deleted', + \ '???END'], getline(1, '$')) + bw! + + " use an invalid text start for the lines in a data block + let b = copy(save_b) + let b[8216:8219] = 0z00000000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???'], getline(1, '$')) + bw! + + " use an incorrect text end (db_txt_end) for the data block + let b = copy(save_b) + let b[8204:8207] = little_endian ? 0z80000000 : 0z00000080 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['??? from here until ???END lines may be messed up', '', + \ '???END'], getline(1, '$')) + bw! + + " remove the data block + let b = copy(save_b) + call writefile(b[:8191], sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???MANY LINES MISSING'], getline(1, '$')) bw! call delete(sn) -- cgit From c1c2c7b3163490b5e4374ee370616ea2581d4fe1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Nov 2022 23:00:50 +0800 Subject: vim-patch:8.2.3080: recover test fails on 32bit systems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Recover test fails on 32bit systems. (Ondřej Súkup) Solution: Detect 32/64 bit systems. (Yegappan Lakshmanan, closes vim/vim#8485, closes vim/vim#8479) https://github.com/vim/vim/commit/576cb75ceb38ed077938d4a1c1265095050f6105 Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_recover.vim | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/nvim/testdir/test_recover.vim') diff --git a/src/nvim/testdir/test_recover.vim b/src/nvim/testdir/test_recover.vim index 10a9e7b4f3..137c73a194 100644 --- a/src/nvim/testdir/test_recover.vim +++ b/src/nvim/testdir/test_recover.vim @@ -207,10 +207,16 @@ func Test_recover_corrupted_swap_file() " Not all fields are written in a system-independent manner. Detect whether " the test is running on a little or big-endian system, so the correct " corruption values can be set. - let little_endian = b[1008:1015] == 0z33323130.00000000 + let little_endian = b[1008:1011] == 0z33323130 + " The swap file header fields can be either 32-bit or 64-bit. + let system_64bit = b[1012:1015] == 0z00000000 " clear the B0_MAGIC_LONG field - let b[1008:1015] = 0z0000000000000000 + if system_64bit + let b[1008:1015] = 0z00000000.00000000 + else + let b[1008:1011] = 0z00000000 + endif call writefile(b, sn) let msg = execute('recover Xfile1') call assert_match('the file has been damaged', msg) @@ -248,7 +254,11 @@ func Test_recover_corrupted_swap_file() " set the block number in a pointer entry to a negative number let b = copy(save_b) - let b[4104:4111] = little_endian ? 0z00000000.00000080 : 0z80000000.00000000 + if system_64bit + let b[4104:4111] = little_endian ? 0z00000000.00000080 : 0z80000000.00000000 + else + let b[4104:4107] = little_endian ? 0z00000080 : 0z80000000 + endif call writefile(b, sn) call assert_fails('recover Xfile1', 'E312:') call assert_equal('Xfile1', @%) @@ -266,7 +276,11 @@ func Test_recover_corrupted_swap_file() " set the number of lines in the data block to zero let b = copy(save_b) - let b[8208:8215] = 0z00000000.00000000 + if system_64bit + let b[8208:8215] = 0z00000000.00000000 + else + let b[8208:8211] = 0z00000000 + endif call writefile(b, sn) call assert_fails('recover Xfile1', 'E312:') call assert_equal('Xfile1', @%) @@ -276,7 +290,11 @@ func Test_recover_corrupted_swap_file() " use an invalid text start for the lines in a data block let b = copy(save_b) - let b[8216:8219] = 0z00000000 + if system_64bit + let b[8216:8219] = 0z00000000 + else + let b[8212:8215] = 0z00000000 + endif call writefile(b, sn) call assert_fails('recover Xfile1', 'E312:') call assert_equal('Xfile1', @%) -- cgit From d8fc390bd04a69f43983fc355026a2f216410318 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Nov 2022 23:02:47 +0800 Subject: vim-patch:8.2.3440: recover test fails if there is an old swap file Problem: Recover test fails if there is an old swap file. Solution: Delete old swap files. https://github.com/vim/vim/commit/f2a8bafa4b815e5b4e50a25c2b3a8a24fbe8aa11 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_recover.vim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/testdir/test_recover.vim') diff --git a/src/nvim/testdir/test_recover.vim b/src/nvim/testdir/test_recover.vim index 137c73a194..9d38b0ebea 100644 --- a/src/nvim/testdir/test_recover.vim +++ b/src/nvim/testdir/test_recover.vim @@ -175,6 +175,12 @@ func Test_recover_empty_swap_file() call assert_match('Unable to read block 0 from .Xfile1.swp', msg) call assert_equal('Xfile1', @%) bw! + + " make sure there are no old swap files laying around + for f in glob('.sw?', 0, 1) + call delete(f) + endfor + " :recover from an empty buffer call assert_fails('recover', 'E305:') call delete('.Xfile1.swp') -- cgit From c269b8dcae08221f1752faf1ecc7dae4d7eed40c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Nov 2022 23:03:10 +0800 Subject: vim-patch:8.2.3498: recover test may fail on some systems Problem: Recover test may fail on some systems. Solution: Adjust the little endian and 64 bit detection. (James McCoy, closes vim/vim#8941) https://github.com/vim/vim/commit/37f341d7236ff8a1e886bbb0f0ba0700ad589373 Co-authored-by: James McCoy --- src/nvim/testdir/test_recover.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir/test_recover.vim') diff --git a/src/nvim/testdir/test_recover.vim b/src/nvim/testdir/test_recover.vim index 9d38b0ebea..f4710c4357 100644 --- a/src/nvim/testdir/test_recover.vim +++ b/src/nvim/testdir/test_recover.vim @@ -213,9 +213,11 @@ func Test_recover_corrupted_swap_file() " Not all fields are written in a system-independent manner. Detect whether " the test is running on a little or big-endian system, so the correct " corruption values can be set. - let little_endian = b[1008:1011] == 0z33323130 - " The swap file header fields can be either 32-bit or 64-bit. - let system_64bit = b[1012:1015] == 0z00000000 + " The B0_MAGIC_LONG field may be 32-bit or 64-bit, depending on the system, + " even though the value stored is only 32-bits. Therefore, need to check + " both the high and low 32-bits to compute these values. + let little_endian = (b[1008:1011] == 0z33323130) || (b[1012:1015] == 0z33323130) + let system_64bit = little_endian ? (b[1012:1015] == 0z00000000) : (b[1008:1011] == 0z00000000) " clear the B0_MAGIC_LONG field if system_64bit -- cgit From 7139035bfd90698ce7214b507b2f8a7766398a68 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Nov 2022 23:30:30 +0800 Subject: vim-patch:9.0.0895: file renamed twice in test, missing feature check Problem: File renamed twice in test; missing feature check. Solution: Remove a rename() call. Add check for cryptv feature. (closes vim/vim#11564) https://github.com/vim/vim/commit/780154bf7a07813e474105837c2b5998009d9c71 Co-authored-by: zeertzjq --- src/nvim/testdir/test_recover.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_recover.vim') diff --git a/src/nvim/testdir/test_recover.vim b/src/nvim/testdir/test_recover.vim index f4710c4357..92e22687af 100644 --- a/src/nvim/testdir/test_recover.vim +++ b/src/nvim/testdir/test_recover.vim @@ -126,7 +126,6 @@ func Test_nocatch_process_still_running() call test_override("uptime", 0) sleep 1 - call rename('Xswap', swname) call feedkeys('e', 'tL') redir => editOutput edit Xswaptest @@ -332,6 +331,7 @@ endfunc " Test for :recover using an encrypted swap file func Test_recover_encrypted_swap_file() + CheckFeature cryptv CheckUnix " Recover an encrypted file from the swap file without the original file -- cgit