summaryrefslogtreecommitdiff
path: root/tests/cp/cp-mv-backup
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cp/cp-mv-backup')
-rwxr-xr-xtests/cp/cp-mv-backup117
1 files changed, 117 insertions, 0 deletions
diff --git a/tests/cp/cp-mv-backup b/tests/cp/cp-mv-backup
new file mode 100755
index 0000000..cfbee41
--- /dev/null
+++ b/tests/cp/cp-mv-backup
@@ -0,0 +1,117 @@
+#!/bin/sh
+# Test basic --backup functionality for both cp and mv.
+
+# Copyright (C) 1999, 2000, 2002, 2004, 2006 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ cp --version
+fi
+
+# Ensure that ls sorts the same way for everyone.
+. $srcdir/../lang-default
+
+. $srcdir/../envvar-check
+
+umask 022
+
+# Be careful to close $actual before removing the containing directory.
+# Use `1>&2' rather than `1<&-' since the latter appears not to work
+# with /bin/sh from powerpc-ibm-aix4.2.0.0.
+
+pwd=`pwd`
+t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
+trap 'status=$?; cd "$pwd" && exec 1>&2; rm -rf $t0 && exit $status' 0
+trap '(exit $?); exit' 1 2 13 15
+
+framework_failure=0
+mkdir -p $tmp || framework_failure=1
+cd $tmp || framework_failure=1
+
+if test $framework_failure = 1; then
+ echo "$0: failure in testing framework" 1>&2
+ (exit 1); exit 1
+fi
+
+actual=actual
+expected=expected
+
+exec 1> $actual
+
+fail=0
+for prog in cp mv; do
+ for initial_files in 'x' 'x y' 'x y y~' 'x y y.~1~' 'x y y~ y.~1~'; do
+ for opt in none off numbered t existing nil simple never; do
+ touch $initial_files
+ $prog --backup=$opt x y || fail=1
+ echo $initial_files $opt: `ls [xy]*`; rm -f x y y~ y.~?~
+ done
+ done
+done
+
+cat <<\EOF > $expected-tmp
+x none: x y
+x off: x y
+x numbered: x y
+x t: x y
+x existing: x y
+x nil: x y
+x simple: x y
+x never: x y
+x y none: x y
+x y off: x y
+x y numbered: x y y.~1~
+x y t: x y y.~1~
+x y existing: x y y~
+x y nil: x y y~
+x y simple: x y y~
+x y never: x y y~
+x y y~ none: x y y~
+x y y~ off: x y y~
+x y y~ numbered: x y y.~1~ y~
+x y y~ t: x y y.~1~ y~
+x y y~ existing: x y y~
+x y y~ nil: x y y~
+x y y~ simple: x y y~
+x y y~ never: x y y~
+x y y.~1~ none: x y y.~1~
+x y y.~1~ off: x y y.~1~
+x y y.~1~ numbered: x y y.~1~ y.~2~
+x y y.~1~ t: x y y.~1~ y.~2~
+x y y.~1~ existing: x y y.~1~ y.~2~
+x y y.~1~ nil: x y y.~1~ y.~2~
+x y y.~1~ simple: x y y.~1~ y~
+x y y.~1~ never: x y y.~1~ y~
+x y y~ y.~1~ none: x y y.~1~ y~
+x y y~ y.~1~ off: x y y.~1~ y~
+x y y~ y.~1~ numbered: x y y.~1~ y.~2~ y~
+x y y~ y.~1~ t: x y y.~1~ y.~2~ y~
+x y y~ y.~1~ existing: x y y.~1~ y.~2~ y~
+x y y~ y.~1~ nil: x y y.~1~ y.~2~ y~
+x y y~ y.~1~ simple: x y y.~1~ y~
+x y y~ y.~1~ never: x y y.~1~ y~
+EOF
+
+sed 's/: x/:/' $expected-tmp |cat $expected-tmp - > $expected
+
+cmp $expected $actual || fail=1
+
+# Uncomment this if you see a failure and want to try to diagnose it.
+test $fail = 1 && diff -c $expected $actual 1>&2
+
+(exit $fail); exit $fail