[apparmor] [patch 1/5] tests: add more details when reporting onexec failures
Tyler Hicks
tyhicks at canonical.com
Fri Mar 18 22:14:24 UTC 2016
On 2016-03-18 10:29:05, steve at nxnw.org wrote:
> Based on a patch by John Johansen <john.johansen at canonical.com>
>
> Add more details to the checks in the regression tests onexec tests, to
> make debugging failures easier. Also, use more local variables to
> indicate what and how many arguments are expected to the onexec check_*
> functions.
>
> Signed-off-by: Steve Beattie <steve at nxnw.org>
Acked-by: Tyler Hicks <tyhicks at canonical.com>
I have suggested some minor changes below. Feel free to roll them in
just before committing.
> ---
> tests/regression/apparmor/onexec.sh | 30 ++++++++++++++++++++----------
> 1 file changed, 20 insertions(+), 10 deletions(-)
>
> Index: b/tests/regression/apparmor/onexec.sh
> ===================================================================
> --- a/tests/regression/apparmor/onexec.sh
> +++ b/tests/regression/apparmor/onexec.sh
> @@ -37,19 +37,22 @@ check_exec()
> {
> local rc
> local actual
> - actual=`cat /proc/$1/attr/exec 2>/dev/null`
> + local desc="$1"
> + local pid="$2"
> + local expected="$3"
> + actual=`cat /proc/${pid}/attr/exec 2>/dev/null`
> rc=$?
>
> # /proc/$1/attr/exec returns invalid argument if onexec has not been called
> if [ $rc -ne 0 ] ; then
> - if [ "$2" == "nochange" ] ; then
> + if [ "${expected}" == "nochange" ] ; then
> return 0
> fi
> - echo "ONEXEC - exec transition not set"
> + echo "ONEXEC (${desc}) - exec transition not set"
> return $rc
> fi
> - if [ "${actual% (*)}" != "$2" ] ; then
> - echo "ONEXEC - check exec '${actual% (*)}' != expected '$2'"
> + if [ "${actual% (*)}" != "${expected}" ] ; then
> + echo "ONEXEC (${desc}) - check exec '${actual% (*)}' != expected '${expected}'"
> return 1
> fi
>
> @@ -60,16 +63,23 @@ check_current()
> {
> local rc
> local actual
> - actual=`cat /proc/$1/attr/current 2>/dev/null`
> + local desc="$1"
> + local pid="$2"
> + local expected="$3"
> + actual=`cat /proc/${pid}/attr/current 2>/dev/null`
> rc=$?
>
> # /proc/$1/attr/current return enoent if the onexec process already exited due to error
Change $1 to ${pid}
> if [ $rc -ne 0 ] ; then
> + # These assume a check has already be done to see if the task is still
> + # around
This comment has odd indenting and it needs:
s/has already be done/has already been done/
> + echo -n "ONEXEC - check current ($1): "
> + cat /proc/$2/attr/current
Change $2 to ${pid}
Tyler
> return $rc
> fi
>
> - if [ "${actual% (*)}" != "$2" ] ; then
> - echo "ONEXEC - check current '${actual% (*)}' != expected '$2'"
> + if [ "${actual% (*)}" != "${expected}" ] ; then
> + echo "ONEXEC - check current (${desc}) '${actual% (*)}' != expected '${expected}'"
> return 1
> fi
>
> @@ -93,12 +103,12 @@ do_test()
> # give the onexec process a chance to run
> sleep 0.05
>
> - if ! check_current $_pid $prof ; then
> + if ! check_current "${desc}" $_pid $prof ; then
> checktestfg
> return
> fi
>
> - if ! check_exec $_pid $target_prof ; then
> + if ! check_exec "${desc}" $_pid $target_prof ; then
> checktestfg
> return
> fi
>
>
> --
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20160318/fc9d376c/attachment-0001.pgp>
More information about the AppArmor
mailing list