adamwill / rpms / openscap

Forked from rpms/openscap 3 years ago
Clone
Blob Blame History Raw
From b2b00e2316439d6517c8b763f542db637ebcf0b0 Mon Sep 17 00:00:00 2001
From: Matus Marhefka <mmarhefk@redhat.com>
Date: Tue, 3 Mar 2020 14:12:39 +0100
Subject: [PATCH] tests/probes/environmentvariable58: add test to cover
 7c78b84dd

---
 .../test_probes_environmentvariable58.sh               | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tests/probes/environmentvariable58/test_probes_environmentvariable58.sh b/tests/probes/environmentvariable58/test_probes_environmentvariable58.sh
index 786ea528a..7679c3495 100755
--- a/tests/probes/environmentvariable58/test_probes_environmentvariable58.sh
+++ b/tests/probes/environmentvariable58/test_probes_environmentvariable58.sh
@@ -24,13 +24,16 @@ function test_probes_environmentvariable58 {
     local ret_val=0;
     local DF="$1.xml"
     local RF="$1.results.xml"
+    echo "result file: $RF"
+    local stderr=$(mktemp $1.err.XXXXXX)
+    echo "stderr file: $stderr"
 
     [ -f $RF ] && rm -f $RF
 
     bash ${srcdir}/$1.xml.sh > $DF
     LINES=$?
 
-    $OSCAP oval eval --results $RF $DF
+    $OSCAP oval eval --results $RF $DF 2> $stderr
 
     if [ -f $RF ]; then
 	verify_results "def" $DF $RF 1 && verify_results "tst" $DF $RF $LINES
@@ -39,6 +42,11 @@ function test_probes_environmentvariable58 {
 	ret_val=1
     fi
 
+    # Test fails if there are any warnings or "Entity has no value" on stderr.
+    echo "Verify that there are no warnings on stderr"
+    grep -Ei "(W:|Entity has no value)" $stderr && ret_val=1
+
+    rm $stderr
     return $ret_val
 }