-
Notifications
You must be signed in to change notification settings - Fork 23
77 lines (71 loc) · 2.38 KB
/
mmio-check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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)"