part-rename.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh
  2. # Test various cases for moving directories across file systems
  3. # Copyright (C) 2000-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_ mv
  16. cleanup_() { rm -rf "$other_partition_tmpdir"; }
  17. . "$abs_srcdir/tests/other-fs-tmpdir"
  18. # Moving a directory specified with a trailing slash from one partition to
  19. # another, and giving it a different name at the destination would cause mv
  20. # to get a failed assertion.
  21. mkdir foo || framework_failure_
  22. mv foo/ "$other_partition_tmpdir/bar" || fail=1
  23. # Moving a non directory from source shouldn't replace empty dir in dest
  24. touch bar || framework_failure_
  25. returns_ 1 mv bar "$other_partition_tmpdir/" || fail=1
  26. # Moving a directory from source shouldn't replace non directory in dest
  27. mkdir bar2
  28. touch "$other_partition_tmpdir/bar2"
  29. returns_ 1 mv bar2 "$other_partition_tmpdir/" || fail=1
  30. # As per POSIX moving directory from source should replace empty dir in dest
  31. mkdir bar3
  32. touch bar3/file
  33. mkdir "$other_partition_tmpdir/bar3"
  34. mv bar3 "$other_partition_tmpdir/" || fail=1
  35. test -e "$other_partition_tmpdir/bar3/file" || fail=1
  36. # As per POSIX moving directory from source shouldn't update dir in dest
  37. mkdir bar3
  38. touch bar3/file2
  39. returns_ 1 mv bar3 "$other_partition_tmpdir/" || fail=1
  40. test -e "$other_partition_tmpdir/bar3/file2" && fail=1
  41. Exit $fail