From 4e313c0b2ad1c2464ce0394b32e70abd5380d48e Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 14 Aug 2012 16:34:37 -0400 Subject: [PATCH] Add a test suite. --- run-tests.sh | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 run-tests.sh 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 <