Skip to contentSkip to conversation

runtime.bash: skip test when checked file doesn't exist

PATCH In review Vitaly Kuznetsov 3 participants 4 messages Oct 15, 2020 KVM

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 runtime.bash: skip test when checked file doesn't exist

Currently, we have the following check condition in x86/unittests.cfg:

check = /sys/module/kvm_intel/parameters/allow_smaller_maxphyaddr=Y

the check, however, passes successfully on AMD because the checked file is just missing. This doesn't sound right, reverse the check: fail if the content of the file doesn't match the expectation or if the file is not there.

---
Changes since v1:
- tabs -> spaces [Thomas]

---
 scripts/runtime.bash | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/runtime.bash +4 -1
index 3121c1ffdae8..99d242d5cf8c 100644
@@ -118,7 +118,10 @@ function run()
     for check_param in "${check[@]}"; do
         path=${check_param%%=*}
         value=${check_param#*=}
-        if [ -f "$path" ] && [ "$(cat $path)" != "$value" ]; then
+        if [ -z "$path" ]; then
+            continue
+        fi
+        if [ ! -f "$path" ] || [ "$(cat $path)" != "$value" ]; then
             print_result "SKIP" $testname "" "$path not equal to $value"
             return 2
         fi
Signature · 1 line
2.25.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 36 lines · Vitaly Kuznetsov

Currently, we have the following check condition in x86/unittests.cfg:

check = /sys/module/kvm_intel/parameters/allow_smaller_maxphyaddr=Y

the check, however, passes successfully on AMD because the checked file is just missing. This doesn't sound right, reverse the check: fail if the content of the file doesn't match the expectation or if the file is not there.

---
Changes since v1:
- tabs -> spaces [Thomas]

---
 scripts/runtime.bash | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/runtime.bash +4 -1
index 3121c1ffdae8..99d242d5cf8c 100644
@@ -118,7 +118,10 @@ function run()
     for check_param in "${check[@]}"; do
         path=${check_param%%=*}
         value=${check_param#*=}
-        if [ -f "$path" ] && [ "$(cat $path)" != "$value" ]; then
+        if [ -z "$path" ]; then
+            continue
+        fi
+        if [ ! -f "$path" ] || [ "$(cat $path)" != "$value" ]; then
             print_result "SKIP" $testname "" "$path not equal to $value"
             return 2
         fi
Signature · 1 line
2.25.4
maintainer
#2 lore raw
In reply to Vitaly Kuznetsov
Quoted 10 lines · Vitaly Kuznetsov

Currently, we have the following check condition in x86/unittests.cfg:

check = /sys/module/kvm_intel/parameters/allow_smaller_maxphyaddr=Y

the check, however, passes successfully on AMD because the checked file is just missing. This doesn't sound right, reverse the check: fail if the content of the file doesn't match the expectation or if the file is not there.

Hi Vitaly, I had already posted a fix for this but I pushed it only to my repo and not to upstream (still getting used to CI!). I pushed it now.

My fix actually checked whether ${check} was not empty at all. That said, the usage of ${check[@]} is wrong because $check is not an array.
So it would break if we wanted to have more than one check.

Paolo

Quoted 24 lines

---
Changes since v1:
- tabs -> spaces [Thomas]

---
 scripts/runtime.bash | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/runtime.bash +4 -1
index 3121c1ffdae8..99d242d5cf8c 100644
@@ -118,7 +118,10 @@ function run()
     for check_param in "${check[@]}"; do
         path=${check_param%%=*}
         value=${check_param#*=}
-        if [ -f "$path" ] && [ "$(cat $path)" != "$value" ]; then
+        if [ -z "$path" ]; then
+            continue
+        fi
+        if [ ! -f "$path" ] || [ "$(cat $path)" != "$value" ]; then
             print_result "SKIP" $testname "" "$path not equal to $value"
             return 2
         fi
#3 lore raw
Quoted 10 lines · Paolo Bonzini
Quoted 9 lines · Vitaly Kuznetsov

Currently, we have the following check condition in x86/unittests.cfg:

check = /sys/module/kvm_intel/parameters/allow_smaller_maxphyaddr=Y

the check, however, passes successfully on AMD because the checked file is just missing. This doesn't sound right, reverse the check: fail if the content of the file doesn't match the expectation or if the file is not there.

Quoted 5 lines
Quoted 1 line

Hi Vitaly, I had already posted a fix for this but I pushed it only to my repo and not to upstream (still getting used to CI!). I pushed it now.

Hm, I still don't see it on gitlab but as long as the bug is fixed I'm fine ;-)

Quoted 4 lines

My fix actually checked whether ${check} was not empty at all. That said, the usage of ${check[@]} is wrong because $check is not an array.
So it would break if we wanted to have more than one check.

Oh, yes, I see.

Quoted 28 lines

Paolo

Quoted 24 lines

---
Changes since v1:
- tabs -> spaces [Thomas]

---
 scripts/runtime.bash | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/runtime.bash +4 -1
index 3121c1ffdae8..99d242d5cf8c 100644
@@ -118,7 +118,10 @@ function run()
     for check_param in "${check[@]}"; do
         path=${check_param%%=*}
         value=${check_param#*=}
-        if [ -f "$path" ] && [ "$(cat $path)" != "$value" ]; then
+        if [ -z "$path" ]; then
+            continue
+        fi
+        if [ ! -f "$path" ] || [ "$(cat $path)" != "$value" ]; then
             print_result "SKIP" $testname "" "$path not equal to $value"
             return 2
         fi
Signature · 1 line
Vitaly