particle-os-tools/test-installation.sh
robojerk 74c7bede5f Initial commit: Particle-OS tools repository
- Complete Particle-OS rebranding from uBlue-OS
- Professional installation system with standardized paths
- Self-initialization system with --init and --reset commands
- Enhanced error messages and dependency checking
- Comprehensive testing infrastructure
- All source scriptlets updated with runtime improvements
- Clean codebase with redundant files moved to archive
- Complete documentation suite
2025-07-11 21:14:33 -07:00

154 lines
No EOL
3.8 KiB
Bash

#!/bin/bash
# Particle-OS Installation Test Script
# Tests all installed tools to ensure they work correctly
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Logging functions
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Test function
test_tool() {
local tool_name="$1"
local command="$2"
local description="$3"
log_info "Testing $tool_name: $description"
if command -v "$tool_name" >/dev/null 2>&1; then
if eval "$command" >/dev/null 2>&1; then
log_success "$tool_name working correctly"
return 0
else
log_warning "$tool_name installed but command failed"
return 1
fi
else
log_error "$tool_name not found in PATH"
return 1
fi
}
# Main test function
main() {
log_info "Particle-OS Installation Test"
log_info "Testing all installed tools..."
echo
local all_passed=true
# Test apt-layer
if test_tool "apt-layer" "apt-layer --help" "help command"; then
log_success "apt-layer basic functionality OK"
else
all_passed=false
fi
# Test composefs
if test_tool "composefs" "composefs --help" "help command"; then
log_success "composefs basic functionality OK"
else
all_passed=false
fi
# Test bootc
if test_tool "bootc" "bootc --help" "help command"; then
log_success "bootc basic functionality OK"
else
all_passed=false
fi
# Test bootupd
if test_tool "bootupd" "bootupd --help" "help command"; then
log_success "bootupd basic functionality OK"
else
all_passed=false
fi
# Test particle-orchestrator
if test_tool "particle-orchestrator" "particle-orchestrator help" "help command"; then
log_success "particle-orchestrator basic functionality OK"
else
all_passed=false
fi
# Test particle-oci
if test_tool "particle-oci" "particle-oci --help" "help command"; then
log_success "particle-oci basic functionality OK"
else
all_passed=false
fi
# Test particle-logrotate
if test_tool "particle-logrotate" "particle-logrotate --help" "help command"; then
log_success "particle-logrotate basic functionality OK"
else
all_passed=false
fi
echo
log_info "Testing system directories..."
# Test system directories
local dirs=(
"/var/lib/particle-os"
"/var/log/particle-os"
"/var/cache/particle-os"
"/usr/local/etc/particle-os"
)
for dir in "${dirs[@]}"; do
if [[ -d "$dir" ]]; then
log_success "✓ Directory exists: $dir"
else
log_warning "⚠ Directory missing: $dir"
all_passed=false
fi
done
# Test configuration file
if [[ -f "/usr/local/etc/particle-config.sh" ]]; then
log_success "✓ Configuration file exists"
else
log_warning "⚠ Configuration file missing"
all_passed=false
fi
echo
if [[ "$all_passed" == "true" ]]; then
log_success "All tests passed! Particle-OS installation is working correctly."
echo
log_info "Next steps:"
log_info "1. Test apt-layer with: sudo apt-layer --init"
log_info "2. Test layer creation: sudo apt-layer base-image new-image package-name"
log_info "3. Test orchestrator: sudo particle-orchestrator status"
else
log_warning "Some tests failed. Please check the installation."
exit 1
fi
}
# Run main function
main "$@"