stat-failed.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh
  2. # Verify that ls works properly when it fails to stat a file that is
  3. # not mentioned on the command line.
  4. # Copyright (C) 2006-2018 Free Software Foundation, Inc.
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
  16. print_ver_ ls
  17. skip_if_root_
  18. LS_MINOR_PROBLEM=1
  19. mkdir d || framework_failure_
  20. ln -s / d/s || framework_failure_
  21. chmod 600 d || framework_failure_
  22. returns_ 1 ls -Log d > out || fail=1
  23. # Linux 2.6.32 client with Isilon OneFS always returns d_type==DT_DIR ('d')
  24. # Newer Linux 3.10.0 returns the more correct DT_UNKNOWN ('?')
  25. grep '^[l?]?' out || skip_ 'unrecognized d_type returned'
  26. cat <<\EOF > exp || framework_failure_
  27. total 0
  28. ?????????? ? ? ? s
  29. EOF
  30. sed 's/^l/?/' out | compare exp - || fail=1
  31. # Ensure that the offsets in --dired output are accurate.
  32. rm -f out exp
  33. returns_ $LS_MINOR_PROBLEM ls --dired -l d > out || fail=1
  34. cat <<\EOF > exp || framework_failure_
  35. total 0
  36. ?????????? ? ? ? ? ? s
  37. //DIRED// 44 45
  38. //DIRED-OPTIONS// --quoting-style=literal
  39. EOF
  40. sed 's/^ l/ ?/' out | compare exp - || fail=1
  41. Exit $fail