From 994c3c82ef1e9a2291e3c1d765ee6aa4cfeeb64f Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 27 Jun 1998 20:20:25 +0000 Subject: [PATCH] . --- tests/cp/same-file | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 tests/cp/same-file diff --git a/tests/cp/same-file b/tests/cp/same-file new file mode 100755 index 0000000..32f1260 --- /dev/null +++ b/tests/cp/same-file @@ -0,0 +1,76 @@ +#!/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 -d -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 +1 [cp: `foo' and `foo' are the same file] foo +1 [cp: `foo' and `foo' are the same file] foo +0 foo foo.~1~ + +1 [cp: `sl1' and `sl2' are the same file] foo sl1 -> foo sl2 -> foo +0 foo sl1 -> foo sl2 sl2.~1~ -> foo +0 foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo +0 foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo + +EOF + +cmp $expected $actual || cat $actual 1>&2 -- 2.7.4