Move surface scan check to its own function
This commit is contained in:
parent
af8b2b7dd3
commit
d667695e9e
2 changed files with 31 additions and 22 deletions
|
|
@ -20,6 +20,7 @@ BADBLOCKS_REGEX = re.compile(
|
|||
r'^Pass completed, (\d+) bad blocks found. .(\d+)/(\d+)/(\d+) errors',
|
||||
re.IGNORECASE,
|
||||
)
|
||||
BADBLOCKS_SKIP_REGEX = re.compile(r'^(Checking|\[)', re.IGNORECASE)
|
||||
CPU_CRITICAL_TEMP = 99
|
||||
CPU_FAILURE_TEMP = 90
|
||||
CPU_TEST_MINUTES = 7
|
||||
|
|
|
|||
|
|
@ -5,7 +5,11 @@ import logging
|
|||
|
||||
from subprocess import STDOUT
|
||||
|
||||
from wk.cfg.hw import BADBLOCKS_LARGE_DISK, BADBLOCKS_REGEX
|
||||
from wk.cfg.hw import (
|
||||
BADBLOCKS_LARGE_DISK,
|
||||
BADBLOCKS_REGEX,
|
||||
BADBLOCKS_SKIP_REGEX,
|
||||
)
|
||||
from wk.exe import run_program
|
||||
from wk.std import (
|
||||
PLATFORM,
|
||||
|
|
@ -20,6 +24,30 @@ LOG = logging.getLogger(__name__)
|
|||
|
||||
|
||||
# Functions
|
||||
def check_surface_scan_results(test_obj, log_path) -> None:
|
||||
"""Check results and set test status."""
|
||||
with open(log_path, 'r', encoding='utf-8') as _f:
|
||||
for line in _f.readlines():
|
||||
line = strip_colors(line.strip())
|
||||
if not line or BADBLOCKS_SKIP_REGEX.match(line):
|
||||
# Skip
|
||||
continue
|
||||
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")}')
|
||||
if not (test_obj.passed or test_obj.failed):
|
||||
test_obj.set_status('Unknown')
|
||||
|
||||
|
||||
def run_scan(test_obj, log_path) -> None:
|
||||
"""Run surface scan and handle exceptions."""
|
||||
block_size = '1024'
|
||||
|
|
@ -58,27 +86,7 @@ def run_scan(test_obj, log_path) -> None:
|
|||
)
|
||||
|
||||
# Check results
|
||||
with open(log_path, 'r', encoding='utf-8') as _f:
|
||||
for line in _f.readlines():
|
||||
line = strip_colors(line.strip())
|
||||
if not line or line.startswith('Checking') or line.startswith('['):
|
||||
# Skip
|
||||
continue
|
||||
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")}')
|
||||
if not (test_obj.passed or test_obj.failed):
|
||||
test_obj.set_status('Unknown')
|
||||
|
||||
check_surface_scan_results(test_obj, log_path)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Reference in a new issue