diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-01-29 22:58:21 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-01-29 22:58:21 +0100 |
commit | 39536dd557e847e80572044c2be319db5886abe3 (patch) | |
tree | a9223044558edf150a07d0fde3f8259c0a655561 /src/testdir | |
parent | 2a4857a1fcf1d188e5b985ac21bcfc532eddde94 (diff) | |
download | vim-git-39536dd557e847e80572044c2be319db5886abe3.tar.gz |
patch 8.1.0846: not easy to recognize the system Vim runs onv8.1.0846
Problem: Not easy to recognize the system Vim runs on.
Solution: Add more items to the features list. (Ozaki Kiichi, closes #3855)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_channel.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_functions.vim | 66 | ||||
-rw-r--r-- | src/testdir/test_terminal.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_writefile.vim | 2 |
4 files changed, 55 insertions, 17 deletions
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index 7b0a91735..f81701a07 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -29,7 +29,7 @@ endfunc func s:get_resources() let pid = getpid() - if has('mac') + if executable('lsof') return systemlist('lsof -p ' . pid . ' | awk ''$4~/^[0-9]*[rwu]$/&&$5=="REG"{print$NF}''') elseif isdirectory('/proc/' . pid . '/fd/') return systemlist('readlink /proc/' . pid . '/fd/* | grep -v ''^/dev/''') diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index ceb848692..b08d9aa85 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -1054,22 +1054,31 @@ func Test_libcall_libcallnr() let libc = 'msvcrt.dll' elseif has('mac') let libc = 'libSystem.B.dylib' - elseif system('uname -s') =~ 'SunOS' - " Set the path to libc.so according to the architecture. - let test_bits = system('file ' . GetVimProg()) - let test_arch = system('uname -p') - if test_bits =~ '64-bit' && test_arch =~ 'sparc' - let libc = '/usr/lib/sparcv9/libc.so' - elseif test_bits =~ '64-bit' && test_arch =~ 'i386' - let libc = '/usr/lib/amd64/libc.so' + elseif executable('ldd') + let libc = matchstr(split(system('ldd ' . GetVimProg())), '/libc\.so\>') + endif + if get(l:, 'libc', '') ==# '' + " On Unix, libc.so can be in various places. + if has('linux') + " There is not documented but regarding the 1st argument of glibc's + " dlopen an empty string and nullptr are equivalent, so using an empty + " string for the 1st argument of libcall allows to call functions. + let libc = '' + elseif has('sun') + " Set the path to libc.so according to the architecture. + let test_bits = system('file ' . GetVimProg()) + let test_arch = system('uname -p') + if test_bits =~ '64-bit' && test_arch =~ 'sparc' + let libc = '/usr/lib/sparcv9/libc.so' + elseif test_bits =~ '64-bit' && test_arch =~ 'i386' + let libc = '/usr/lib/amd64/libc.so' + else + let libc = '/usr/lib/libc.so' + endif else - let libc = '/usr/lib/libc.so' + " Unfortunately skip this test until a good way is found. + return endif - else - " On Unix, libc.so can be in various places. - " Interestingly, using an empty string for the 1st argument of libcall - " allows to call functions from libc which is not documented. - let libc = '' endif if has('win32') @@ -1208,3 +1217,32 @@ func Test_confirm() call assert_fails('call confirm("Are you sure?", "&Yes\n&No\n", [])', 'E745:') call assert_fails('call confirm("Are you sure?", "&Yes\n&No\n", 0, [])', 'E730:') endfunc + +func Test_platform_name() + " The system matches at most only one name. + let names = ['amiga', 'beos', 'bsd', 'hpux', 'linux', 'mac', 'qnx', 'sun', 'vms', 'win32', 'win32unix'] + call assert_inrange(0, 1, len(filter(copy(names), 'has(v:val)'))) + + " Is Unix? + call assert_equal(has('beos'), has('beos') && has('unix')) + call assert_equal(has('bsd'), has('bsd') && has('unix')) + call assert_equal(has('hpux'), has('hpux') && has('unix')) + call assert_equal(has('linux'), has('linux') && has('unix')) + call assert_equal(has('mac'), has('mac') && has('unix')) + call assert_equal(has('qnx'), has('qnx') && has('unix')) + call assert_equal(has('sun'), has('sun') && has('unix')) + call assert_equal(has('win32'), has('win32') && !has('unix')) + call assert_equal(has('win32unix'), has('win32unix') && has('unix')) + + if has('unix') && executable('uname') + let uname = system('uname') + call assert_equal(uname =~? 'BeOS', has('beos')) + call assert_equal(uname =~? 'BSD\|DragonFly', has('bsd')) + call assert_equal(uname =~? 'HP-UX', has('hpux')) + call assert_equal(uname =~? 'Linux', has('linux')) + call assert_equal(uname =~? 'Darwin', has('mac')) + call assert_equal(uname =~? 'QNX', has('qnx')) + call assert_equal(uname =~? 'SunOS', has('sun')) + call assert_equal(uname =~? 'CYGWIN\|MSYS', has('win32unix')) + endif +endfunc diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index 25ec2b5ca..698da0498 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -559,7 +559,7 @@ endfunction func Test_terminal_noblock() let buf = term_start(&shell) - if has('mac') + if has('bsd') || has('mac') || has('sun') " The shell or something else has a problem dealing with more than 1000 " characters at the same time. let len = 1000 diff --git a/src/testdir/test_writefile.vim b/src/testdir/test_writefile.vim index 2e47b48a8..ff3675661 100644 --- a/src/testdir/test_writefile.vim +++ b/src/testdir/test_writefile.vim @@ -33,7 +33,7 @@ func Test_writefile_fails_gently() endfunc func Test_writefile_fails_conversion() - if !has('iconv') || system('uname -s') =~ 'SunOS' + if !has('iconv') || has('sun') return endif set nobackup nowritebackup |