tests: factor 350 fail=0 initializations into test-lib.sh
[platform/upstream/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, 2007-2009 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 3 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, see <http://www.gnu.org/licenses/>.
19
20 if test "$VERBOSE" = yes; then
21   set -x
22   mv --version
23 fi
24
25 . $srcdir/test-lib.sh
26 cleanup_() { rm -rf "$other_partition_tmpdir"; }
27 . "$abs_srcdir/other-fs-tmpdir"
28
29 rem_file="$other_partition_tmpdir/file"
30 rem_symlink="$other_partition_tmpdir/symlink"
31 file=to-sym-$$
32
33
34 rm -f $file || framework_failure
35 echo local > $file || framework_failure
36 echo remote > $rem_file || framework_failure
37 ln -s $rem_file $rem_symlink || framework_failure
38
39 # This mv command should succeed, unlinking the symlink
40 # before copying.
41 mv $file $rem_symlink || fail=1
42
43 # Make sure $file is gone.
44 test -f $file && fail=1
45
46 # Make sure $rem_file is unmodified.
47 test `cat $rem_file` = remote || fail=1
48
49 Exit $fail