aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2021-01-07 15:24:35 -0800
committerRob Landley <rob@landley.net>2021-01-08 17:27:57 -0600
commit661130b38cbf74056430e4b280512369dfcd9fe9 (patch)
treec121c97cf0febbaec9b5032bab3e8053ee9f8b7d
parentb6b5becf359370c7f32d8419bcf8f50a47fbe933 (diff)
downloadtoybox-661130b38cbf74056430e4b280512369dfcd9fe9.tar.gz
chmod.test: fix the tests to work on mksh as well as bash.
mksh doesn't support the {a..b} bashism or the ${!name} bashism, causing the tests to fail on Android. This works for me on both mksh and bash (both tested on Debian).
-rwxr-xr-xtests/chmod.test18
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/chmod.test b/tests/chmod.test
index 9adca60f..cd4f8100 100755
--- a/tests/chmod.test
+++ b/tests/chmod.test
@@ -24,16 +24,20 @@ mkdir dir
touch file
# We don't need to test all 512 permissions
-file=- dir=d DOfile=touch DOdir=mkdir
-unset touch mkdir d
-for U in {0..7}; do for G in 0 3 6; do for O in 0 7; do for T in dir file; do
+for U in $(seq 0 7); do for G in 0 3 6; do for O in 0 7; do for T in dir file; do
chmod 777 $T 2>/dev/null
- X=DO$T
- rm -rf $T && ${!X} $T
+ rm -rf $T
+ if [ "$T" == file ]; then
+ touch file
+ C=-
+ else
+ mkdir dir
+ C=d
+ fi
testing "$U$G$O $T" "chmod $U$G$O $T && ls -ld $T | cut -d' ' -f 1" \
- "${!T}$(num2perm $U$G$O)\n" "" ""
+ "${C}$(num2perm $U$G$O)\n" "" ""
done; done; done; done
-unset U G O T X
+unset U G O T C
rm -rf dir file && mkdir dir && touch file 640
testing "750 dir 640 file" "chmod 750 dir 640 file &&