894d3562cc2848c2ff3cc0135eb5253a93e2660e
[platform/upstream/coreutils.git] / tests / mv / mv-special-1
1 #! /bin/sh
2
3 if test "$VERBOSE" = yes; then
4   set -x
5   mv --version
6 fi
7
8 pwd=`pwd`
9 tmp=mv-spec.$$
10 trap 'status=$?; cd $pwd; exec 1>&2; rm -rf $tmp $other_partition_tmpdir && exit $status' 0
11 trap '(exit $?); exit' 1 2 13 15
12
13 . $srcdir/setup
14 . $srcdir/../envvar-check
15 # Make sure we get English translations.
16 . $srcdir/../lang-default
17
18 if test -z "$other_partition_tmpdir"; then
19   (exit 77); exit 77
20 fi
21
22 null=mv-null
23 dir=mv-dir
24
25 framework_failure=0
26 mkdir $tmp || framework_failure=1
27 cd $tmp || framework_failure=1
28 rm -f $null || framework_failure=1
29 mknod $null p || framework_failure=1
30 test -p $null || framework_failure=1
31 mkdir -p $dir/a/b/c $dir/d/e/f || framework_failure=1
32 touch $dir/a/b/c/file1 $dir/d/e/f/file2 || framework_failure=1
33
34 if test $framework_failure = 1; then
35   echo '********************************************'
36   echo 'NOTICE: unable to create test prerequisites'
37   echo '********************************************'
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   (exit 77); exit 77
42 fi
43
44 fail=0
45 mv --verbose $null $dir $other_partition_tmpdir > out || fail=1
46 # Make sure the files are gone.
47 test -p $null && fail=1
48 test -d $dir && fail=1
49 # Make sure they were moved.
50 test -p $other_partition_tmpdir/$null || fail=1
51 test -d $other_partition_tmpdir/$dir/a/b/c || fail=1
52
53 # POSIX says rename (A, B) can succeed if A and B are on different file systems,
54 # so ignore chatter about when files are removed and copied rather than renamed.
55 sed "
56   /^removed /d
57   s,$other_partition_tmpdir,XXX,
58 " out | sort > out2
59
60 cat <<EOF | sort > exp
61 \`$null' -> \`XXX/$null'
62 \`$dir' -> \`XXX/$dir'
63 \`$dir/a' -> \`XXX/$dir/a'
64 \`$dir/a/b' -> \`XXX/$dir/a/b'
65 \`$dir/a/b/c' -> \`XXX/$dir/a/b/c'
66 \`$dir/a/b/c/file1' -> \`XXX/$dir/a/b/c/file1'
67 \`$dir/d' -> \`XXX/$dir/d'
68 \`$dir/d/e' -> \`XXX/$dir/d/e'
69 \`$dir/d/e/f' -> \`XXX/$dir/d/e/f'
70 \`$dir/d/e/f/file2' -> \`XXX/$dir/d/e/f/file2'
71 EOF
72
73 cmp out2 exp || fail=1
74
75 # cd $other_partition_tmpdir
76 # ls -l -A -R $other_partition_tmpdir
77
78 (exit $fail); exit $fail