build: prepare to enable -Werror also for gnulib-tests/
[coreutils/ericb.git] / tests / mv / mv-special-1
blob35bdc84c6813cbf0173a4e0d6c9046ab22b69875
1 #! /bin/sh
2 # Test "mv" with special files.
4 # Copyright (C) 1998-2000, 2002, 2004-2010 Free Software Foundation, Inc.
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.
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.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 if test "$VERBOSE" = yes; then
20 set -x
21 mv --version
24 . $srcdir/test-lib.sh
25 cleanup_() { rm -rf "$other_partition_tmpdir"; }
26 . "$abs_srcdir/other-fs-tmpdir"
28 null=mv-null
29 dir=mv-dir
31 rm -f $null || framework_failure
32 mknod $null p || framework_failure
33 test -p $null || framework_failure
34 mkdir -p $dir/a/b/c $dir/d/e/f || framework_failure
35 touch $dir/a/b/c/file1 $dir/d/e/f/file2 || framework_failure
37 # We used to...
38 # exit 77 here to indicate that we couldn't run the test.
39 # At least running on SunOS 4.1.4, using a directory NFS mounted
40 # from an OpenBSD system, the above mknod fails.
41 # It's not worth making an exception any more.
43 mv --verbose $null $dir "$other_partition_tmpdir" > out || fail=1
44 # Make sure the files are gone.
45 test -p $null && fail=1
46 test -d $dir && fail=1
47 # Make sure they were moved.
48 test -p "$other_partition_tmpdir/$null" || fail=1
49 test -d "$other_partition_tmpdir/$dir/a/b/c" || fail=1
51 # POSIX says rename (A, B) can succeed if A and B are on different file systems,
52 # so ignore chatter about when files are removed and copied rather than renamed.
53 sed "
54 /^removed /d
55 s,$other_partition_tmpdir,XXX,
56 " out | sort > out2
58 cat <<EOF | sort > exp
59 \`$null' -> \`XXX/$null'
60 \`$dir' -> \`XXX/$dir'
61 \`$dir/a' -> \`XXX/$dir/a'
62 \`$dir/a/b' -> \`XXX/$dir/a/b'
63 \`$dir/a/b/c' -> \`XXX/$dir/a/b/c'
64 \`$dir/a/b/c/file1' -> \`XXX/$dir/a/b/c/file1'
65 \`$dir/d' -> \`XXX/$dir/d'
66 \`$dir/d/e' -> \`XXX/$dir/d/e'
67 \`$dir/d/e/f' -> \`XXX/$dir/d/e/f'
68 \`$dir/d/e/f/file2' -> \`XXX/$dir/d/e/f/file2'
69 EOF
71 compare out2 exp || fail=1
73 # cd "$other_partition_tmpdir"
74 # ls -l -A -R "$other_partition_tmpdir"
76 Exit $fail