From a78105fa13537a1992c9e2142e21487605bae135 Mon Sep 17 00:00:00 2001 From: Arnaud Taffanel Date: Thu, 13 Jun 2024 10:42:34 +0200 Subject: [PATCH] Add integration test showing that the Crazyflie object cannot be sent between threads --- tests/syncsend_test.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/syncsend_test.rs diff --git a/tests/syncsend_test.rs b/tests/syncsend_test.rs new file mode 100644 index 0000000..a6d7392 --- /dev/null +++ b/tests/syncsend_test.rs @@ -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> { + 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(()) +} \ No newline at end of file