1#!/bin/sh
2# Test various cases for moving directories across file systems
3
4# Copyright (C) 2000-2023 Free Software Foundation, Inc.
5
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <https://www.gnu.org/licenses/>.
18
19. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20print_ver_ mv
21cleanup_() { rm -rf "$other_partition_tmpdir"; }
22. "$abs_srcdir/tests/other-fs-tmpdir"
23
24
25# Moving a directory specified with a trailing slash from one partition to
26# another, and giving it a different name at the destination would cause mv
27# to get a failed assertion.
28mkdir foo || framework_failure_
29mv foo/ "$other_partition_tmpdir/bar" || fail=1
30
31
32# Moving a non directory from source shouldn't replace empty dir in dest
33touch bar || framework_failure_
34returns_ 1 mv bar "$other_partition_tmpdir/" || fail=1
35
36
37# Moving a directory from source shouldn't replace non directory in dest
38mkdir bar2
39touch "$other_partition_tmpdir/bar2"
40returns_ 1 mv bar2 "$other_partition_tmpdir/" || fail=1
41
42
43# As per POSIX moving directory from source should replace empty dir in dest
44mkdir bar3
45touch bar3/file
46mkdir "$other_partition_tmpdir/bar3"
47mv bar3 "$other_partition_tmpdir/" || fail=1
48test -e "$other_partition_tmpdir/bar3/file" || fail=1
49
50
51# As per POSIX moving directory from source shouldn't update dir in dest
52mkdir bar3
53touch bar3/file2
54returns_ 1 mv bar3 "$other_partition_tmpdir/" || fail=1
55test -e "$other_partition_tmpdir/bar3/file2" && fail=1
56
57Exit $fail
58