badblocks section working
This commit is contained in:
parent
e96ac5c156
commit
8b936f5413
1 changed files with 62 additions and 11 deletions
|
|
@ -383,7 +383,6 @@ class State():
|
||||||
self.cpu = None
|
self.cpu = None
|
||||||
self.disks = []
|
self.disks = []
|
||||||
self.panes = {}
|
self.panes = {}
|
||||||
self.progress_out = '{}/progress.out'.format(global_vars['LogDir'])
|
|
||||||
self.quick_mode = False
|
self.quick_mode = False
|
||||||
self.tests = OrderedDict({
|
self.tests = OrderedDict({
|
||||||
'Prime95': {
|
'Prime95': {
|
||||||
|
|
@ -423,6 +422,7 @@ class State():
|
||||||
os.makedirs(global_vars['LogDir'], exist_ok=True)
|
os.makedirs(global_vars['LogDir'], exist_ok=True)
|
||||||
global_vars['LogFile'] = '{}/Hardware Diagnostics.log'.format(
|
global_vars['LogFile'] = '{}/Hardware Diagnostics.log'.format(
|
||||||
global_vars['LogDir'])
|
global_vars['LogDir'])
|
||||||
|
self.progress_out = '{}/progress.out'.format(global_vars['LogDir'])
|
||||||
|
|
||||||
# Add CPU
|
# Add CPU
|
||||||
self.cpu = CpuObj()
|
self.cpu = CpuObj()
|
||||||
|
|
@ -723,19 +723,68 @@ def run_badblocks_test(state, test):
|
||||||
# Bail early
|
# Bail early
|
||||||
if test.disabled:
|
if test.disabled:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Prep
|
||||||
print_log('Starting badblocks test for {}'.format(test.dev.path))
|
print_log('Starting badblocks test for {}'.format(test.dev.path))
|
||||||
tmux_update_pane(
|
|
||||||
state.panes['Top'],
|
|
||||||
text='{}\nbadblocks: {}'.format(TOP_PANE_TEXT, test.dev.description))
|
|
||||||
print_standard('TODO: run_badblocks_test({})'.format(
|
|
||||||
test.dev.path))
|
|
||||||
test.started = True
|
test.started = True
|
||||||
test.update_status()
|
test.update_status()
|
||||||
update_progress_pane(state)
|
update_progress_pane(state)
|
||||||
sleep(3)
|
|
||||||
|
# Update top pane
|
||||||
|
tmux_update_pane(
|
||||||
|
state.panes['Top'],
|
||||||
|
text='{}\nbadblocks: {}'.format(TOP_PANE_TEXT, test.dev.description))
|
||||||
|
|
||||||
|
# Create monitor pane
|
||||||
|
test.badblocks_out = '{}/badblocks.out'.format(global_vars['LogDir'])
|
||||||
|
state.panes['badblocks'] = tmux_split_window(
|
||||||
|
lines=5, vertical=True, watch=test.badblocks_out, watch_cmd='tail')
|
||||||
|
|
||||||
|
# Show disk details
|
||||||
|
clear_screen()
|
||||||
|
show_report(test.dev.generate_report())
|
||||||
|
print_standard(' ')
|
||||||
|
|
||||||
|
# Start badblocks
|
||||||
|
print_standard('Running badblocks test...')
|
||||||
|
test.badblocks_proc = popen_program(
|
||||||
|
['sudo', 'hw-diags-badblocks', test.dev.path, test.badblocks_out],
|
||||||
|
pipe=True)
|
||||||
|
test.badblocks_proc.wait()
|
||||||
|
|
||||||
|
# Check result and create report
|
||||||
|
try:
|
||||||
|
test.badblocks_out = test.badblocks_proc.stdout.read().decode()
|
||||||
|
except Exception as err:
|
||||||
|
test.badblocks_out = 'Error: {}'.format(err)
|
||||||
|
for line in test.badblocks_out.splitlines():
|
||||||
|
line = line.strip()
|
||||||
|
if not line or re.search(r'^Checking', line, re.IGNORECASE):
|
||||||
|
# Skip empty and progress lines
|
||||||
|
continue
|
||||||
|
if re.search(r'^Pass completed.*0.*0/0/0', line, re.IGNORECASE):
|
||||||
|
test.report.append(' {}'.format(line))
|
||||||
|
test.passed = True
|
||||||
|
else:
|
||||||
|
test.report.append(' {YELLOW}{line}{CLEAR}'.format(
|
||||||
|
line=line, **COLORS))
|
||||||
|
test.failed = True
|
||||||
|
|
||||||
|
# Update status
|
||||||
|
if test.failed:
|
||||||
|
test.update_status('NS')
|
||||||
|
elif test.passed:
|
||||||
|
test.update_status('CS')
|
||||||
|
else:
|
||||||
test.update_status('Unknown')
|
test.update_status('Unknown')
|
||||||
|
|
||||||
|
# Done
|
||||||
update_progress_pane(state)
|
update_progress_pane(state)
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
tmux_kill_pane(state.panes['badblocks'])
|
||||||
|
pause()
|
||||||
|
|
||||||
def run_hw_tests(state):
|
def run_hw_tests(state):
|
||||||
"""Run enabled hardware tests."""
|
"""Run enabled hardware tests."""
|
||||||
print_standard('Scanning devices...')
|
print_standard('Scanning devices...')
|
||||||
|
|
@ -828,6 +877,8 @@ def run_mprime_test(state, test):
|
||||||
# Bail early
|
# Bail early
|
||||||
if test.disabled:
|
if test.disabled:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Prep
|
||||||
print_log('Starting Prime95 test')
|
print_log('Starting Prime95 test')
|
||||||
test.started = True
|
test.started = True
|
||||||
test.update_status()
|
test.update_status()
|
||||||
|
|
@ -835,9 +886,9 @@ def run_mprime_test(state, test):
|
||||||
test.sensor_data = get_sensor_data()
|
test.sensor_data = get_sensor_data()
|
||||||
|
|
||||||
# Update top pane
|
# Update top pane
|
||||||
test.title = '{}\nPrime95: {}'.format(
|
tmux_update_pane(
|
||||||
TOP_PANE_TEXT, test.dev.name)
|
state.panes['Top'],
|
||||||
tmux_update_pane(state.panes['Top'], text=test.title)
|
text='{}\nPrime95: {}'.format(TOP_PANE_TEXT, test.dev.name))
|
||||||
|
|
||||||
# Start live sensor monitor
|
# Start live sensor monitor
|
||||||
test.sensors_out = '{}/sensors.out'.format(global_vars['TmpDir'])
|
test.sensors_out = '{}/sensors.out'.format(global_vars['TmpDir'])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue