diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 16:58:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 16:58:41 +0000 |
commit | e1908ae95dd4c9d19ee4dfabfc8bf8a7f85943fe (patch) | |
tree | f5cc731bedcac0fb7fe14d952e4581e749f8bb87 /tests/readlink | |
parent | Initial commit. (diff) | |
download | coreutils-e1908ae95dd4c9d19ee4dfabfc8bf8a7f85943fe.tar.xz coreutils-e1908ae95dd4c9d19ee4dfabfc8bf8a7f85943fe.zip |
Adding upstream version 9.4.upstream/9.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/readlink')
-rwxr-xr-x | tests/readlink/can-e.sh | 104 | ||||
-rwxr-xr-x | tests/readlink/can-f.sh | 153 | ||||
-rwxr-xr-x | tests/readlink/can-m.sh | 141 | ||||
-rwxr-xr-x | tests/readlink/multi.sh | 46 | ||||
-rwxr-xr-x | tests/readlink/readlink-fp-loop.sh | 68 | ||||
-rwxr-xr-x | tests/readlink/readlink-root.sh | 92 | ||||
-rwxr-xr-x | tests/readlink/rl-1.sh | 43 |
7 files changed, 647 insertions, 0 deletions
diff --git a/tests/readlink/can-e.sh b/tests/readlink/can-e.sh new file mode 100755 index 0000000..6237e8d --- /dev/null +++ b/tests/readlink/can-e.sh @@ -0,0 +1,104 @@ +#!/bin/sh +# tests for canonicalize-existing mode (readlink -e). + +# Copyright (C) 2004-2023 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ readlink pwd + +pwd=$(pwd) +my_pwd=$(env pwd -P) +tmp=d + +mkdir $tmp || framework_failure_ +cd $tmp || framework_failure_ + +mkdir subdir removed || framework_failure_ +touch regfile || framework_failure_ + +ln -s regfile link1 || framework_failure_ +ln -s subdir link2 || framework_failure_ +ln -s missing link3 || framework_failure_ +ln -s subdir/missing link4 || framework_failure_ + +cd "$pwd/$tmp/removed" || framework_failure_ + +# Skip this test if the system doesn't let you remove the working directory. +if rmdir ../removed 2>/dev/null; then + v=$(returns_ 1 readlink -e .) || fail=1 + test -z "$v" || fail=1 +fi + +cd "$pwd/$tmp" || fail=1 + +for p in "" "$pwd/$tmp/"; do + + v=$(readlink -e "${p}regfile") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(returns_ 1 readlink -e "${p}./regfile/") || fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}subdir") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -e "${p}./subdir/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(returns_ 1 readlink -e "${p}missing") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -e "${p}./missing/") || fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}link1") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(returns_ 1 readlink -e "${p}./link1/") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -e "${p}link1/more") || fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}link2") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -e "${p}./link2/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(returns_ 1 readlink -e "${p}link2/more") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -e "${p}link3") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -e "${p}./link3/") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -e "${p}link3/more") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -e "${p}link4") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -e "${p}./link4/") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -e "${p}link4/more") || fail=1 + test -z "$v" || fail=1 +done + +Exit $fail diff --git a/tests/readlink/can-f.sh b/tests/readlink/can-f.sh new file mode 100755 index 0000000..83460e5 --- /dev/null +++ b/tests/readlink/can-f.sh @@ -0,0 +1,153 @@ +#!/bin/sh +# tests for canonicalize mode (readlink -f). + +# Copyright (C) 2004-2023 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ readlink pwd + +pwd=$(pwd) +my_pwd=$(env pwd -P) +tmp=d + +mkdir $tmp || framework_failure_ +cd $tmp || framework_failure_ + +mkdir subdir removed || framework_failure_ +touch regfile || framework_failure_ + +ln -s regfile link1 || framework_failure_ +ln -s subdir link2 || framework_failure_ +ln -s missing link3 || framework_failure_ +ln -s subdir/missing link4 || framework_failure_ +ln -s link5 link5 || framework_failure_ + +cd "$pwd/$tmp/removed" || framework_failure_ + +# Skip this test if the system doesn't let you remove the working directory. +if rmdir ../removed 2>/dev/null; then + v=$(returns_ 1 readlink -e .) || fail=1 + test -z "$v" || fail=1 +fi + +cd "$pwd/$tmp" || fail=1 + +for p in "" "$pwd/$tmp/"; do + + v=$(readlink -f "${p}regfile") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(returns_ 1 readlink -f "${p}./regfile/") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -f "${p}regfile/more") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -f "${p}./regfile/more/") || fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}subdir") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -f "${p}./subdir/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -f "${p}subdir/more") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -f "${p}./subdir/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -f "${p}missing") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -f "${p}./missing/") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(returns_ 1 readlink -f "${p}missing/more") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -f "${p}./missing/more/") || fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}link1") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(returns_ 1 readlink -f "${p}./link1/") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -f "${p}link1/more") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -f "${p}./link1/more/") || fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}link2") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -f "${p}./link2/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -f "${p}link2/more") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -f "${p}./link2/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(returns_ 1 readlink -f "${p}link2/more/more2") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -f "${p}./link2/more/more2/") || fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}link3") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -f "${p}./link3/") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(returns_ 1 readlink -f "${p}link3/more") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -f "${p}./link3/more/") || fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}link4") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 + + v=$(readlink -f "${p}./link4/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 + + v=$(returns_ 1 readlink -f "${p}link4/more") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -f "${p}./link4/more") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -f "${p}link5") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -f "${p}./link5/") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -f "${p}link5/more") || fail=1 + test -z "$v" || fail=1 + + v=$(returns_ 1 readlink -f "${p}./link5/more") || fail=1 + test -z "$v" || fail=1 +done + +Exit $fail diff --git a/tests/readlink/can-m.sh b/tests/readlink/can-m.sh new file mode 100755 index 0000000..4cc3122 --- /dev/null +++ b/tests/readlink/can-m.sh @@ -0,0 +1,141 @@ +#!/bin/sh +# tests for canonicalize-missing mode (readlink -m). + +# Copyright (C) 2004-2023 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ readlink pwd + +pwd=$(pwd) +my_pwd=$(env pwd -P) +tmp=d + +mkdir $tmp || framework_failure_ +cd $tmp || framework_failure_ + +mkdir subdir removed || framework_failure_ +touch regfile || framework_failure_ + +ln -s regfile link1 || framework_failure_ +ln -s subdir link2 || framework_failure_ +ln -s missing link3 || framework_failure_ +ln -s subdir/missing link4 || framework_failure_ + +cd "$pwd/$tmp/removed" || framework_failure_ + +# Skip this test if the system doesn't let you remove the working directory. +if rmdir ../removed 2>/dev/null; then + v=$(returns_ 1 readlink -e .) || fail=1 + test -z "$v" || fail=1 +fi + +cd "$pwd/$tmp" || fail=1 + +for p in "" "$pwd/$tmp/"; do + + v=$(readlink -m "${p}regfile") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(readlink -m "${p}./regfile/") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(readlink -m "${p}regfile/more") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile/more" || fail=1 + + v=$(readlink -m "${p}./regfile/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile/more" || fail=1 + + v=$(readlink -m "${p}subdir") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -m "${p}./subdir/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -m "${p}subdir/more") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -m "${p}./subdir/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -m "${p}missing") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -m "${p}./missing/") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -m "${p}missing/more") || fail=1 + test "$v" = "$my_pwd/$tmp/missing/more" || fail=1 + + v=$(readlink -m "${p}./missing/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/missing/more" || fail=1 + + v=$(readlink -m "${p}link1") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(readlink -m "${p}./link1/") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(readlink -m "${p}link1/more") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile/more" || fail=1 + + v=$(readlink -m "${p}./link1/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile/more" || fail=1 + + v=$(readlink -m "${p}link2") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -m "${p}./link2/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -m "${p}link2/more") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -m "${p}./link2/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -m "${p}link2/more/more2") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more/more2" || fail=1 + + v=$(readlink -m "${p}./link2/more/more2/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more/more2" || fail=1 + + v=$(readlink -m "${p}link3") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -m "${p}./link3/") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -m "${p}link3/more") || fail=1 + test "$v" = "$my_pwd/$tmp/missing/more" || fail=1 + + v=$(readlink -m "${p}./link3/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/missing/more" || fail=1 + + v=$(readlink -m "${p}link4") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 + + v=$(readlink -m "${p}./link4/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 + + v=$(readlink -m "${p}link4/more") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/missing/more" || fail=1 + + v=$(readlink -m "${p}./link4/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/missing/more" || fail=1 + +done + +Exit $fail diff --git a/tests/readlink/multi.sh b/tests/readlink/multi.sh new file mode 100755 index 0000000..5de903d --- /dev/null +++ b/tests/readlink/multi.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# test multiple argument handling. + +# Copyright (C) 2012-2023 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ readlink + +touch regfile || framework_failure_ +ln -s regfile link1 || framework_failure_ + +readlink link1 link1 || fail=1 +returns_ 1 readlink link1 link2 || fail=1 +returns_ 1 readlink link1 link2 link1 || fail=1 +readlink -m link1 link2 || fail=1 + +printf '/1\0/1\0' > exp || framework_failure_ +readlink -m --zero /1 /1 > out || fail=1 +compare exp out || fail=1 + +# The largely redundant --no-newline option is ignored with multiple args. +# Note BSD's readlink suppresses all delimiters, even with multiple args, +# but that functionality was not thought useful. +readlink -n -m --zero /1 /1 > out || fail=1 +compare exp out || fail=1 + +# Note the edge case that the last xargs run may not have a delimiter +rm out || framework_failure_ +printf '/1\0/1\0/1' > exp || framework_failure_ +printf '/1 /1 /1 ' | xargs -n2 readlink -n -m --zero >> out || fail=1 +compare exp out || fail=1 + +Exit $fail diff --git a/tests/readlink/readlink-fp-loop.sh b/tests/readlink/readlink-fp-loop.sh new file mode 100755 index 0000000..f1e277a --- /dev/null +++ b/tests/readlink/readlink-fp-loop.sh @@ -0,0 +1,68 @@ +#!/bin/sh +# readlink from 6.9 would fail with a false-positive symlink loop error + +# Copyright (C) 2007-2023 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ readlink pwd +cwd=$(env pwd -P) + +# To trigger this bug, we have to construct a name/situation during +# the resolution of which the code dereferences the same symlink (S) +# two different times with no actual loop. In addition, arrange +# so that the second and fourth calls to readlink operate on S. + +ln -s s p || framework_failure_ +ln -s d s || framework_failure_ +mkdir d || framework_failure_ +echo 2 > d/2 || framework_failure_ +ln -s ../s/2 d/1 || framework_failure_ + +# With coreutils-6.9, this would fail with ELOOP. +readlink -v -e p/1 > out || fail=1 +# readlink -e d/2 > exp || fail=1 +echo "$cwd/d/2" > exp || framework_failure_ +compare exp out || fail=1 + +# Construct a real loop and make sure readlink still detects it. +ln -sf ../s/1 d/2 || framework_failure_ +readlink -v -e p/1 2> out && fail=1 +readlink_msg=$(cat out) +case $readlink_msg in + "readlink: p/1: "*) ;; + *) fail=1;; +esac +symlink_loop_msg=${readlink_msg#"readlink: p/1: "} + +# Exercise the hash table code. +ln -nsf ../s/3 d/2 || framework_failure_ +ln -nsf ../p/4 d/3 || framework_failure_ +ln -nsf ../p/5 d/4 || framework_failure_ +ln -nsf ../p/6 d/5 || framework_failure_ +ln -nsf ../p/7 d/6 || framework_failure_ +ln -nsf ../p/8 d/7 || framework_failure_ +echo x > d/8 || framework_failure_ +readlink -v -e p/1 > out || fail=1 +echo "$cwd/d/8" > exp || framework_failure_ +compare exp out || fail=1 + +# A trivial loop +ln -s loop loop +readlink -v -e loop 2> out && fail=1 +echo "readlink: loop: $symlink_loop_msg" > exp || framework_failure_ +compare exp out || fail=1 + +Exit $fail diff --git a/tests/readlink/readlink-root.sh b/tests/readlink/readlink-root.sh new file mode 100755 index 0000000..0015d3d --- /dev/null +++ b/tests/readlink/readlink-root.sh @@ -0,0 +1,92 @@ +#!/bin/sh +# tests for canonicalize-existing mode (readlink -e) on /. + +# Copyright (C) 2012-2023 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ readlink + +stat_single=$(stat -c %d:%i /) || framework_failure_ +stat_double=$(stat -c %d:%i //) || framework_failure_ +double_slash=// +if test x"$stat_single" = x"$stat_double"; then + double_slash=/ +fi + +test -d /dev || framework_failure_ + +ln -s / one || framework_failure_ +ln -s // two || framework_failure_ +ln -s /// three || framework_failure_ +ln -s /./..// one-dots || framework_failure_ +ln -s //./..// two-dots || framework_failure_ +ln -s ///./..// three-dots || framework_failure_ +ln -s /dev one-dev || framework_failure_ +ln -s //dev two-dev || framework_failure_ +ln -s ///dev three-dev || framework_failure_ + +cat >exp <<EOF || framework_failure_ +/ +$double_slash +/ +/ +$double_slash +/ +/ +$double_slash +/ +/ +$double_slash +/ +/dev +${double_slash}dev +/dev +/dev +${double_slash}dev +/dev +/dev +${double_slash}dev +/dev +EOF + +{ + readlink -e / || fail=1 + readlink -e // || fail=1 + readlink -e /// || fail=1 + readlink -e /.//.. || fail=1 + readlink -e //.//.. || fail=1 + readlink -e ///.//.. || fail=1 + readlink -e one || fail=1 + readlink -e two || fail=1 + readlink -e three || fail=1 + readlink -e one-dots || fail=1 + readlink -e two-dots || fail=1 + readlink -e three-dots || fail=1 + readlink -e one-dev || fail=1 + # We know /dev exists, but cannot assume //dev exists + readlink -f two-dev || fail=1 + readlink -e three-dev || fail=1 + readlink -e one/dev || fail=1 + readlink -f two/dev || fail=1 + readlink -e three/dev || fail=1 + readlink -e one-dots/dev || fail=1 + readlink -f two-dots/dev || fail=1 + readlink -e three-dots/dev || fail=1 +} > out + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/readlink/rl-1.sh b/tests/readlink/rl-1.sh new file mode 100755 index 0000000..3bdb033 --- /dev/null +++ b/tests/readlink/rl-1.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# test for readlink mode. + +# Copyright (C) 2004-2023 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ readlink + +mkdir subdir || framework_failure_ +touch regfile || framework_failure_ +ln -s regfile link1 || framework_failure_ +ln -s missing link2 || framework_failure_ + + +v=$(readlink link1) || fail=1 +test "$v" = regfile || fail=1 + +v=$(readlink link2) || fail=1 +test "$v" = missing || fail=1 + +v=$(returns_ 1 readlink subdir) || fail=1 +test -z "$v" || fail=1 + +v=$(returns_ 1 readlink regfile) || fail=1 +test -z "$v" || fail=1 + +v=$(returns_ 1 readlink missing) || fail=1 +test -z "$v" || fail=1 + +Exit $fail |