Fix badblocks reports
- Better filter the raw results, stripping the backspaces from the text. - Fix color used when printing to the screen
This commit is contained in:
parent
2431e2e00e
commit
60168e14ae
2 changed files with 26 additions and 8 deletions
|
|
@ -21,7 +21,9 @@ BADBLOCKS_REGEX = re.compile(
|
|||
r'^Pass completed, (\d+) bad blocks found. .(\d+)/(\d+)/(\d+) errors',
|
||||
re.IGNORECASE,
|
||||
)
|
||||
BADBLOCKS_RESULTS_REGEX = re.compile(r'^(.*?)\x08.*\x08(.*)')
|
||||
BADBLOCKS_RESULTS_REGEX = re.compile(
|
||||
r'^(Checking for bad blocks .read-only test.: ).*\x08+(done|\s+).*?(\x08+)?'
|
||||
)
|
||||
BADBLOCKS_SKIP_REGEX = re.compile(r'^(Checking|\[)', re.IGNORECASE)
|
||||
CPU_CRITICAL_TEMP = 99
|
||||
CPU_FAILURE_TEMP = 90
|
||||
|
|
|
|||
|
|
@ -29,31 +29,47 @@ LOG = logging.getLogger(__name__)
|
|||
# Functions
|
||||
def check_surface_scan_results(test_obj, log_path) -> None:
|
||||
"""Check results and set test status."""
|
||||
report = []
|
||||
report_color = None
|
||||
|
||||
# Read result
|
||||
with open(log_path, 'r', encoding='utf-8') as _f:
|
||||
for line in _f.readlines():
|
||||
# TODO: Test further to restrict report to just the results
|
||||
line = strip_colors(line.strip())
|
||||
#if not line or BADBLOCKS_SKIP_REGEX.match(line):
|
||||
if not line:
|
||||
# Skip
|
||||
continue
|
||||
|
||||
# Clean line by removing backspaces/etc
|
||||
line = BADBLOCKS_RESULTS_REGEX.sub(r'\1 \2', line)
|
||||
match = BADBLOCKS_RESULTS_REGEX.match(line)
|
||||
if match:
|
||||
if match.group(2) == ' done':
|
||||
line = BADBLOCKS_RESULTS_REGEX.sub(r'\1done', line)
|
||||
else:
|
||||
line = BADBLOCKS_RESULTS_REGEX.sub(r'\1\2', line)
|
||||
line = line.replace(r'\x08', '')
|
||||
line = line.strip()
|
||||
|
||||
# Add to report
|
||||
report.append(line)
|
||||
match = BADBLOCKS_REGEX.search(line)
|
||||
if match:
|
||||
if all(s == '0' for s in match.groups()):
|
||||
test_obj.passed = True
|
||||
test_obj.report.append(f' {line}')
|
||||
test_obj.set_status('Passed')
|
||||
else:
|
||||
test_obj.failed = True
|
||||
test_obj.report.append(f' {color_string(line, "YELLOW")}')
|
||||
test_obj.set_status('Failed')
|
||||
else:
|
||||
test_obj.report.append(f' {color_string(line, "YELLOW")}')
|
||||
|
||||
# Set report color and save to test_obj
|
||||
if test_obj.failed:
|
||||
report_color = 'RED'
|
||||
elif not test_obj.passed:
|
||||
report_color = 'YELLOW'
|
||||
for line in report:
|
||||
test_obj.report.append(f' {color_string(line, report_color)}')
|
||||
|
||||
# Handle undefined result status
|
||||
if not (test_obj.passed or test_obj.failed):
|
||||
test_obj.set_status('Unknown')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue