#!/bin/bash # Test binary validation system set -e echo "========================================" echo "Binary Validation System Test Suite" echo "========================================" PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$PROJECT_ROOT" # Test 1: Validate existing binary echo "" echo "Test 1: Validate hyperopt_mamba2_demo binary" echo "----------------------------------------" if [ ! -f "target/release/examples/hyperopt_mamba2_demo" ]; then echo "⚠️ Binary not found, building first..." cargo build -p ml --example hyperopt_mamba2_demo --release --features cuda fi ./scripts/validate_binary.sh hyperopt_mamba2_demo echo "✅ Test 1 passed: Validation script works" # Test 2: Local binary smoke test echo "" echo "Test 2: Smoke test binary functionality" echo "----------------------------------------" if target/release/examples/hyperopt_mamba2_demo --help | grep -q "base-dir"; then echo "✅ Test 2 passed: Binary has correct CLI arguments" else echo "❌ Test 2 failed: Binary missing --base-dir argument" exit 1 fi # Test 3: Checksum comparison echo "" echo "Test 3: Checksum calculation" echo "----------------------------------------" LOCAL_SHA=$(sha256sum target/release/examples/hyperopt_mamba2_demo | awk '{print $1}') echo "Local SHA256: $LOCAL_SHA" if [ -n "$LOCAL_SHA" ] && [ ${#LOCAL_SHA} -eq 64 ]; then echo "✅ Test 3 passed: Checksum calculated correctly (64 chars)" else echo "❌ Test 3 failed: Invalid checksum format" exit 1 fi # Test 4: Python validation integration echo "" echo "Test 4: Python script integration" echo "----------------------------------------" if python3 -c " import subprocess import os project_root = os.getcwd() result = subprocess.run( [os.path.join(project_root, 'scripts/validate_binary.sh'), 'hyperopt_mamba2_demo'], capture_output=True, text=True, cwd=project_root ) if result.returncode == 0: print('✅ Test 4 passed: Python can call validation script') exit(0) elif 'VALIDATION: LOCAL_ONLY' in result.stdout: print('✅ Test 4 passed: Validation works (local-only mode)') exit(0) else: print('❌ Test 4 failed: Python integration broken') print(result.stdout) print(result.stderr) exit(1) "; then : else exit 1 fi echo "" echo "========================================" echo "✅ All validation tests passed" echo "========================================" echo "" echo "Validation system is ready for production use." echo "" echo "Next steps:" echo "1. Test deployment with: python3 scripts/runpod_deploy.py --dry-run" echo "2. Review SAFE_DEPLOYMENT_CHECKLIST.md for full workflow"