tests/stm32: add uart async and blocking flush test.

This commit is contained in:
Dario Nieuwenhuis 2024-10-14 12:43:59 +02:00
parent ad5f7bf6f7
commit 014583aaa5
2 changed files with 24 additions and 0 deletions

View File

@ -33,6 +33,13 @@ async fn main(_spawner: Spawner) {
let mut buf = [0; 2]; let mut buf = [0; 2];
usart.blocking_read(&mut buf).unwrap(); usart.blocking_read(&mut buf).unwrap();
assert_eq!(buf, data); assert_eq!(buf, data);
// Test flush doesn't hang.
usart.blocking_write(&data).unwrap();
usart.blocking_flush().unwrap();
// Test flush doesn't hang if there's nothing to flush
usart.blocking_flush().unwrap();
} }
// Test error handling with with an overflow error // Test error handling with with an overflow error

View File

@ -51,6 +51,23 @@ async fn main(_spawner: Spawner) {
assert_eq!(tx_buf, rx_buf); assert_eq!(tx_buf, rx_buf);
} }
// Test flush doesn't hang. Check multiple combinations of async+blocking.
tx.write(&tx_buf).await.unwrap();
tx.flush().await.unwrap();
tx.flush().await.unwrap();
tx.write(&tx_buf).await.unwrap();
tx.blocking_flush().unwrap();
tx.flush().await.unwrap();
tx.blocking_write(&tx_buf).unwrap();
tx.blocking_flush().unwrap();
tx.flush().await.unwrap();
tx.blocking_write(&tx_buf).unwrap();
tx.flush().await.unwrap();
tx.blocking_flush().unwrap();
info!("Test OK"); info!("Test OK");
cortex_m::asm::bkpt(); cortex_m::asm::bkpt();
} }