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

« back to all changes in this revision

Viewing changes to tests/mv/childproof

  • 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 cp/mv/ln don't clobber a just-copied/moved/linked file.
3
 
# With fileutils-4.1 and earlier, this test would fail for cp and mv.
4
 
# With coreutils-6.9 and earlier, this test would fail for ln.
5
 
 
6
 
# Copyright (C) 2001, 2004, 2006-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 ln
23
 
 
24
 
skip_if_root_
25
 
 
26
 
mkdir a b c || framework_failure_
27
 
echo a > a/f || framework_failure_
28
 
echo b > b/f || framework_failure_
29
 
 
30
 
 
31
 
cp a/f b/f c 2> /dev/null && fail=1
32
 
test -f a/f || fail=1
33
 
test -f b/f || fail=1
34
 
test -f c/f || fail=1
35
 
test "`cat c/f`" = a || fail=1
36
 
rm -f c/f
37
 
 
38
 
# With --backup=numbered, it should succeed
39
 
cp --backup=numbered a/f b/f c || fail=1
40
 
test -f a/f || fail=1
41
 
test -f b/f || fail=1
42
 
test -f c/f || fail=1
43
 
test -f c/f.~1~ || fail=1
44
 
rm -f c/f*
45
 
 
46
 
mv a/f b/f c 2> /dev/null && fail=1
47
 
test -f a/f && fail=1
48
 
test -f b/f || fail=1
49
 
test -f c/f || fail=1
50
 
test "`cat c/f`" = a || fail=1
51
 
 
52
 
# Make sure mv still works when moving hard links.
53
 
# This is where the same_file test is necessary, and why
54
 
# we save file names in addition to dev/ino.
55
 
rm -f c/f* b/f
56
 
touch a/f
57
 
ln a/f b/g
58
 
mv a/f b/g c || fail=1
59
 
test -f a/f && fail=1
60
 
test -f b/g && fail=1
61
 
test -f c/f || fail=1
62
 
test -f c/g || fail=1
63
 
 
64
 
touch a/f b/f b/g
65
 
mv a/f b/f b/g c 2> /dev/null && fail=1
66
 
test -f a/f && fail=1  # a/f should have been moved
67
 
test -f b/f || fail=1  # b/f should remain
68
 
test -f b/g && fail=1  # b/g should have been moved
69
 
test -f c/f || fail=1
70
 
test -f c/g || fail=1
71
 
 
72
 
# Test ln -f.
73
 
 
74
 
rm -f a/f b/f c/f
75
 
echo a > a/f || fail=1
76
 
echo b > b/f || fail=1
77
 
ln -f a/f b/f c 2> /dev/null && fail=1
78
 
# a/f and c/f must be linked
79
 
test `stat --format %i a/f` = `stat --format %i c/f` || fail=1
80
 
# b/f and c/f must not be linked
81
 
test `stat --format %i b/f` = `stat --format %i c/f` && fail=1
82
 
 
83
 
Exit $fail