Skip to content

Commit

Permalink
Slightly clean up embassy HIL tests (#1937)
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani authored Aug 13, 2024
1 parent c53ba38 commit 6b6e628
Showing 1 changed file with 20 additions and 32 deletions.
52 changes: 20 additions & 32 deletions hil-test/tests/embassy_timers_executors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ use esp_hal::{
use esp_hal::{interrupt::Priority, timer::systimer::SystemTimer};
#[cfg(not(feature = "esp32"))]
use esp_hal_embassy::InterruptExecutor;
#[cfg(not(feature = "esp32"))]
use static_cell::StaticCell;

macro_rules! mk_static {
($t:ty,$val:expr) => {{
Expand All @@ -60,68 +58,58 @@ unsafe fn __make_static<T>(t: &mut T) -> &'static mut T {
mod task_invokers {
use test_helpers::*;

use crate::*;
use super::*;

#[embassy_executor::task]
pub async fn test_one_shot_timg_invoker() {
let outcome;
{
outcome = test_helpers::test_one_shot_timg().await;
}
let outcome = test_helpers::test_one_shot_timg().await;

embedded_test::export::check_outcome(outcome);
}

#[embassy_executor::task]
#[cfg(not(feature = "esp32"))]
pub async fn test_one_shot_systimer_invoker() {
let outcome;
{
outcome = task_invokers::test_one_shot_systimer().await;
}
let outcome = task_invokers::test_one_shot_systimer().await;

embedded_test::export::check_outcome(outcome);
}

#[embassy_executor::task]
pub async fn test_join_timg_invoker() {
let outcome;
{
outcome = test_join_timg().await;
}
let outcome = test_join_timg().await;

embedded_test::export::check_outcome(outcome);
}

#[embassy_executor::task]
#[cfg(not(feature = "esp32"))]
pub async fn test_join_systimer_invoker() {
let outcome;
{
outcome = test_join_systimer().await;
}
let outcome = test_join_systimer().await;

embedded_test::export::check_outcome(outcome);
}

#[embassy_executor::task]
#[cfg(not(feature = "esp32"))]
pub async fn test_interrupt_executor_invoker() {
let outcome;
{
outcome = test_interrupt_executor().await;
}
let outcome = test_interrupt_executor().await;

embedded_test::export::check_outcome(outcome);
}

#[embassy_executor::task]
pub async fn test_tick_and_increment_invoker() {
let outcome;
{
outcome = tick_and_increment().await;
}
let outcome = tick_and_increment().await;

embedded_test::export::check_outcome(outcome);
}
}

// List of the functions that are ACTUALLY TESTS but are called in the invokers
mod test_helpers {
use crate::*;
use super::*;

pub async fn test_one_shot_timg() {
let peripherals = unsafe { Peripherals::steal() };
let system = SystemControl::new(peripherals.SYSTEM);
Expand Down Expand Up @@ -457,10 +445,10 @@ mod test {
let timers = mk_static!([OneShotTimer<ErasedTimer>; 2], timers);
esp_hal_embassy::init(&clocks, timers);

static EXECUTOR: StaticCell<InterruptExecutor<2>> = StaticCell::new();
let executor =
InterruptExecutor::new(system.software_interrupt_control.software_interrupt2);
let executor = EXECUTOR.init(executor);
let executor = mk_static!(
InterruptExecutor<2>,
InterruptExecutor::new(system.software_interrupt_control.software_interrupt2)
);

let spawner_int = executor.start(Priority::Priority3);
spawner_int.must_spawn(test_interrupt_executor_invoker());
Expand Down

0 comments on commit 6b6e628

Please sign in to comment.