Skip to content

Commit 985acb5

Browse files
authored
Merge pull request #499 from riscv-software-src/debug_workflow
debug: Actually run tests in github workflow.
2 parents 81f5ad4 + 87dc207 commit 985acb5

File tree

1 file changed

+172
-0
lines changed

1 file changed

+172
-0
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Build Spike and run a couple of debug tests.
2+
3+
name: Test OpenOCD against 2 spike configurations
4+
5+
env:
6+
SPIKE_REPO: https://github.com/riscv-software-src/riscv-isa-sim.git
7+
SPIKE_REV: master
8+
RISCV_TESTS_REPO: https://github.com/riscv-software-src/riscv-tests.git
9+
RISCV_TESTS_REV: master
10+
OPENOCD_REPO: https://github.com/riscv/riscv-openocd.git
11+
OPENOCD_REV: riscv
12+
TOOLCHAIN_URL: https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v12.2.0-1/xpack-riscv-none-elf-gcc-12.2.0-1-linux-x64.tar.gz
13+
14+
on:
15+
# Run on merges to master to populate the cache with entities that are
16+
# accessible by every pull request.
17+
push:
18+
branches:
19+
- riscv
20+
paths:
21+
- 'debug/**'
22+
- '.github/workflows/spike-openocd-tests.yml'
23+
pull_request:
24+
types: [synchronize, opened, reopened]
25+
paths:
26+
- 'debug/**'
27+
- '.github/workflows/spike-openocd-tests.yml'
28+
29+
# There is some commented out code below that would be useful in adding this
30+
# workflow to other repos. Ideally we can come up with something that would
31+
# leave this file almost identical between repos, so they can all easily run
32+
# this test suite.
33+
34+
jobs:
35+
test:
36+
name: Test debug (Ubuntu)
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v3
40+
with:
41+
submodules: recursive
42+
43+
- name: Install packages
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y device-tree-compiler build-essential
47+
48+
- name: Get revisions of dependencies
49+
run: |
50+
SPIKE_COMMIT=$( git ls-remote "$SPIKE_REPO" $SPIKE_REV | awk '{ print $1; }' )
51+
OPENOCD_COMMIT=$( git ls-remote "$OPENOCD_REPO" $OPENOCD_REV | awk '{ print $1; }' )
52+
echo "Revison of Spike: $SPIKE_COMMIT"
53+
echo "Revision of OpenOCD: $OPENOCD_COMMIT"
54+
# Save for later use
55+
echo "SPIKE_COMMIT=$SPIKE_COMMIT" >> $GITHUB_ENV
56+
echo "OPENOCD_COMMIT=$OPENOCD_COMMIT" >> $GITHUB_ENV
57+
58+
- name: Get the toolchain from cache (if available)
59+
id: cache-restore-toolchain
60+
uses: actions/cache/restore@v3
61+
with:
62+
path: /opt/riscv/toolchain
63+
key: "toolchain-${{env.TOOLCHAIN_URL}}"
64+
65+
- if: ${{ steps.cache-restore-toolchain.outputs.cache-hit != 'true' }}
66+
name: Download Toolchain (if not cached)
67+
run: |
68+
mkdir -p /opt/riscv/toolchain
69+
wget --progress=dot:giga $TOOLCHAIN_URL -O /tmp/toolchain.tar.gz
70+
71+
- if: ${{ steps.cache-restore-toolchain.outputs.cache-hit != 'true' }}
72+
name: Install Toolchain (if not cached)
73+
run: tar zxf /tmp/toolchain.tar.gz --strip-components=1 -C /opt/riscv/toolchain
74+
75+
- name: Save the toolchain to the cache (if necessary)
76+
id: cache-save-toolchain
77+
uses: actions/cache/save@v3
78+
with:
79+
path: /opt/riscv/toolchain
80+
key: "toolchain-${{env.TOOLCHAIN_URL}}"
81+
82+
- name: Get OpenOCD from cache (if available)
83+
id: cache-restore-openocd
84+
uses: actions/cache/restore@v3
85+
with:
86+
path: /opt/riscv/openocd
87+
key: "openocd-${{env.OPENOCD_COMMIT}}"
88+
89+
- if: ${{ steps.cache-restore-openocd.outputs.cache-hit != 'true' }}
90+
name: Download OpenOCD source (if not cached)
91+
run: |
92+
git clone "$OPENOCD_REPO"
93+
cd riscv-openocd
94+
git checkout "$OPENOCD_COMMIT"
95+
git submodule update --init --recursive
96+
97+
- if: ${{ steps.cache-restore-openocd.outputs.cache-hit != 'true' }}
98+
name: Build OpenOCD (if not cached)
99+
run: |
100+
cd riscv-openocd
101+
./bootstrap
102+
./configure --prefix=/opt/riscv/openocd
103+
make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
104+
make install
105+
106+
- if: ${{ steps.cache-restore-openocd.outputs.cache-hit != 'true' }}
107+
name: Save OpenOCD to cache (if built)
108+
id: cache-save-openocd
109+
uses: actions/cache/save@v3
110+
with:
111+
path: /opt/riscv/openocd
112+
key: "openocd-${{env.OPENOCD_COMMIT}}"
113+
114+
- name: Get spike from cache (if available)
115+
id: cache-restore-spike
116+
uses: actions/cache/restore@v3
117+
with:
118+
path: /opt/riscv/spike
119+
key: "spike-${{env.SPIKE_COMMIT}}"
120+
121+
- if: ${{ steps.cache-restore-spike.outputs.cache-hit != 'true' }}
122+
name: Download Spike source (if not cached)
123+
run: |
124+
git clone "$SPIKE_REPO"
125+
cd riscv-isa-sim
126+
git checkout "$SPIKE_COMMIT"
127+
git submodule update --init --recursive
128+
129+
- if: ${{ steps.cache-restore-spike.outputs.cache-hit != 'true' }}
130+
name: Build Spike (if not cached)
131+
run: |
132+
cd riscv-isa-sim
133+
mkdir build && cd build
134+
../configure --prefix=/opt/riscv/spike
135+
make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
136+
make install
137+
138+
- if: ${{ steps.cache-restore-spike.outputs.cache-hit != 'true' }}
139+
name: Save spike to cache (if built)
140+
id: cache-save-spike
141+
uses: actions/cache/save@v3
142+
with:
143+
path: /opt/riscv/spike
144+
key: "spike-${{env.SPIKE_COMMIT}}"
145+
146+
- name: Run Spike32 Tests
147+
id: spike32-tests
148+
run: |
149+
cd debug
150+
./gdbserver.py targets/RISC-V/spike32.py --print-failures \
151+
--gcc /opt/riscv/toolchain/bin/riscv-none-elf-gcc \
152+
--gdb /opt/riscv/toolchain/bin/riscv-none-elf-gdb \
153+
--sim_cmd /opt/riscv/spike/bin/spike \
154+
--server_cmd /opt/riscv/openocd/bin/openocd
155+
156+
- name: Run Spike64-2 Tests
157+
if: success() || steps.spike32-tests.conclusion == 'failure'
158+
run: |
159+
cd debug
160+
./gdbserver.py targets/RISC-V/spike64-2.py --print-failures \
161+
--gcc /opt/riscv/toolchain/bin/riscv-none-elf-gcc \
162+
--gdb /opt/riscv/toolchain/bin/riscv-none-elf-gdb \
163+
--sim_cmd /opt/riscv/spike/bin/spike \
164+
--server_cmd /opt/riscv/openocd/bin/openocd
165+
166+
- name: Archive test logs
167+
# Proceed even if there was a failed test
168+
if: ${{ success() || failure() }}
169+
uses: actions/upload-artifact@v3
170+
with:
171+
name: test-logs
172+
path: riscv-tests/debug/logs

0 commit comments

Comments
 (0)