- Fixed missing setup_tmpfs() function that was causing silent failures - Added comprehensive system scanning for browsers, IDEs, gaming caches - Implemented detailed optimization information display for transparency - Added German locale compatibility for 'free' command (Speicher: vs Mem:) - Fixed division by zero errors in RAM calculations - Created tmpfs-info.sh helper script for detailed status reporting - Enhanced scanning to work on already-optimized systems - Added comprehensive optimization breakdowns with purpose explanations
53 lines
1.5 KiB
Bash
Executable File
53 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Test RAM calculation and display fixes
|
|
|
|
echo "🧪 Testing RAM Display Fixes"
|
|
echo "============================"
|
|
echo ""
|
|
|
|
echo "Current system RAM detection:"
|
|
ram_gb=$(free -g | awk '/^Mem:/{print $2}')
|
|
ram_mb=$(free -m | awk '/^Mem:/{print $2}')
|
|
|
|
echo " free -g result: ${ram_gb}GB"
|
|
echo " free -m result: ${ram_mb}MB"
|
|
echo ""
|
|
|
|
echo "Testing the enhanced logic:"
|
|
|
|
# Simulate the fixed logic
|
|
if [[ $ram_gb -eq 0 && $ram_mb -gt 0 ]]; then
|
|
echo " Detected edge case: free -g returned 0"
|
|
ram_gb_fixed=$((ram_mb / 1024))
|
|
[[ $ram_gb_fixed -eq 0 ]] && ram_gb_fixed=1
|
|
echo " Fixed ram_gb: ${ram_gb_fixed}GB (calculated from ${ram_mb}MB)"
|
|
else
|
|
ram_gb_fixed=$ram_gb
|
|
echo " Normal case: ram_gb = ${ram_gb_fixed}GB"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# Test percentage calculation
|
|
total_mb=12800
|
|
echo "Testing percentage calculation with ${total_mb}MB tmpfs:"
|
|
|
|
if [[ $ram_gb_fixed -gt 0 ]]; then
|
|
ram_percent=$(( (total_mb * 100) / (ram_gb_fixed * 1024) ))
|
|
echo " Result: ${total_mb}MB is ${ram_percent}% of ${ram_gb_fixed}GB RAM ✅"
|
|
else
|
|
echo " Error: Still would cause division by zero ❌"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Display output test:"
|
|
echo " 📊 Total tmpfs allocation: ${total_mb}MB (${ram_percent}% of ${ram_gb_fixed}GB RAM)"
|
|
echo " ⚡ Combined benefit: Optimized memory management for your ${ram_gb_fixed}GB system"
|
|
|
|
echo ""
|
|
echo "✅ Fixed issues:"
|
|
echo " 1. No more '0% of GB RAM' display"
|
|
echo " 2. No more 'GB system' without number"
|
|
echo " 3. Proper fallback from MB to GB calculation"
|
|
echo " 4. Minimum 1GB display for edge cases"
|