Parsing stderr should be enough, but check also 'cat' exit code
in case of error message change or other problem.

Signed-off-by: Petr Vorel <pvo...@suse.cz>
---
New in v2.

 testcases/kernel/security/integrity/ima/tests/ima_setup.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh 
b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
index 9732aa7b43..83fcefb4fc 100644
--- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
@@ -209,6 +209,7 @@ verify_ima_policy()
 load_ima_policy()
 {
        local file="$TST_DATAROOT/$REQUIRED_POLICY_CONTENT"
+       local ret
 
        if [ "$LTP_IMA_LOAD_POLICY" != 1 ]; then
                if [ "$IMA_MISSING_POLICY_CONTENT" = 1 ]; then
@@ -228,6 +229,7 @@ load_ima_policy()
        fi
 
        cat "$file" 2> log > $IMA_POLICY
+       ret=$?
        if grep -q "Device or resource busy" log; then
                tst_brk TBROK "loading policy failed"
        fi
@@ -236,6 +238,10 @@ load_ima_policy()
                tst_brk TCONF "loading unsigned policy failed"
        fi
 
+       if [ $ret -ne 0 ]; then
+               tst_brk TBROK "loading policy failed"
+       fi
+
        IMA_POLICY_LOADED=1
 
        tst_res TINFO "example policy successfully loaded"
-- 
2.47.2


Reply via email to