From: Michael Orlitzky Date: Tue, 14 Aug 2012 20:34:37 +0000 (-0400) Subject: Add a test suite. X-Git-Tag: v0.0.1~17 X-Git-Url: https://gitweb.michael.orlitzky.com/?p=apply-default-acl.git;a=commitdiff_plain;h=4e313c0b2ad1c2464ce0394b32e70abd5380d48e Add a test suite. --- diff --git a/run-tests.sh b/run-tests.sh new file mode 100755 index 0000000..7f6838f --- /dev/null +++ b/run-tests.sh @@ -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 <