Skip to content

Commit

Permalink
tests/stm32: add uart async and blocking flush test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Oct 14, 2024
1 parent ad5f7bf commit 014583a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/stm32/src/bin/usart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ async fn main(_spawner: Spawner) {
let mut buf = [0; 2];
usart.blocking_read(&mut buf).unwrap();
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
Expand Down
17 changes: 17 additions & 0 deletions tests/stm32/src/bin/usart_dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ async fn main(_spawner: Spawner) {
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");
cortex_m::asm::bkpt();
}

0 comments on commit 014583a

Please sign in to comment.