can-e.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/bin/sh
  2. # tests for canonicalize-existing mode (readlink -e).
  3. # Copyright (C) 2004-2018 Free Software Foundation, Inc.
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
  15. print_ver_ readlink pwd
  16. pwd=$(pwd)
  17. my_pwd=$(env pwd -P)
  18. tmp=d
  19. mkdir $tmp || framework_failure_
  20. cd $tmp || framework_failure_
  21. mkdir subdir removed || framework_failure_
  22. touch regfile || framework_failure_
  23. ln -s regfile link1 || framework_failure_
  24. ln -s subdir link2 || framework_failure_
  25. ln -s missing link3 || framework_failure_
  26. ln -s subdir/missing link4 || framework_failure_
  27. cd "$pwd/$tmp/removed" || framework_failure_
  28. # Skip this test if the system doesn't let you remove the working directory.
  29. if rmdir ../removed 2>/dev/null; then
  30. v=$(returns_ 1 readlink -e .) || fail=1
  31. test -z "$v" || fail=1
  32. fi
  33. cd "$pwd/$tmp" || fail=1
  34. for p in "" "$pwd/$tmp/"; do
  35. v=$(readlink -e "${p}regfile") || fail=1
  36. test "$v" = "$my_pwd/$tmp/regfile" || fail=1
  37. v=$(returns_ 1 readlink -e "${p}./regfile/") || fail=1
  38. test -z "$v" || fail=1
  39. v=$(readlink -e "${p}subdir") || fail=1
  40. test "$v" = "$my_pwd/$tmp/subdir" || fail=1
  41. v=$(readlink -e "${p}./subdir/") || fail=1
  42. test "$v" = "$my_pwd/$tmp/subdir" || fail=1
  43. v=$(returns_ 1 readlink -e "${p}missing") || fail=1
  44. test -z "$v" || fail=1
  45. v=$(returns_ 1 readlink -e "${p}./missing/") || fail=1
  46. test -z "$v" || fail=1
  47. v=$(readlink -e "${p}link1") || fail=1
  48. test "$v" = "$my_pwd/$tmp/regfile" || fail=1
  49. v=$(returns_ 1 readlink -e "${p}./link1/") || fail=1
  50. test -z "$v" || fail=1
  51. v=$(returns_ 1 readlink -e "${p}link1/more") || fail=1
  52. test -z "$v" || fail=1
  53. v=$(readlink -e "${p}link2") || fail=1
  54. test "$v" = "$my_pwd/$tmp/subdir" || fail=1
  55. v=$(readlink -e "${p}./link2/") || fail=1
  56. test "$v" = "$my_pwd/$tmp/subdir" || fail=1
  57. v=$(returns_ 1 readlink -e "${p}link2/more") || fail=1
  58. test -z "$v" || fail=1
  59. v=$(returns_ 1 readlink -e "${p}link3") || fail=1
  60. test -z "$v" || fail=1
  61. v=$(returns_ 1 readlink -e "${p}./link3/") || fail=1
  62. test -z "$v" || fail=1
  63. v=$(returns_ 1 readlink -e "${p}link3/more") || fail=1
  64. test -z "$v" || fail=1
  65. v=$(returns_ 1 readlink -e "${p}link4") || fail=1
  66. test -z "$v" || fail=1
  67. v=$(returns_ 1 readlink -e "${p}./link4/") || fail=1
  68. test -z "$v" || fail=1
  69. v=$(returns_ 1 readlink -e "${p}link4/more") || fail=1
  70. test -z "$v" || fail=1
  71. done
  72. Exit $fail