doc: update the instructions for generating a coverage report
[coreutils.git] / tests / ls / dangle.sh
blobea455ffabd390981cb55b34d3649b3a3d3d9bceb
1 #!/bin/sh
2 # Make sure ls properly handles dangling symlinks vs. ls's -L, -H, options.
4 # Copyright (C) 2003-2017 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ ls
22 LS_MINOR_PROBLEM=1
23 LS_FAILURE=2
25 ln -s no-such-file dangle || framework_failure_
26 mkdir -p dir/sub || framework_failure_
27 ln -s dir slink-to-dir || framework_failure_
28 mkdir d || framework_failure_
29 ln -s no-such d/dangle || framework_failure_
30 printf '? dangle\n' > subdir_Li_exp || framework_failure_
31 printf 'total 0\n? dangle\n' > subdir_Ls_exp || framework_failure_
33 # This must exit nonzero.
34 returns_ $LS_FAILURE ls -L dangle > /dev/null 2>&1 || fail=1
35 # So must this.
36 returns_ $LS_FAILURE ls -H dangle > /dev/null 2>&1 || fail=1
38 # This must exit successfully.
39 ls dangle >> out || fail=1
41 ls slink-to-dir >> out 2>&1 || fail=1
42 ls -H slink-to-dir >> out 2>&1 || fail=1
43 ls -L slink-to-dir >> out 2>&1 || fail=1
45 cat <<\EOF > exp
46 dangle
47 sub
48 sub
49 sub
50 EOF
52 compare exp out || fail=1
54 # Ensure that ls -Li prints "?" as the inode of a dangling symlink.
55 rm -f out
56 returns_ $LS_MINOR_PROBLEM ls -Li d > out 2>/dev/null || fail=1
57 compare subdir_Li_exp out || fail=1
59 # Ensure that ls -Ls prints "?" as the allocation of a dangling symlink.
60 rm -f out
61 returns_ $LS_MINOR_PROBLEM ls -Ls d > out 2>/dev/null || fail=1
62 compare subdir_Ls_exp out || fail=1
64 Exit $fail