~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/cp/cp-mv-enotsup-xattr

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# Ensure that mv, cp -a and cp --preserve=xattr(all) options do work
3
 
# as expected on file system without their support and do show correct
4
 
# diagnostics when required
5
 
 
6
 
# Copyright (C) 2009-2011 Free Software Foundation, Inc.
7
 
 
8
 
# This program is free software: you can redistribute it and/or modify
9
 
# it under the terms of the GNU General Public License as published by
10
 
# the Free Software Foundation, either version 3 of the License, or
11
 
# (at your option) any later version.
12
 
 
13
 
# This program is distributed in the hope that it will be useful,
14
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
# GNU General Public License for more details.
17
 
 
18
 
# You should have received a copy of the GNU General Public License
19
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 
 
21
 
. "${srcdir=.}/init.sh"; path_prepend_ ../src
22
 
print_ver_ cp mv
23
 
 
24
 
require_root_
25
 
require_mkfs_PATH_
26
 
 
27
 
cwd=`pwd`
28
 
cleanup_() { cd /; umount "$cwd/noxattr"; umount "$cwd/xattr"; }
29
 
 
30
 
skip=0
31
 
 
32
 
# Mount an ext2 loopback file system at $WHERE with $OPTS
33
 
make_fs() {
34
 
  where="$1"
35
 
  opts="$2"
36
 
 
37
 
  fs="$where.bin"
38
 
 
39
 
  dd if=/dev/zero of="$fs" bs=8192 count=200 > /dev/null 2>&1 \
40
 
                                                 || skip=1
41
 
  mkdir "$where"                                 || skip=1
42
 
  mkfs -t ext2 -F "$fs" ||
43
 
    skip_ "failed to create ext2 file system"
44
 
  mount -oloop,$opts "$fs" "$where"              || skip=1
45
 
  echo test > "$where"/f                         || skip=1
46
 
  test -s "$where"/f                             || skip=1
47
 
 
48
 
  test $skip = 1 &&
49
 
    skip_ "insufficient mount/ext2 support"
50
 
}
51
 
 
52
 
make_fs noxattr nouser_xattr
53
 
make_fs xattr   user_xattr
54
 
 
55
 
# testing xattr name-value pair
56
 
xattr_name="user.foo"
57
 
xattr_value="bar"
58
 
xattr_pair="$xattr_name=\"$xattr_value\""
59
 
 
60
 
echo test > xattr/a || framework_failure_
61
 
getfattr -d xattr/a >out_a || skip_ "failed to get xattr of file"
62
 
grep -F "$xattr_pair" out_a >/dev/null && framework_failure_
63
 
setfattr -n "$xattr_name" -v "$xattr_value" xattr/a >out_a \
64
 
  || skip_ "failed to set xattr of file"
65
 
getfattr -d xattr/a >out_a || skip_ "failed to get xattr of file"
66
 
grep -F "$xattr_pair" out_a >/dev/null \
67
 
  || skip_ "failed to set xattr of file"
68
 
 
69
 
 
70
 
# This should pass without diagnostics
71
 
cp -a xattr/a noxattr/ 2>err || fail=1
72
 
test -s noxattr/a   || fail=1  # destination file must not be empty
73
 
test -s err         && fail=1  # there must be no stderr output
74
 
 
75
 
rm -f err noxattr/a
76
 
 
77
 
# This should pass without diagnostics (new file)
78
 
cp --preserve=all xattr/a noxattr/ 2>err || fail=1
79
 
test -s noxattr/a   || fail=1  # destination file must not be empty
80
 
test -s err         && fail=1  # there must be no stderr output
81
 
 
82
 
# This should pass without diagnostics (existing file)
83
 
cp --preserve=all xattr/a noxattr/ 2>err || fail=1
84
 
test -s noxattr/a   || fail=1  # destination file must not be empty
85
 
test -s err         && fail=1  # there must be no stderr output
86
 
 
87
 
rm -f err noxattr/a
88
 
 
89
 
# This should fail with coresponding diagnostics
90
 
cp -a --preserve=xattr xattr/a noxattr/ 2>err && fail=1
91
 
if grep '^#define USE_XATTR 1' $CONFIG_HEADER > /dev/null; then
92
 
cat <<\EOF > exp
93
 
cp: setting attributes for `noxattr/a': Operation not supported
94
 
EOF
95
 
else
96
 
cat <<\EOF > exp
97
 
cp: cannot preserve extended attributes, cp is built without xattr support
98
 
EOF
99
 
fi
100
 
 
101
 
compare err exp     || fail=1
102
 
 
103
 
rm -f err noxattr/a
104
 
 
105
 
# This should pass without diagnostics
106
 
mv xattr/a noxattr/ 2>err || fail=1
107
 
test -s noxattr/a         || fail=1  # destination file must not be empty
108
 
test -s err               && fail=1  # there must be no stderr output
109
 
 
110
 
Exit $fail