Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
2Shirt 2022-05-14 18:02:05 -07:00
commit 4ffd06235e
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
9 changed files with 70 additions and 36 deletions

View file

@ -161,6 +161,8 @@ TEMP_COLORS = {
100: 'ORANGE_RED', 100: 'ORANGE_RED',
} }
TESTSTATION_FILE = '/run/archiso/bootmnt/teststation.name' TESTSTATION_FILE = '/run/archiso/bootmnt/teststation.name'
TEST_MODE_BADBLOCKS_LIMIT = '10000' # Last block to read
TEST_MODE_CPU_LIMIT = 0.25 # Number of minutes to test
# THRESHOLDS: Rates used to determine HDD/SSD pass/fail # THRESHOLDS: Rates used to determine HDD/SSD pass/fail
THRESH_HDD_MIN = 50 * 1024**2 THRESH_HDD_MIN = 50 * 1024**2
THRESH_HDD_AVG_HIGH = 75 * 1024**2 THRESH_HDD_AVG_HIGH = 75 * 1024**2

View file

@ -38,7 +38,7 @@ class DeviceTooSmallError(RuntimeError):
# Functions # Functions
def calc_io_dd_values(dev_size) -> dict[str, int]: def calc_io_dd_values(dev_size, test_mode=False) -> dict[str, int]:
"""Calculate I/O benchmark dd values, returns dict. """Calculate I/O benchmark dd values, returns dict.
Calculations: Calculations:
@ -63,7 +63,11 @@ def calc_io_dd_values(dev_size) -> dict[str, int]:
This is needed to ensure an even testing across the dev This is needed to ensure an even testing across the dev
This is calculated by using the fractional amount left off This is calculated by using the fractional amount left off
of the skip_blocks variable of the skip_blocks variable
test_mode limits the benchmark to IO_MINIMUM_TEST_SIZE (if possible)
""" """
if test_mode:
dev_size = min(IO_MINIMUM_TEST_SIZE, dev_size)
read_total = min(IO_MINIMUM_TEST_SIZE, dev_size) read_total = min(IO_MINIMUM_TEST_SIZE, dev_size)
read_total = max(read_total, dev_size*IO_ALT_TEST_SIZE_FACTOR) read_total = max(read_total, dev_size*IO_ALT_TEST_SIZE_FACTOR)
read_chunks = int(read_total // IO_CHUNK_SIZE) read_chunks = int(read_total // IO_CHUNK_SIZE)
@ -135,7 +139,7 @@ def check_io_results(test_obj, rate_list, graph_width) -> None:
test_obj.set_status('Unknown') test_obj.set_status('Unknown')
def run_io_test(test_obj, log_path) -> None: def run_io_test(test_obj, log_path, test_mode=False) -> None:
"""Run I/O benchmark and handle exceptions.""" """Run I/O benchmark and handle exceptions."""
dev_path = test_obj.dev.path dev_path = test_obj.dev.path
if PLATFORM == 'Darwin': if PLATFORM == 'Darwin':
@ -148,7 +152,7 @@ def run_io_test(test_obj, log_path) -> None:
# Get dd values or bail # Get dd values or bail
try: try:
dd_values = calc_io_dd_values(test_obj.dev.size) dd_values = calc_io_dd_values(test_obj.dev.size, test_mode=test_mode)
except DeviceTooSmallError: except DeviceTooSmallError:
test_obj.set_status('N/A') test_obj.set_status('N/A')
test_obj.report.append( test_obj.report.append(

View file

@ -46,6 +46,7 @@ Options:
-c --cli Force CLI mode -c --cli Force CLI mode
-h --help Show this page -h --help Show this page
-q --quick Skip menu and perform a quick check -q --quick Skip menu and perform a quick check
-t --test-mode Run diags in test mode
--ignore-smart-errors NOT RECOMMENDED! --ignore-smart-errors NOT RECOMMENDED!
Only use if you have RTFM, Only use if you have RTFM,
@ -139,8 +140,10 @@ class State():
"""Check for mid-run SMART failures and failed test(s).""" """Check for mid-run SMART failures and failed test(s)."""
for dev in self.disks: for dev in self.disks:
disk_smart_status_check(dev, mid_run=True) disk_smart_status_check(dev, mid_run=True)
if any(test.failed for test in dev.tests): for test in dev.tests:
dev.disable_disk_tests() if test.failed and 'Attributes' not in test.name:
dev.disable_disk_tests()
break
def fix_tmux_layout(self, forced=True) -> None: def fix_tmux_layout(self, forced=True) -> None:
"""Fix tmux layout based on cfg.hw.TMUX_LAYOUT.""" """Fix tmux layout based on cfg.hw.TMUX_LAYOUT."""
@ -410,7 +413,7 @@ def build_menu(cli_mode=False, quick_mode=False) -> std.Menu:
return menu return menu
def cpu_stress_tests(state, test_objects) -> None: def cpu_stress_tests(state, test_objects, test_mode=False) -> None:
# pylint: disable=too-many-statements # pylint: disable=too-many-statements
"""CPU & cooling check using Prime95 and Sysbench.""" """CPU & cooling check using Prime95 and Sysbench."""
LOG.info('CPU Test (Prime95)') LOG.info('CPU Test (Prime95)')
@ -418,6 +421,9 @@ def cpu_stress_tests(state, test_objects) -> None:
prime_log = pathlib.Path(f'{state.log_dir}/prime.log') prime_log = pathlib.Path(f'{state.log_dir}/prime.log')
run_sysbench = False run_sysbench = False
sensors_out = pathlib.Path(f'{state.log_dir}/sensors.out') sensors_out = pathlib.Path(f'{state.log_dir}/sensors.out')
test_minutes = cfg.hw.CPU_TEST_MINUTES
if test_mode:
test_minutes = cfg.hw.TEST_MODE_CPU_LIMIT
test_mprime_obj, test_cooling_obj = test_objects test_mprime_obj, test_cooling_obj = test_objects
# Bail early # Bail early
@ -462,7 +468,7 @@ def cpu_stress_tests(state, test_objects) -> None:
# Show countdown # Show countdown
print('') print('')
try: try:
print_countdown(proc=proc_mprime, seconds=cfg.hw.CPU_TEST_MINUTES*60) print_countdown(proc=proc_mprime, seconds=test_minutes*60)
except KeyboardInterrupt: except KeyboardInterrupt:
aborted = True aborted = True
@ -506,7 +512,7 @@ def cpu_stress_tests(state, test_objects) -> None:
pane=state.panes['Prime95'], pane=state.panes['Prime95'],
) )
try: try:
print_countdown(proc=proc_sysbench, seconds=cfg.hw.CPU_TEST_MINUTES*60) print_countdown(proc=proc_sysbench, seconds=test_minutes*60)
except AttributeError: except AttributeError:
# Assuming the sysbench process wasn't found and proc was set to None # Assuming the sysbench process wasn't found and proc was set to None
LOG.error('Failed to find sysbench process', exc_info=True) LOG.error('Failed to find sysbench process', exc_info=True)
@ -548,7 +554,8 @@ def cpu_stress_tests(state, test_objects) -> None:
raise std.GenericAbort('Aborted') raise std.GenericAbort('Aborted')
def disk_attribute_check(state, test_objects) -> None: def disk_attribute_check(state, test_objects, test_mode=False) -> None:
# pylint: disable=unused-argument
"""Disk attribute check.""" """Disk attribute check."""
LOG.info('Disk Attribute Check') LOG.info('Disk Attribute Check')
for test in test_objects: for test in test_objects:
@ -562,7 +569,8 @@ def disk_attribute_check(state, test_objects) -> None:
state.update_progress_pane() state.update_progress_pane()
def disk_io_benchmark(state, test_objects, skip_usb=True) -> None: def disk_io_benchmark(
state, test_objects, skip_usb=True, test_mode=False) -> None:
"""Disk I/O benchmark using dd.""" """Disk I/O benchmark using dd."""
LOG.info('Disk I/O Benchmark (dd)') LOG.info('Disk I/O Benchmark (dd)')
aborted = False aborted = False
@ -605,7 +613,7 @@ def disk_io_benchmark(state, test_objects, skip_usb=True) -> None:
) )
state.update_progress_pane() state.update_progress_pane()
try: try:
hw_benchmark.run_io_test(test, test_log) hw_benchmark.run_io_test(test, test_log, test_mode=test_mode)
except KeyboardInterrupt: except KeyboardInterrupt:
aborted = True aborted = True
except (subprocess.CalledProcessError, TypeError, ValueError) as err: except (subprocess.CalledProcessError, TypeError, ValueError) as err:
@ -632,7 +640,8 @@ def disk_io_benchmark(state, test_objects, skip_usb=True) -> None:
raise std.GenericAbort('Aborted') raise std.GenericAbort('Aborted')
def disk_self_test(state, test_objects) -> None: def disk_self_test(state, test_objects, test_mode=False) -> None:
# pylint: disable=unused-argument
"""Disk self-test if available.""" """Disk self-test if available."""
LOG.info('Disk Self-Test(s)') LOG.info('Disk Self-Test(s)')
aborted = False aborted = False
@ -703,15 +712,15 @@ def disk_smart_status_check(dev, mid_run=True) -> None:
color = 'YELLOW' color = 'YELLOW'
# Log errors if detected # Log errors if detected
if msg: if msg and not dev.contains_note(msg):
msg = f'{msg}{" during diagnostics" if mid_run else ""}.' msg = f'{msg}{" during diagnostics" if mid_run else ""}'
LOG.warning(msg) LOG.warning(msg)
dev.add_note(msg, color) dev.add_note(msg, color)
# Set Disk Attributes test result # Set Disk Attributes test result
for test in dev.tests: for test in dev.tests:
if test.name == 'Disk Attributes': if test.name == 'Disk Attributes':
test.failed = test.failed or msg test.failed = bool(test.failed or msg)
test.passed = not test.failed test.passed = not test.failed
if test.failed: if test.failed:
test.set_status('Failed') test.set_status('Failed')
@ -723,7 +732,7 @@ def disk_smart_status_check(dev, mid_run=True) -> None:
dev.disable_disk_tests() dev.disable_disk_tests()
def disk_surface_scan(state, test_objects) -> None: def disk_surface_scan(state, test_objects, test_mode=False) -> None:
"""Read-only disk surface scan using badblocks.""" """Read-only disk surface scan using badblocks."""
LOG.info('Disk Surface Scan (badblocks)') LOG.info('Disk Surface Scan (badblocks)')
aborted = False aborted = False
@ -757,7 +766,7 @@ def disk_surface_scan(state, test_objects) -> None:
# Start thread # Start thread
test_log = f'{state.log_dir}/{test.dev.path.name}_badblocks.log' test_log = f'{state.log_dir}/{test.dev.path.name}_badblocks.log'
threads.append(exe.start_thread( threads.append(exe.start_thread(
hw_surface_scan.run_scan, args=(test, test_log), hw_surface_scan.run_scan, args=(test, test_log, test_mode),
)) ))
# Show progress # Show progress
@ -819,7 +828,7 @@ def main() -> None:
# Quick Mode # Quick Mode
if args['--quick']: if args['--quick']:
menu.toggles['osTicket Integration']['Selected'] = False menu.toggles['osTicket Integration']['Selected'] = False
run_diags(state, menu, quick_mode=True) run_diags(state, menu, quick_mode=True, test_mode=args['--test-mode'])
return return
# Show menu # Show menu
@ -868,7 +877,7 @@ def main() -> None:
# Start diagnostics # Start diagnostics
if 'Start' in selection: if 'Start' in selection:
run_diags(state, menu, quick_mode=False) run_diags(state, menu, quick_mode=False, test_mode=args['--test-mode'])
# Reset top pane # Reset top pane
state.update_top_pane('Main Menu') state.update_top_pane('Main Menu')
@ -1117,6 +1126,7 @@ def ost_update_checkboxes(state):
def print_countdown(proc, seconds) -> None: def print_countdown(proc, seconds) -> None:
"""Print countdown to screen while proc is alive.""" """Print countdown to screen while proc is alive."""
seconds = int(seconds)
for i in range(seconds): for i in range(seconds):
sec_left = (seconds - i) % 60 sec_left = (seconds - i) % 60
min_left = int((seconds - i) / 60) min_left = int((seconds - i) / 60)
@ -1142,7 +1152,7 @@ def print_countdown(proc, seconds) -> None:
print('') print('')
def run_diags(state, menu, quick_mode=False) -> None: def run_diags(state, menu, quick_mode=False, test_mode=False) -> None:
"""Run selected diagnostics.""" """Run selected diagnostics."""
aborted = False aborted = False
atexit.register(state.save_debug_reports) atexit.register(state.save_debug_reports)
@ -1185,7 +1195,7 @@ def run_diags(state, menu, quick_mode=False) -> None:
args.append(menu.toggles[IO_SIZE_SKIP_NAME]['Selected']) args.append(menu.toggles[IO_SIZE_SKIP_NAME]['Selected'])
std.clear_screen() std.clear_screen()
try: try:
function(state, *args) function(state, *args, test_mode=test_mode)
except (KeyboardInterrupt, std.GenericAbort): except (KeyboardInterrupt, std.GenericAbort):
aborted = True aborted = True
state.abort_testing() state.abort_testing()

