From 584a1cbb108d62a9dd3752347b937dcfebaeb8f7 Mon Sep 17 00:00:00 2001 From: Fabing Li Date: Sat, 29 Mar 2025 01:47:31 +0000 Subject: [PATCH] Reconstruct the integration/OSDK tests for flexible arch support --- .github/actions/test/action.yml | 99 ++++++++++++ .github/workflows/test_asterinas.yml | 216 --------------------------- .github/workflows/test_osdk.yml | 76 ---------- .github/workflows/test_x86.yml | 108 ++++++++++++++ .github/workflows/test_x86_tdx.yml | 72 +++++++++ README.md | 4 +- README_CN.md | 4 +- README_JP.md | 4 +- 8 files changed, 285 insertions(+), 298 deletions(-) create mode 100644 .github/actions/test/action.yml delete mode 100644 .github/workflows/test_asterinas.yml delete mode 100644 .github/workflows/test_osdk.yml create mode 100644 .github/workflows/test_x86.yml create mode 100644 .github/workflows/test_x86_tdx.yml diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml new file mode 100644 index 00000000..c70925c1 --- /dev/null +++ b/.github/actions/test/action.yml @@ -0,0 +1,99 @@ +name: 'Test' +description: 'Run tests for Asterinas' +branding: + icon: 'check-circle' + color: 'green' +inputs: + # Test Configuration + auto_test: + description: 'Test type (general, osdk, boot, syscall, test)' + required: true + release: + description: 'Whether to run in release mode' + required: false + + # Virtualization Settings + enable_kvm: + description: 'Enable KVM acceleration' + required: false + intel_tdx: + description: 'Enable Intel TDX support' + required: false + smp: + description: 'Number of CPUs' + required: false + netdev: + description: 'Network device type (user/tap)' + required: false + scheme: + description: 'Test scheme (default/microvm/iommu)' + required: false + + # Test Parameters + extra_blocklists: + description: 'Extra blocklists directories' + required: false + syscall_test_dir: + description: 'Syscall test directory' + required: false + boot_protocol: + description: 'Boot protocol (linux-efi-handover64/multiboot/multiboot2/linux-legacy32)' + required: false + +runs: + using: 'composite' + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup environment + shell: bash + run: | + # Set common environment variables using GitHub's environment files + if [[ "${{ inputs.intel_tdx }}" == "true" ]]; then + echo "RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static" >> $GITHUB_ENV + echo "RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup" >> $GITHUB_ENV + fi + + - name: Run basic tests + if: ${{ inputs.auto_test == 'general' }} + shell: bash + run: | + if [[ "${{ matrix.id }}" == "lint" ]]; then + make check + elif [[ "${{ matrix.id }}" == "compile" ]]; then + make build FEATURES=all + elif [[ "${{ matrix.id }}" == "usermode_test" ]]; then + make test + elif [[ "${{ matrix.id }}" == "ktest" ]]; then + make ktest NETDEV=tap + fi + + - name: Run integration test + if: ${{ !(inputs.auto_test == 'general' || inputs.auto_test == 'osdk') }} + shell: bash + run: | + CMD="make run AUTO_TEST=${{ inputs.auto_test }}" + [[ "${{ inputs.intel_tdx }}" == "true" ]] && CMD+=" INTEL_TDX=1" + [[ "${{ inputs.release }}" == "true" ]] && CMD+=" RELEASE=1" + [[ "${{ inputs.enable_kvm }}" == "false" ]] && CMD+=" ENABLE_KVM=0" + [[ -n "${{ inputs.smp }}" ]] && CMD+=" SMP=${{ inputs.smp }}" + [[ -n "${{ inputs.netdev }}" ]] && CMD+=" NETDEV=${{ inputs.netdev }}" + [[ -n "${{ inputs.scheme }}" ]] && CMD+=" SCHEME=${{ inputs.scheme }}" + [[ -n "${{ inputs.extra_blocklists }}" ]] && CMD+=" EXTRA_BLOCKLISTS_DIRS=${{ inputs.extra_blocklists }}" + [[ -n "${{ inputs.syscall_test_dir }}" ]] && CMD+=" SYSCALL_TEST_DIR=${{ inputs.syscall_test_dir }}" + [[ -n "${{ inputs.boot_protocol }}" ]] && CMD+=" BOOT_PROTOCOL=${{ inputs.boot_protocol }}" + + echo "Executing: $CMD" + eval $CMD + + - name: Run OSDK tests + if: ${{ inputs.auto_test == 'osdk' }} + shell: bash + run: | + [[ "${{ !contains(matrix.container, 'osdk') }}" == "true" ]] && make check_osdk + if [[ "${{ inputs.intel_tdx }}" == "true" ]]; then + RUSTUP_HOME=/root/.rustup make test_osdk INTEL_TDX=1 + else + RUSTUP_HOME=/root/.rustup make test_osdk + fi diff --git a/.github/workflows/test_asterinas.yml b/.github/workflows/test_asterinas.yml deleted file mode 100644 index 8d38ae48..00000000 --- a/.github/workflows/test_asterinas.yml +++ /dev/null @@ -1,216 +0,0 @@ -name: Test Asterinas - -on: - pull_request: - push: - branches: - - main - # Schedule to run on every day at 22:00 UTC (06:00 Beijing Time) - schedule: - - cron: '0 22 * * *' - -jobs: - lint: - if: github.event_name == 'push' || github.event_name == 'pull_request' - runs-on: ubuntu-latest - timeout-minutes: 15 - container: asterinas/asterinas:0.14.1-20250326 - steps: - - run: echo "Running in asterinas/asterinas:0.14.1-20250326" - - - uses: actions/checkout@v4 - - - name: Check - id: check - run: make check - - compilation: - if: github.event_name == 'push' || github.event_name == 'pull_request' - runs-on: ubuntu-latest - timeout-minutes: 15 - container: asterinas/asterinas:0.14.1-20250326 - steps: - - run: echo "Running in asterinas/asterinas:0.14.1-20250326" - - - uses: actions/checkout@v4 - - # The compilation test builds the project with all features enabled. - # In contrast, subsequent tests may choose to enable select features. - - name: Compilation - id: compilation - run: make build FEATURES=all - - unit-test: - if: github.event_name == 'push' || github.event_name == 'pull_request' - runs-on: ubuntu-latest - timeout-minutes: 15 - container: - image: asterinas/asterinas:0.14.1-20250326 - options: --device=/dev/kvm --privileged - steps: - - run: echo "Running in asterinas/asterinas:0.14.1-20250326" - - - uses: actions/checkout@v4 - - - name: Usermode Unit test - id: usermode_unit_test - run: make test - - - name: Ktest Unit Test - id: ktest_unit_test - run: make ktest NETDEV=tap - - # TODO: add component check. - - integration-test: - if: github.event_name == 'push' || github.event_name == 'pull_request' - runs-on: ubuntu-latest - timeout-minutes: 15 - container: - image: asterinas/asterinas:0.14.1-20250326 - options: --device=/dev/kvm --privileged - strategy: - matrix: - # The ids of each test - test_id: - - 'boot_test_mb' - - 'boot_test_linux_legacy32' - - 'syscall_test' - - 'syscall_test_at_ext2_microvm' - - 'syscall_test_at_ext2_iommu' - - 'syscall_test_at_exfat_linux' - - 'smp_syscall_test_mb2' - - 'test_linux' - - 'smp_test_mb2' - fail-fast: false - - steps: - - run: echo "Running in asterinas/asterinas:0.14.1-20250326" - - - uses: actions/checkout@v4 - - - name: SMP Boot Test (Multiboot) - id: boot_test_mb - if: ${{ matrix.test_id == 'boot_test_mb' }} - run: make run AUTO_TEST=boot ENABLE_KVM=1 BOOT_PROTOCOL=multiboot RELEASE=1 SMP=4 NETDEV=tap - - - name: SMP Boot Test (Linux Legacy 32-bit Boot Protocol) - id: boot_test_linux_legacy32 - if: ${{ matrix.test_id == 'boot_test_linux_legacy32' }} - run: make run AUTO_TEST=boot ENABLE_KVM=1 BOOT_PROTOCOL=linux-legacy32 RELEASE=1 SMP=4 NETDEV=tap - - - name: Syscall Test (Linux EFI PE/COFF Boot Protocol) (Debug Build) - id: syscall_test - if: ${{ matrix.test_id == 'syscall_test' }} - run: make run AUTO_TEST=syscall ENABLE_KVM=1 BOOT_PROTOCOL=linux-efi-pe64 RELEASE=0 NETDEV=tap - - - name: Syscall Test at Ext2 (MicroVM) - id: syscall_test_at_ext2_microvm - if: ${{ matrix.test_id == 'syscall_test_at_ext2_microvm' }} - run: make run AUTO_TEST=syscall SYSCALL_TEST_DIR=/ext2 ENABLE_KVM=1 SCHEME=microvm RELEASE=1 NETDEV=tap - - - name: Syscall Test at Ext2 (IOMMU) (Debug Build) - id: syscall_test_at_ext2_iommu - if: ${{ matrix.test_id == 'syscall_test_at_ext2_iommu' }} - run: make run AUTO_TEST=syscall SYSCALL_TEST_DIR=/ext2 ENABLE_KVM=1 SCHEME=iommu RELEASE=0 NETDEV=tap - - - name: Syscall Test at Exfat (Multiboot2) (without KVM enabled) - id: syscall_test_at_exfat_linux - if: ${{ matrix.test_id == 'syscall_test_at_exfat_linux' }} - run: | - make run AUTO_TEST=syscall \ - SYSCALL_TEST_DIR=/exfat EXTRA_BLOCKLISTS_DIRS=blocklists.exfat \ - ENABLE_KVM=0 BOOT_PROTOCOL=multiboot2 RELEASE=1 NETDEV=tap - - - name: SMP Syscall Test (Multiboot2) - id: smp_syscall_test_mb2 - if: ${{ matrix.test_id == 'smp_syscall_test_mb2' }} - run: make run AUTO_TEST=syscall ENABLE_KVM=1 BOOT_PROTOCOL=multiboot2 RELEASE=1 SMP=4 NETDEV=tap - - - name: General Test (Linux EFI Handover Boot Protocol) - id: test_linux - if: ${{ matrix.test_id == 'test_linux' }} - run: make run AUTO_TEST=test ENABLE_KVM=1 BOOT_PROTOCOL=linux-efi-handover64 RELEASE=1 NETDEV=tap - - - name: SMP General Test (Multiboot2) - id: smp_test_mb2 - if: ${{ matrix.test_id == 'smp_test_mb2' }} - run: make run AUTO_TEST=test ENABLE_KVM=1 BOOT_PROTOCOL=multiboot2 RELEASE=1 SMP=4 NETDEV=tap - - integration-test-tdx: - if: github.event_name == 'schedule' - runs-on: self-hosted - timeout-minutes: 30 - container: - image: asterinas/asterinas:0.14.1-20250326-tdx - options: --device=/dev/kvm --privileged - env: - # Need to set up proxy since the self-hosted CI server is located in China, - # which has poor network connection to the official Rust crate repositories. - RUSTUP_DIST_SERVER: https://mirrors.ustc.edu.cn/rust-static - RUSTUP_UPDATE_ROOT: https://mirrors.ustc.edu.cn/rust-static/rustup - steps: - - run: echo "Running in asterinas/asterinas:0.14.1-20250326-tdx" - - uses: actions/checkout@v4 - - name: Set up the environment - run: | - chmod +x test/benchmark/bench_linux_and_aster.sh - # Set up git due to the network issue on the self-hosted runner - git config --global --add safe.directory /__w/asterinas/asterinas - git config --global http.sslVerify false - git config --global http.version HTTP/1.1 - - name: TDX Boot Test - uses: nick-invision/retry@v2 - id: tdx_boot_test - with: - timeout_minutes: 20 - max_attempts: 3 - command: make run AUTO_TEST=boot RELEASE=1 INTEL_TDX=1 - - - name: TDX Syscall Test - uses: nick-invision/retry@v2 - id: tdx_syscall_test - with: - timeout_minutes: 20 - max_attempts: 3 - command: make run AUTO_TEST=syscall RELEASE=1 INTEL_TDX=1 - - - name: TDX Syscall Test at Exfat - uses: nick-invision/retry@v2 - id: tdx_syscall_test_at_exfat - with: - timeout_minutes: 20 - max_attempts: 3 - command: make run AUTO_TEST=syscall SYSCALL_TEST_DIR=/exfat EXTRA_BLOCKLISTS_DIRS=blocklists.exfat RELEASE=1 INTEL_TDX=1 - - - name: TDX General Test - uses: nick-invision/retry@v2 - id: tdx_general_test - with: - timeout_minutes: 20 - max_attempts: 3 - command: make run AUTO_TEST=test RELEASE=1 INTEL_TDX=1 - - - name: TDX SMP Boot Test - uses: nick-invision/retry@v2 - id: tdx_smp_boot_test - with: - timeout_minutes: 20 - max_attempts: 3 - command: make run AUTO_TEST=boot INTEL_TDX=1 RELEASE=1 SMP=4 NETDEV=tap - - - name: TDX SMP General Test - uses: nick-invision/retry@v2 - id: tdx_smp_general_test - with: - timeout_minutes: 20 - max_attempts: 3 - command: make run AUTO_TEST=test INTEL_TDX=1 RELEASE=1 SMP=4 NETDEV=tap - - - name: TDX SMP Syscall Test - uses: nick-invision/retry@v2 - id: tdx_smp_syscall_test - with: - timeout_minutes: 20 - max_attempts: 3 - command: make run AUTO_TEST=syscall INTEL_TDX=1 RELEASE=1 SMP=4 NETDEV=tap diff --git a/.github/workflows/test_osdk.yml b/.github/workflows/test_osdk.yml deleted file mode 100644 index 7ec12ae4..00000000 --- a/.github/workflows/test_osdk.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Test OSDK - -on: - pull_request: - paths: - - osdk/** - - ostd/** - - tools/** - - Cargo.toml - push: - branches: - - main - # Schedule to run on every day at 21:00 UTC (05:00 Beijing Time) - schedule: - - cron: '0 21 * * *' - -jobs: - osdk-test: - if: github.event_name == 'push' || github.event_name == 'pull_request' - runs-on: ubuntu-latest - timeout-minutes: 30 - strategy: - matrix: - # asterinas/asterinas:0.14.1-20250326 container is the developing container of asterinas, - # asterinas/osdk:0.14.1-20250326 container is built with the intructions from Asterinas Book - container: ['asterinas/asterinas:0.14.1-20250326', 'asterinas/osdk:0.14.1-20250326'] - fail-fast: false - container: ${{ matrix.container }} - steps: - - run: echo "Running in ${{ matrix.container }}" - - - uses: actions/checkout@v4 - - - name: Lint - id: lint - if: matrix.container == 'asterinas/asterinas:0.14.1-20250326' - run: make check_osdk - - # Github's actions/checkout@v4 will result in a new user (not root) - # and thus not using the Rust environment we set up in the container. - # So the RUSTUP_HOME needs to be set here. - - name: Unit test - id: unit_test - run: RUSTUP_HOME=/root/.rustup make test_osdk - - osdk-test-tdx: - if: github.event_name == 'schedule' - runs-on: self-hosted - timeout-minutes: 30 - env: - # Need to set up proxy since the self-hosted CI server is located in China, - # which has poor network connection to the official Rust crate repositories. - RUSTUP_DIST_SERVER: https://mirrors.ustc.edu.cn/rust-static - RUSTUP_UPDATE_ROOT: https://mirrors.ustc.edu.cn/rust-static/rustup - strategy: - matrix: - # asterinas/asterinas:0.14.1-20250326-tdx container is the developing container of asterinas, - # asterinas/osdk:0.14.1-20250326-tdx container is built with the intructions from Asterinas Book - container: ['asterinas/asterinas:0.14.1-20250326-tdx', 'asterinas/osdk:0.14.1-20250326-tdx'] - fail-fast: false - container: - image: ${{ matrix.container }} - options: --device=/dev/kvm --privileged - steps: - - run: echo "Running in ${{ matrix.container }}" - - uses: actions/checkout@v4 - - name: Lint - id: lint - if: matrix.container == 'asterinas/asterinas:0.14.1-20250326-tdx' - run: make check_osdk - # Github's actions/checkout@v4 will result in a new user (not root) - # and thus not using the Rust environment we set up in the container. - # So the RUSTUP_HOME needs to be set here. - - name: Unit test - id: unit_test - run: RUSTUP_HOME=/root/.rustup INTEL_TDX=1 make test_osdk diff --git a/.github/workflows/test_x86.yml b/.github/workflows/test_x86.yml new file mode 100644 index 00000000..ec14bef2 --- /dev/null +++ b/.github/workflows/test_x86.yml @@ -0,0 +1,108 @@ +name: Test x86-64 + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + +jobs: + basic-test: + runs-on: ubuntu-latest + container: + image: asterinas/asterinas:0.14.1-20250326 + options: --device=/dev/kvm --privileged + strategy: + matrix: + id: ['lint', 'compile', 'usermode_test', 'ktest'] + fail-fast: false + steps: + - uses: actions/checkout@v4 + - name: Run basic tests + uses: ./.github/actions/test + with: + auto_test: 'general' + runs_on: 'ubuntu-latest' + + integration-test: + runs-on: ubuntu-latest + container: + image: asterinas/asterinas:0.14.1-20250326 + options: --device=/dev/kvm --privileged + strategy: + matrix: + include: + # SMP Boot Test (Linux Legacy 32-bit Boot Protocol) + - test_id: 'boot-legacy32' + boot_protocol: 'linux-legacy32' + smp: 4 + # SMP Boot Test (Multiboot) + - test_id: 'boot-multiboot2-smp4' + boot_protocol: 'multiboot' + smp: 4 + + # Syscall Test (Linux EFI PE/COFF Boot Protocol) (Debug Build) + - test_id: 'syscall-debug' + release: false + boot_protocol: 'linux-efi-pe64' + # Syscall Test at Ext2 (MicroVM) + - test_id: 'syscall-ext2-microvm' + scheme: 'microvm' + syscall_test_dir: '/ext2' + # Syscall Test at Ext2 (IOMMU) (Debug Build) + - test_id: 'syscall-ext2-iommu-debug' + scheme: 'iommu' + syscall_test_dir: '/ext2' + release: false + # Syscall Test at Exfat (Multiboot2) (without KVM enabled) + - test_id: 'syscall-exfat-multiboot2-nokvm' + boot_protocol: 'multiboot2' + enable_kvm: false + extra_blocklists: 'blocklists.exfat' + syscall_test_dir: '/exfat' + # SMP Syscall Test (Multiboot2) + - test_id: 'syscall-multiboot2-smp4' + boot_protocol: 'multiboot2' + smp: 4 + + # General Test (Linux EFI Handover) + - test_id: 'general-handover64' + boot_protocol: 'linux-efi-handover64' + # SMP General Test (Multiboot2) + - test_id: 'general-multiboot2-smp4' + boot_protocol: 'multiboot2' + smp: 4 + fail-fast: false + steps: + - uses: actions/checkout@v4 + - name: Run integration tests + uses: ./.github/actions/test + with: + auto_test: ${{ (startsWith(matrix.test_id, 'boot') && 'boot') || + (startsWith(matrix.test_id, 'syscall') && 'syscall') || 'test' }} + release: ${{ matrix.release || true }} + enable_kvm: ${{ matrix.enable_kvm || true }} + smp: ${{ matrix.smp }} + netdev: ${{ matrix.netdev || 'tap' }} + scheme: ${{ matrix.scheme }} + extra_blocklists: ${{ matrix.extra_blocklists }} + syscall_test_dir: ${{ matrix.syscall_test_dir }} + boot_protocol: ${{ matrix.boot_protocol || 'linux-efi-handover64' }} + + osdk-test: + runs-on: ubuntu-latest + strategy: + matrix: + image: ['asterinas/asterinas:0.14.1-20250326', 'asterinas/osdk:0.14.1-20250326'] + fail-fast: false + container: + image: ${{ matrix.image }} + options: --device=/dev/kvm --privileged + steps: + - uses: actions/checkout@v4 + - name: Run OSDK tests + uses: ./.github/actions/test + with: + auto_test: 'osdk' + intel_tdx: false diff --git a/.github/workflows/test_x86_tdx.yml b/.github/workflows/test_x86_tdx.yml new file mode 100644 index 00000000..2f918ce8 --- /dev/null +++ b/.github/workflows/test_x86_tdx.yml @@ -0,0 +1,72 @@ +name: Test Intel TDX + +on: + workflow_dispatch: + # Schedule to run on every day at 22:00 UTC (06:00 Beijing Time) + schedule: + - cron: '0 22 * * *' + +jobs: + integration-test: + runs-on: self-hosted + container: + image: asterinas/asterinas:0.14.1-20250326-tdx + options: --device=/dev/kvm --privileged + strategy: + matrix: + include: + # Boot Test (linux-efi-handover64) + - test_id: 'boot-handover64' + # SMP Boot Test + - test_id: 'boot-handover64-smp4' + netdev: 'tap' + smp: 4 + + # Syscall Test + - test_id: 'syscall' + # Syscall Test at Exfat + - test_id: 'syscall-exfat' + extra_blocklists: 'blocklists.exfat' + syscall_test_dir: '/exfat' + # SMP Syscall Test + - test_id: 'syscall-smp4' + netdev: 'tap' + smp: 4 + + # General Test + - test_id: 'general' + # SMP General Test + - test_id: 'general-tap-smp4' + netdev: 'tap' + smp: 4 + fail-fast: false + steps: + - uses: actions/checkout@v4 + - name: Run TDX integration tests + uses: ./.github/actions/test + with: + auto_test: ${{ startsWith(matrix.test_id, 'boot') && 'boot' || + startsWith(matrix.test_id, 'syscall') && 'syscall' || 'test' }} + intel_tdx: true + release: true + smp: ${{ matrix.smp }} + netdev: ${{ matrix.netdev }} + extra_blocklists: ${{ matrix.extra_blocklists }} + syscall_test_dir: ${{ matrix.syscall_test_dir }} + + osdk-test: + runs-on: self-hosted + strategy: + matrix: + image: ['asterinas/asterinas:0.14.1-20250326-tdx', 'asterinas/osdk:0.14.1-20250326-tdx'] + fail-fast: false + container: + image: ${{ matrix.image }} + options: --device=/dev/kvm --privileged + steps: + - uses: actions/checkout@v4 + - name: Run TDX OSDK tests + uses: ./.github/actions/test + with: + auto_test: 'osdk' + intel_tdx: true diff --git a/README.md b/README.md index 10cb31cd..560931f1 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@

asterinas-logo
A secure, fast, and general-purpose OS kernel written in Rust and compatible with Linux
- Test OSDK - Test Asterinas + Test x86-64 + Test Intel TDX Benchmark Asterinas

diff --git a/README_CN.md b/README_CN.md index 843b8dd9..654ff29f 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,8 +1,8 @@

asterinas-logo
一个安全、快速、通用的操作系统内核,使用Rust编写,并与Linux兼容
- Test OSDK - Test Asterinas + Test x86-64 + Test Intel TDX Benchmark Asterinas

diff --git a/README_JP.md b/README_JP.md index 40617784..d5a8a3c7 100644 --- a/README_JP.md +++ b/README_JP.md @@ -1,8 +1,8 @@

asterinas-logo
安全で高速、汎用的なOSカーネル。Rustで書かれ、Linuxと互換性があります
- Test OSDK - Test Asterinas + Test x86-64 + Test Intel TDX Benchmark Asterinas