Procházet zdrojové kódy

pipeline: run some script to test functionalities

Signed-off-by: greatbridf <greatbridf@icloud.com>
greatbridf před 6 měsíci
rodič
revize
621d8996ed
3 změnil soubory, kde provedl 47 přidání a 13 odebrání
  1. 29 12
      .github/workflows/test-build.yaml
  2. 5 1
      Makefile.src
  3. 13 0
      script/test.sh

+ 29 - 12
.github/workflows/test-build.yaml

@@ -10,32 +10,49 @@ on:
   workflow_dispatch:
   workflow_dispatch:
 
 
 jobs:
 jobs:
-  run-build:
+  build-and-run-test:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        arch: [riscv64, loongarch64]
+        include:
+          - arch: riscv64
+            target: riscv64gc-unknown-none-elf
+          - arch: loongarch64
+            target: loongarch64-unknown-none-softfloat
     steps:
     steps:
       - name: Checkout code
       - name: Checkout code
         uses: actions/checkout@v4
         uses: actions/checkout@v4
-      
+
       - name: Setup rust nightly
       - name: Setup rust nightly
         run: rustup component add rust-src llvm-tools
         run: rustup component add rust-src llvm-tools
 
 
       - name: Configure
       - name: Configure
         run: ./configure
         run: ./configure
 
 
-      - name: Build for riscv64 targets
-        run: make build ARCH=riscv64 MODE=release
+      - name: Run build for ${{ matrix.arch }} targets
+        run: |
+          make build ARCH=${{ matrix.arch }} MODE=release
+          zstd -k build/boot-${{ matrix.arch }}.img
 
 
-      - name: Upload riscv64 build artifacts
+      - name: Upload build artifacts
         uses: actions/upload-artifact@v4
         uses: actions/upload-artifact@v4
         with:
         with:
-          name: kernel-riscv64
-          path: build/riscv64gc-unknown-none-elf/release/eonix_kernel
+          name: eonix-kernel-and-image-${{ matrix.arch }}
+          path: |
+            build/${{ matrix.target }}/release/eonix_kernel
+            build/boot-${{ matrix.arch }}.img.zst
 
 
-      - name: Build for loongarch64 targets
-        run: make build ARCH=loongarch64 MODE=release
+      - name: Test run for ${{ matrix.arch }}
+        run: sh script/test.sh
+        env:
+          ARCH: ${{ matrix.arch }}
+        timeout-minutes: 2
+        continue-on-error: true
 
 
-      - name: Upload loongarch64 build artifacts
+      - name: Upload run log
         uses: actions/upload-artifact@v4
         uses: actions/upload-artifact@v4
         with:
         with:
-          name: kernel-loongarch64
-          path: build/loongarch64gc-unknown-none-elf/release/eonix_kernel
+          name: test-${{ matrix.arch }}.log
+          path: build/test-*.log

+ 5 - 1
Makefile.src

@@ -21,7 +21,7 @@ KERNEL_SOURCES := $(shell find src macros crates -name '*.rs' -type f)
 KERNEL_CARGO_MANIFESTS += $(shell find src macros crates -name Cargo.toml -type f)
 KERNEL_CARGO_MANIFESTS += $(shell find src macros crates -name Cargo.toml -type f)
 KERNEL_DEPS := $(KERNEL_SOURCES) $(KERNEL_CARGO_MANIFESTS)
 KERNEL_DEPS := $(KERNEL_SOURCES) $(KERNEL_CARGO_MANIFESTS)
 
 
-QEMU_ARGS ?= -no-reboot -no-shutdown
+QEMU_ARGS ?= -no-reboot
 CARGO_FLAGS := --profile $(PROFILE) --features $(FEATURES)$(if $(SMP),$(COMMA)smp,)
 CARGO_FLAGS := --profile $(PROFILE) --features $(FEATURES)$(if $(SMP),$(COMMA)smp,)
 
 
 ifeq ($(HOST),darwin)
 ifeq ($(HOST),darwin)
@@ -122,6 +122,10 @@ run: build build/kernel.sym
 srun: build build/kernel.sym
 srun: build build/kernel.sym
 	$(QEMU) $(QEMU_ARGS) -display none -S -s -serial mon:stdio
 	$(QEMU) $(QEMU_ARGS) -display none -S -s -serial mon:stdio
 
 
+.PHONY: test-run
+test-run: build
+	$(QEMU) $(QEMU_ARGS) -display none -serial stdio
+
 .PHONY: clean
 .PHONY: clean
 clean:
 clean:
 	-rm -rf build
 	-rm -rf build

+ 13 - 0
script/test.sh

@@ -0,0 +1,13 @@
+#!/bin/sh
+
+SUCCESS_MSG="###$RANDOM :SuCCeSS: $RANDOM###"
+
+if [ "$ARCH" = "" ]; then
+    echo "Error: ARCH environment variable is not set." >&2
+    exit 1
+fi
+
+printf "ls\necho \"$SUCCESS_MSG\"\npoweroff\n" \
+    | make test-run ARCH=$ARCH MODE=release \
+    | tee build/test-$$.log \
+    | grep "$SUCCESS_MSG" > /dev/null && echo TEST\ $$\ WITH\ ARCH=$ARCH\ PASSED