Skip to content

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

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

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

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
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 ./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)"