/ firmware / tests / hello.rs
hello.rs
 1  //! `describe("Hello (smoke)")`
 2  //!
 3  //! Trivial smoke test that proves the embedded-test runner is wired up
 4  //! and embassy is alive.
 5  
 6  #![no_std]
 7  #![no_main]
 8  
 9  #[path = "common/mod.rs"]
10  mod common;
11  
12  use defmt::info;
13  
14  use common::Device;
15  
16  esp_bootloader_esp_idf::esp_app_desc!();
17  
18  #[cfg(test)]
19  #[embedded_test::setup]
20  fn setup() {
21      rtt_target::rtt_init_defmt!();
22  }
23  
24  #[cfg(test)]
25  #[embedded_test::tests(default_timeout = 5, executor = esp_rtos::embassy::Executor::new())]
26  mod tests {
27      use super::*;
28  
29      #[init]
30      fn init() -> Device {
31          info!("=== Hello (smoke) — describe block ===");
32          common::setup::boot_device()
33      }
34  
35      /// `it("user observes that arithmetic still works")`
36      #[test]
37      async fn user_observes_that_arithmetic_still_works(
38          _device: Device,
39      ) -> Result<(), &'static str> {
40          embassy_time::Timer::after(embassy_time::Duration::from_millis(10)).await;
41  
42          if 1 + 1 != 2 {
43              return Err("device: arithmetic broke; nothing else can be trusted");
44          }
45          Ok(())
46      }
47  }