]> gitweb.michael.orlitzky.com - apply-default-acl.git/commitdiff
Add a test suite.
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 14 Aug 2012 20:34:37 +0000 (16:34 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 14 Aug 2012 20:34:37 +0000 (16:34 -0400)
run-tests.sh [new file with mode: 0755]

diff --git a/run-tests.sh b/run-tests.sh
new file mode 100755 (executable)
index 0000000..7f6838f
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+# Our exit code.
+RESULT=0
+
+# The directory where we'll do all the ACL manipulation.
+TESTDIR=test
+
+acl_reset() {
+    # Remove any ACLs on our test directory and remove its contents.
+    setfacl --remove-all --recursive "$TESTDIR"
+    rm "${TESTDIR}"/*
+}
+
+compare() {
+    if [[ "${ACTUAL}" == "${EXPECTED}" ]]; then
+       echo "Success."
+    else
+       echo "Failure."
+       echo "Expected result:"
+       echo "${EXPECTED}"
+       echo "Actual result:"
+       echo "${ACTUAL}"
+       RESULT=1
+    fi
+}
+
+# Start by removing and recreating the 'acl' directory.
+rm -rf "${TESTDIR}"
+mkdir "${TESTDIR}"
+
+
+# When using a minimal ACL, the default user, group, and other
+# permissions should all be propagated to the mode bits.
+
+TARGET="${TESTDIR}"/foo
+touch "${TARGET}"
+chmod 777 "${TARGET}"
+setfacl -d -m user::r-- "${TESTDIR}"
+setfacl -d -m group::r-- "${TESTDIR}"
+setfacl -d -m other::r-- "${TESTDIR}"
+
+./aclq "${TARGET}"
+
+EXPECTED=$(cat <<EOF
+user::r--
+group::r--
+other::r--
+
+EOF
+)
+
+ACTUAL=`getfacl --omit-header "${TARGET}"`
+compare