Skip to content

Commit

Permalink
add integration testing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tullom committed Jan 8, 2025
1 parent 3a87161 commit c0d7213
Show file tree
Hide file tree
Showing 22 changed files with 520 additions and 77 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/hwtest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow executes HW tests on an NXP RT600 EVK.
# NOTE: for now it simply executes a build on the self-hosted test runner PC.
#
permissions:
contents: read
on:
push:
branches: [main]
pull_request:

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
name: hwtest-automation
jobs:
hwtest-automation:
runs-on: self-hosted
name: Run integration tests
strategy:
matrix:
target: [thumbv8m.main-none-eabihf]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: run tests
run: |
cd examples\rt685s-evk
$sshcommand = "ssh [email protected] ./run_tests.sh " + "${{env.BRANCH_NAME}}"
Write-Output $sshcommand
Restore-VMCheckpoint -VMName "hwrunner" -Name "fresh" -Confirm:$false
# Pause for 5 seconds
Start-Sleep -Seconds 5
$output = Invoke-Expression $sshcommand
# Output the result
Write-Output $output
Restore-VMCheckpoint -VMName "hwrunner" -Name "fresh" -Confirm:$false
# Determine the success or failure based on the output
if ($output -match "Some tests failed:") {
exit 1
}
elseif ($output -match "All tests passed!") {
exit 0
}
exit 1
10 changes: 10 additions & 0 deletions examples/rt685s-evk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ futures = { version = "0.3.30", default-features = false, features = [
"async-await",
] }
mimxrt600-fcb = "0.1.0"

rand = { version = "0.8.5", default-features = false }

[profile.release]
lto = true # better optimizations


[[bin]]
name = "test-gpio-blinky"
path = "src/tests/test-gpio-blinky.rs"

