aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-01-14 03:43:49 -0600
committerElliott Hughes <enh@google.com>2015-01-14 03:43:49 -0600
commit50d320777a47132f07eb4e6707b7247f8db8861a (patch)
treef57f9e9e11835e35fbfea5274ef34722c63134c3 /tests
parent698a160868dba71766a8607b72a07eaa63d74da4 (diff)
downloadtoybox-50d320777a47132f07eb4e6707b7247f8db8861a.tar.gz
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
new test: and here's the patch to fix "owner:" ":group" and the ":" special case:
Diffstat (limited to 'tests')
-rw-r--r--tests/chown.test41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/chown.test b/tests/chown.test
new file mode 100644
index 00000000..40ed7b5f
--- /dev/null
+++ b/tests/chown.test
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+if [ "$(id -u)" -ne 0 ]
+then
+ echo "SKIPPED: chown (not root)"
+ continue 2>/dev/null
+ exit
+fi
+
+# We chown between user "root" and the last user in /etc/passwd,
+# and group "root" and the last group in /etc/group.
+
+USR="$(sed -n '$s/:.*//p' /etc/passwd)"
+GRP="$(sed -n '$s/:.*//p' /etc/group)"
+
+# Set up a little testing hierarchy
+
+rm -rf testdir &&
+mkdir testdir &&
+touch testdir/file
+F=testdir/file
+
+# Wrapper to reset groups and return results
+
+OUT="&& echo \$(ls -l testdir/file | awk '{print \$3,\$4}')"
+
+#testing "name" "command" "result" "infile" "stdin"
+
+# Basic smoketest
+testing "chown initial" "chown root:root $F $OUT" "root root\n" "" ""
+testing "chown usr:grp" "chown $USR:$GRP $F $OUT" "$USR $GRP\n" "" ""
+testing "chown root" "chown root $F $OUT" "root $GRP\n" "" ""
+# TODO: can we test "owner:"?
+testing "chown :grp" "chown root:root $F && chown :$GRP $F $OUT" \
+ "root $GRP\n" "" ""
+testing "chown :" "chown $USR:$GRP $F && chown : $F $OUT" \
+ "$USR $GRP\n" "" ""
+
+rm -rf testdir