Run tests on Github Actions

This commit is contained in:
Conrad Kramer 2023-08-05 08:32:54 -07:00
parent 1907b11545
commit 17af030893
6 changed files with 38 additions and 44 deletions

22
tun/tests/tokio.rs Normal file
View file

@ -0,0 +1,22 @@
use std::net::Ipv4Addr;
#[tokio::test]
#[cfg(feature = "tokio")]
async fn test_create() {
let tun = tun::TunInterface::new().unwrap();
let async_tun = tun::tokio::TunInterface::new(tun).unwrap();
}
#[tokio::test]
#[ignore = "requires interactivity"]
#[cfg(all(feature = "tokio", not(target_os = "windows")))]
async fn test_write() {
let tun = tun::TunInterface::new().unwrap();
tun.set_ipv4_addr(Ipv4Addr::from([192, 168, 1, 10]))
.unwrap();
let async_tun = tun::tokio::TunInterface::new(tun).unwrap();
let mut buf = [0u8; 1500];
buf[0] = 6 << 4;
let bytes_written = async_tun.write(&buf).await.unwrap();
assert!(bytes_written > 0);
}