Skip to content

Commit

Permalink
Use global timeout in hil tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajSadel committed Dec 4, 2024
1 parent a63ed82 commit e06f820
Show file tree
Hide file tree
Showing 44 changed files with 44 additions and 221 deletions.
2 changes: 1 addition & 1 deletion hil-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ digest = { version = "0.10.7", default-features = false }
elliptic-curve = { version = "0.13.8", default-features = false, features = ["sec1"] }
embassy-executor = { version = "0.6.0", default-features = false }
# Add the `embedded-test/defmt` feature for more verbose testing
embedded-test = { version = "0.5.0", default-features = false }
embedded-test = { version = "0.5.0", git = "https://github.com/probe-rs/embedded-test.git", rev = "7109473", default-features = false }
fugit = "0.3.7"
hex-literal = "0.4.1"
nb = "1.1.0"
Expand Down
8 changes: 1 addition & 7 deletions hil-test/tests/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct Context<'a> {
}

#[cfg(test)]
#[embedded_test::tests]
#[embedded_test::tests(default_timeout = 3)]
mod tests {
use super::*;

Expand All @@ -30,7 +30,6 @@ mod tests {
}

#[test]
#[timeout(3)]
fn test_aes_128_encryption(mut ctx: Context<'static>) {
let keytext = b"SUp4SeCp@sSw0rd";
let plaintext = b"message";
Expand All @@ -51,7 +50,6 @@ mod tests {
}

#[test]
#[timeout(3)]
fn test_aes_128_decryption(mut ctx: Context<'static>) {
let keytext = b"SUp4SeCp@sSw0rd";
let plaintext = b"message";
Expand All @@ -69,7 +67,6 @@ mod tests {
}

#[test]
#[timeout(3)]
#[cfg(any(feature = "esp32", feature = "esp32s2"))]
fn test_aes_192_encryption(mut ctx: Context<'static>) {
let keytext = b"SUp4SeCp@sSw0rd";
Expand All @@ -91,7 +88,6 @@ mod tests {
}

#[test]
#[timeout(3)]
#[cfg(any(feature = "esp32", feature = "esp32s2"))]
fn test_aes_192_decryption(mut ctx: Context<'static>) {
let keytext = b"SUp4SeCp@sSw0rd";
Expand All @@ -110,7 +106,6 @@ mod tests {
}

#[test]
#[timeout(3)]
fn test_aes_256_encryption(mut ctx: Context<'static>) {
let keytext = b"SUp4SeCp@sSw0rd";
let plaintext = b"message";
Expand All @@ -131,7 +126,6 @@ mod tests {
}

#[test]
#[timeout(3)]
fn test_aes_256_decryption(mut ctx: Context<'static>) {
let keytext = b"SUp4SeCp@sSw0rd";
let plaintext = b"message";
Expand Down
6 changes: 1 addition & 5 deletions hil-test/tests/aes_dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use hil_test as _;
const DMA_BUFFER_SIZE: usize = 16;

#[cfg(test)]
#[embedded_test::tests]
#[embedded_test::tests(default_timeout = 3)]
mod tests {
use super::*;

Expand All @@ -25,7 +25,6 @@ mod tests {
}

#[test]
#[timeout(3)]
fn test_aes_128_dma_encryption(peripherals: Peripherals) {
let dma_channel = peripherals.DMA_CH0;

Expand Down Expand Up @@ -64,7 +63,6 @@ mod tests {
}

#[test]
#[timeout(3)]
fn test_aes_128_dma_decryption(peripherals: Peripherals) {
let dma_channel = peripherals.DMA_CH0;

Expand Down Expand Up @@ -102,7 +100,6 @@ mod tests {
}

#[test]
#[timeout(3)]
fn test_aes_256_dma_encryption(peripherals: Peripherals) {
let dma_channel = peripherals.DMA_CH0;

Expand Down Expand Up @@ -141,7 +138,6 @@ mod tests {
}

#[test]
#[timeout(3)]
fn test_aes_256_dma_decryption(peripherals: Peripherals) {
let dma_channel = peripherals.DMA_CH0;

Expand Down
3 changes: 1 addition & 2 deletions hil-test/tests/clock_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct Context<'a> {
}

#[cfg(test)]
#[embedded_test::tests]
#[embedded_test::tests(default_timeout = 3)]
mod tests {
use super::*;

Expand All @@ -26,7 +26,6 @@ mod tests {
}

#[test]
#[timeout(3)]
fn test_estimated_clock(mut ctx: Context<'static>) {
cfg_if::cfg_if! {
if #[cfg(feature = "esp32c2")] {
Expand Down
4 changes: 1 addition & 3 deletions hil-test/tests/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ use esp_hal::rom::{crc, md5};
use hil_test as _;

#[cfg(test)]
#[embedded_test::tests]
#[embedded_test::tests(default_timeout = 3)]
mod tests {
use super::*;

#[init]
fn init() {}

#[test]
#[timeout(3)]
fn test_crc() {
let data = "123456789";

Expand All @@ -43,7 +42,6 @@ mod tests {
}

#[test]
#[timeout(3)]
fn test_md5() {
let sentence = "The quick brown fox jumps over a lazy dog";

Expand Down
4 changes: 1 addition & 3 deletions hil-test/tests/critical_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use hil_test as _;

#[cfg(test)]
#[embedded_test::tests]
#[embedded_test::tests(default_timeout = 3)]
mod tests {
use esp_hal::sync::Locked;

Expand All @@ -20,7 +20,6 @@ mod tests {
}

#[test]
#[timeout(3)]
fn critical_section_is_reentrant() {
let mut flag = false;

Expand All @@ -34,7 +33,6 @@ mod tests {
}

#[test]
#[timeout(3)]
fn locked_can_provide_mutable_access() {
let flag = Locked::new(false);

Expand Down
5 changes: 1 addition & 4 deletions hil-test/tests/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct Context {
}

#[cfg(test)]
#[embedded_test::tests]
#[embedded_test::tests(default_timeout = 2)]
mod tests {
use super::*;

Expand All @@ -27,7 +27,6 @@ mod tests {
}

#[test]
#[timeout(2)]
fn delay_ns(mut ctx: Context) {
let t1 = esp_hal::time::now();
ctx.delay.delay_ns(600_000_000);
Expand All @@ -42,7 +41,6 @@ mod tests {
}

#[test]
#[timeout(2)]
fn delay_700millis(ctx: Context) {
let t1 = esp_hal::time::now();
ctx.delay.delay_millis(700);
Expand All @@ -57,7 +55,6 @@ mod tests {
}

#[test]
#[timeout(2)]
fn delay_1_500_000us(mut ctx: Context) {
let t1 = esp_hal::time::now();
ctx.delay.delay_us(1_500_000);
Expand Down
11 changes: 1 addition & 10 deletions hil-test/tests/delay_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async fn test_async_delay_ms(mut timer: impl DelayNs, duration: u32) {
}

#[cfg(test)]
#[embedded_test::tests(executor = esp_hal_embassy::Executor::new())]
#[embedded_test::tests(default_timeout = 2, executor = esp_hal_embassy::Executor::new())]
mod tests {
use super::*;

Expand All @@ -82,15 +82,13 @@ mod tests {

#[cfg(systimer)]
#[test]
#[timeout(2)]
async fn test_systimer_async_delay_ns(ctx: Context) {
let alarms = SystemTimer::new(ctx.peripherals.SYSTIMER);

test_async_delay_ns(OneShotTimer::new(alarms.alarm0).into_async(), 10_000_000).await;
}

#[test]
#[timeout(2)]
async fn test_timg0_async_delay_ns(ctx: Context) {
let timg0 = TimerGroup::new(ctx.peripherals.TIMG0);

Expand All @@ -101,7 +99,6 @@ mod tests {

#[cfg(timg1)]
#[test]
#[timeout(2)]
async fn test_timg1_async_delay_ns(ctx: Context) {
let timg1 = TimerGroup::new(ctx.peripherals.TIMG1);

Expand All @@ -112,15 +109,13 @@ mod tests {

#[cfg(systimer)]
#[test]
#[timeout(2)]
async fn test_systimer_async_delay_us(ctx: Context) {
let alarms = SystemTimer::new(ctx.peripherals.SYSTIMER);

test_async_delay_us(OneShotTimer::new(alarms.alarm0).into_async(), 10_000).await;
}

#[test]
#[timeout(2)]
async fn test_timg0_async_delay_us(ctx: Context) {
let timg0 = TimerGroup::new(ctx.peripherals.TIMG0);

Expand All @@ -131,7 +126,6 @@ mod tests {

#[cfg(timg1)]
#[test]
#[timeout(2)]
async fn test_timg1_async_delay_us(ctx: Context) {
let timg1 = TimerGroup::new(ctx.peripherals.TIMG1);

Expand All @@ -142,15 +136,13 @@ mod tests {

#[cfg(systimer)]
#[test]
#[timeout(2)]
async fn test_systimer_async_delay_ms(ctx: Context) {
let alarms = SystemTimer::new(ctx.peripherals.SYSTIMER);

test_async_delay_ms(OneShotTimer::new(alarms.alarm0).into_async(), 10).await;
}

#[test]
#[timeout(2)]
async fn test_timg0_async_delay_ms(ctx: Context) {
let timg0 = TimerGroup::new(ctx.peripherals.TIMG0);

Expand All @@ -161,7 +153,6 @@ mod tests {

#[cfg(timg1)]
#[test]
#[timeout(2)]
async fn test_timg1_async_delay_ms(ctx: Context) {
let timg1 = TimerGroup::new(ctx.peripherals.TIMG1);

Expand Down
Loading

0 comments on commit e06f820

Please sign in to comment.