Skip to content

Commit

Permalink
Add integration test showing that the Crazyflie object cannot be sent…
Browse files Browse the repository at this point in the history
… between threads
  • Loading branch information
ataffanel committed Jun 13, 2024
1 parent d63fae6 commit a78105f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/syncsend_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Test that the Crazyflie object can be sent between threads

use std::thread::spawn;
use crazyflie_lib::Crazyflie;

#[async_std::test]
async fn crazyflie_can_be_sent_to_thread() -> Result<(), Box<dyn std::error::Error>> {
let link_context = crazyflie_link::LinkContext::new(async_executors::AsyncStd);

// Scan for Crazyflies on the default address
let found = link_context.scan([0xE7; 5]).await?;

if let Some(uri) = found.first() {
// Connect to the first Crazyflie found
let cf = crazyflie_lib::Crazyflie::connect_from_uri(
async_executors::AsyncStd,
&link_context,
uri,
)
.await?;

let _ = spawn(move || {
cf
}).join().unwrap();
}
Ok(())
}

0 comments on commit a78105f

Please sign in to comment.