[[bin]]
name = "test-gpio-flex"
path = "src/tests/test-gpio-flex.rs"
2 changes: 2 additions & 0 deletions examples/rt685s-evk/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ fn main() {
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");

println!("cargo::rustc-link-arg-tests=-Tembedded-test.x");

// Inject crate version into the .biv section.
File::create(out.join("biv.rs"))
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion examples/rt685s-evk/src/bin/clocks-blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use embassy_executor::Spawner;
use embassy_imxrt::iopctl::IopctlPin;
use embassy_imxrt::{clocks, gpio};
use embassy_time::Timer;
use {defmt_rtt as _, embassy_imxrt as _, panic_probe as _};
use {defmt_rtt as _, embassy_imxrt as _};

#[embassy_executor::main]
async fn main(_spawner: Spawner) {
Expand Down
2 changes: 1 addition & 1 deletion examples/rt685s-evk/src/bin/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
extern crate embassy_imxrt_examples;

use defmt::*;
use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_imxrt::crc::{Config, Crc, Polynomial};
use {defmt_rtt as _, panic_probe as _};

#[embassy_executor::main]
async fn main(_spawner: Spawner) {
Expand Down
123 changes: 60 additions & 63 deletions examples/rt685s-evk/src/bin/dma-mem.rs
Original file line number Diff line number Diff line change
@@ -1,50 +1,47 @@
#![no_std]
#![no_main]

extern crate embassy_imxrt_examples;

use defmt::*;
use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_imxrt::dma::channel::Channel;
use embassy_imxrt::dma::transfer::{Priority, Transfer, TransferOptions, Width};
use embassy_imxrt::dma::transfer::{Priority, TransferOptions, Width};
use embassy_imxrt::dma::Dma;
use embassy_imxrt::peripherals::*;
use {defmt_rtt as _, panic_probe as _};

const TEST_LEN: usize = 16;

macro_rules! test_dma_channel {
($peripherals:expr, $instance:ident, $number:expr) => {
($peripherals: expr, $rng: expr, $instance: ident, $number: expr) => {
let ch = Dma::reserve_channel::<$instance>($peripherals.$instance);
dma_test(ch, $number).await;
};
}

async fn dma_test(ch: Channel<'static>, number: usize) {
for width in [Width::Bit8, Width::Bit16, Width::Bit32] {
let mut srcbuf: [u8; TEST_LEN] = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
let mut dstbuf = [0u8; TEST_LEN];
srcbuf[0] = number as u8;
for width in [Width::Bit8, Width::Bit16, Width::Bit32] {
let mut srcbuf: [u8; TEST_LEN] = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
let mut dstbuf = [0u8; TEST_LEN];
srcbuf[0] = $number;

let mut options = TransferOptions::default();
options.width = width;
options.priority = Priority::Priority0;
let mut options = TransferOptions::default();
options.width = width;
options.priority = Priority::Priority0;
ch.write_to_memory(&srcbuf[..], &mut dstbuf[..], options).await;

Transfer::new_write_mem(&ch, &srcbuf, &mut dstbuf, options).await;

if srcbuf == dstbuf {
info!(
"DMA transfer width: {}, on channel {} completed successfully: {:02x}",
width.byte_width(),
number,
dstbuf.iter().as_slice()
);
} else {
error!(
"DMA transfer width: {}, on channel {} failed!",
width.byte_width(),
number
);
if srcbuf == dstbuf {
info!(
"DMA transfer width: {}, on channel {} completed successfully: {:02x}",
width.byte_width(),
$number,
dstbuf.iter().as_slice()
);
} else {
info!(
"DMA transfer width: {}, on channel {} failed!",
width.byte_width(),
$number
);
}
}
}
};
}

#[embassy_executor::main]
Expand All @@ -53,38 +50,38 @@ async fn main(_spawner: Spawner) {

info!("Test memory-to-memory DMA transfers");

test_dma_channel!(p, DMA0_CH0, 0);
test_dma_channel!(p, DMA0_CH1, 1);
test_dma_channel!(p, DMA0_CH2, 2);
test_dma_channel!(p, DMA0_CH3, 3);
test_dma_channel!(p, DMA0_CH4, 4);
test_dma_channel!(p, DMA0_CH5, 5);
test_dma_channel!(p, DMA0_CH6, 6);
test_dma_channel!(p, DMA0_CH7, 7);
test_dma_channel!(p, DMA0_CH8, 8);
test_dma_channel!(p, DMA0_CH9, 9);
test_dma_channel!(p, DMA0_CH10, 10);
test_dma_channel!(p, DMA0_CH11, 11);
test_dma_channel!(p, DMA0_CH12, 12);
test_dma_channel!(p, DMA0_CH13, 13);
test_dma_channel!(p, DMA0_CH14, 14);
test_dma_channel!(p, DMA0_CH15, 15);
test_dma_channel!(p, DMA0_CH16, 16);
test_dma_channel!(p, DMA0_CH17, 17);
test_dma_channel!(p, DMA0_CH18, 18);
test_dma_channel!(p, DMA0_CH19, 19);
test_dma_channel!(p, DMA0_CH20, 20);
test_dma_channel!(p, DMA0_CH21, 21);
test_dma_channel!(p, DMA0_CH22, 22);
test_dma_channel!(p, DMA0_CH23, 23);
test_dma_channel!(p, DMA0_CH24, 24);
test_dma_channel!(p, DMA0_CH25, 25);
test_dma_channel!(p, DMA0_CH26, 26);
test_dma_channel!(p, DMA0_CH27, 27);
test_dma_channel!(p, DMA0_CH28, 28);
test_dma_channel!(p, DMA0_CH29, 29);
test_dma_channel!(p, DMA0_CH30, 30);
test_dma_channel!(p, DMA0_CH31, 31);
test_dma_channel!(p, rng, DMA0_CH0, 0);
test_dma_channel!(p, rng, DMA0_CH1, 1);
test_dma_channel!(p, rng, DMA0_CH2, 2);
test_dma_channel!(p, rng, DMA0_CH3, 3);
test_dma_channel!(p, rng, DMA0_CH4, 4);
test_dma_channel!(p, rng, DMA0_CH5, 5);
test_dma_channel!(p, rng, DMA0_CH6, 6);
test_dma_channel!(p, rng, DMA0_CH7, 7);
test_dma_channel!(p, rng, DMA0_CH8, 8);
test_dma_channel!(p, rng, DMA0_CH9, 9);
test_dma_channel!(p, rng, DMA0_CH10, 10);
test_dma_channel!(p, rng, DMA0_CH11, 11);
test_dma_channel!(p, rng, DMA0_CH12, 12);
test_dma_channel!(p, rng, DMA0_CH13, 13);
test_dma_channel!(p, rng, DMA0_CH14, 14);
test_dma_channel!(p, rng, DMA0_CH15, 15);
test_dma_channel!(p, rng, DMA0_CH16, 16);
test_dma_channel!(p, rng, DMA0_CH17, 17);
test_dma_channel!(p, rng, DMA0_CH18, 18);
test_dma_channel!(p, rng, DMA0_CH19, 19);
test_dma_channel!(p, rng, DMA0_CH20, 20);
test_dma_channel!(p, rng, DMA0_CH21, 21);
test_dma_channel!(p, rng, DMA0_CH22, 22);
test_dma_channel!(p, rng, DMA0_CH23, 23);
test_dma_channel!(p, rng, DMA0_CH24, 24);
test_dma_channel!(p, rng, DMA0_CH25, 25);
test_dma_channel!(p, rng, DMA0_CH26, 26);
test_dma_channel!(p, rng, DMA0_CH27, 27);
test_dma_channel!(p, rng, DMA0_CH28, 28);
test_dma_channel!(p, rng, DMA0_CH29, 29);
test_dma_channel!(p, rng, DMA0_CH30, 30);
test_dma_channel!(p, rng, DMA0_CH31, 31);

info!("DMA transfer tests completed");
}
2 changes: 1 addition & 1 deletion examples/rt685s-evk/src/bin/gpio-async-input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
extern crate embassy_imxrt_examples;

use defmt::*;
use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_imxrt::gpio;
use embassy_time::{Duration, Ticker};
use {defmt_rtt as _, panic_probe as _};

#[embassy_executor::task]
async fn monitor_task(mut monitor: gpio::Input<'static>) {
Expand Down
2 changes: 1 addition & 1 deletion examples/rt685s-evk/src/bin/hello-world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
extern crate embassy_imxrt_examples;

use defmt::info;
use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};

#[embassy_executor::main]
async fn main(_spawner: Spawner) {
Expand Down
2 changes: 1 addition & 1 deletion examples/rt685s-evk/src/bin/i2c-master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
extern crate embassy_imxrt_examples;

use defmt::{error, info};
use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_imxrt::i2c;
use embassy_time::Timer;
use embedded_hal_1::i2c::I2c;
use {defmt_rtt as _, panic_probe as _};

const ACC_ADDR: u8 = 0x1E;

Expand Down
2 changes: 1 addition & 1 deletion examples/rt685s-evk/src/bin/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
extern crate embassy_imxrt_examples;

use defmt::*;
use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_imxrt::rng::Rng;
use embassy_imxrt::{bind_interrupts, peripherals, rng};
use rand::RngCore;
use {defmt_rtt as _, panic_probe as _};

bind_interrupts!(struct Irqs {
RNG => rng::InterruptHandler<peripherals::RNG>;
Expand Down
2 changes: 1 addition & 1 deletion examples/rt685s-evk/src/bin/rtc-time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
extern crate embassy_imxrt_examples;

use defmt::info;
use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_imxrt::time_driver::*;
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};

#[embassy_executor::main]
async fn main(_spawner: Spawner) {
Expand Down
4 changes: 3 additions & 1 deletion examples/rt685s-evk/src/bin/sha256-async.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#![no_std]
#![no_main]

extern crate embassy_imxrt_examples;

use defmt::*;
use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_imxrt::hashcrypt::{hasher, Hashcrypt};
use {defmt_rtt as _, panic_probe as _};

#[embassy_executor::main]
async fn main(_spawner: Spawner) {
Expand Down
4 changes: 3 additions & 1 deletion examples/rt685s-evk/src/bin/sha256.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#![no_std]
#![no_main]

extern crate embassy_imxrt_examples;

use defmt::*;
use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_imxrt::hashcrypt::{hasher, Hashcrypt};
use {defmt_rtt as _, panic_probe as _};

#[embassy_executor::main]
async fn main(_spawner: Spawner) {
Expand Down
2 changes: 1 addition & 1 deletion examples/rt685s-evk/src/bin/time-driver-blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use defmt::info;
use embassy_executor::Spawner;
use embassy_imxrt::gpio;
use embassy_time::Timer;
use {defmt_rtt as _, embassy_imxrt as _, panic_probe as _};
use {defmt_rtt as _, embassy_imxrt as _};

#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
Expand Down
2 changes: 1 addition & 1 deletion examples/rt685s-evk/src/bin/uart-async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
extern crate embassy_imxrt_examples;

use defmt::info;
use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_imxrt::uart::{Async, Uart};
use embassy_imxrt::{bind_interrupts, peripherals, uart};
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};

bind_interrupts!(struct Irqs {
FLEXCOMM2 => uart::InterruptHandler<peripherals::FLEXCOMM2>;
Expand Down
2 changes: 1 addition & 1 deletion examples/rt685s-evk/src/bin/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
extern crate embassy_imxrt_examples;

use defmt::info;
use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_imxrt::uart::{Blocking, Uart, UartRx, UartTx};
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};

#[embassy_executor::task]
async fn usart4_task(mut uart: UartRx<'static, Blocking>) {
Expand Down
2 changes: 1 addition & 1 deletion examples/rt685s-evk/src/bin/wwdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ extern crate embassy_imxrt_examples;

use cortex_m::peripheral::NVIC;
use defmt::{info, warn};
use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_imxrt::pac::{interrupt, Interrupt};
use embassy_imxrt::wwdt::WindowedWatchdog;
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};

#[embassy_executor::main]
async fn main(_spawner: Spawner) {
Expand Down
Loading

0 comments on commit c0d7213

Please sign in to comment.