Skip to content

Commit

Permalink
Merge pull request #245 from chipsalliance/wsip/drop_periph_test
Browse files Browse the repository at this point in the history
Merge GDB tests into one
  • Loading branch information
tmichalak authored Oct 16, 2024
2 parents 199eae1 + a9658b8 commit d22fa40
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 225 deletions.
29 changes: 0 additions & 29 deletions .github/scripts/breakpoint.gdb

This file was deleted.

1 change: 0 additions & 1 deletion .github/scripts/breakpoint_golden.txt

This file was deleted.

6 changes: 3 additions & 3 deletions .github/scripts/dump_and_compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
set -ex

# Invoke GDB and dump core registers
${GCC_PREFIX}-gdb -n --batch -x dump_registers.gdb >gdb.log
${GCC_PREFIX}-gdb -n --batch -x test.gdb >gdb.log
# Parse the log, extract register values. Skip those which change as the
# program executes since we don't know at which point we tap in.
cat gdb.log | grep -E '^ra |^sp |^gp |^tp |^t[01256] |^s[0-9]+ |^a[0-9]+ |^\$[0-9]+' >regdump.txt
cat gdb.log | grep -E '^ra |^sp |^gp |^tp |^t[01256] |^s[0-9]+ |^a[0-9]+ |^\$[0-9]+' >gdb_test_dump.txt

# Compare the dumps
# TODO this temporarily exits with success just to allow collecting coverage data
# without considering the truthness of register values.
diff -E -y regdump_golden.txt regdump.txt || true
diff -E -y gdb_test_golden.txt gdb_test_dump.txt || true

24 changes: 0 additions & 24 deletions .github/scripts/dump_registers.gdb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ s10 0x0 0
s11 0x0 0
t5 0x0 0
t6 0x0 0
$1 = {0xcafebaba, 0xdeadbeef, 0xfeedbaca, 0xa5a5a5a5}
$2 = {0x1234567, 0x89abcdef, 0x55555555, 0xaaaaaaaa}
$3 = {0xaaaab0b7, 0xaaa08093, 0x7c009073, 0x90734191, 0x50b77f91, 0x80931234, 0xf1376780, 0x7111abcd}
Breakpoint 1, 0x0000001c in ?? ()
27 changes: 0 additions & 27 deletions .github/scripts/mem_access.sh

This file was deleted.

3 changes: 0 additions & 3 deletions .github/scripts/mem_access_golden.txt

This file was deleted.

44 changes: 0 additions & 44 deletions .github/scripts/peripheral_access.gdb

This file was deleted.

25 changes: 0 additions & 25 deletions .github/scripts/peripheral_access.sh

This file was deleted.

9 changes: 0 additions & 9 deletions .github/scripts/peripheral_access_golden.txt

This file was deleted.

16 changes: 14 additions & 2 deletions .github/scripts/mem_access.gdb → .github/scripts/test.gdb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ set remotetimeout 30
target extended-remote :3333

echo Connected, waiting...\n
shell sleep 5s
shell sleep 30s

echo Dumping registers...\n
info registers
echo Accessing DCCM...\n
set *(0x00080000) = 0x01234567
set *(0x00080004) = 0x89ABCDEF
Expand Down Expand Up @@ -119,17 +121,27 @@ set *(0xd0000008) = 0x55555555
set *(0xd000000C) = 0xAAAAAAAA
print/x *0xd0000000@4

echo Setting Breakpoint 1...\n
hbreak *0x1c

echo Continuing...\n
continue

delete

# This causes an error. Let's execute it anyway for coverage.
echo Accessing region at 0xe0000000...\n
set *(0xe0000000) = 0x01234567
set *(0xe0000004) = 0x89ABCDEF
set *(0xe0000008) = 0x55555555
set *(0xe000000C) = 0xAAAAAAAA
print/x *0xe0000000@4

echo Accessing region at 0xf0000000...\n
set *(0xf0000000) = 0x01234567
set *(0xf0000004) = 0x89ABCDEF
set *(0xf0000008) = 0x55555555
set *(0xf000000C) = 0xAAAAAAAA
print/x *0xf0000000@4

