rt-tests: hwlatdetect: Add check that width is not zero
PATCH 1/1 rt-tests: hwlatdetect: Add check that width is not zero
Check that width is not zero before division when calculating the MTBF
Signed-off-by John Kacur <[email protected]>
--- src/hwlatdetect/hwlatdetect.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
src/hwlatdetect/hwlatdetect.py +3 -2
@@ -564,8 +564,9 @@ if __name__ == '__main__': info(f"Samples exceeding threshold: {exceeding}") if exceeding > 1: - mtbf = ((float(detect.last) - float(detect.first)) * int(detect.get('window')) - / ((exceeding - 1) * int(detect.get('width')))) + width = int(detect.get('width')) + if width > 0: + mtbf = (((float(detect.last) - float(detect.first)) * int(detect.get('window'))) / ((exceeding - 1) * width)) info(f"MTBF: {mtbf:.3f} seconds") if detect.have_msr:
Signature · 1 line
2.53.0