dc845c94e0f82f8d134c46986ec9d7ca4abb6936
[platform/upstream/coreutils.git] / tests / mv / part-hardlink
1 #!/bin/sh
2 # Ensure that hard links are preserved when moving between partitions
3 # and when the links are in separate command line arguments.
4 # For additional constraints, see the comment in copy.c.
5 # Before coreutils-5.2.1, this test would fail.
6
7 if test "$VERBOSE" = yes; then
8   set -x
9   mv --version
10 fi
11
12 . $srcdir/setup
13 . $srcdir/../envvar-check
14
15 pwd=`pwd`
16 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
17 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
18 trap '(exit $?); exit' 1 2 13 15
19
20 if test -z "$other_partition_tmpdir"; then
21   (exit 77); exit 77
22 fi
23 t0="$t0 $other_partition_tmpdir"
24
25 framework_failure=0
26 mkdir -p $tmp || framework_failure=1
27 cd $tmp || framework_failure=1
28 touch f || framework_failure=1
29 ln f g || framework_failure=1
30 mkdir a b || framework_failure=1
31 touch a/1 || framework_failure=1
32 ln a/1 b/1 || framework_failure=1
33
34 if test $framework_failure = 1; then
35   echo "$0: failure in testing framework" 1>&2
36   (exit 1); exit 1
37 fi
38
39 fail=0
40
41 mv f g $other_partition_tmpdir || fail=1
42 mv a b $other_partition_tmpdir || fail=1
43
44 cd $other_partition_tmpdir
45 set `ls -Ci f g`
46 test $1 = $3 || fail=1
47 set `ls -Ci a/1 b/1`
48 test $1 = $3 || fail=1
49
50 (exit $fail); exit $fail