[autotest-client-tests][PATCH 1/2] UBUNTU: SAUCE: ubuntu_boot: fix return value for kernel_taint_test.py
Po-Hsu Lin
po-hsu.lin at canonical.com
Wed Mar 30 10:12:05 UTC 2022
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 at canonical.com>
---
ubuntu_boot/kernel_taint_test.py | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
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():
--
2.25.1
More information about the kernel-team
mailing list