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

« back to all changes in this revision

Viewing changes to tests/cp/cp-mv-backup.sh

  • 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
# Test basic --backup functionality for both cp and mv.
 
3
 
 
4
# Copyright (C) 1999-2012 Free Software Foundation, Inc.
 
5
 
 
6
# This program is free software: you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation, either version 3 of the License, or
 
9
# (at your option) any later version.
 
10
 
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
 
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 
 
19
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 
20
print_ver_ cp
 
21
 
 
22
umask 022
 
23
 
 
24
# Be careful to close $actual before removing the containing directory.
 
25
# Use '1>&2' rather than '1<&-' since the latter appears not to work
 
26
# with /bin/sh from powerpc-ibm-aix4.2.0.0.
 
27
 
 
28
actual=actual
 
29
expected=expected
 
30
 
 
31
exec 3>&1 1> $actual
 
32
 
 
33
for prog in cp mv; do
 
34
  for initial_files in 'x' 'x y' 'x y y~' 'x y y.~1~' 'x y y~ y.~1~'; do
 
35
    for opt in none off  numbered t  existing nil  simple never; do
 
36
      touch $initial_files
 
37
        $prog --backup=$opt x y || fail=1
 
38
      echo $initial_files $opt: $(ls [xy]*); rm -f x y y~ y.~?~
 
39
    done
 
40
  done
 
41
done
 
42
 
 
43
cat <<\EOF > $expected-tmp
 
44
x none: x y
 
45
x off: x y
 
46
x numbered: x y
 
47
x t: x y
 
48
x existing: x y
 
49
x nil: x y
 
50
x simple: x y
 
51
x never: x y
 
52
x y none: x y
 
53
x y off: x y
 
54
x y numbered: x y y.~1~
 
55
x y t: x y y.~1~
 
56
x y existing: x y y~
 
57
x y nil: x y y~
 
58
x y simple: x y y~
 
59
x y never: x y y~
 
60
x y y~ none: x y y~
 
61
x y y~ off: x y y~
 
62
x y y~ numbered: x y y.~1~ y~
 
63
x y y~ t: x y y.~1~ y~
 
64
x y y~ existing: x y y~
 
65
x y y~ nil: x y y~
 
66
x y y~ simple: x y y~
 
67
x y y~ never: x y y~
 
68
x y y.~1~ none: x y y.~1~
 
69
x y y.~1~ off: x y y.~1~
 
70
x y y.~1~ numbered: x y y.~1~ y.~2~
 
71
x y y.~1~ t: x y y.~1~ y.~2~
 
72
x y y.~1~ existing: x y y.~1~ y.~2~
 
73
x y y.~1~ nil: x y y.~1~ y.~2~
 
74
x y y.~1~ simple: x y y.~1~ y~
 
75
x y y.~1~ never: x y y.~1~ y~
 
76
x y y~ y.~1~ none: x y y.~1~ y~
 
77
x y y~ y.~1~ off: x y y.~1~ y~
 
78
x y y~ y.~1~ numbered: x y y.~1~ y.~2~ y~
 
79
x y y~ y.~1~ t: x y y.~1~ y.~2~ y~
 
80
x y y~ y.~1~ existing: x y y.~1~ y.~2~ y~
 
81
x y y~ y.~1~ nil: x y y.~1~ y.~2~ y~
 
82
x y y~ y.~1~ simple: x y y.~1~ y~
 
83
x y y~ y.~1~ never: x y y.~1~ y~
 
84
EOF
 
85
 
 
86
sed 's/: x/:/' $expected-tmp |cat $expected-tmp - > $expected
 
87
 
 
88
exec 1>&3 3>&-
 
89
 
 
90
compare $expected $actual || fail=1
 
91
 
 
92
Exit $fail