build: ensure sys/select.h is included
[coreutils.git] / tests / mv / mv-special-1.sh
blob964df44d2a095d8742cbf86354e86f728c4ee38f
1 #!/bin/sh
2 # Test "mv" with special files.
4 # Copyright (C) 1998-2019 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 <https://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ mv
21 cleanup_() { rm -rf "$other_partition_tmpdir"; }
22 . "$abs_srcdir/tests/other-fs-tmpdir"
24 null=mv-null
25 dir=mv-dir
27 rm -f $null || framework_failure_
28 mknod $null p || framework_failure_
29 test -p $null || framework_failure_
30 mkdir -p $dir/a/b/c $dir/d/e/f || framework_failure_
31 touch $dir/a/b/c/file1 $dir/d/e/f/file2 || framework_failure_
33 # We used to...
34 # exit 77 here to indicate that we couldn't run the test.
35 # At least running on SunOS 4.1.4, using a directory NFS mounted
36 # from an OpenBSD system, the above mknod fails.
37 # It's not worth making an exception any more.
39 mv --verbose $null $dir "$other_partition_tmpdir" > out || fail=1
40 # Make sure the files are gone.
41 test -p $null && fail=1
42 test -d $dir && fail=1
43 # Make sure they were moved.
44 test -p "$other_partition_tmpdir/$null" || fail=1
45 test -d "$other_partition_tmpdir/$dir/a/b/c" || fail=1
47 # POSIX says rename (A, B) can succeed if A and B are on different file systems,
48 # so ignore chatter about when files are removed and copied rather than renamed.
49 sed "
50 /^removed /d
51 s,renamed ,,
52 s,copied ,,
53 s,$other_partition_tmpdir,XXX,
54 s,created directory 'XXX/\(.*\)','\1' -> 'XXX/\1',
55 " out | sort > out2
57 cat <<EOF | sort > exp
58 '$null' -> 'XXX/$null'
59 '$dir' -> 'XXX/$dir'
60 '$dir/a' -> 'XXX/$dir/a'
61 '$dir/a/b' -> 'XXX/$dir/a/b'
62 '$dir/a/b/c' -> 'XXX/$dir/a/b/c'
63 '$dir/a/b/c/file1' -> 'XXX/$dir/a/b/c/file1'
64 '$dir/d' -> 'XXX/$dir/d'
65 '$dir/d/e' -> 'XXX/$dir/d/e'
66 '$dir/d/e/f' -> 'XXX/$dir/d/e/f'
67 '$dir/d/e/f/file2' -> 'XXX/$dir/d/e/f/file2'
68 EOF
70 compare exp out2 || fail=1
72 # cd "$other_partition_tmpdir"
73 # ls -l -A -R "$other_partition_tmpdir"
75 Exit $fail