@@ -122,6 +122,41 @@ func Test_nonexistent_file()
122122 call assert_equal (' ' , getfperm (fname))
123123endfunc
124124
125+ func Test_getftype ()
126+ call assert_equal (' file' , getftype (v: progpath ))
127+ call assert_equal (' dir' , getftype (' .' ))
128+
129+ if ! has (' unix' )
130+ return
131+ endif
132+
133+ silent ! ln -s Xfile Xlink
134+ call assert_equal (' link' , getftype (' Xlink' ))
135+ call delete (' Xlink' )
136+
137+ if executable (' mkfifo' )
138+ silent ! mkfifo Xfifo
139+ call assert_equal (' fifo' , getftype (' Xfifo' ))
140+ call delete (' Xfifo' )
141+ endif
142+
143+ for cdevfile in systemlist (' find /dev -type c -maxdepth 2 2>/dev/null' )
144+ call assert_equal (' cdev' , getftype (cdevfile))
145+ endfor
146+
147+ for bdevfile in systemlist (' find /dev -type b -maxdepth 2 2>/dev/null' )
148+ call assert_equal (' bdev' , getftype (bdevfile))
149+ endfor
150+
151+ " The /run/ directory typically contains socket files.
152+ " If it does not, test won't fail but will not test socket files.
153+ for socketfile in systemlist (' find /run -type s -maxdepth 2 2>/dev/null' )
154+ call assert_equal (' socket' , getftype (socketfile))
155+ endfor
156+
157+ " TODO: file type 'other' is not tested. How can we test it?
158+ endfunc
159+
125160func Test_win32_symlink_dir ()
126161 " On Windows, non-admin users cannot create symlinks.
127162 " So we use an existing symlink for this test.
0 commit comments