# end the simulation gracefully
set *(volatile unsigned char*)0xd0580000 = 0xff
65 changes: 7 additions & 58 deletions .github/workflows/test-openocd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,82 +69,31 @@ jobs:
-f ${RV_ROOT}/testbench/openocd_scripts/jtag_cg.tcl
pkill openocd || true
- name: Test with GDB-test (register access)
- name: Test with GDB-test (register access, memory access, breakpoints)
run: |
# TODO GDB is in /opt/riscv and a separate toolchain is installed with apt. Make this better.
export PATH=/opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin:$PATH
export RV_ROOT=$(pwd)
mkdir reg_test
make -C reg_test -f ${RV_ROOT}/tools/Makefile verilator-build program.hex TEST=infinite_loop \
mkdir gdb_test
make -C gdb_test -f ${RV_ROOT}/tools/Makefile verilator-build program.hex TEST=infinite_loop \
CONF_PARAMS="-set build_${{ matrix.bus }} -set openocd_test" COVERAGE=${{ matrix.coverage }}
cd reg_test
cd gdb_test
${RV_ROOT}/.github/scripts/gdb_test.sh \
/bin/bash -c 'cd ${RV_ROOT}/.github/scripts && ./dump_and_compare.sh' || true
pkill openocd || true
- name: Test with GDB-test (memory access)
run: |
# TODO GDB is in /opt/riscv and a separate toolchain is installed with apt. Make this better.
export PATH=/opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin:$PATH
export RV_ROOT=$(pwd)
mkdir mem_test
make -C mem_test -f ${RV_ROOT}/tools/Makefile verilator-build program.hex TEST=infinite_loop \
CONF_PARAMS="-set build_${{ matrix.bus }} -set openocd_test" COVERAGE=${{ matrix.coverage }}
cd mem_test
${RV_ROOT}/.github/scripts/gdb_test.sh \
/bin/bash -c 'cd ${RV_ROOT}/.github/scripts && ./mem_access.sh' || true
pkill openocd || true
- name: Test with GDB-test (peripheral access)
run: |
# TODO REMOVE THIS TEST, as we aim to target all possible memory regions in the test above this,
# and there are no actual peripherals in the tesbench.
# TODO GDB is in /opt/riscv and a separate toolchain is installed with apt. Make this better.
export PATH=/opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin:$PATH
export RV_ROOT=$(pwd)
mkdir periph_test
make -C periph_test -f ${RV_ROOT}/tools/Makefile verilator-build program.hex TEST=infinite_loop \
CONF_PARAMS="-set build_${{ matrix.bus }} -set openocd_test" COVERAGE=${{ matrix.coverage }}
cd periph_test
${RV_ROOT}/.github/scripts/gdb_test.sh \
/bin/bash -c 'cd ${RV_ROOT}/.github/scripts && ./peripheral_access.sh' || true
pkill openocd || true
- name: Test with GDB-test (breakpoints)
run: |
# TODO GDB is in /opt/riscv and a separate toolchain is installed with apt. Make this better.
export PATH=/opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin:$PATH
export RV_ROOT=$(pwd)
mkdir breakpoint_test
make -C breakpoint_test -f ${RV_ROOT}/tools/Makefile verilator-build program.hex TEST=infinite_loop \
CONF_PARAMS="-set build_${{ matrix.bus }} -set openocd_test" COVERAGE=${{ matrix.coverage }}
cd breakpoint_test
${RV_ROOT}/.github/scripts/gdb_test.sh \
/bin/bash -c 'cd ${RV_ROOT}/.github/scripts && ./breakpoint.sh' || true
pkill openocd || true
- name: Prepare coverage data
shell: bash
run: |
export PATH=/opt/verilator/bin:$PATH
export RV_ROOT=$(pwd)
sis -d convert --dat-dir ${RV_ROOT}/run
sis -d convert --dat-dir ${RV_ROOT}/reg_test
sis -d convert --dat-dir ${RV_ROOT}/mem_test
sis -d convert --dat-dir ${RV_ROOT}/periph_test
sis -d convert --dat-dir ${RV_ROOT}/breakpoint_test
sis -d convert --dat-dir ${RV_ROOT}/gdb_test
mkdir -p results
mv ${RV_ROOT}/run/coverage.info \
results/coverage_openocd_${{ matrix.bus }}_${{ matrix.coverage }}.info
mv ${RV_ROOT}/reg_test/coverage.info \
results/coverage_openocd_reg_test_${{ matrix.bus }}_${{ matrix.coverage }}.info
mv ${RV_ROOT}/mem_test/coverage.info \
results/coverage_openocd__mem_test_${{ matrix.bus }}_${{ matrix.coverage }}.info
mv ${RV_ROOT}/periph_test/coverage.info \
results/coverage_openocd_periph_test_${{ matrix.bus }}_${{ matrix.coverage }}.info
mv ${RV_ROOT}/breakpoint_test/coverage.info \
results/coverage_openocd_breakpoint_test_${{ matrix.bus }}_${{ matrix.coverage }}.info
mv ${RV_ROOT}/gdb_test/coverage.info \
results/coverage_openocd_gdb_test_${{ matrix.bus }}_${{ matrix.coverage }}.info
- name: Pack artifacts
if: always()
Expand Down

0 comments on commit d22fa40

Please sign in to comment.