-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tun integration test (WIP) - 4 (wintun)
- Loading branch information
1 parent
4a88c9b
commit 2a26d5e
Showing
10 changed files
with
133 additions
and
111 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
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
This file was deleted.
Oops, something went wrong.
Binary file not shown.
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,6 @@ | ||
#![cfg(feature = "sim-tests")] | ||
mod network; | ||
mod simulation; | ||
mod tests; | ||
mod tracer; | ||
mod tun_device; |
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
File renamed without changes.
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,33 @@ | ||
use crate::simulation::Simulation; | ||
use crate::tun_device::{tun, tun_lock}; | ||
use crate::{network, simulation, tracer}; | ||
use std::sync::mpsc::channel; | ||
use std::sync::Arc; | ||
use std::thread; | ||
use std::time::Duration; | ||
|
||
#[test] | ||
fn test_simulation() -> anyhow::Result<()> { | ||
run_test(simulation::make_sim()) | ||
} | ||
|
||
fn run_test(simulation: Simulation) -> anyhow::Result<()> { | ||
let _lock = tun_lock().lock(); | ||
let tun = tun(); | ||
let (_tx, rx) = channel(); | ||
let sim = Arc::new(simulation); | ||
let _handle = { | ||
let sim = sim.clone(); | ||
thread::spawn(move || network::Network::new().run(tun, sim, rx).unwrap()) | ||
}; | ||
// allow time for the routing table to reflect the tun device. | ||
thread::sleep(Duration::from_millis(10000)); | ||
|
||
tracer::Tracer::new(sim).trace()?; | ||
|
||
// after the tracing round is done, allow the network time to process all in-flight packets | ||
// thread::sleep(Duration::from_millis(1000)); | ||
// tx.send(())?; | ||
// handle.join().expect("join"); | ||
Ok(()) | ||
} |
File renamed without changes.
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