Tizen 2.0 Release
[external/tizen-coreutils.git] / tests / mv / acl
1 #!/bin/sh
2 # move files/directories across file system boundaries
3 # and make sure acls are preserved
4
5 # Copyright (C) 2005, 2006 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 . $srcdir/../acl
23 . $srcdir/../other-fs-tmpdir
24 # Make sure we get English translations.
25 . $srcdir/../lang-default
26
27 # Skip this test if cp was built without ACL support:
28 grep '^#define USE_ACL 0' $CONFIG_HEADER > /dev/null && \
29   {
30     echo 1>&2 "$0: insufficient ACL support, so skipping this test"
31     (exit 77); exit 77
32   }
33
34 if test "$VERBOSE" = yes; then
35   set -x
36   mv --version
37   getfacl --version
38   setfacl --version
39 fi
40
41 if test -z "$other_partition_tmpdir"; then
42   (exit 77); exit 77
43 fi
44
45 pwd=`pwd`
46 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
47 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
48 trap '(exit $?); exit $?' 1 2 13 15
49
50 t0="$t0 $other_partition_tmpdir"
51
52 framework_failure=0
53 mkdir -p $tmp || framework_failure=1
54 cd $tmp || framework_failure=1
55
56 touch file || framework_failure=1
57 t1=$other_partition_tmpdir/t1
58 touch $t1 || framework_failure=1
59
60 if test $framework_failure = 1; then
61   echo 'failure in testing framework'
62   (exit 1); exit 1
63 fi
64
65 skip=no
66 # Ensure that setfacl and getfacl work on this file system.
67 setfacl -m user:bin:rw file 2> /dev/null || skip=.
68 # And on the destination file system.
69 setfacl -m user:bin:rw $t1 || skip=$other_partition_tmpdir
70 acl1=`getfacl file` || skip=yes
71
72 test $skip != no &&
73   {
74     echo "$0: '$skip' is not on a suitable file system for this test" 1>&2
75     echo "$0: skipping this test" 1>&2
76     (exit 77); exit 77
77   }
78
79 # move the access acl of a file
80 mv file $other_partition_tmpdir || fail=1
81 acl2=`cd $other_partition_tmpdir && getfacl file` || framework_failure=1
82 test "$acl1" = "$acl2" || fail=1
83
84 # move the access acl of a directory
85 mkdir dir || framework_failure=1
86 setfacl -m user:bin:rw dir || framework_failure=1
87 acl1=`getfacl dir` || framework_failure=1
88 mv dir $other_partition_tmpdir || fail=1
89 acl2=`cd $other_partition_tmpdir && getfacl dir` || framework_failure=1
90 test "$acl1" = "$acl2" || fail=1
91
92 # move the default acl of a directory
93 mkdir dir2 || framework_failure=1
94 setfacl -d -m user:bin:rw dir2 || framework_failure=1
95 acl1=`getfacl dir2` || framework_failure=1
96 mv dir2 $other_partition_tmpdir || fail=1
97 acl2=`cd $other_partition_tmpdir && getfacl dir2` || framework_failure=1
98 test "$acl1" = "$acl2" || fail=1
99
100 if test $framework_failure = 1; then
101   echo 'failure in testing framework'
102   (exit 1); exit 1
103 fi
104
105 exit $fail