1#!/bin/sh
2# Test --classify processing
3
4# Copyright (C) 2020-2023 Free Software Foundation, Inc.
5
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.
10
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.
15
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <https://www.gnu.org/licenses/>.
18
19. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20print_ver_ ls
21
22mkdir testdir || framework_failure_
23cd testdir || framework_failure_
24mkdir dir || framework_failure_
25touch regular executable || framework_failure_
26chmod a+x executable || framework_failure_
27ln -s regular slink-reg || framework_failure_
28ln -s dir slink-dir || framework_failure_
29ln -s nowhere slink-dangle || framework_failure_
30mknod block b 20 20 2> /dev/null && block="block
31"
32mknod char c 10 10 2> /dev/null && char="char
33"
34mkfifo_or_skip_ fifo
35cd ..
36
37cat <<EOF > exp
38$block${char}dir/
39executable*
40fifo|
41regular
42slink-dangle@
43slink-dir@
44slink-reg@
45EOF
46sed 's/[*/@|]//' exp > exp2 || framework_failure_
47
48ls --classify testdir > out || fail=1
49ls --classify=always testdir > out2 || fail=1
50ls --classify=auto testdir > out3 || fail=1
51ls --classify=never testdir > out4 || fail=1
52
53compare exp out || fail=1
54
55compare exp out2 || fail=1
56
57compare exp2 out3 || fail=1
58
59compare exp2 out4 || fail=1
60
61returns_ 1 ls --classify=invalid || fail=1
62
63Exit $fail
64