boot-fix/test-script.sh
2025-08-28 11:17:37 -07:00

55 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
# Test script for GRUB repair script
# This script tests basic functionality without actually mounting systems
echo "Testing GRUB repair script..."
# Test help functionality
echo "Testing help command..."
./grub-repair.sh --help > /dev/null
if [ $? -eq 0 ]; then
echo "✓ Help command works"
else
echo "✗ Help command failed"
fi
# Test detect command (should work without root)
echo "Testing detect command..."
./grub-repair.sh detect > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "✓ Detect command works"
else
echo "✗ Detect command failed (expected without root)"
fi
# Test invalid command
echo "Testing invalid command..."
./grub-repair.sh invalid-command > /dev/null 2>&1
if [ $? -eq 1 ]; then
echo "✓ Invalid command handling works"
else
echo "✗ Invalid command handling failed"
fi
# Test script syntax
echo "Testing script syntax..."
bash -n grub-repair.sh
if [ $? -eq 0 ]; then
echo "✓ Script syntax is valid"
else
echo "✗ Script syntax errors found"
fi
# Test script permissions
if [ -x grub-repair.sh ]; then
echo "✓ Script is executable"
else
echo "✗ Script is not executable"
fi
echo "Basic tests completed!"
echo ""
echo "To run full tests (requires root):"
echo "sudo ./grub-repair.sh detect"
echo "sudo ./grub-repair.sh --help"