thomson

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

hello_test.rs (908B)


      1 //! Demo test suite using embedded-test
      2 //!
      3 //! You can run this using `cargo test` as usual.
      4 
      5 #![no_std]
      6 #![no_main]
      7 
      8 esp_bootloader_esp_idf::esp_app_desc!();
      9 
     10 #[cfg(test)]
     11 #[embedded_test::tests(executor = esp_rtos::embassy::Executor::new())]
     12 mod tests {
     13     use defmt::assert_eq;
     14 
     15     #[init]
     16     fn init() {
     17         let peripherals = esp_hal::init(esp_hal::Config::default());
     18 
     19         let timg0 = esp_hal::timer::timg::TimerGroup::new(peripherals.TIMG0);
     20         let sw_interrupt =
     21             esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
     22         esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0);
     23 
     24         rtt_target::rtt_init_defmt!();
     25     }
     26 
     27     #[test]
     28     async fn hello_test() {
     29         defmt::info!("Running test!");
     30 
     31         embassy_time::Timer::after(embassy_time::Duration::from_millis(100)).await;
     32         assert_eq!(1 + 1, 2);
     33     }
     34 }