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',
}
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
THRESH_HDD_MIN = 50 * 1024**2
THRESH_HDD_AVG_HIGH = 75 * 1024**2

View file

@ -38,7 +38,7 @@ class DeviceTooSmallError(RuntimeError):
# 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.
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 calculated by using the fractional amount left off
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 = max(read_total, dev_size*IO_ALT_TEST_SIZE_FACTOR)
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')
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."""
dev_path = test_obj.dev.path
if PLATFORM == 'Darwin':
@ -148,7 +152,7 @@ def run_io_test(test_obj, log_path) -> None:
# Get dd values or bail
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:
test_obj.set_status('N/A')
test_obj.report.append(

View file

@ -46,6 +46,7 @@ Options:
-c --cli Force CLI mode
-h --help Show this page
-q --quick Skip menu and perform a quick check
-t --test-mode Run diags in test mode
--ignore-smart-errors NOT RECOMMENDED!
Only use if you have RTFM,
@ -139,8 +140,10 @@ class State():
"""Check for mid-run SMART failures and failed test(s)."""
for dev in self.disks:
disk_smart_status_check(dev, mid_run=True)
if any(test.failed for test in dev.tests):
dev.disable_disk_tests()
for test in dev.tests:
if test.failed and 'Attributes' not in test.name:
dev.disable_disk_tests()
break
def fix_tmux_layout(self, forced=True) -> None:
"""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
def cpu_stress_tests(state, test_objects) -> None:
def cpu_stress_tests(state, test_objects, test_mode=False) -> None:
# pylint: disable=too-many-statements
"""CPU & cooling check using Prime95 and Sysbench."""
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')
run_sysbench = False
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
# Bail early
@ -462,7 +468,7 @@ def cpu_stress_tests(state, test_objects) -> None:
# Show countdown
print('')
try:
print_countdown(proc=proc_mprime, seconds=cfg.hw.CPU_TEST_MINUTES*60)
print_countdown(proc=proc_mprime, seconds=test_minutes*60)
except KeyboardInterrupt:
aborted = True
@ -506,7 +512,7 @@ def cpu_stress_tests(state, test_objects) -> None:
pane=state.panes['Prime95'],
)
try:
print_countdown(proc=proc_sysbench, seconds=cfg.hw.CPU_TEST_MINUTES*60)
print_countdown(proc=proc_sysbench, seconds=test_minutes*60)
except AttributeError:
# Assuming the sysbench process wasn't found and proc was set to None
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')
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."""
LOG.info('Disk Attribute Check')
for test in test_objects:
@ -562,7 +569,8 @@ def disk_attribute_check(state, test_objects) -> None:
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."""
LOG.info('Disk I/O Benchmark (dd)')
aborted = False
@ -605,7 +613,7 @@ def disk_io_benchmark(state, test_objects, skip_usb=True) -> None:
)
state.update_progress_pane()
try:
hw_benchmark.run_io_test(test, test_log)
hw_benchmark.run_io_test(test, test_log, test_mode=test_mode)
except KeyboardInterrupt:
aborted = True
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')
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."""
LOG.info('Disk Self-Test(s)')
aborted = False
@ -703,15 +712,15 @@ def disk_smart_status_check(dev, mid_run=True) -> None:
color = 'YELLOW'
# Log errors if detected
if msg:
msg = f'{msg}{" during diagnostics" if mid_run else ""}.'
if msg and not dev.contains_note(msg):
msg = f'{msg}{" during diagnostics" if mid_run else ""}'
LOG.warning(msg)
dev.add_note(msg, color)
# Set Disk Attributes test result
for test in dev.tests:
if test.name == 'Disk Attributes':
test.failed = test.failed or msg
test.failed = bool(test.failed or msg)
test.passed = not test.failed
if test.failed:
test.set_status('Failed')
@ -723,7 +732,7 @@ def disk_smart_status_check(dev, mid_run=True) -> None:
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."""
LOG.info('Disk Surface Scan (badblocks)')
aborted = False
@ -757,7 +766,7 @@ def disk_surface_scan(state, test_objects) -> None:
# Start thread
test_log = f'{state.log_dir}/{test.dev.path.name}_badblocks.log'
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
@ -819,7 +828,7 @@ def main() -> None:
# Quick Mode
if args['--quick']:
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
# Show menu
@ -868,7 +877,7 @@ def main() -> None:
# Start diagnostics
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
state.update_top_pane('Main Menu')
@ -1117,6 +1126,7 @@ def ost_update_checkboxes(state):
def print_countdown(proc, seconds) -> None:
"""Print countdown to screen while proc is alive."""
seconds = int(seconds)
for i in range(seconds):
sec_left = (seconds - i) % 60
min_left = int((seconds - i) / 60)
@ -1142,7 +1152,7 @@ def print_countdown(proc, seconds) -> None:
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."""
aborted = False
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'])
std.clear_screen()
try:
function(state, *args)
function(state, *args, test_mode=test_mode)
except (KeyboardInterrupt, std.GenericAbort):
aborted = True
state.abort_testing()

View file

@ -17,7 +17,7 @@ from wk.hw.smart import (
generate_attribute_report,
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
@ -76,6 +76,14 @@ class Disk:
self.notes.append(note)
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:
"""Disable all tests."""
LOG.warning('Disabling all tests for: %s', self.path)

View file

@ -9,6 +9,7 @@ from wk.cfg.hw import (
BADBLOCKS_LARGE_DISK,
BADBLOCKS_REGEX,
BADBLOCKS_SKIP_REGEX,
TEST_MODE_BADBLOCKS_LIMIT,
)
from wk.exe import run_program
from wk.std import (
@ -48,7 +49,7 @@ def check_surface_scan_results(test_obj, log_path) -> None:
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."""
block_size = '1024'
dev = test_obj.dev
@ -67,6 +68,10 @@ def run_scan(test_obj, log_path) -> None:
# Start scan
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:
size_str = bytes_to_string(dev.size, use_binary=False)
_f.write(

View file

@ -15,7 +15,7 @@ source=(https://dl.suckless.org/$pkgname/$pkgname-$pkgver.tar.gz
terminfo.patch
README.terminfo.rst
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
st-desktopentry-0.8.4-edit.diff
https://st.suckless.org/patches/scrollback/st-scrollback-20210507-4536f46.diff
@ -27,7 +27,7 @@ sha256sums=('ea6832203ed02ff74182bcb8adaa9ec454c8f989e79232cb859665e2f544ab37'
'f9deea445a5c6203a0e8e699f3c3b55e27275f17fb408562c4dd5d649edeea23'
'0ebcbba881832adf9c98ce9fe7667c851d3cc3345077cb8ebe32702698665be2'
'42e4803ce2a67835f7e533a707a8a28e3804a26ced163145108970b9aee5fb81'
'1758a0930a06bf51497923bbd0b1d88a33d4ed4deb770fd85e56e5170c3a2c5b'
'5be9b40d2b51761685f6503e92028a7858cc6571a8867b88612fce8a70514d5b'
'946051d123dfe21d8f5ef0f1070c473443f4779dc0bd7edf7c8497f67e325a49'
'51d22293b6a2c19471f31160bfebf832dfe2a2768e226520d46c3321d7592649'
'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 **/
configuration {
show-icons: true;
icon-theme: "Papirus";
show-icons: true;
icon-theme: "Papirus";
}

View file

@ -37,25 +37,25 @@ echo "Done"
if [[ "${dpi}" -ge 192 ]]; then
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
sed -i 's/!Xft.dpi: 192/Xft.dpi: 192/' "${HOME}/.Xresources"
sed -i 's/pixelsize=12/pixelsize=24/' "${HOME}/.Xresources"
# GDK
export GDK_SCALE=2
export GDK_DPI_SCALE=0.5
# 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
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"
sed -i 's/Hack 10/Hack 20/g' \
"${HOME}/.config/tint2/tint2rc"