Skip to contentSkip to conversation

ts-livepatch-run: Treat (just) falseish from OutputCheck as fail

PATCH In review Ian Jackson 2 participants 6 messages Jan 16, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ts-livepatch-run: Treat (just) falseish from OutputCheck as fail

This is more idiomatic. All existing OutputChecks return booleans, so no functional change.

CC Konrad Rzeszutek Wilk <[email protected]>
---
 ts-livepatch-run | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
ts-livepatch-run +2 -2
index f1194586..8fdb8004 100755
@@ -147,8 +147,8 @@ sub livepatch_test () {
         }
         if (defined($test->{OutputCheck})) {
             $_ = $output;
-            $rc=$test->{OutputCheck}->();
-            if ($rc ne 1) {
+            my $ok = $test->{OutputCheck}->();
+            if (!$ok) {
                 die "FAILED! OutputCheck=$test->{OutputCheck}, input=$output\n";
             }
         }
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH 2/3 ts-livepatch-run: Print a message about expected failures

target_cmd_output_root_status prints the command exit status. If that was a failure and the failure was as expected, this can be confusing to readers who do not know that this is a possibility. So print a message about it.

CC Konrad Rzeszutek Wilk <[email protected]>
---
 ts-livepatch-run | 3 +++
 1 file changed, 3 insertions(+)
ts-livepatch-run +3 -0
index 8fdb8004..f011e64e 100755
@@ -152,6 +152,9 @@ sub livepatch_test () {
                 die "FAILED! OutputCheck=$test->{OutputCheck}, input=$output\n";
             }
         }
+	if ($expected_rc) {
+	    logm "... that failure ($rc) was as required; all is well.";
+        }
    }
    return 0;
 }
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 2/3
#2 lore raw

Re: [OSSTEST PATCH 2/3] ts-livepatch-run: Print a message about expected failures

Quoted 7 lines · Ian Jackson

target_cmd_output_root_status prints the command exit status. If that was a failure and the failure was as expected, this can be confusing to readers who do not know that this is a possibility. So print a message about it.

CC Konrad Rzeszutek Wilk <[email protected]>

Thank you!

Quoted 21 lines
---
 ts-livepatch-run | 3 +++
 1 file changed, 3 insertions(+)
ts-livepatch-run +3 -0
index 8fdb8004..f011e64e 100755
@@ -152,6 +152,9 @@ sub livepatch_test () {
                 die "FAILED! OutputCheck=$test->{OutputCheck}, input=$output\n";
             }
         }
+	if ($expected_rc) {
+	    logm "... that failure ($rc) was as required; all is well.";
+        }
    }
    return 0;
 }
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw

PATCH 3/3 ts-livepatch-run: Fix erroneous $$ in double-check

In reply to Ian Jackson

The doubled $s here are simply a mistake. The result is to make this test ineffective, since $$file' means the value of the variable whose name is in the variable $file', which here will never exist. This produces a `Use of uninitialized value' warning and substitutes the empty string, so overall we test the existence of the directory.

The missing check is not of much consequence since this check is not really expected ever to fail, and if it does, some actual test execution would fail due to the missing file.

So overall I think the only change is to log output.

CC Konrad Rzeszutek Wilk <[email protected]>
---
 ts-livepatch-run | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ts-livepatch-run +1 -1
index f011e64e..86a79791 100755
@@ -161,7 +161,7 @@ sub livepatch_test () {
 
 sub livepatch_check () {
     foreach my $file (@livepatch_files) {
-        if (!target_file_exists($ho, "/usr/lib/debug/xen-livepatch/$$file")) {
+        if (!target_file_exists($ho, "/usr/lib/debug/xen-livepatch/$file")) {
             die "$file is missing!\n";
         }
     }
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 3/3
#4 lore raw

Re: [OSSTEST PATCH 3/3] ts-livepatch-run: Fix erroneous $$ in double-check

Quoted 6 lines · Ian Jackson

The doubled $s here are simply a mistake. The result is to make this test ineffective, since $$file' means the value of the variable whose name is in the variable $file', which here will never exist. This produces a `Use of uninitialized value' warning and substitutes the empty string, so overall we test the existence of the directory.

Quoted 8 lines

The missing check is not of much consequence since this check is not really expected ever to fail, and if it does, some actual test execution would fail due to the missing file.

So overall I think the only change is to log output.

CC Konrad Rzeszutek Wilk <[email protected]>

Thank you!

Quoted 20 lines
---
 ts-livepatch-run | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ts-livepatch-run +1 -1
index f011e64e..86a79791 100755
@@ -161,7 +161,7 @@ sub livepatch_test () {
 
 sub livepatch_check () {
     foreach my $file (@livepatch_files) {
-        if (!target_file_exists($ho, "/usr/lib/debug/xen-livepatch/$$file")) {
+        if (!target_file_exists($ho, "/usr/lib/debug/xen-livepatch/$file")) {
             die "$file is missing!\n";
         }
     }
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 1/3
#5 lore raw
In reply to Ian Jackson
Quoted 5 lines · Ian Jackson

This is more idiomatic. All existing OutputChecks return booleans, so no functional change.

CC Konrad Rzeszutek Wilk <[email protected]>

Thank you!

Quoted 22 lines
---
 ts-livepatch-run | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
ts-livepatch-run +2 -2
index f1194586..8fdb8004 100755
@@ -147,8 +147,8 @@ sub livepatch_test () {
         }
         if (defined($test->{OutputCheck})) {
             $_ = $output;
-            $rc=$test->{OutputCheck}->();
-            if ($rc ne 1) {
+            my $ok = $test->{OutputCheck}->();
+            if (!$ok) {
                 die "FAILED! OutputCheck=$test->{OutputCheck}, input=$output\n";
             }
         }
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel