From a5531a10014c2b11c9f547ea84129089b7ef9394 Mon Sep 17 00:00:00 2001 From: Jiri Konecny Date: Fri, 9 Aug 2024 19:58:57 +0200 Subject: [PATCH] Fix RESULT validation Currently if RESULT file has an issue after the "SUCCESS" word it will tell success. That works in most of the cases but not if validation is done in the %post of KS but also later in the .sh file. If %post section was fine and add SUCCESS but validation section will found issue it would take the whole test as successful. Fix this in all the impacted tests and also in the functions.sh. --- encrypt-device.sh | 2 +- encrypt-swap.sh | 2 +- escrow-cert.sh | 2 +- functions.sh | 2 +- nosave-1.sh | 2 +- nosave-2.sh | 2 +- nosave-3.sh | 2 +- proxy-auth.sh | 12 ++---------- proxy-cmdline.sh | 12 ++---------- proxy-kickstart.sh | 12 ++---------- raid-1.sh | 2 +- raid-ddf.sh | 2 +- 12 files changed, 15 insertions(+), 39 deletions(-) diff --git a/encrypt-device.sh b/encrypt-device.sh index a00d831c..b0829b3b 100755 --- a/encrypt-device.sh +++ b/encrypt-device.sh @@ -34,7 +34,7 @@ validate() { if [[ $? != 0 ]]; then status=1 echo '*** /home/RESULT does not exist in VM image.' - elif [[ "${result}" != SUCCESS* ]]; then + elif [[ "${result%% *}" != SUCCESS ]]; then status=1 echo "${result}" fi diff --git a/encrypt-swap.sh b/encrypt-swap.sh index cdecc38b..f71d411c 100755 --- a/encrypt-swap.sh +++ b/encrypt-swap.sh @@ -44,7 +44,7 @@ validate() { if [[ $? != 0 ]]; then status=1 echo '*** /root/RESULT does not exist in VM image.' - elif [[ "${result}" != SUCCESS* ]]; then + elif [[ "${result%% *}" != SUCCESS ]]; then status=1 echo "${result}" fi diff --git a/escrow-cert.sh b/escrow-cert.sh index ab270b5f..d3895e53 100755 --- a/escrow-cert.sh +++ b/escrow-cert.sh @@ -35,7 +35,7 @@ validate() { if [[ $? != 0 ]]; then status=1 echo '*** /root/RESULT does not exist in VM image.' - elif [[ "${result}" != SUCCESS* ]]; then + elif [[ "${result%% *}" != SUCCESS ]]; then status=1 echo "${result}" fi diff --git a/functions.sh b/functions.sh index 855d5679..21d733fa 100644 --- a/functions.sh +++ b/functions.sh @@ -212,7 +212,7 @@ check_result_file() { if [[ $? != 0 ]]; then status=1 echo '*** /root/RESULT does not exist in VM image.' - elif [[ "${result}" != SUCCESS* ]]; then + elif [[ "${result%% *}" != SUCCESS ]]; then status=1 echo "${result}" fi diff --git a/nosave-1.sh b/nosave-1.sh index cfbe44c7..1abe8972 100755 --- a/nosave-1.sh +++ b/nosave-1.sh @@ -50,7 +50,7 @@ validate() { if [[ $? != 0 ]]; then status=1 echo '*** /root/RESULT does not exist in VM image.' - elif [[ "${result}" != SUCCESS* ]]; then + elif [[ "${result%% *}" != SUCCESS ]]; then status=1 echo "${result}" else diff --git a/nosave-2.sh b/nosave-2.sh index be83bedd..0ea9f340 100755 --- a/nosave-2.sh +++ b/nosave-2.sh @@ -50,7 +50,7 @@ validate() { if [[ $? != 0 ]]; then status=1 echo '*** /root/RESULT does not exist in VM image.' - elif [[ "${result}" != SUCCESS* ]]; then + elif [[ "${result%% *}" != SUCCESS ]]; then status=1 echo "${result}" else diff --git a/nosave-3.sh b/nosave-3.sh index d6c76fdf..db758e5a 100755 --- a/nosave-3.sh +++ b/nosave-3.sh @@ -50,7 +50,7 @@ validate() { if [[ $? != 0 ]]; then status=1 echo '*** /root/RESULT does not exist in VM image.' - elif [[ "${result}" != SUCCESS* ]]; then + elif [[ "${result%% *}" != SUCCESS ]]; then status=1 echo "${result}" else diff --git a/proxy-auth.sh b/proxy-auth.sh index 8a17b0c9..ce97e06f 100755 --- a/proxy-auth.sh +++ b/proxy-auth.sh @@ -93,16 +93,8 @@ validate() { fi fi - result=$(cat ${tmpdir}/RESULT) - if [[ $? != 0 ]]; then - echo '*** /root/RESULT does not exist in VM image.' - return 1 - elif [[ "${result}" != SUCCESS* ]]; then - echo "${result}" - return 1 - else - return 0 - fi + check_result_file "${tmpdir}" + return $? } cleanup() { diff --git a/proxy-cmdline.sh b/proxy-cmdline.sh index c00e4704..6a10cd04 100755 --- a/proxy-cmdline.sh +++ b/proxy-cmdline.sh @@ -50,14 +50,6 @@ validate() { check_proxy_settings $tmpdir - result=$(cat ${tmpdir}/RESULT) - if [[ $? != 0 ]]; then - echo '*** /root/RESULT does not exist in VM image.' - return 1 - elif [[ "${result}" != SUCCESS* ]]; then - echo "${result}" - return 1 - else - return 0 - fi + check_result_file "${tmpdir}" + return $? } diff --git a/proxy-kickstart.sh b/proxy-kickstart.sh index db793844..494b7e0b 100755 --- a/proxy-kickstart.sh +++ b/proxy-kickstart.sh @@ -87,16 +87,8 @@ validate() { fi fi - result=$(cat ${tmpdir}/RESULT) - if [[ $? != 0 ]]; then - echo '*** /root/RESULT does not exist in VM image.' - return 1 - elif [[ "${result}" != SUCCESS* ]]; then - echo "${result}" - return 1 - else - return 0 - fi + check_result_file "${tmpdir}" + return $? } cleanup() { diff --git a/raid-1.sh b/raid-1.sh index c4cb0cae..f7f8a6db 100755 --- a/raid-1.sh +++ b/raid-1.sh @@ -42,7 +42,7 @@ validate() { if [[ $? != 0 ]]; then status=1 echo '*** /root/RESULT does not exist in VM image.' - elif [[ "${result}" != SUCCESS* ]]; then + elif [[ "${result%% *}" != SUCCESS ]]; then status=1 echo "${result}" fi diff --git a/raid-ddf.sh b/raid-ddf.sh index 9648ce82..6512dc67 100755 --- a/raid-ddf.sh +++ b/raid-ddf.sh @@ -50,7 +50,7 @@ validate() { if [[ $? != 0 ]]; then status=1 echo '*** /root/RESULT does not exist in VM image.' - elif [[ "${result}" != SUCCESS* ]]; then + elif [[ "${result%% *}" != SUCCESS ]]; then status=1 echo "${result}" fi