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:
@@ -300,46 +300,48 @@ checktestfg()
|
|||||||
|
|
||||||
ret=`cat $outfile 2>/dev/null`
|
ret=`cat $outfile 2>/dev/null`
|
||||||
teststatus=pass
|
teststatus=pass
|
||||||
|
testresult=pass
|
||||||
case "$ret" in
|
failurereason=""
|
||||||
PASS) if [ "$_pfmode" != "pass" -a -z "${_known}" ]
|
while IFS= read -r line; do
|
||||||
then
|
case "$line" in
|
||||||
echo "Error: ${testname} passed. Test '${_testdesc}' was expected to '${_pfmode}'"
|
PASS) ;;
|
||||||
testfailed
|
FAIL*) testresult=fail
|
||||||
return
|
failurereason=". Reason for failure '${line}'"
|
||||||
elif [ "$_pfmode" == "pass" -a -n "${_known}" ]
|
break
|
||||||
then
|
;;
|
||||||
echo "Alert: ${testname} passed. Test '${_testdesc}' was marked as expected pass but known problem (xpass)"
|
SIGNAL*) killedsig=`echo $line | sed 's/SIGNAL//'`
|
||||||
fi
|
case "$_pfmode" in
|
||||||
;;
|
signal*) expectedsig=`echo ${_pfmode} | sed 's/signal//'`
|
||||||
FAIL*) if [ "$_pfmode" != "fail" -a -z "${_known}" ]
|
if [ -n "${expectedsig}" -a ${expectedsig} != ${killedsig} ]
|
||||||
then
|
then
|
||||||
echo "Error: ${testname} failed. Test '${_testdesc}' was expected to '${_pfmode}'. Reason for failure '${ret}'"
|
echo "Error: ${testname} failed. Test '${_testdesc}' was expected to terminate with signal ${expectedsig}${_known}. Instead it terminated with signal ${killedsig}"
|
||||||
testfailed
|
testfailed
|
||||||
return
|
return
|
||||||
elif [ "$_pfmode" == "fail" -a -n "${_known}" ]
|
fi
|
||||||
then
|
;;
|
||||||
echo "Alert: ${testname} failed. Test '${_testdesc}' was marked as expected fail but known problem (xfail)."
|
*) echo "Error: ${testname} failed. Test '${_testdesc}' was expected to '${_pfmode}'${_known}. Reason for failure 'killed by signal ${killedsig}'"
|
||||||
fi
|
|
||||||
;;
|
|
||||||
SIGNAL*) killedsig=`echo $ret | sed 's/SIGNAL//'`
|
|
||||||
case "$_pfmode" in
|
|
||||||
signal*) expectedsig=`echo ${_pfmode} | sed 's/signal//'`
|
|
||||||
if [ -n "${expectedsig}" -a ${expectedsig} != ${killedsig} ]
|
|
||||||
then
|
|
||||||
echo "Error: ${testname} failed. Test '${_testdesc}' was expected to terminate with signal ${expectedsig}${_known}. Instead it terminated with signal ${killedsig}"
|
|
||||||
testfailed
|
testfailed
|
||||||
return
|
return
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*) testerror
|
||||||
|
return
|
||||||
;;
|
;;
|
||||||
*) echo "Error: ${testname} failed. Test '${_testdesc}' was expected to '${_pfmode}'${_known}. Reason for failure 'killed by signal ${killedsig}'"
|
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
|
testfailed
|
||||||
return
|
return
|
||||||
;;
|
elif [ "$_pfmode" == "$testresult" -a -n "${_known}" ]
|
||||||
esac
|
then
|
||||||
;;
|
echo "Alert: ${testname} ${testresult}ed. Test '${_testdesc}' was marked as expected $_pfmode but known problem (x$_pfmode)"
|
||||||
*) testerror
|
fi
|
||||||
return
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user