aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-11-17 22:52:58 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-11-17 22:53:24 +0800
commit442a7e89b8de0959c41007f42b1a59cf52b814fe (patch)
treefb168d938e644e75a76d706bcb25239276489d27
parent3f75f25f9c077a284aedab09c5813d887a62f464 (diff)
downloadrneovim-442a7e89b8de0959c41007f42b1a59cf52b814fe.tar.gz
rneovim-442a7e89b8de0959c41007f42b1a59cf52b814fe.tar.bz2
rneovim-442a7e89b8de0959c41007f42b1a59cf52b814fe.zip
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 <yegappan@yahoo.com>
-rw-r--r--src/nvim/testdir/test_recover.vim42
-rw-r--r--src/nvim/testdir/test_swap.vim2
2 files changed, 37 insertions, 7 deletions
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
diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim
index 10c0fed783..024a3b02bc 100644
--- a/src/nvim/testdir/test_swap.vim
+++ b/src/nvim/testdir/test_swap.vim
@@ -505,7 +505,7 @@ endfunc
func Test_missing_swap_file()
CheckUnix
new Xfile1
- call delete('.Xfile1.swp')
+ call delete(swapname(''))
call assert_fails('file Xfile2', 'E301:')
call assert_equal('Xfile2', bufname())
call assert_true(bufexists('Xfile1'))