| #!/bin/sh |
| |
|
|
| |
|
|
| |
| |
| |
| |
|
|
| |
| |
| |
| |
|
|
| |
| |
|
|
| . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src |
| print_ver_ realpath |
|
|
| 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 |
| nl=' |
| ' |
|
|
| test -d /dev || framework_failure_ |
|
|
| |
|
|
| mkdir -p dir1/dir2 || framework_failure_ |
| ln -s dir1/dir2 ldir2 || framework_failure_ |
| touch dir1/f dir1/dir2/f || framework_failure_ |
| ln -s / one || framework_failure_ |
| ln -s // two || framework_failure_ |
| ln -s /// three || framework_failure_ |
|
|
| |
| realpath -Pqz . >/dev/null || fail=1 |
| |
| returns_ 1 realpath >/dev/null || fail=1 |
| returns_ 1 realpath --relative-base . --relative-to . || fail=1 |
| returns_ 1 realpath --relative-base . || fail=1 |
|
|
| |
| returns_ 1 realpath -e --relative-to=dir1/f --relative-base=. . || fail=1 |
| realpath -e --relative-to=dir1/ --relative-base=. . || fail=1 |
|
|
| |
| realpath -e -E --relative-to=dir1/f --relative-base=. . || fail=1 |
|
|
| |
| returns_ 1 realpath -m '' || fail=1 |
| returns_ 1 realpath --relative-base= --relative-to=. . || fail=1 |
|
|
| |
| this=$(realpath .) |
| test "$(realpath ldir2/..)" = "$this/dir1" || fail=1 |
| test "$(realpath -L ldir2/..)" = "$this" || fail=1 |
| test "$(realpath -s ldir2)" = "$this/ldir2" || fail=1 |
|
|
| |
| test $(realpath -m --relative-to=prefix prefixed/1) = '../prefixed/1' || fail=1 |
| test $(realpath -m --relative-to=prefixed prefix/1) = '../prefix/1' || fail=1 |
| test $(realpath -m --relative-to=prefixed prefixed/1) = '1' || fail=1 |
|
|
| |
| test $(realpath -sm --relative-to=/usr /) = '..' || fail=1 |
| |
| test $(realpath -sm --relative-to=/ /usr) = 'usr' || fail=1 |
|
|
| |
| out=$(realpath -sm --relative-base=/usr --relative-to=/usr /tmp /usr) || fail=1 |
| test "$out" = "/tmp$nl." || fail=1 |
| out=$(realpath -sm --relative-base=/ --relative-to=/ / /usr) || fail=1 |
| test "$out" = ".${nl}usr" || fail=1 |
| |
| out=$(realpath -sm --relative-base=/usr /tmp /usr) || fail=1 |
| test "$out" = "/tmp$nl." || fail=1 |
| out=$(realpath -sm --relative-base=/ / /usr) || fail=1 |
| test "$out" = ".${nl}usr" || fail=1 |
| |
| |
| out=$(realpath -sm --relative-base=/usr/local --relative-to=/usr \ |
| /usr /usr/local) || fail=1 |
| test "$out" = "/usr${nl}/usr/local" || fail=1 |
|
|
| |
| test "$(realpath / // ///)" = "/$nl$double_slash$nl/" || fail=1 |
| test "$(realpath one two three)" = "/$nl$double_slash$nl/" || fail=1 |
| out=$(realpath -sm --relative-to=/ / // /dev //dev) || fail=1 |
| if test $double_slash = //; then |
| test "$out" = ".$nl//${nl}dev$nl//dev" || fail=1 |
| else |
| test "$out" = ".$nl.${nl}dev${nl}dev" || fail=1 |
| fi |
| out=$(realpath -sm --relative-to=// / // /dev //dev) || fail=1 |
| if test $double_slash = //; then |
| test "$out" = "/$nl.$nl/dev${nl}dev" || fail=1 |
| else |
| test "$out" = ".$nl.${nl}dev${nl}dev" || fail=1 |
| fi |
| out=$(realpath --relative-base=/ --relative-to=// / //) || fail=1 |
| if test $double_slash = //; then |
| test "$out" = "/$nl//" || fail=1 |
| else |
| test "$out" = ".$nl." || fail=1 |
| fi |
|
|
| Exit $fail |
|
|