aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-11-25 16:02:31 -0600
committerRob Landley <rob@landley.net>2020-11-25 16:02:31 -0600
commit5109da9b3e6a898c8e0ad647303a1b375e3d97d3 (patch)
tree9c5e062735fd069b0b014de23d728314b0b4d74e /tests
parente3ce0338d4c4d60052b6f9f92175218cf6cf97c8 (diff)
downloadtoybox-5109da9b3e6a898c8e0ad647303a1b375e3d97d3.tar.gz
Luke Frankart pointed out a typo (0x111 should be 0111). Fix and update
tests to catch this. While there add -k to test sticky bit.
Diffstat (limited to 'tests')
-rw-r--r--tests/test.test27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/test.test b/tests/test.test
index 7f574f08..1295be41 100644
--- a/tests/test.test
+++ b/tests/test.test
@@ -42,7 +42,32 @@ testing "! -e" 'type_test ! -e' "n" "" ""
rm f L s p
rmdir d
-# TODO: Test rwx gu t
+# test -rwx each bit position and failure
+touch walrus
+MASK=111
+for i in x w r k g u; do
+ [ $i == k ] && MASK=1000
+ # test everything off produces "off"
+ chmod 000 walrus
+ testcmd "-$i 0" "-$i walrus || echo yes" "yes\n" "" ""
+ chmod $((7777-$MASK)) walrus
+ testcmd "-$i inverted" "-$i walrus || echo yes" "yes\n" "" ""
+ MASK=$(($MASK<<1))
+done
+unset MASK
+# Test setuid setgid sticky enabled
+for i in uu+s gg+s k+t; do
+ chmod 000 walrus
+ chmod ${i:1}+s walrus
+ testcmd "-${i:0:1}" "-${i:0:1} walrus && echo yes" "yes\n" "" ""
+done
+# test each ugo+rwx bit position individually
+for i in 1 10 100; do for j in x w r; do
+ chmod $i walrus
+ testcmd "-$j $i" "-$j walrus && echo yes" "yes\n" "" ""
+ i=$((i<<1))
+done; done
+rm -f walrus
testcmd "" "'' || echo yes" "yes\n" "" ""
testcmd "" "a && echo yes" "yes\n" "" ""