mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 13:58:22 +00:00
tests: parse result of multiple lines in output
There are some tests like attach_disconnected and posix_mq that can have a program that calls another. For example, posix_mq_rcv calls posix_mq_snd. Both of them write to the same output file, but the code that checks the result expects only one line. This change enables checking multiple lines in the output file and passing or failing accordingly. Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
This commit is contained in:
parent
c8a2dc34d9
commit
dc73f0fc0b
@ -300,29 +300,16 @@ checktestfg()
|
||||
|
||||
ret=`cat $outfile 2>/dev/null`
|
||||
teststatus=pass
|
||||
|
||||
case "$ret" in
|
||||
PASS) if [ "$_pfmode" != "pass" -a -z "${_known}" ]
|
||||
then
|
||||
echo "Error: ${testname} passed. Test '${_testdesc}' was expected to '${_pfmode}'"
|
||||
testfailed
|
||||
return
|
||||
elif [ "$_pfmode" == "pass" -a -n "${_known}" ]
|
||||
then
|
||||
echo "Alert: ${testname} passed. Test '${_testdesc}' was marked as expected pass but known problem (xpass)"
|
||||
fi
|
||||
testresult=pass
|
||||
failurereason=""
|
||||
while IFS= read -r line; do
|
||||
case "$line" in
|
||||
PASS) ;;
|
||||
FAIL*) testresult=fail
|
||||
failurereason=". Reason for failure '${line}'"
|
||||
break
|
||||
;;
|
||||
FAIL*) if [ "$_pfmode" != "fail" -a -z "${_known}" ]
|
||||
then
|
||||
echo "Error: ${testname} failed. Test '${_testdesc}' was expected to '${_pfmode}'. Reason for failure '${ret}'"
|
||||
testfailed
|
||||
return
|
||||
elif [ "$_pfmode" == "fail" -a -n "${_known}" ]
|
||||
then
|
||||
echo "Alert: ${testname} failed. Test '${_testdesc}' was marked as expected fail but known problem (xfail)."
|
||||
fi
|
||||
;;
|
||||
SIGNAL*) killedsig=`echo $ret | sed 's/SIGNAL//'`
|
||||
SIGNAL*) killedsig=`echo $line | sed 's/SIGNAL//'`
|
||||
case "$_pfmode" in
|
||||
signal*) expectedsig=`echo ${_pfmode} | sed 's/signal//'`
|
||||
if [ -n "${expectedsig}" -a ${expectedsig} != ${killedsig} ]
|
||||
@ -342,6 +329,21 @@ checktestfg()
|
||||
return
|
||||
;;
|
||||
esac
|
||||
done <<< "$ret"
|
||||
|
||||
case "$_pfmode" in
|
||||
signal*) ;;
|
||||
*) if [ "$_pfmode" != "$testresult" -a -z "${_known}" ]
|
||||
then
|
||||
echo "Error: ${testname} ${testresult}ed. Test '${_testdesc}' was expected to '${_pfmode}'$failurereason"
|
||||
testfailed
|
||||
return
|
||||
elif [ "$_pfmode" == "$testresult" -a -n "${_known}" ]
|
||||
then
|
||||
echo "Alert: ${testname} ${testresult}ed. Test '${_testdesc}' was marked as expected $_pfmode but known problem (x$_pfmode)"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $# -gt 0 ]
|
||||
then
|
||||
|
Loading…
x
Reference in New Issue
Block a user