summaryrefslogtreecommitdiff
diff options
authorPo-Hsu Lin <po-hsu.lin@canonical.com>2021-07-19 19:59:39 +0800
committerPo-Hsu Lin <po-hsu.lin@canonical.com>2021-07-19 20:11:38 +0800
commit11f1532e586f3014c6476c4b4f188bda61cf9a95 (patch)
tree094d0e2bea0fea4fda5d513554601c38428adacf
parentd82e5c29ea247eaa2cadac534ebe8886d53089ec (diff)
bin/kernel_taint_test.py: return 0 for passed cases, 1 for othersphlin/fix-tainted-check
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. e.g. on a system with kernel warning $ ./kernel_taint_test.py Kernel taint value is 512 Taint bit value: 9 (kernel issued warning) Taint bit value: 9 (kernel issued warning) $ echo $? 0 Let's just simplify the return logic of report_failures() to return either 0 or 1. Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
-rwxr-xr-xbin/kernel_taint_test.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/bin/kernel_taint_test.py b/bin/kernel_taint_test.py
index de59bbe..2ee70c1 100755
--- a/bin/kernel_taint_test.py
+++ b/bin/kernel_taint_test.py
@@ -153,14 +153,13 @@ def report_failures(taints):
else:
print("Taint bit value: {} ({})".format(i, taint_meanings[i]))
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():