#!/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"