summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1998-06-27 20:10:29 +0000
committerJim Meyering <jim@meyering.net>1998-06-27 20:10:29 +0000
commit162f6824cfe95d73cadafe3194fa93bc508eb717 (patch)
tree14665964dc09e32e1a4c9a9ee721e27a6c25d1c8 /tests
parentfeccdc6c584bdecb93ac5b47818b0dd3af75bedb (diff)
downloadcoreutils-162f6824cfe95d73cadafe3194fa93bc508eb717.tar.xz
*** empty log message ***
Diffstat (limited to 'tests')
-rwxr-xr-xtests/cp/new72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/cp/new b/tests/cp/new
new file mode 100755
index 000000000..5e06f22b8
--- /dev/null
+++ b/tests/cp/new
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+LANGUAGE=C; export LANGUAGE
+LANG=C; export LANG
+
+VERSION_CONTROL=numbered; export VERSION_CONTROL
+
+pwd=`pwd`
+PATH=$pwd/../../src:$PATH
+
+actual=actual-$$
+expected=expected-$$
+trap "cd $pwd; rm -rf $actual $expected dir" 0 1 2 3 15
+
+exec 1> $actual
+
+contents=XYZ
+for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2'; do
+ for options in '' -b -bd -bdf; do
+ rm -rf dir
+ mkdir dir
+ cd dir
+ echo $contents > foo
+ case "$args" in *symlink*) ln -s foo symlink ;; esac
+ case "$args" in *sl1*) ln -s foo sl1;; esac
+ case "$args" in *sl2*) ln -s foo sl2;; esac
+ (
+ (
+ cp $options $args 2>.err
+ echo $?
+ test -s .err && echo "[`cat .err`]"
+ # Strip off all but the file names.
+ ls -lG * | sed 's/^..............................................//'
+ for f in $args; do
+ if test -f $f; then
+ # make sure the file was copied.
+ case "`cat $f`" in
+ "$contents") ;;
+ *) echo cp FAILED;;
+ esac
+ else
+ echo symlink-loop
+ fi
+ done
+ ) | tr '\012' ' '
+ echo
+ ) | sed 's/ *$//'
+ cd ..
+ done
+ echo
+done
+
+cat <<\EOF > $expected
+1 [cp: `foo' and `symlink' are the same file] foo symlink -> foo
+0 foo symlink symlink.~1~ -> foo
+0 foo symlink symlink.~1~ -> foo
+0 foo symlink symlink.~1~ -> foo
+
+1 [cp: `symlink' and `foo' are the same file] foo symlink -> foo
+1 [cp: `symlink' and `foo' are the same file] foo symlink -> foo
+0 foo -> foo foo.~1~ symlink -> foo symlink-loop symlink-loop
+0 foo -> foo foo.~1~ symlink -> foo symlink-loop symlink-loop
+
+1 [cp: `foo' and `foo' are the same file] foo symlink -> foo
+1 [cp: `foo' and `foo' are the same file] foo symlink -> foo
+1 [cp: `foo' and `foo' are the same file] foo symlink -> foo
+0 foo foo.~1~ symlink -> foo
+
+EOF
+
+cat $actual 1>&2
+cmp $expected $actual