Tizen 2.0 Release
[external/tizen-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 # Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
8
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 # 02110-1301, USA.
23
24 if test "$VERBOSE" = yes; then
25   set -x
26   mv --version
27 fi
28
29 . $srcdir/../other-fs-tmpdir
30 . $srcdir/../envvar-check
31
32 pwd=`pwd`
33 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
34 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
35 trap '(exit $?); exit' 1 2 13 15
36
37 if test -z "$other_partition_tmpdir"; then
38   (exit 77); exit 77
39 fi
40 t0="$t0 $other_partition_tmpdir"
41
42 framework_failure=0
43 mkdir -p $tmp || framework_failure=1
44 cd $tmp || framework_failure=1
45 touch f || framework_failure=1
46 ln f g || framework_failure=1
47 mkdir a b || framework_failure=1
48 touch a/1 || framework_failure=1
49 ln a/1 b/1 || framework_failure=1
50
51 if test $framework_failure = 1; then
52   echo "$0: failure in testing framework" 1>&2
53   (exit 1); exit 1
54 fi
55
56 fail=0
57
58 mv f g $other_partition_tmpdir || fail=1
59 mv a b $other_partition_tmpdir || fail=1
60
61 cd $other_partition_tmpdir
62 set `ls -Ci f g`
63 test $1 = $3 || fail=1
64 set `ls -Ci a/1 b/1`
65 test $1 = $3 || fail=1
66
67 (exit $fail); exit $fail