Tizen 2.0 Release
[external/tizen-coreutils.git] / tests / mv / to-symlink
1 #!/bin/sh
2 # Make sure that the copying code used in an inter-partition
3 # move unlinks a destination symlink before opening it.
4
5 # Copyright (C) 1999, 2000 Free Software Foundation, Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
21
22 if test "$VERBOSE" = yes; then
23   set -x
24   mv --version
25 fi
26
27 . $srcdir/../other-fs-tmpdir
28 . $srcdir/../envvar-check
29
30 if test -z "$other_partition_tmpdir"; then
31   exit 77
32 fi
33
34 rem_file="$other_partition_tmpdir/file"
35 rem_symlink="$other_partition_tmpdir/symlink"
36 file=to-sym-$$
37
38 fail=0
39
40 trap 'rm -fr $file $other_partition_tmpdir; exit $fail' 0 1 2 3 15
41
42 framework_failure=0
43 rm -f $file || framework_failure=1
44 echo local > $file || framework_failure=1
45 echo remote > $rem_file || framework_failure=1
46 ln -s $rem_file $rem_symlink || framework_failure=1
47
48 if test $framework_failure = 1; then
49   echo 'failure in testing framework'
50   exit 1
51 fi
52
53 # This mv command should succeed, unlinking the symlink
54 # before copying.
55 mv $file $rem_symlink || fail=1
56
57 # Make sure $file is gone.
58 test -f $file && fail=1
59
60 # Make sure $rem_file is unmodified.
61 test `cat $rem_file` = remote || fail=1
62
63 exit $fail