mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 20:07:04 +01:00
Reformat three fixes libs with shfmt ahead of coverage work
shfmt runs on every staged shell file and rewrites drifted libs, which moves coverage denominators and invalidates measurements taken minutes earlier. Landing the reformat first makes every number measured from here the number that survives pre-commit. thorium_repairs.sh converts from 2-space indent to tabs; the other two only lose runs of blank lines. `git diff -w` shows no token changed, shellcheck is clean, and the 20-file suite stays green. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a2b235210f
commit
afe6ac3a33
@ -0,0 +1,43 @@
|
||||
{
|
||||
"intent": "Normalize shfmt formatting of three fixes/lib shell libraries before writing tests against them, so that coverage denominators measured later are the ones that survive pre-commit.",
|
||||
"scope": [
|
||||
"linux_configuration/scripts/single_use/fixes/lib/thorium_repairs.sh",
|
||||
"linux_configuration/scripts/single_use/fixes/lib/hosts_guard_migrate.sh",
|
||||
"linux_configuration/scripts/single_use/fixes/lib/arch_cpu.sh",
|
||||
"Non-goal: any behavioural change; this is formatting only"
|
||||
],
|
||||
"changes": [
|
||||
"Ran shfmt -w on the three libs shfmt -l reported as drifted; thorium_repairs.sh converted from 2-space indent to tabs",
|
||||
"Collapsed runs of three blank lines to one in arch_cpu.sh and hosts_guard_migrate.sh (shfmt's own normalization)"
|
||||
],
|
||||
"verification": [
|
||||
{
|
||||
"command": "git diff -w -- arch_cpu.sh hosts_guard_migrate.sh",
|
||||
"result": "pass",
|
||||
"evidence": "Only blank-line collapsing (3 -> 1) appears; no token changed. thorium_repairs.sh is empty under -w, i.e. pure indent conversion."
|
||||
},
|
||||
{
|
||||
"command": "shellcheck thorium_repairs.sh hosts_guard_migrate.sh arch_cpu.sh",
|
||||
"result": "pass",
|
||||
"evidence": "No findings, zero suppressions."
|
||||
},
|
||||
{
|
||||
"command": "bash linux_configuration/scripts/single_use/fixes/lib/tests/run_all.sh",
|
||||
"result": "pass",
|
||||
"evidence": "All fixes lib test files passed; ubuntu_perf_more: 24 passed, 0 failed. 20 test files green."
|
||||
},
|
||||
{
|
||||
"command": "wc -l on all 8 target libs",
|
||||
"result": "pass",
|
||||
"evidence": "Post-format: thorium_repairs 179, hosts_guard_migrate 159, arch_cpu 124, ubuntu_perf_fixes 215, arch_hardware 202, nvidia_config 180, hosts_guard_rollback 141, arch_sysctl 122. All under the 250-line cap."
|
||||
}
|
||||
],
|
||||
"risks": [
|
||||
"shfmt reformatting changes coverage denominators; doing it before any measurement is precisely what removes that risk for the upcoming test work",
|
||||
"thorium_repairs.sh's indent change is large in diff terms (294 lines) despite being semantically inert"
|
||||
],
|
||||
"rollback": [
|
||||
"git revert the commit; the libs return to their prior indentation",
|
||||
"Re-run tests/run_all.sh to confirm the suite is still green after rollback"
|
||||
]
|
||||
}
|
||||
@ -119,8 +119,6 @@ IOEOF
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
# ===================================================================
|
||||
# Apply all tweaks
|
||||
# ===================================================================
|
||||
|
||||
@ -33,8 +33,6 @@ validate_requirements() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
install_plugins() {
|
||||
run mkdir -p "$PLUGIN_INSTALL_DIR"
|
||||
local src
|
||||
|
||||
@ -7,173 +7,173 @@
|
||||
|
||||
# Fix 1: Handle corrupted Local State file (most common crash cause)
|
||||
fix_local_state() {
|
||||
log_info "Checking Local State file..."
|
||||
local local_state="$THORIUM_CONFIG_DIR/Local State"
|
||||
log_info "Checking Local State file..."
|
||||
local local_state="$THORIUM_CONFIG_DIR/Local State"
|
||||
|
||||
if [[ -f $local_state ]]; then
|
||||
# Check if it's valid JSON
|
||||
if ! python3 -c "import json; json.load(open('$local_state'))" 2> /dev/null; then
|
||||
log_warn "Local State file appears corrupted"
|
||||
backup_if_exists "$local_state"
|
||||
else
|
||||
# Even if valid JSON, back it up as it can still cause crashes
|
||||
log_info "Local State exists - backing up (common crash source)"
|
||||
backup_if_exists "$local_state"
|
||||
fi
|
||||
else
|
||||
log_info "No Local State file found (OK for fresh install)"
|
||||
fi
|
||||
if [[ -f $local_state ]]; then
|
||||
# Check if it's valid JSON
|
||||
if ! python3 -c "import json; json.load(open('$local_state'))" 2>/dev/null; then
|
||||
log_warn "Local State file appears corrupted"
|
||||
backup_if_exists "$local_state"
|
||||
else
|
||||
# Even if valid JSON, back it up as it can still cause crashes
|
||||
log_info "Local State exists - backing up (common crash source)"
|
||||
backup_if_exists "$local_state"
|
||||
fi
|
||||
else
|
||||
log_info "No Local State file found (OK for fresh install)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Fix 2: Clear singleton lock files
|
||||
fix_singleton_locks() {
|
||||
log_info "Clearing singleton lock files..."
|
||||
local locks=(
|
||||
"$THORIUM_CONFIG_DIR/SingletonLock"
|
||||
"$THORIUM_CONFIG_DIR/SingletonSocket"
|
||||
"$THORIUM_CONFIG_DIR/SingletonCookie"
|
||||
)
|
||||
log_info "Clearing singleton lock files..."
|
||||
local locks=(
|
||||
"$THORIUM_CONFIG_DIR/SingletonLock"
|
||||
"$THORIUM_CONFIG_DIR/SingletonSocket"
|
||||
"$THORIUM_CONFIG_DIR/SingletonCookie"
|
||||
)
|
||||
|
||||
local cleared=0
|
||||
for lock in "${locks[@]}"; do
|
||||
if remove_if_exists "$lock"; then
|
||||
((cleared++)) || true
|
||||
fi
|
||||
done
|
||||
local cleared=0
|
||||
for lock in "${locks[@]}"; do
|
||||
if remove_if_exists "$lock"; then
|
||||
((cleared++)) || true
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $cleared -eq 0 ]]; then
|
||||
log_info "No stale lock files found"
|
||||
fi
|
||||
if [[ $cleared -eq 0 ]]; then
|
||||
log_info "No stale lock files found"
|
||||
fi
|
||||
}
|
||||
|
||||
# Fix 3: Clear GPU cache
|
||||
fix_gpu_cache() {
|
||||
log_info "Clearing GPU cache..."
|
||||
local gpu_paths=(
|
||||
"$THORIUM_CONFIG_DIR/GPUCache"
|
||||
"$THORIUM_CONFIG_DIR/Default/GPUCache"
|
||||
"$THORIUM_CONFIG_DIR/ShaderCache"
|
||||
"$THORIUM_CONFIG_DIR/Default/ShaderCache"
|
||||
)
|
||||
log_info "Clearing GPU cache..."
|
||||
local gpu_paths=(
|
||||
"$THORIUM_CONFIG_DIR/GPUCache"
|
||||
"$THORIUM_CONFIG_DIR/Default/GPUCache"
|
||||
"$THORIUM_CONFIG_DIR/ShaderCache"
|
||||
"$THORIUM_CONFIG_DIR/Default/ShaderCache"
|
||||
)
|
||||
|
||||
local cleared=0
|
||||
for cache in "${gpu_paths[@]}"; do
|
||||
if remove_if_exists "$cache"; then
|
||||
((cleared++)) || true
|
||||
fi
|
||||
done
|
||||
local cleared=0
|
||||
for cache in "${gpu_paths[@]}"; do
|
||||
if remove_if_exists "$cache"; then
|
||||
((cleared++)) || true
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $cleared -eq 0 ]]; then
|
||||
log_info "No GPU cache to clear"
|
||||
fi
|
||||
if [[ $cleared -eq 0 ]]; then
|
||||
log_info "No GPU cache to clear"
|
||||
fi
|
||||
}
|
||||
|
||||
# Fix 4: Clear crash reports (can accumulate and cause issues)
|
||||
fix_crash_reports() {
|
||||
log_info "Clearing old crash reports..."
|
||||
local crash_dir="$THORIUM_CONFIG_DIR/Crash Reports"
|
||||
log_info "Clearing old crash reports..."
|
||||
local crash_dir="$THORIUM_CONFIG_DIR/Crash Reports"
|
||||
|
||||
if [[ -d $crash_dir ]]; then
|
||||
local crash_count
|
||||
crash_count=$(find "$crash_dir" -type f 2> /dev/null | wc -l)
|
||||
if [[ $crash_count -gt 0 ]]; then
|
||||
if [[ $DRY_RUN == true ]]; then
|
||||
echo " [dry-run] Would clear $crash_count crash report(s)"
|
||||
else
|
||||
rm -rf "$crash_dir"
|
||||
log_ok "Cleared $crash_count crash report(s)"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [[ -d $crash_dir ]]; then
|
||||
local crash_count
|
||||
crash_count=$(find "$crash_dir" -type f 2>/dev/null | wc -l)
|
||||
if [[ $crash_count -gt 0 ]]; then
|
||||
if [[ $DRY_RUN == true ]]; then
|
||||
echo " [dry-run] Would clear $crash_count crash report(s)"
|
||||
else
|
||||
rm -rf "$crash_dir"
|
||||
log_ok "Cleared $crash_count crash report(s)"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Fix 5: Aggressive cleaning (optional)
|
||||
fix_aggressive() {
|
||||
if [[ $AGGRESSIVE != true ]]; then
|
||||
return
|
||||
fi
|
||||
if [[ $AGGRESSIVE != true ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
log_warn "Applying aggressive fixes (may lose some site data)..."
|
||||
log_warn "Applying aggressive fixes (may lose some site data)..."
|
||||
|
||||
local aggressive_paths=(
|
||||
"$THORIUM_CONFIG_DIR/Default/Service Worker"
|
||||
"$THORIUM_CONFIG_DIR/Default/Cache"
|
||||
"$THORIUM_CONFIG_DIR/Default/Code Cache"
|
||||
"$THORIUM_CONFIG_DIR/Default/IndexedDB"
|
||||
"$THORIUM_CONFIG_DIR/BrowserMetrics"
|
||||
"$THORIUM_CONFIG_DIR/component_crx_cache"
|
||||
)
|
||||
local aggressive_paths=(
|
||||
"$THORIUM_CONFIG_DIR/Default/Service Worker"
|
||||
"$THORIUM_CONFIG_DIR/Default/Cache"
|
||||
"$THORIUM_CONFIG_DIR/Default/Code Cache"
|
||||
"$THORIUM_CONFIG_DIR/Default/IndexedDB"
|
||||
"$THORIUM_CONFIG_DIR/BrowserMetrics"
|
||||
"$THORIUM_CONFIG_DIR/component_crx_cache"
|
||||
)
|
||||
|
||||
for path in "${aggressive_paths[@]}"; do
|
||||
remove_if_exists "$path"
|
||||
done
|
||||
for path in "${aggressive_paths[@]}"; do
|
||||
remove_if_exists "$path"
|
||||
done
|
||||
|
||||
# Backup potentially corrupted databases
|
||||
local db_files=(
|
||||
"$THORIUM_CONFIG_DIR/Default/Web Data"
|
||||
"$THORIUM_CONFIG_DIR/Default/History"
|
||||
)
|
||||
# Backup potentially corrupted databases
|
||||
local db_files=(
|
||||
"$THORIUM_CONFIG_DIR/Default/Web Data"
|
||||
"$THORIUM_CONFIG_DIR/Default/History"
|
||||
)
|
||||
|
||||
for db in "${db_files[@]}"; do
|
||||
if [[ -f $db ]]; then
|
||||
log_info "Checking database: $(basename "$db")"
|
||||
# Simple corruption check - if sqlite3 can't open it, back it up
|
||||
if command -v sqlite3 &> /dev/null; then
|
||||
if ! sqlite3 "$db" "PRAGMA integrity_check;" &> /dev/null; then
|
||||
log_warn "Database may be corrupted: $(basename "$db")"
|
||||
backup_if_exists "$db"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
for db in "${db_files[@]}"; do
|
||||
if [[ -f $db ]]; then
|
||||
log_info "Checking database: $(basename "$db")"
|
||||
# Simple corruption check - if sqlite3 can't open it, back it up
|
||||
if command -v sqlite3 &>/dev/null; then
|
||||
if ! sqlite3 "$db" "PRAGMA integrity_check;" &>/dev/null; then
|
||||
log_warn "Database may be corrupted: $(basename "$db")"
|
||||
backup_if_exists "$db"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Test if Thorium starts successfully
|
||||
test_thorium() {
|
||||
if [[ $TEST_AFTER != true ]]; then
|
||||
return
|
||||
fi
|
||||
if [[ $TEST_AFTER != true ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
log_info "Testing Thorium startup..."
|
||||
log_info "Testing Thorium startup..."
|
||||
|
||||
if [[ $DRY_RUN == true ]]; then
|
||||
echo " [dry-run] Would test thorium-browser startup"
|
||||
return
|
||||
fi
|
||||
if [[ $DRY_RUN == true ]]; then
|
||||
echo " [dry-run] Would test thorium-browser startup"
|
||||
return
|
||||
fi
|
||||
|
||||
# Start Thorium in background
|
||||
thorium-browser &> /dev/null &
|
||||
local pid=$!
|
||||
# Start Thorium in background
|
||||
thorium-browser &>/dev/null &
|
||||
local pid=$!
|
||||
|
||||
# Wait a few seconds and check if it's still running
|
||||
sleep 4
|
||||
# Wait a few seconds and check if it's still running
|
||||
sleep 4
|
||||
|
||||
if kill -0 "$pid" 2> /dev/null; then
|
||||
log_ok "Thorium started successfully! (PID: $pid)"
|
||||
echo -e "${GREEN}Fix successful!${NC} Thorium is now running."
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
log_ok "Thorium started successfully! (PID: $pid)"
|
||||
echo -e "${GREEN}Fix successful!${NC} Thorium is now running."
|
||||
|
||||
# Offer to keep it running or kill it
|
||||
read -r -p "Keep browser running? [Y/n] " response
|
||||
case "$response" in
|
||||
[nN]*)
|
||||
kill "$pid" 2> /dev/null || true
|
||||
log_info "Browser closed"
|
||||
;;
|
||||
*)
|
||||
log_info "Browser left running"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
log_error "Thorium still crashing after fixes"
|
||||
echo -e "${RED}Standard fixes did not resolve the issue.${NC}"
|
||||
echo ""
|
||||
echo "Try these additional steps:"
|
||||
echo " 1. Run with --aggressive flag for deeper cleaning"
|
||||
echo " 2. Test with fresh profile: thorium-browser --user-data-dir=/tmp/thorium-test"
|
||||
echo " 3. Reinstall: yay -S thorium-browser-bin"
|
||||
echo " 4. Check NVIDIA drivers: nvidia-smi"
|
||||
exit 1
|
||||
fi
|
||||
# Offer to keep it running or kill it
|
||||
read -r -p "Keep browser running? [Y/n] " response
|
||||
case "$response" in
|
||||
[nN]*)
|
||||
kill "$pid" 2>/dev/null || true
|
||||
log_info "Browser closed"
|
||||
;;
|
||||
*)
|
||||
log_info "Browser left running"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
log_error "Thorium still crashing after fixes"
|
||||
echo -e "${RED}Standard fixes did not resolve the issue.${NC}"
|
||||
echo ""
|
||||
echo "Try these additional steps:"
|
||||
echo " 1. Run with --aggressive flag for deeper cleaning"
|
||||
echo " 2. Test with fresh profile: thorium-browser --user-data-dir=/tmp/thorium-test"
|
||||
echo " 3. Reinstall: yay -S thorium-browser-bin"
|
||||
echo " 4. Check NVIDIA drivers: nvidia-smi"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main execution
|
||||
|
||||
Loading…
Reference in New Issue
Block a user