Run tests on Github Actions
This commit is contained in:
parent
1907b11545
commit
17af030893
6 changed files with 38 additions and 44 deletions
22
tun/tests/tokio.rs
Normal file
22
tun/tests/tokio.rs
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue