Rework SMART self-test sections (again)
- Use results from self-test log rather than self-test details - Include more result details in more scenarios - Only add self-test results to the report to avoid duplicate/conflicting info - Add check if test started but didn't finish (again?)
This commit is contained in:
parent
88d3ade64d
commit
4feb15182e
2 changed files with 18 additions and 13 deletions
|
|
@ -540,7 +540,7 @@ def disk_self_test(state, test_objects, test_mode=False) -> None:
|
|||
|
||||
# Show progress
|
||||
if threads[-1].is_alive():
|
||||
state.ui.add_worker_pane(lines=4, watch_cmd='tail', watch_file=test_log)
|
||||
state.ui.add_worker_pane(lines=4, watch_file=test_log)
|
||||
|
||||
# Wait for all tests to complete
|
||||
state.update_progress_file()
|
||||
|
|
|
|||
|
|
@ -42,25 +42,24 @@ def build_self_test_report(test_obj, aborted=False) -> None:
|
|||
last known progress instead of just "was aborted by host."
|
||||
"""
|
||||
report = [ansi.color_string('Self-Test', 'BLUE')]
|
||||
test_details = get_smart_self_test_details(test_obj.dev)
|
||||
test_result = test_details.get('status', {}).get('string', 'Unknown')
|
||||
test_result = get_smart_self_test_last_result(test_obj.dev)
|
||||
|
||||
# Build report
|
||||
if test_obj.disabled or test_obj.status == 'Denied':
|
||||
report.append(ansi.color_string(f' {test_obj.status}', 'RED'))
|
||||
elif test_obj.status == 'N/A' or not test_obj.dev.attributes:
|
||||
report.append(ansi.color_string(f' {test_obj.status}', 'YELLOW'))
|
||||
elif test_obj.status == 'TestInProgress':
|
||||
report.append(ansi.color_string(' Failed to stop previous test', 'RED'))
|
||||
test_obj.set_status('Failed')
|
||||
else:
|
||||
# Other cases include self-test result string
|
||||
report.append(f' {test_result.capitalize()}')
|
||||
if aborted and not (test_obj.passed or test_obj.failed):
|
||||
report.append(ansi.color_string(' Aborted', 'YELLOW'))
|
||||
test_obj.set_status('Aborted')
|
||||
if test_obj.status == 'TestInProgress':
|
||||
report.append(ansi.color_string(' Failed to stop previous test', 'RED'))
|
||||
test_obj.set_status('Failed')
|
||||
elif test_obj.status == 'TimedOut':
|
||||
report.append(ansi.color_string(' TimedOut', 'YELLOW'))
|
||||
elif aborted and not (test_obj.passed or test_obj.failed):
|
||||
report.append(ansi.color_string(' Aborted', 'YELLOW'))
|
||||
test_obj.set_status('Aborted')
|
||||
report.append(f' {test_result}')
|
||||
|
||||
# Done
|
||||
test_obj.report.extend(report)
|
||||
|
|
@ -219,7 +218,7 @@ def get_known_disk_attributes(model) -> dict[str | int, dict[str, Any]]:
|
|||
return known_attributes
|
||||
|
||||
|
||||
def get_smart_self_test_details(dev) -> dict[Any, Any]:
|
||||
def get_smart_self_test_details(dev) -> dict[str, Any]:
|
||||
"""Shorthand to get deeply nested self-test details, returns dict."""
|
||||
details = {}
|
||||
try:
|
||||
|
|
@ -241,7 +240,9 @@ def get_smart_self_test_last_result(dev) -> str:
|
|||
'ata_smart_self_test_log', {}).get(
|
||||
'standard', {}).get(
|
||||
'table', [])
|
||||
if not data:
|
||||
try:
|
||||
data = data[0]
|
||||
except IndexError:
|
||||
# No results found
|
||||
return result
|
||||
|
||||
|
|
@ -291,7 +292,6 @@ def monitor_smart_self_test(test_obj, header_str, log_path) -> bool:
|
|||
result = get_smart_self_test_last_result(test_obj.dev)
|
||||
if result == 'Unknown':
|
||||
result = 'SMART self-test failed to start'
|
||||
test_obj.dev.add_note(result)
|
||||
test_obj.failed = True
|
||||
test_obj.set_status('TimedOut')
|
||||
break
|
||||
|
|
@ -307,6 +307,11 @@ def monitor_smart_self_test(test_obj, header_str, log_path) -> bool:
|
|||
finished = True
|
||||
break
|
||||
|
||||
# Check if timed out
|
||||
if started and not finished:
|
||||
test_obj.failed = True
|
||||
test_obj.set_status('TimedOut')
|
||||
|
||||
# Done
|
||||
return finished
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue