From: Michael Orlitzky Date: Wed, 28 Mar 2018 03:55:33 +0000 (-0400) Subject: run-tests.sh: use auto-incrementing test numbers. X-Git-Tag: v0.4.0~7 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=940d3a24319ed7fd67ae0f400add78af4e37b1c7;p=apply-default-acl.git run-tests.sh: use auto-incrementing test numbers. --- diff --git a/run-tests.sh b/run-tests.sh index 7873932..923c19c 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -37,6 +37,9 @@ BIN=$(realpath src/apply-default-acl) # The directory where we'll do all the ACL manipulation. TESTDIR=test +# Will auto-increment. +TESTNUM=0 + acl_reset() { # Remove any ACLs on our test directory and remove its contents. setfacl --remove-all --recursive "${TESTDIR}" @@ -69,7 +72,7 @@ mkdir "${TESTDIR}" # When using a minimal ACL, the default user, group, and other # permissions should all be propagated to the mode bits. -TESTNUM=1 +((TESTNUM++)) TARGET="${TESTDIR}"/foo touch "${TARGET}" chmod 777 "${TARGET}" @@ -90,7 +93,7 @@ ACTUAL=$(getfacl --omit-header "${TARGET}") compare # Do the same thing as the last test, except with an extended ACL. -TESTNUM=2 +((TESTNUM++)) setfacl -d -m user::r-- "${TESTDIR}" setfacl -d -m group::r-- "${TESTDIR}" setfacl -d -m other::r-- "${TESTDIR}" @@ -115,7 +118,7 @@ compare # A file shared by a group, should still be group-writable # afterwards. -TESTNUM=3 +((TESTNUM++)) touch "${TARGET}" chmod 644 "${TARGET}" setfacl -d -m group:${USERS[0]}:rwx "${TESTDIR}" @@ -136,7 +139,7 @@ compare # Same test as before except with a directory. -TESTNUM=4 +((TESTNUM++)) setfacl -d -m group:${USERS[0]}:rwx "${TESTDIR}" mkdir "${TARGET}" chmod 755 "${TARGET}" @@ -162,7 +165,7 @@ compare # With no default, things are left alone. -TESTNUM=5 +((TESTNUM++)) touch "${TARGET}" chmod 744 "${TARGET}" $BIN "${TARGET}" @@ -183,7 +186,7 @@ compare # Since the default ACL will grant r-x to group/other, they will wind # up with it. -TESTNUM=6 +((TESTNUM++)) touch "${TARGET}" chmod 744 "${TARGET}" setfacl -d -m user:${USERS[0]}:rwx "${TESTDIR}" @@ -206,7 +209,7 @@ compare # Some named entries can be granted execute permissions as the result # of reapplication. -TESTNUM=7 +((TESTNUM++)) touch "${TARGET}" chmod 744 "${TARGET}" setfacl -m user:${USERS[1]}:rw "${TARGET}" @@ -235,7 +238,7 @@ compare # We should not retain any entries that aren't in the default. -TESTNUM=8 +((TESTNUM++)) touch "${TARGET}" chmod 644 "${TARGET}" setfacl -m user:${USERS[1]}:rw "${TARGET}" @@ -257,7 +260,7 @@ compare # A slightly modified test #1 to make sure it works right. -TESTNUM=9 +((TESTNUM++)) TARGET="${TESTDIR}"/foo touch "${TARGET}" chmod 777 "${TARGET}" @@ -278,7 +281,7 @@ compare # If the default ACL mask denies execute, we should respect that # regardless of the existing execute permissions. -TESTNUM=10 +((TESTNUM++)) TARGET="${TESTDIR}"/foo touch "${TARGET}" chmod 777 "${TARGET}" @@ -304,7 +307,7 @@ compare # The --recursive mode should work normally if the argument is a # normal file. See Test #1. -TESTNUM=11 +((TESTNUM++)) TARGET="${TESTDIR}"/foo setfacl -d -m user::r-- "${TESTDIR}" setfacl -d -m group::r-- "${TESTDIR}" @@ -326,7 +329,7 @@ compare # The --recursive mode should work recursively. -TESTNUM=12 +((TESTNUM++)) TARGET="${TESTDIR}"/foo mkdir -p "${TARGET}" touch "${TARGET}"/baz @@ -352,7 +355,7 @@ compare # The --recursive mode should work recursively. This time # check a directory, and pass the short command-line flag. -TESTNUM=13 +((TESTNUM++)) TARGET="${TESTDIR}"/foo mkdir -p "${TARGET}" touch "${TARGET}"/baz @@ -381,7 +384,7 @@ compare # Test double application on a directory. # -TESTNUM=14 +((TESTNUM++)) TARGET="${TESTDIR}"/baz mkdir "${TARGET}" chmod 644 "${TARGET}" @@ -411,7 +414,7 @@ compare # Same as previous test, with 755 initial perms. # -TESTNUM=15 +((TESTNUM++)) TARGET="${TESTDIR}"/baz mkdir "${TARGET}" chmod 755 "${TARGET}" @@ -441,7 +444,7 @@ compare # Same as previous two tests, only with a file. # -TESTNUM=16 +((TESTNUM++)) TARGET="${TESTDIR}"/foo touch "${TARGET}" chmod 644 "${TARGET}" @@ -464,7 +467,7 @@ compare # User-executable files should not wind up exec-masked. -TESTNUM=17 +((TESTNUM++)) TARGET="${TESTDIR}"/foo touch "${TARGET}" chmod 700 "${TARGET}" @@ -486,7 +489,7 @@ compare # Group-executable files should not wind up exec-masked. -TESTNUM=18 +((TESTNUM++)) TARGET="${TESTDIR}"/foo touch "${TARGET}" chmod 670 "${TARGET}" @@ -508,7 +511,7 @@ compare # Other-executable files should not wind up exec-masked. -TESTNUM=19 +((TESTNUM++)) TARGET="${TESTDIR}"/foo touch "${TARGET}" chmod 607 "${TARGET}" @@ -532,7 +535,7 @@ compare # Test #16's setup repeated with the --no-exec-mask flag. # -TESTNUM=20 +((TESTNUM++)) TARGET="${TESTDIR}"/foo touch "${TARGET}" chmod 644 "${TARGET}" @@ -559,7 +562,7 @@ compare # Test #20 repeated recursively to make sure the flags play nice # together. -TESTNUM=21 +((TESTNUM++)) PARENT_DIR="${TESTDIR}"/foo TARGET="${PARENT_DIR}"/bar mkdir "${PARENT_DIR}" @@ -585,7 +588,7 @@ compare # Make sure a mask with an execute bit doesn't count as being # executable. # -TESTNUM=22 +((TESTNUM++)) TARGET="${TESTDIR}"/foo touch "${TARGET}" chmod 644 "${TARGET}" @@ -612,7 +615,7 @@ compare # Same as test #2, except we pass multiple files on the command # line and check the result of the first one. -TESTNUM=23 +((TESTNUM++)) setfacl -d -m user::r-- "${TESTDIR}" setfacl -d -m group::r-- "${TESTDIR}" setfacl -d -m other::r-- "${TESTDIR}" @@ -640,7 +643,7 @@ compare # Same as the previous test with the argument order switched. -TESTNUM=24 +((TESTNUM++)) setfacl -d -m user::r-- "${TESTDIR}" setfacl -d -m group::r-- "${TESTDIR}" setfacl -d -m other::r-- "${TESTDIR}" @@ -668,20 +671,20 @@ compare # If we call apply-default-acl on a single file that does not exist, # we get the expected error. -TESTNUM=25 +((TESTNUM++)) ACTUAL=$( "${BIN}" test/nonexistent 2>&1 ) EXPECTED="test/nonexistent: No such file or directory" compare # Same as the previous test, but with --recursive. -TESTNUM=26 +((TESTNUM++)) ACTUAL=$( "${BIN}" --recursive test/nonexistent 2>&1 ) EXPECTED="test/nonexistent: No such file or directory" compare # If we call apply-default-acl on more than one file, it should report any # that don't exist (but proceed to operate on the others). -TESTNUM=27 +((TESTNUM++)) DUMMY1="${TESTDIR}/dummy1" DUMMY2="${TESTDIR}/dummy2" touch "${DUMMY1}" "${DUMMY2}" @@ -691,7 +694,7 @@ compare # Ensure that symlinks are not followed. -TESTNUM=28 +((TESTNUM++)) TARGET="${TESTDIR}/foo" LINK2TARGET="${TESTDIR}/foo-sym" touch "${TARGET}" @@ -711,7 +714,7 @@ compare # Ensure that symlinks are not followed in subdirectories # (recursively). -TESTNUM=29 +((TESTNUM++)) TARGET="${TESTDIR}/bar" touch "${TARGET}" mkdir "${TESTDIR}/foo" @@ -725,7 +728,7 @@ compare # Ensure that hard links are ignored. -TESTNUM=30 +((TESTNUM++)) TARGET="${TESTDIR}/foo" LINK2TARGET="${TESTDIR}/bar" touch "${TARGET}" @@ -746,7 +749,7 @@ compare # We should be able to run the tool with a relative path from within a # directory that contains a symlink, so long as the relative path # doesn't contain one. -TESTNUM=31 +((TESTNUM++)) TARGET="${TESTDIR}/foo/bar" LINK2TARGET="${TESTDIR}/baz" mkdir -p $(dirname "${TARGET}") @@ -770,7 +773,7 @@ compare # Ensure that symlinks in non-terminal path components are not followed. -TESTNUM=32 +((TESTNUM++)) TARGET="${TESTDIR}/foo/bar/baz" LINK2FOO="${TESTDIR}/quux" mkdir -p $(dirname "${TARGET}") @@ -784,7 +787,7 @@ compare # Test that our exit code succeeds on a single, normal path. -TESTNUM=33 +((TESTNUM++)) TARGET="${TESTDIR}/foo" touch "${TARGET}" setfacl --default --modify user:${USERS[0]}:rw "${TESTDIR}" @@ -795,7 +798,7 @@ compare # Test that our exit code fails on a symlink. -TESTNUM=34 +((TESTNUM++)) TARGET="${TESTDIR}/bar" touch "${TESTDIR}/foo" ln -s foo "${TARGET}" @@ -807,7 +810,7 @@ compare # The previous test should fail, even if we use --recursive. -TESTNUM=35 +((TESTNUM++)) TARGET="${TESTDIR}/bar" touch "${TESTDIR}/foo" ln -s foo "${TARGET}" @@ -819,7 +822,7 @@ compare # Test the return value for nonexistent paths. -TESTNUM=36 +((TESTNUM++)) TARGET="${TESTDIR}/foo" "${BIN}" "${TARGET}" &>/dev/null ACTUAL="$?" @@ -830,7 +833,7 @@ compare # Test that one "failure" exit code overrides two "successes" # We need a default ACL on ${TESTDIR} because otherwise we do # nothing, successfully, on the symlink path. -TESTNUM=37 +((TESTNUM++)) mkdir "${TESTDIR}/foo" ln -s foo "${TESTDIR}/bar" mkdir "${TESTDIR}/baz" @@ -842,7 +845,7 @@ compare # The failure should prevail when using --recursive, too. -TESTNUM=38 +((TESTNUM++)) mkdir "${TESTDIR}/foo" ln -s foo "${TESTDIR}/bar" mkdir "${TESTDIR}/baz" @@ -854,7 +857,7 @@ compare # We should get "Not a directory" if we stick a trailing slash on the # end of the path to a file. -TESTNUM=39 +((TESTNUM++)) TARGET="${TESTDIR}/foo" touch "${TARGET}" ACTUAL=$( "${BIN}" "${TARGET}/" 2>&1 ) @@ -864,7 +867,7 @@ compare # We should be a no-op on files contained in directories that have no # default ACL. -TESTNUM=40 +((TESTNUM++)) TARGET="${TESTDIR}/foo" touch "${TARGET}" setfacl --modify user:${USERS[0]}:rw "${TARGET}" @@ -876,7 +879,7 @@ compare # We should be a no-op on directories contained in directories that # have no default ACL (same as the previous test, but with a directory). -TESTNUM=41 +((TESTNUM++)) TARGET="${TESTDIR}/foo" mkdir "${TARGET}" setfacl --modify user:${USERS[0]}:rw "${TARGET}" @@ -888,7 +891,7 @@ compare # Make sure we descend into subdirectories that don't have default ACLs. -TESTNUM=42 +((TESTNUM++)) TARGET="${TESTDIR}/foo/bar/baz" mkdir -p $(dirname "${TARGET}") touch "${TARGET}" @@ -903,7 +906,7 @@ compare # Ensure that we don't get "error" results for symlinks encountered # during a recursive traversal. -TESTNUM=43 +((TESTNUM++)) TARGET="${TESTDIR}" mkdir "${TARGET}/foo" mkdir "${TARGET}/bar"