Skip to content

[tests] replace perf.json total_cycles value when instrument found #9

[tests] replace perf.json total_cycles value when instrument found

[tests] replace perf.json total_cycles value when instrument found #9

Workflow file for this run

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"]
# No t1emu for now
ip: ["t1rocketemu"]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Build vcs emulator"
run: |
set -o pipefail
set -o errexit
PATH="$(nix build '.#gawk.out' --print-out-paths --no-link)/bin:$PATH"
PATH="$(nix build '.#jq.out' --print-out-paths --no-link)/bin:$PATH"
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 build '.#t1.${{matrix.config}}.${{matrix.ip}}.run.emurt-test.simple.vcs-emu' --impure
# Test 1: Test mmio-event.jsonl file exists
mmioResultFile="$(realpath ./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=$(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)"