#!/bin/bash # Quick validation script for the GSP vGPU-IO project # Run this to verify structure before committing set -e RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' log_info() { echo -e "${GREEN}[INFO]${NC} $1"; } log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } log_error() { echo -e "${RED}[ERROR]${NC} $1"; } PROJECT_ROOT="${OPEN_IOV_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}" cd "$PROJECT_ROOT" log_info "=== GSP vGPU-IO Project Validation ===" # Check firmware log_info "Checking firmware..." FW="$PROJECT_ROOT/firmware/57X-GSP/570.144/gsp-570.144.fwimage.bin" if [ ! -f "$FW" ]; then log_error "Firmware not found: $FW" exit 1 fi SIZE=$(stat -c%s "$FW") MD5=$(md5sum "$FW" | cut -d' ' -f1) log_info "Firmware size: $SIZE bytes" log_info "Firmware MD5: $MD5" if [ "$MD5" != "13ce12a392a31eeb79a2e6ebd3a4a93a" ]; then log_error "MD5 mismatch!" exit 1 fi log_info "Firmware OK ✓" # Check decompiled output log_info "Checking decompiled output..." DECOMP_DIR="$PROJECT_ROOT/firmware/57X-GSP/570.144/decompiled" COUNT=$(ls "$DECOMP_DIR"/*.c 2>/dev/null | wc -l) log_info "Decompiled files: $COUNT" if [ "$COUNT" -lt 80 ]; then log_warn "Expected at least 80 files, got $COUNT" fi # Check key functions for func in \ "FUN_ram_057a1ac0" \ "FUN_ram_04cb8188" \ "FUN_ram_04f00b0c" \ "FUN_ram_04f00c78" \ "FUN_ram_057e94ec" \ "FUN_ram_051efbf4" \ "FUN_ram_059be7f4"; do if ! ls "$DECOMP_DIR/${func}_ram_"*.c 2>/dev/null | grep -q .; then log_error "Missing key function: $func" exit 1 fi done # Check entry point (different naming pattern) if [ ! -f "$DECOMP_DIR/entry_ram_04009000.c" ]; then log_error "Missing entry point" exit 1 fi log_info "Key functions present ✓" # Check driver structure log_info "Checking driver structure..." DRIVER="$PROJECT_ROOT/driver" for dir in core rpc vf bar wpr migration debugfs include; do if [ ! -d "$DRIVER/$dir" ]; then log_error "Missing driver directory: $dir" exit 1 fi done log_info "Driver directories OK ✓" # Check driver source files for file in \ "core/gsp_core.c" \ "rpc/gsp_rpc.c" \ "vf/gsp_vf.c" \ "bar/gsp_bar.c" \ "wpr/gsp_wpr.c" \ "migration/gsp_migration.c" \ "debugfs/gsp_debugfs.c" \ "include/gsp_core.h" \ "Makefile"; do if [ ! -f "$DRIVER/$file" ]; then log_error "Missing driver file: $file" exit 1 fi done log_info "Driver source files OK ✓" # Check wiki documentation log_info "Checking wiki documentation..." WIKI="$PROJECT_ROOT/wiki" for doc in \ "GSP-570.144W-Firmware-Analysis.md" \ "RPC-Message-Format.md" \ "BAR-Emulation-Specification.md" \ "WPR-Management.md" \ "Migration-Protocol.md" \ "vGPU-IO-Integration-Guide.md" \ "Address-Reference.md" \ "Error-Codes.md" \ "Glossary.md" \ "README.md"; do if [ ! -f "$WIKI/$doc" ]; then log_error "Missing wiki doc: $doc" exit 1 fi done log_info "Wiki docs OK ✓" # Check test structure log_info "Checking test structure..." TESTS="$PROJECT_ROOT/kernel/tests" for test in \ "gsp_vgpu_comprehensive_test.c" \ "gsp_vgpu_kunit_test.c" \ "gsp_vgpu_mock_test.c" \ "gsp_rpc_test.c" \ "Makefile"; do if [ ! -f "$TESTS/$test" ]; then log_error "Missing test: $test" exit 1 fi done log_info "Kernel tests OK ✓" # Check userspace tests USERS="$PROJECT_ROOT/userspace/tests" for file in "test_vgpu_userspace.c" "Makefile"; do if [ ! -f "$USERS/$file" ]; then log_error "Missing userspace test: $file" exit 1 fi done log_info "Userspace tests OK ✓" # Check userspace library USRLIB="$PROJECT_ROOT/userspace/lib" USRINC="$PROJECT_ROOT/userspace/include" for file in "libvgpu.c" "Makefile" "libvgpu.pc.in"; do if [ ! -f "$USRLIB/$file" ]; then log_error "Missing userspace lib: $file" exit 1 fi done if [ ! -f "$USRINC/libvgpu.h" ]; then log_error "Missing userspace lib: libvgpu.h" exit 1 fi log_info "Userspace lib OK ✓" # Check examples EXAMPLES="$PROJECT_ROOT/userspace/examples" for file in "example_vgpu.c" "Makefile"; do if [ ! -f "$EXAMPLES/$file" ]; then log_error "Missing example: $file" exit 1 fi done log_info "Examples OK ✓" # Check userspace top-level Makefile if [ ! -f "$PROJECT_ROOT/userspace/Makefile" ]; then log_error "Missing userspace Makefile" exit 1 fi log_info "Userspace Makefile OK ✓" # Check integration test runner if [ ! -f "$PROJECT_ROOT/tools/test/run_integration_tests.sh" ]; then log_error "Missing integration test runner" exit 1 fi log_info "Integration test runner OK ✓" # Check CI/CD if [ ! -f "$PROJECT_ROOT/.github/workflows/ci.yml" ]; then log_error "Missing CI workflow" exit 1 fi log_info "CI/CD workflow OK ✓" # Check top-level README if [ ! -f "$PROJECT_ROOT/README.md" ]; then log_error "Missing top-level README" exit 1 fi log_info "README OK ✓" # Syntax check C files (basic) log_info "Running basic syntax checks..." for cfile in $(find "$DRIVER" -name "*.c" -o -name "*.h"); do # Check for basic issues if grep -q "TODO\|FIXME\|XXX" "$cfile"; then log_warn "$cfile contains TODO/FIXME/XXX" fi done log_info "Syntax check complete ✓" # Summary log_info "=== Validation Complete ===" log_info "All checks passed! ✓" log_info "" log_info "Project structure:" log_info " Firmware: $FW" log_info " Decompiled: $COUNT files" log_info " Driver modules: 7 (core, rpc, vf, bar, wpr, migration, debugfs)" log_info " Wiki docs: 10 files" log_info " Kernel tests: 4 test modules + Makefile" log_info " Userspace tests: 1 test + Makefile" log_info " Integration: run_integration_tests.sh" log_info " CI/CD: GitHub Actions" log_info " README: Project documentation" exit 0