diff options
author | Elliott Hughes <enh@google.com> | 2019-06-25 14:23:48 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-06-26 18:36:37 -0500 |
commit | b75675297700e365cc8482b048ad9a7fc4946065 (patch) | |
tree | 105efbd4b8a5c57d008bd73b498b3aa3503b332c /tests | |
parent | 38e239f7c1bda5e4dbc0c37abecb806386b223ae (diff) | |
download | toybox-b75675297700e365cc8482b048ad9a7fc4946065.tar.gz |
Fix cp.test to pass even if you're root or have a restrictive umask.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/cp.test | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/cp.test b/tests/cp.test index 9ee6cd0e..6c798b4b 100755 --- a/tests/cp.test +++ b/tests/cp.test @@ -2,6 +2,9 @@ [ -f testing.sh ] && . testing.sh +OLDUMASK=$(umask) +umask 0002 + # Create test file dd if=/dev/urandom of=random bs=64 count=1 2> /dev/null @@ -35,17 +38,20 @@ rm -rf two three walrus touch two chmod 000 two -testing "file->inaccessable [fail]" \ +skipnot [ $(id -u) -ne 0 ] # Root doesn't count. +testing "file->inaccessible [fail]" \ "cp random two 2>/dev/null || echo yes" "yes\n" "" "" rm -f two touch two chmod 000 two -testing "-f file->inaccessable" \ +skipnot [ $(id -u) -ne 0 ] # Root doesn't count. +testing "-f file->inaccessible" \ "cp -f random two && cmp random two && echo yes" "yes\n" "" "" mkdir sub chmod 000 sub -testing "file->inaccessable_dir [fail]" \ +skipnot [ $(id -u) -ne 0 ] # Root doesn't count. +testing "file->inaccessible_dir [fail]" \ "cp random sub 2>/dev/null || echo yes" "yes\n" "" "" rm two rmdir sub @@ -101,9 +107,9 @@ rm -rf one one_ touch walrus chmod 644 walrus ln -s walrus woot - testing "symlink dest permissions" "cp woot carpenter && stat -c %A carpenter" \ "-rw-r--r--\n" "" "" +rm -rf walrus woot carpenter # cp -r ../source destdir # cp -r one/two/three missing @@ -114,3 +120,5 @@ testing "symlink dest permissions" "cp woot carpenter && stat -c %A carpenter" \ # Make sure it's truncating existing file # copy with -d at top level, with -d in directory, without -d at top level, # without -d in directory + +umask $OLDUMASK |