1
0
forked from aniani/vim

patch 8.1.0318: the getftype() test may fail for char devices

Problem:    The getftype() test may fail for char devices if the file
            disappeared in between the listing and the getftype() call.
Solution:   Ignore empty result. (Ozaki Kiichi, closes #3360)
This commit is contained in:
Bram Moolenaar
2018-08-22 20:16:16 +02:00
parent 320bf2d85e
commit 3b3a506f57
2 changed files with 17 additions and 3 deletions

View File

@@ -141,17 +141,29 @@ func Test_getftype()
endif endif
for cdevfile in systemlist('find /dev -type c -maxdepth 2 2>/dev/null') for cdevfile in systemlist('find /dev -type c -maxdepth 2 2>/dev/null')
call assert_equal('cdev', getftype(cdevfile)) let type = getftype(cdevfile)
" ignore empty result, can happen if the file disappeared
if type != ''
call assert_equal('cdev', type)
endif
endfor endfor
for bdevfile in systemlist('find /dev -type b -maxdepth 2 2>/dev/null') for bdevfile in systemlist('find /dev -type b -maxdepth 2 2>/dev/null')
call assert_equal('bdev', getftype(bdevfile)) let type = getftype(bdevfile)
" ignore empty result, can happen if the file disappeared
if type != ''
call assert_equal('bdev', type)
endif
endfor endfor
" The /run/ directory typically contains socket files. " The /run/ directory typically contains socket files.
" If it does not, test won't fail but will not test socket files. " If it does not, test won't fail but will not test socket files.
for socketfile in systemlist('find /run -type s -maxdepth 2 2>/dev/null') for socketfile in systemlist('find /run -type s -maxdepth 2 2>/dev/null')
call assert_equal('socket', getftype(socketfile)) let type = getftype(socketfile)
" ignore empty result, can happen if the file disappeared
if type != ''
call assert_equal('socket', type)
endif
endfor endfor
" TODO: file type 'other' is not tested. How can we test it? " TODO: file type 'other' is not tested. How can we test it?

View File

@@ -794,6 +794,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
318,
/**/ /**/
317, 317,
/**/ /**/