]> gitweb.michael.orlitzky.com - apply-default-acl.git/blob - run-tests.sh
Add a test suite.
[apply-default-acl.git] / run-tests.sh
1 #!/bin/bash
2
3 # Our exit code.
4 RESULT=0
5
6 # The directory where we'll do all the ACL manipulation.
7 TESTDIR=test
8
9 acl_reset() {
10 # Remove any ACLs on our test directory and remove its contents.
11 setfacl --remove-all --recursive "$TESTDIR"
12 rm "${TESTDIR}"/*
13 }
14
15 compare() {
16 if [[ "${ACTUAL}" == "${EXPECTED}" ]]; then
17 echo "Success."
18 else
19 echo "Failure."
20 echo "Expected result:"
21 echo "${EXPECTED}"
22 echo "Actual result:"
23 echo "${ACTUAL}"
24 RESULT=1
25 fi
26 }
27
28 # Start by removing and recreating the 'acl' directory.
29 rm -rf "${TESTDIR}"
30 mkdir "${TESTDIR}"
31
32
33 # When using a minimal ACL, the default user, group, and other
34 # permissions should all be propagated to the mode bits.
35
36 TARGET="${TESTDIR}"/foo
37 touch "${TARGET}"
38 chmod 777 "${TARGET}"
39 setfacl -d -m user::r-- "${TESTDIR}"
40 setfacl -d -m group::r-- "${TESTDIR}"
41 setfacl -d -m other::r-- "${TESTDIR}"
42
43 ./aclq "${TARGET}"
44
45 EXPECTED=$(cat <<EOF
46 user::r--
47 group::r--
48 other::r--
49
50 EOF
51 )
52
53 ACTUAL=`getfacl --omit-header "${TARGET}"`
54 compare