Add C test cases to CI #331
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validate | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
CI: 1 | |
CARGO_TERM_COLOR: always | |
RENODE_DIR: /opt/renode/ | |
# Used by renode-test to generate snapshots of failed tests | |
RENODE_CI_MODE: YES | |
DLA_BIN: dla | |
DLA_VALIDATION_BIN: validate | |
# Used for setting up RISC-V GCC toolchain for C tests | |
RISCV: /opt/riscv/ | |
RISCV_XLEN: riscv64 | |
GCC_VER: "2024.04.12" | |
UBUNTU_VER: ubuntu-22.04 | |
jobs: | |
check-bsp: | |
runs-on: ubuntu-latest | |
env: | |
RUSTFLAGS: -D warnings | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install requirements | |
run: rustup target add riscv64imac-unknown-none-elf riscv32im-unknown-none-elf | |
- name: Run linter | |
working-directory: ./examples/headsail-bsp | |
run: cargo clippy -- -D clippy::style | |
- name: Check BSP (-Fsysctrl-rt) | |
working-directory: ./examples/headsail-bsp | |
run: cargo check -Fsysctrl-rt | |
- name: Check BSP (-Fsysctrl-rt -Fvp) | |
working-directory: ./examples/headsail-bsp | |
run: cargo check -Fsysctrl-rt -Fvp | |
- name: Check BSP examples (-Fsysctrl-rt) | |
working-directory: ./examples/headsail-bsp | |
run: cargo check --examples -Fsysctrl-rt -Fpanic-uart | |
- name: Check BSP examples (-Fsysctrl-rt -Fvp) | |
working-directory: ./examples/headsail-bsp | |
run: cargo check --examples -Fsysctrl-rt -Fvp -Fpanic-uart | |
- name: Check BSP (-Fhpc-rt) | |
working-directory: ./examples/headsail-bsp | |
run: cargo check -Fhpc-rt | |
- name: Check BSP (-Fhpc-rt -Fvp) | |
working-directory: ./examples/headsail-bsp | |
run: cargo check -Fhpc-rt -Fvp | |
- name: Check BSP examples (-Fhpc-rt) | |
working-directory: ./examples/headsail-bsp | |
run: cargo check --examples -Fhpc-rt -Fpanic-uart | |
- name: Check BSP examples (-Fhpc-rt -Fvp) | |
working-directory: ./examples/headsail-bsp | |
run: cargo check --examples -Fhpc-rt -Fvp -Fpanic-uart | |
build-dla-example: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install requirements | |
run: rustup target add riscv64imac-unknown-none-elf | |
- name: Run linter | |
working-directory: ./examples/hpc/ | |
run: cargo clippy -- -D clippy::style | |
- name: Build examples | |
working-directory: ./examples/hpc/hello-dla | |
run: cargo build --example dla | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: $DLA_BIN | |
path: ./examples/hpc/target/riscv64imac-unknown-none-elf/debug/examples/dla | |
if-no-files-found: error | |
retention-days: 14 | |
run-dla-example: | |
needs: build-dla-example | |
runs-on: ubuntu-latest | |
container: | |
image: antmicro/renode:1.14.0 | |
options: --user root | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: $DLA_BIN | |
- name: Create Renode peripheral symlinks | |
run: ln -s $(readlink -f "./vp/devel/python_peripherals/DLA.py") "$RENODE_DIR/scripts/pydev/DLA.py" | |
- name: Run example | |
run: renode-test scripts/robot/is_hello.robot --variable BIN:"$(readlink -f $DLA_BIN)" | |
- name: Upload snapshots | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
path: snapshots/ | |
build-dla-validation: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create RISC-V GCC directory | |
shell: bash | |
run: mkdir /tmp/riscv-gnu-toolchain | |
- name: Download GCC | |
working-directory: /tmp/riscv-gnu-toolchain/ | |
run: | | |
wget -q https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/$GCC_VER/$RISCV_XLEN-elf-$UBUNTU_VER-gcc-nightly-$GCC_VER-nightly.tar.gz | |
mkdir ${RISCV} && \ | |
tar -xf $RISCV_XLEN-elf-$UBUNTU_VER-gcc-nightly-$GCC_VER-nightly.tar.gz --strip-components 1 -C $RISCV | |
export PATH="${RISCV}"/bin:${PATH} | |
echo "${RISCV}/bin" >> $GITHUB_PATH | |
$RISCV_XLEN-unknown-elf-gcc --version | |
$RISCV_XLEN-unknown-elf-ld --version | |
- name: Install rustup target | |
run: rustup target add riscv64imac-unknown-none-elf | |
- name: Build validation | |
working-directory: ./examples/hpc/dla-driver | |
run: cargo build --example validate -Fvp -Fhpc --target riscv64imac-unknown-none-elf | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: $DLA_VALIDATION_BIN | |
path: ./examples/hpc/target/riscv64imac-unknown-none-elf/debug/examples/validate | |
if-no-files-found: error | |
retention-days: 14 | |
run-dla-validation: | |
needs: build-dla-validation | |
runs-on: ubuntu-latest | |
container: | |
image: antmicro/renode:1.14.0 | |
options: --user root | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: $DLA_VALIDATION_BIN | |
- name: Install python dependencies | |
run: pip install -r ./scripts/robot/requirements.txt | |
- name: Create Renode peripheral symlinks | |
run: ln -s $(readlink -f "./vp/devel/python_peripherals/DLA.py") "$RENODE_DIR/scripts/pydev/DLA.py" | |
- name: Run dla validation | |
run: renode-test ./scripts/robot/dla_validate.robot --variable BIN:"$(readlink -f $DLA_VALIDATION_BIN)" | |
- name: Upload snapshots | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
path: snapshots/ | |
build-ffi: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install requirements | |
run: rustup target add riscv64imac-unknown-none-elf riscv32im-unknown-none-elf | |
- name: Build FFI without RT on SysCtrl | |
working-directory: ./examples/headsail-bsp-ffi | |
run: cargo build --target=riscv32im-unknown-none-elf -Fpanic-uart | |
- name: Build FFI without RT on HPC | |
working-directory: ./examples/headsail-bsp-ffi | |
run: cargo build --target=riscv64imac-unknown-none-elf -Fpanic-uart | |
build-minimal-c: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create RISC-V GCC directory | |
shell: bash | |
run: mkdir /tmp/riscv-gnu-toolchain | |
- name: Download GCC | |
working-directory: /tmp/riscv-gnu-toolchain/ | |
run: | | |
wget -q https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/$GCC_VER/$RISCV_XLEN-elf-$UBUNTU_VER-gcc-nightly-$GCC_VER-nightly.tar.gz | |
mkdir ${RISCV} && \ | |
tar -xf $RISCV_XLEN-elf-$UBUNTU_VER-gcc-nightly-$GCC_VER-nightly.tar.gz --strip-components 1 -C $RISCV | |
export PATH="${RISCV}"/bin:${PATH} | |
echo "${RISCV}/bin" >> $GITHUB_PATH | |
$RISCV_XLEN-unknown-elf-gcc --version | |
$RISCV_XLEN-unknown-elf-ld --version | |
- name: Build minimal C project | |
working-directory: ./examples/hpc-c/hello-hpc | |
shell: bash | |
run: | | |
source ../scripts/export_riscv.env | |
mkdir -p build && cd build | |
cmake .. && make | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hello-hpc-c.elf | |
path: ./examples/hpc-c/hello-hpc/build/hello-hpc | |
if-no-files-found: error | |
retention-days: 14 | |
build-ffi-test: | |
needs: build-minimal-c | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create RISC-V GCC directory | |
shell: bash | |
run: mkdir /tmp/riscv-gnu-toolchain | |
- name: Download GCC | |
working-directory: /tmp/riscv-gnu-toolchain/ | |
run: | | |
wget -q https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/$GCC_VER/$RISCV_XLEN-elf-$UBUNTU_VER-gcc-nightly-$GCC_VER-nightly.tar.gz | |
mkdir ${RISCV} && \ | |
tar -xf $RISCV_XLEN-elf-$UBUNTU_VER-gcc-nightly-$GCC_VER-nightly.tar.gz --strip-components 1 -C $RISCV | |
export PATH="${RISCV}"/bin:${PATH} | |
echo "${RISCV}/bin" >> $GITHUB_PATH | |
$RISCV_XLEN-unknown-elf-gcc --version | |
$RISCV_XLEN-unknown-elf-ld --version | |
- name: Build FFI test project | |
working-directory: ./examples/hpc-c/test-bsp-ffi | |
shell: bash | |
run: | | |
source ../scripts/export_riscv.env | |
mkdir -p build && cd build | |
cmake .. && make | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-bsp-ffi.elf | |
path: ./examples/hpc-c/test-bsp-ffi/build/test-bsp-ffi | |
if-no-files-found: error | |
retention-days: 14 | |
run-minimal-c: | |
needs: build-minimal-c | |
runs-on: ubuntu-latest | |
container: | |
image: antmicro/renode:1.14.0 | |
options: --user root | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download binary | |
uses: actions/download-artifact@v4 | |
with: | |
name: hello-hpc-c.elf | |
- name: Create Renode peripheral symlinks | |
run: ln -s $(readlink -f "./vp/devel/python_peripherals/DLA.py") "$RENODE_DIR/scripts/pydev/DLA.py" | |
- name: Run example | |
run: renode-test scripts/robot/is_hello.robot --variable BIN:"$(readlink -f hello-hpc-c.elf)" | |
- name: Upload snapshots | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
path: snapshots/ | |
run-ffi-test: | |
needs: build-ffi-test | |
runs-on: ubuntu-latest | |
container: | |
image: antmicro/renode:1.14.0 | |
options: --user root | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download binary | |
uses: actions/download-artifact@v4 | |
with: | |
name: test-bsp-ffi.elf | |
- name: Create Renode peripheral symlinks | |
run: ln -s $(readlink -f "./vp/devel/python_peripherals/DLA.py") "$RENODE_DIR/scripts/pydev/DLA.py" | |
- name: Run example | |
run: renode-test scripts/robot/is_hello.robot --variable BIN:"$(readlink -f test-bsp-ffi.elf)" | |
- name: Upload snapshots | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
path: snapshots/ |