View file

@ -17,7 +17,7 @@ from wk.hw.smart import (
generate_attribute_report, generate_attribute_report,
update_smart_details, update_smart_details,
) )
from wk.std import PLATFORM, bytes_to_string, color_string from wk.std import PLATFORM, bytes_to_string, color_string, strip_colors
# STATIC VARIABLES # STATIC VARIABLES
@ -76,6 +76,14 @@ class Disk:
self.notes.append(note) self.notes.append(note)
self.notes.sort() self.notes.sort()
def contains_note(self, note_str) -> bool:
"""Check if note is already present."""
present = False
for note in self.notes:
if note_str == strip_colors(note):
present = True
return present
def disable_disk_tests(self) -> None: def disable_disk_tests(self) -> None:
"""Disable all tests.""" """Disable all tests."""
LOG.warning('Disabling all tests for: %s', self.path) LOG.warning('Disabling all tests for: %s', self.path)

View file

@ -9,6 +9,7 @@ from wk.cfg.hw import (
BADBLOCKS_LARGE_DISK, BADBLOCKS_LARGE_DISK,
BADBLOCKS_REGEX, BADBLOCKS_REGEX,
BADBLOCKS_SKIP_REGEX, BADBLOCKS_SKIP_REGEX,
TEST_MODE_BADBLOCKS_LIMIT,
) )
from wk.exe import run_program from wk.exe import run_program
from wk.std import ( from wk.std import (
@ -48,7 +49,7 @@ def check_surface_scan_results(test_obj, log_path) -> None:
test_obj.set_status('Unknown') test_obj.set_status('Unknown')
def run_scan(test_obj, log_path) -> None: def run_scan(test_obj, log_path, test_mode=False) -> None:
"""Run surface scan and handle exceptions.""" """Run surface scan and handle exceptions."""
block_size = '1024' block_size = '1024'
dev = test_obj.dev dev = test_obj.dev
@ -67,6 +68,10 @@ def run_scan(test_obj, log_path) -> None:
# Start scan # Start scan
cmd = ['sudo', 'badblocks', '-sv', '-b', block_size, '-e', '1', dev_path] cmd = ['sudo', 'badblocks', '-sv', '-b', block_size, '-e', '1', dev_path]
if test_mode:
# Only test a limited scope instead of the whole device
cmd.append(TEST_MODE_BADBLOCKS_LIMIT)
with open(log_path, 'a', encoding='utf-8') as _f: with open(log_path, 'a', encoding='utf-8') as _f:
size_str = bytes_to_string(dev.size, use_binary=False) size_str = bytes_to_string(dev.size, use_binary=False)
_f.write( _f.write(

View file

@ -15,7 +15,7 @@ source=(https://dl.suckless.org/$pkgname/$pkgname-$pkgver.tar.gz
terminfo.patch terminfo.patch
README.terminfo.rst README.terminfo.rst
https://st.suckless.org/patches/alpha/st-alpha-20220206-0.8.5.diff https://st.suckless.org/patches/alpha/st-alpha-20220206-0.8.5.diff
st-colors.diff https://st.suckless.org/patches/xresources/st-xresources-20200604-9ba7ecf.diff
https://st.suckless.org/patches/delkey/st-delkey-20201112-4ef0cbd.diff https://st.suckless.org/patches/delkey/st-delkey-20201112-4ef0cbd.diff
st-desktopentry-0.8.4-edit.diff st-desktopentry-0.8.4-edit.diff
https://st.suckless.org/patches/scrollback/st-scrollback-20210507-4536f46.diff https://st.suckless.org/patches/scrollback/st-scrollback-20210507-4536f46.diff
@ -27,7 +27,7 @@ sha256sums=('ea6832203ed02ff74182bcb8adaa9ec454c8f989e79232cb859665e2f544ab37'
'f9deea445a5c6203a0e8e699f3c3b55e27275f17fb408562c4dd5d649edeea23' 'f9deea445a5c6203a0e8e699f3c3b55e27275f17fb408562c4dd5d649edeea23'
'0ebcbba881832adf9c98ce9fe7667c851d3cc3345077cb8ebe32702698665be2' '0ebcbba881832adf9c98ce9fe7667c851d3cc3345077cb8ebe32702698665be2'
'42e4803ce2a67835f7e533a707a8a28e3804a26ced163145108970b9aee5fb81' '42e4803ce2a67835f7e533a707a8a28e3804a26ced163145108970b9aee5fb81'
'1758a0930a06bf51497923bbd0b1d88a33d4ed4deb770fd85e56e5170c3a2c5b' '5be9b40d2b51761685f6503e92028a7858cc6571a8867b88612fce8a70514d5b'
'946051d123dfe21d8f5ef0f1070c473443f4779dc0bd7edf7c8497f67e325a49' '946051d123dfe21d8f5ef0f1070c473443f4779dc0bd7edf7c8497f67e325a49'
'51d22293b6a2c19471f31160bfebf832dfe2a2768e226520d46c3321d7592649' '51d22293b6a2c19471f31160bfebf832dfe2a2768e226520d46c3321d7592649'
'19d8f4e7fd0d1933dc6fcf6c7333db08e1b40fc75795464660c4d723eb62511c' '19d8f4e7fd0d1933dc6fcf6c7333db08e1b40fc75795464660c4d723eb62511c'

View file

@ -0,0 +1,5 @@
! Fonts
!Xft.dpi: 192
! st
st.font: Hack:pixelsize=12:antialias=true:autohint=true

View file

@ -1,6 +1,6 @@
/** Basic config file **/ /** Basic config file **/
configuration { configuration {
show-icons: true; show-icons: true;
icon-theme: "Papirus"; icon-theme: "Papirus";
} }

View file

@ -37,25 +37,25 @@ echo "Done"
if [[ "${dpi}" -ge 192 ]]; then if [[ "${dpi}" -ge 192 ]]; then
echo -n "Updating settings for HiDPI... " echo -n "Updating settings for HiDPI... "
# Conky
sed -i 's/default_graph_height = 24/default_graph_height = 48/' "${HOME}/.config/conky/base.conf"
sed -i 's/gap_x = 20/gap_x = 40/' "${HOME}/.config/conky/base.conf"
sed -i 's/gap_y = 24/gap_y = 48/' "${HOME}/.config/conky/base.conf"
sed -i 's/maximum_width = 180/maximum_width = 360/' "${HOME}/.config/conky/base.conf"
sed -i 's/minimum_width = 180/minimum_width = 360/' "${HOME}/.config/conky/base.conf"
# Fonts # Fonts
sed -i 's/!Xft.dpi: 192/Xft.dpi: 192/' "${HOME}/.Xresources" sed -i 's/!Xft.dpi: 192/Xft.dpi: 192/' "${HOME}/.Xresources"
sed -i 's/pixelsize=12/pixelsize=24/' "${HOME}/.Xresources"
# GDK # GDK
export GDK_SCALE=2 export GDK_SCALE=2
export GDK_DPI_SCALE=0.5 export GDK_DPI_SCALE=0.5
# Rofi # Rofi
sed -i -r 's/Noto Sans 12/Noto Sans 24/' "${HOME}/.config/rofi/config" sed -i -r 's/}/ dpi: 1;\n}/' "${HOME}/.config/rofi/config.rasi"
sed -i 's/10px/20px/' "${HOME}/.config/rofi/applets/menu/configs/rounded/powermenu.rasi"
sed -i 's/12px/24px/' "${HOME}/.config/rofi/applets/menu/configs/rounded/powermenu.rasi"
sed -i 's/15px/30px/' "${HOME}/.config/rofi/applets/menu/configs/rounded/powermenu.rasi"
sed -i 's/20px/40px/' "${HOME}/.config/rofi/applets/menu/configs/rounded/powermenu.rasi"
sed -i 's/40px/80px/' "${HOME}/.config/rofi/applets/menu/configs/rounded/powermenu.rasi"
sed -i 's/800px/2000px/' "${HOME}/.config/rofi/applets/menu/configs/rounded/powermenu.rasi"
# Tint2 # Tint2
sed -i 's/panel_size = 100% 30/panel_size = 100% 60/' \ sed -i 's/panel_size = 99% 30/panel_size = 99% 60/' \
"${HOME}/.config/tint2/tint2rc" "${HOME}/.config/tint2/tint2rc"
sed -i 's/Hack 10/Hack 20/g' \ sed -i 's/Hack 10/Hack 20/g' \
"${HOME}/.config/tint2/tint2rc" "${HOME}/.config/tint2/tint2rc"