diff mbox series

[autotest-client-tests,1/2] UBUNTU: SAUCE: ubuntu_boot: fix return value for kernel_taint_test.py

Message ID 20220330101206.124838-2-po-hsu.lin@canonical.com
State New
Headers show
Series ubuntu_boot: fix return value for kernel_taint_test.py and format improvement | expand

Commit Message

Po-Hsu Lin March 30, 2022, 10:12 a.m. UTC
exit takes only integer args in the range 0 - 255
If we return the taint value read from /proc/sys/kernel/tainted,
it might exceed this range and causing unexpected behaviour.

On a system with kernel warning, e.g. Intel node spitfire with 4.4
$ ./kernel_taint_test.py
Kernel taint value is 512
Taint bit value: 9 (kernel issued warning)
$ echo 0
0

Let's just simplify the return logic of report_failures() to return
either 0 or 1.

We still return -1 when the tainted file does not exist, this will be
handled in the followup patch.

Luckily we do run this test along with log check test, so even with
this test reporting a false negative result, we can still catch
warnings with the log check test.

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
 ubuntu_boot/kernel_taint_test.py | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/ubuntu_boot/kernel_taint_test.py b/ubuntu_boot/kernel_taint_test.py
index 259c05cc..73177089 100755
--- a/ubuntu_boot/kernel_taint_test.py
+++ b/ubuntu_boot/kernel_taint_test.py
@@ -115,14 +115,13 @@  def report_failures(taints):
                 continue
             count += 1
 
-    if taints == 0:
-        print("No kernel taints detected.")
-
-    if taints and count == 0:
-        # we found only taint 11
-        return count
+    if count == 0:
+        # else case below contains expected issue in case 0 / 11 / 12
+        if not taints:
+            print("No kernel taints detected.")
+        return 0
     else:
-        return taints
+        return 1
 
 
 def main():