-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
- Loading branch information
1 parent
8ad8940
commit 3effbcc
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use anyhow::*; | ||
use clap::Parser; | ||
use mavlink_server::{cli, drivers, hub, logger, stats, web}; | ||
use tracing::*; | ||
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 10)] | ||
async fn test_udpserver_receive_only() -> Result<()> { | ||
cli::init_with(cli::Args::parse_from(vec![ | ||
"", // For some unknown reason, the first argument is ignored | ||
"udpclient:0.0.0.0:3333", | ||
"udpserver://0.0.0.0:3333?direction=receiver", | ||
"--mavlink-heartbeat-frequency", | ||
"10", | ||
])); | ||
|
||
for driver in cli::endpoints() { | ||
hub::add_driver(driver).await?; | ||
} | ||
|
||
stats::set_period(tokio::time::Duration::from_millis(100)).await?; | ||
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; | ||
for (uuid, driver) in stats::drivers_stats().await? { | ||
if *driver.name == "UdpServer" { | ||
assert!(driver.stats.output.is_none()); | ||
assert!(driver.stats.input.is_some()); | ||
} | ||
|
||
if *driver.name == "UdpClient" { | ||
assert!(driver.stats.output.is_some()); | ||
assert!(driver.stats.input.is_none()); | ||
} | ||
} | ||
|
||
for (id, driver_info) in hub::drivers().await? { | ||
debug!("Removing driver id {id:?} ({driver_info:?})"); | ||
hub::remove_driver(id).await?; | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 10)] | ||
#[ignore] | ||
async fn test_udpserver_send_only() -> Result<()> { | ||
cli::init_with(cli::Args::parse_from(vec![ | ||
"", // For some unknown reason, the first argument is ignored | ||
"udpclient:0.0.0.0:3333", | ||
"udpserver://0.0.0.0:3333?direction=sender", | ||
"--mavlink-heartbeat-frequency", | ||
"10", | ||
])); | ||
|
||
for driver in cli::endpoints() { | ||
hub::add_driver(driver).await?; | ||
} | ||
|
||
stats::set_period(tokio::time::Duration::from_millis(100)).await?; | ||
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; | ||
for (uuid, driver) in stats::drivers_stats().await? { | ||
if *driver.name == "UdpServer" { | ||
assert!(driver.stats.output.is_some()); | ||
assert!(driver.stats.input.is_none()); | ||
} | ||
|
||
if *driver.name == "UdpClient" { | ||
assert!(driver.stats.output.is_some()); | ||
assert!(driver.stats.input.is_some()); | ||
} | ||
} | ||
|
||
for (id, driver_info) in hub::drivers().await? { | ||
debug!("Removing driver id {id:?} ({driver_info:?})"); | ||
hub::remove_driver(id).await?; | ||
} | ||
|
||
Ok(()) | ||
} |