summaryrefslogtreecommitdiff
path: root/tests/cp/perm
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-08-12 13:23:18 +0000
committerJim Meyering <jim@meyering.net>2000-08-12 13:23:18 +0000
commit00874a5dad347989536d4f31e1034dff68e82483 (patch)
tree02ee0b67ee350a246f4c5e3ea718cdb7069746d1 /tests/cp/perm
parent52f183032939e2be70796d9d882c0fff58e8557a (diff)
downloadcoreutils-00874a5dad347989536d4f31e1034dff68e82483.tar.xz
*** empty log message ***
Diffstat (limited to 'tests/cp/perm')
-rwxr-xr-xtests/cp/perm65
1 files changed, 43 insertions, 22 deletions
diff --git a/tests/cp/perm b/tests/cp/perm
index b87c8fa5a..4bc3cddbc 100755
--- a/tests/cp/perm
+++ b/tests/cp/perm
@@ -1,6 +1,14 @@
#!/bin/sh
# Make sure the permission-preserving code in copy.c (mv, cp, install) works.
+if test "$VERBOSE" = yes; then
+ set -x
+ cp --version
+ mv --version
+fi
+
+. $srcdir/../envvar-check
+
pwd=`pwd`
tmp=perm.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
@@ -10,8 +18,7 @@ framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
-touch f || framework_failure=1
-chmod u=r,go= f || framework_failure=1
+umask 037
if test $framework_failure = 1; then
echo 'failure in testing framework'
@@ -20,25 +27,39 @@ fi
fail=0
-cp -p f f2 || fail=1
-
-# Permissions on f2 must be `-r--------'
-
-set X `ls -l f2`
-shift
-test "$1" = -r-------- || fail=1
-chmod u+w,g=rwx f2 || fail=1
-
-# Again, but with an existing target.
-cp -p f f2 || fail=1
-set X `ls -l f2`
-shift
-test "$1" = -r-------- || fail=1
-
-# Again, but with an existing target, and this time with `-f'.
-cp -p -f f f2 || fail=1
-set X `ls -l f2`
-shift
-test "$1" = -r-------- || fail=1
+# Now, try it with `mv', with combinations of --force, no-f and
+# existing-destination and not.
+for cmd in mv 'cp -p' cp; do
+ for force in '' -f; do
+ for existing_dest in yes no; do
+ for g_perm in r w x rw wx xr rwx; do
+ for o_perm in r w x rw wx xr rwx; do
+ touch src || exit 1
+ chmod u=r,go= src || exit 1
+ rm -f dest
+ test $existing_dest = yes && {
+ touch dest || exit 1
+ chmod u=rw,g=$g_perm,o=$o_perm dest || exit 1
+ }
+ $cmd $force src dest || exit 1
+ test "$cmd" = mv && test -f src && exit 1
+ test "$cmd" = cp && { test -f src || exit 1; }
+ set X `ls -l dest`
+ shift
+ case "$cmd:$force:$existing_dest" in
+ cp::yes)
+ _g_perm=`echo rwx|sed 's/[^'$g_perm']/-/g'`
+ _o_perm=`echo rwx|sed 's/[^'$o_perm']/-/g'`
+ expected_perms=-rw-$_g_perm$_o_perm;;
+ *) expected_perms=-r--------;;
+ esac
+ test x$1 = x$expected_perms || exit 1
+ # Perform only one iteration when there's no existing destination.
+ test $existing_dest = no && break 3
+ done
+ done
+ done
+ done
+done
(exit $fail); exit