From 8032512882d7ea852f170747c38ac077101be9ea Mon Sep 17 00:00:00 2001 From: Avimitin Date: Tue, 14 Jan 2025 15:23:43 +0800 Subject: [PATCH] [ci] add individual test for MMIO Signed-off-by: Avimitin --- .github/workflows/mmio-check.yml | 77 ++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/mmio-check.yml diff --git a/.github/workflows/mmio-check.yml b/.github/workflows/mmio-check.yml new file mode 100644 index 0000000000..4756e21300 --- /dev/null +++ b/.github/workflows/mmio-check.yml @@ -0,0 +1,77 @@ +name: T1 MMIO Check +on: + pull_request: + types: + - opened + - synchronize + - reopened + - ready_for_review + - labeled +env: + USER: runner + +# Cancel the current workflow when new commit pushed +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + build-emulators: + name: "Build Emulators" + runs-on: [self-hosted, linux, nixos, BIGRAM] + strategy: + fail-fast: false + matrix: + config: ["blastoise"] + ip: ["t1rocketemu", "t1emu"] + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: "Build vcs emulator" + run: | + set -o pipefail + set -o errexit + passWith() { + local msg="$1"; shift + echo + printf ">> PASS: $msg\n" "$@" + echo + } + failWith() { + local msg="$1"; shift + echo + printf ">> FAIL: $msg\n" "$@" >&2 + echo + exit 1 + } + + nix develop -c t1-helper run \ + --config ${{ matrix.config }} --ip ${{ matrix.ip }} --emu vcs-emu \ + emurt-test.simple + + # Test 1: Test mmio-event.jsonl file exists + mmioResultFile="$(realpath $PWD/./t1-sim-result/result/mmio-event.jsonl)" + if [[ ! -r "$mmioResultFile" ]]; then + failWith "mmio-event.jsonl not found" + fi + passWith "mmio-result file found ($mmioResultFile)" + + # Test 2: Test output is expected String + mmioOutput=$(jq -r 'select(.event == "uart-write") | .value' "$mmioResultFile" \ + | awk '{ printf "%c", $1}') + expectResult="Hello, World" + if [[ "$mmioOutput" != "$expectResult" ]]; then + failWith "Expect '$expectResult', got '$mmioOutput'" + fi + passWith "mmio-result is expected ($mmioOutput)" + + # Test 3: Test program instrument did work + calculator=$(realpath ./nix/t1/run/calculate-cycle.py) + cd $(dirname "$mmioResultFile") + cycles=$(python3 "$calculator") + total_cycles=$(nix run '.#jq' -- .total_cycles perf.json) + if (( $cycles < 0 || $cycles > $total_cycles )); then + failWith "invalid program instrument $cycles found" + fi + passWith "program instrument cycles is valid ($cycles)"