mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Merge 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> MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1140 Approved-by: John Johansen <john@jjmx.net> Merged-by: John Johansen <john@jjmx.net>
This commit is contained in:
commit
253eace573
2 changed files with 37 additions and 36 deletions
|
@ -300,46 +300,48 @@ 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
|
||||
;;
|
||||
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//'`
|
||||
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}"
|
||||
testresult=pass
|
||||
failurereason=""
|
||||
while IFS= read -r line; do
|
||||
case "$line" in
|
||||
PASS) ;;
|
||||
FAIL*) testresult=fail
|
||||
failurereason=". Reason for failure '${line}'"
|
||||
break
|
||||
;;
|
||||
SIGNAL*) killedsig=`echo $line | 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
|
||||
return
|
||||
fi
|
||||
;;
|
||||
*) echo "Error: ${testname} failed. Test '${_testdesc}' was expected to '${_pfmode}'${_known}. Reason for failure 'killed by signal ${killedsig}'"
|
||||
testfailed
|
||||
return
|
||||
fi
|
||||
;;
|
||||
*) echo "Error: ${testname} failed. Test '${_testdesc}' was expected to '${_pfmode}'${_known}. Reason for failure 'killed by signal ${killedsig}'"
|
||||
testfailed
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*) testerror
|
||||
return
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*) testerror
|
||||
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
|
||||
|
||||
|
|
|
@ -100,7 +100,6 @@ sleep 1
|
|||
rm -f ${socket}
|
||||
|
||||
# PASS - confined -> confined
|
||||
echo "PASS-----------------------------------------"
|
||||
genprofile $file:$okperm $af_unix $socket:rw $fd_client:px -- image=$fd_client $file:$okperm $af_unix $socket:rw
|
||||
runchecktest "fd passing; confined -> confined" pass $file $fd_client $socket
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue