Run tests on Github Actions

This commit is contained in:
Conrad Kramer 2023-08-05 08:32:54 -07:00
parent 86b53c9dcd
commit 290284ef4b
3 changed files with 15 additions and 10 deletions

View file

@ -1,6 +1,6 @@
use fehler::throws;
use std::io::Error;
use std::net::{Ipv4Addr};
use std::net::Ipv4Addr;
use tun::TunInterface;
#[test]
@ -26,6 +26,8 @@ fn test_set_get_ipv4() {
#[throws]
#[cfg(not(any(target_os = "windows", target_vendor = "apple")))]
fn test_set_get_ipv6() {
use std::net::Ipv6Addr;
let tun = TunInterface::new()?;
let addr = Ipv6Addr::new(1, 1, 1, 1, 1, 1, 1, 1);

View file

@ -18,7 +18,7 @@ fn tst_read() {
println!("tun ip: {:?}", tun.ipv4_addr()?);
println!("Waiting for a packet...");
let buf = &mut [0u8; 1500];
let res = tun.read(buf);
let res = tun.recv(buf);
println!("Received!");
assert!(res.is_ok());
}
@ -28,9 +28,9 @@ fn tst_read() {
#[ignore = "requires interactivity"]
#[cfg(not(target_os = "windows"))]
fn write_packets() {
let mut tun = TunInterface::new()?;
let tun = TunInterface::new()?;
let mut buf = [0u8; 1500];
buf[0] = 6 << 4;
let bytes_written = tun.write(&buf)?;
let bytes_written = tun.send(&buf)?;
assert_eq!(bytes_written, 1504);
}