summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorcyqsimon <28627918+cyqsimon@users.noreply.github.com>2023-10-07 22:13:14 +0800
committercyqsimon <28627918+cyqsimon@users.noreply.github.com>2023-10-07 22:35:35 +0800
commit72b04c82aec4a21fabe1bf694d56f44eb5cae193 (patch)
treec6e953f47d323d268959cfedcfa136778234af62 /src
parentf1b49254c2c07efd4720beb1c742b6e94a0c94ee (diff)
Compact tests using `rstest`
Diffstat (limited to 'src')
-rw-r--r--src/tests/cases/snapshots/bandwhich__tests__cases__ui__full-width-under-30-height-0.snap (renamed from src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_full_width_under_30_height.snap)0
-rw-r--r--src/tests/cases/snapshots/bandwhich__tests__cases__ui__full-width-under-30-height-1.snap (renamed from src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_full_width_under_30_height-2.snap)0
-rw-r--r--src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_50_width_under_50_height-2.snap55
-rw-r--r--src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_50_width_under_50_height.snap55
-rw-r--r--src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-120-width-full-height-0.snap (renamed from src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_120_width_full_height.snap)0
-rw-r--r--src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-120-width-full-height-1.snap (renamed from src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_120_width_full_height-2.snap)0
-rw-r--r--src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-120-width-under-30-height-0.snap (renamed from src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_120_width_under_30_height.snap)0
-rw-r--r--src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-120-width-under-30-height-1.snap (renamed from src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_120_width_under_30_height-2.snap)0
-rw-r--r--src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-50-width-under-50-height-0.snap55
-rw-r--r--src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-50-width-under-50-height-1.snap55
-rw-r--r--src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-70-width-under-30-height-0.snap (renamed from src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_70_width_under_30_height.snap)0
-rw-r--r--src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-70-width-under-30-height-1.snap (renamed from src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_70_width_under_30_height-2.snap)0
-rw-r--r--src/tests/cases/test_utils.rs123
-rw-r--r--src/tests/cases/ui.rs708
14 files changed, 286 insertions, 765 deletions
diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_full_width_under_30_height.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__full-width-under-30-height-0.snap
index 1e26e22..1e26e22 100644
--- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_full_width_under_30_height.snap
+++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__full-width-under-30-height-0.snap
diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_full_width_under_30_height-2.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__full-width-under-30-height-1.snap
index 9c60b32..9c60b32 100644
--- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_full_width_under_30_height-2.snap
+++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__full-width-under-30-height-1.snap
diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_50_width_under_50_height-2.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_50_width_under_50_height-2.snap
deleted file mode 100644
index b7493b4..0000000
--- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_50_width_under_50_height-2.snap
+++ /dev/null
@@ -1,55 +0,0 @@
----
-source: src/tests/cases/ui.rs
-assertion_line: 1580
-expression: "&terminal_draw_events_mirror[1]"
----
- 98Bps
-
-
- 5 0Bps / 28Bps
- 4 0Bps / 26Bps
- 1 0Bps / 22Bps
- 2 0Bps / 21Bps
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 3.3.3.3 0Bps / 28Bps
- 2.2.2.2 0Bps / 26Bps
- 1.1.1.1 0Bps / 22Bps
- 4.4.4.4 0Bps / 21Bps
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_50_width_under_50_height.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_50_width_under_50_height.snap
deleted file mode 100644
index 15cfa04..0000000
--- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_50_width_under_50_height.snap
+++ /dev/null
@@ -1,55 +0,0 @@
----
-source: src/tests/cases/ui.rs
-assertion_line: 1579
-expression: "&terminal_draw_events_mirror[0]"
----
- Total Up / Down: 0Bps / 0Bps
-┌Utilization by process name────────────────────┐
-│Process Up / Down │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-└───────────────────────────────────────────────┘
-┌Utilization by remote address──────────────────┐
-│Remote Address Up / Down │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-│ │
-└───────────────────────────────────────────────┘
- Press <SPACE> to pause.
-
diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_120_width_full_height.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-120-width-full-height-0.snap
index 53043a7..53043a7 100644
--- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_120_width_full_height.snap
+++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-120-width-full-height-0.snap
diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_120_width_full_height-2.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-120-width-full-height-1.snap
index 8230e66..8230e66 100644
--- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_120_width_full_height-2.snap
+++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-120-width-full-height-1.snap
diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_120_width_under_30_height.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-120-width-under-30-height-0.snap
index 0bbc796..0bbc796 100644
--- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_120_width_under_30_height.snap
+++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-120-width-under-30-height-0.snap
diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_120_width_under_30_height-2.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-120-width-under-30-height-1.snap
index 06cb645..06cb645 100644
--- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_120_width_under_30_height-2.snap
+++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-120-width-under-30-height-1.snap
diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-50-width-under-50-height-0.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-50-width-under-50-height-0.snap
new file mode 100644
index 0000000..b0c7143
--- /dev/null
+++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-50-width-under-50-height-0.snap
@@ -0,0 +1,55 @@
+---
+source: src/tests/cases/ui.rs
+expression: "&terminal_draw_events_mirror[0]"
+---
+ Total Up / Down: 0Bps / 0Bps
+┌Utilization by process name─────────────────────┐
+│Process Up / Down │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+└────────────────────────────────────────────────┘
+┌Utilization by remote address───────────────────┐
+│Remote Address Up / Down │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+│ │
+└────────────────────────────────────────────────┘
+ Press <SPACE> to pause.
+
diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-50-width-under-50-height-1.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-50-width-under-50-height-1.snap
new file mode 100644
index 0000000..8e7dbcb
--- /dev/null
+++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-50-width-under-50-height-1.snap
@@ -0,0 +1,55 @@
+---
+source: src/tests/cases/ui.rs
+expression: "&terminal_draw_events_mirror[1]"
+---
+ 98Bps
+
+
+ 5 0Bps / 28Bps
+ 4 0Bps / 26Bps
+ 1 0Bps / 22Bps
+ 2 0Bps / 21Bps
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 3.3.3.3 0Bps / 28Bps
+ 2.2.2.2 0Bps / 26Bps
+ 1.1.1.1 0Bps / 22Bps
+ 4.4.4.4 0Bps / 21Bps
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_70_width_under_30_height.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-70-width-under-30-height-0.snap
index 281674a..281674a 100644
--- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_70_width_under_30_height.snap
+++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-70-width-under-30-height-0.snap
diff --git a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_70_width_under_30_height-2.snap b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-70-width-under-30-height-1.snap
index 6f24434..6f24434 100644
--- a/src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout_under_70_width_under_30_height-2.snap
+++ b/src/tests/cases/snapshots/bandwhich__tests__cases__ui__under-70-width-under-30-height-1.snap
diff --git a/src/tests/cases/test_utils.rs b/src/tests/cases/test_utils.rs
index d2df990..bd0400e 100644
--- a/src/tests/cases/test_utils.rs
+++ b/src/tests/cases/test_utils.rs
@@ -9,6 +9,7 @@ use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
use packet_builder::*;
use pnet::{datalink::DataLinkReceiver, packet::Packet};
use pnet_base::MacAddr;
+use rstest::fixture;
use crate::{
network::dns::Client,
@@ -56,7 +57,8 @@ pub fn build_tcp_packet(
pkt.packet().to_vec()
}
-pub fn sample_frames() -> Vec<Box<dyn DataLinkReceiver>> {
+#[fixture]
+pub fn sample_frames_short() -> Vec<Box<dyn DataLinkReceiver>> {
vec![NetworkFrames::new(vec![
Some(build_tcp_packet(
"10.0.0.2",
@@ -82,6 +84,125 @@ pub fn sample_frames() -> Vec<Box<dyn DataLinkReceiver>> {
]) as Box<dyn DataLinkReceiver>]
}
+#[fixture]
+pub fn sample_frames_sustained_one_process() -> Vec<Box<dyn DataLinkReceiver>> {
+ vec![NetworkFrames::new(vec![
+ Some(build_tcp_packet(
+ "1.1.1.1",
+ "10.0.0.2",
+ 12345,
+ 443,
+ b"I have come from 1.1.1.1",
+ )),
+ None, // sleep
+ Some(build_tcp_packet(
+ "1.1.1.1",
+ "10.0.0.2",
+ 12345,
+ 443,
+ b"Same here, but one second later",
+ )),
+ ]) as Box<dyn DataLinkReceiver>]
+}
+
+#[fixture]
+pub fn sample_frames_sustained_multiple_processes() -> Vec<Box<dyn DataLinkReceiver>> {
+ vec![NetworkFrames::new(vec![
+ Some(build_tcp_packet(
+ "1.1.1.1",
+ "10.0.0.2",
+ 12345,
+ 443,
+ b"I have come from 1.1.1.1",
+ )),
+ Some(build_tcp_packet(
+ "3.3.3.3",
+ "10.0.0.2",
+ 1337,
+ 4435,
+ b"I come from 3.3.3.3",
+ )),
+ None, // sleep
+ Some(build_tcp_packet(
+ "1.1.1.1",
+ "10.0.0.2",
+ 12345,
+ 443,
+ b"I have come from 1.1.1.1 one second later",
+ )),
+ Some(build_tcp_packet(
+ "3.3.3.3",
+ "10.0.0.2",
+ 1337,
+ 4435,
+ b"I come 3.3.3.3 one second later",
+ )),
+ ]) as Box<dyn DataLinkReceiver>]
+}
+
+#[fixture]
+pub fn sample_frames_sustained_long() -> Vec<Box<dyn DataLinkReceiver>> {
+ vec![NetworkFrames::new(vec![
+ Some(build_tcp_packet(
+ "10.0.0.2",
+ "3.3.3.3",
+ 4435,
+ 1337,
+ b"omw to 3.3.3.3",
+ )),
+ Some(build_tcp_packet(
+ "3.3.3.3",
+ "10.0.0.2",
+ 1337,
+ 4435,
+ b"I was just there!",
+ )),
+ Some(build_tcp_packet(
+ "1.1.1.1",
+ "10.0.0.2",
+ 12345,
+ 443,
+ b"Is it nice there? I think 1.1.1.1 is dull",
+ )),
+ Some(build_tcp_packet(
+ "10.0.0.2",
+ "1.1.1.1",
+ 443,
+ 12345,
+ b"Well, I heard 1.1.1.1 is all the rage",
+ )),
+ None, // sleep
+ Some(build_tcp_packet(
+ "10.0.0.2",
+ "3.3.3.3",
+ 4435,
+ 1337,
+ b"Wait for me!",
+ )),
+ Some(build_tcp_packet(
+ "3.3.3.3",
+ "10.0.0.2",
+ 1337,
+ 4435,
+ b"They're waiting for you...",
+ )),
+ Some(build_tcp_packet(
+ "1.1.1.1",
+ "10.0.0.2",
+ 12345,
+ 443,
+ b"1.1.1.1 forever!",
+ )),
+ Some(build_tcp_packet(
+ "10.0.0.2",
+ "1.1.1.1",
+ 443,
+ 12345,
+ b"10.0.0.2 forever!",
+ )),
+ ]) as Box<dyn DataLinkReceiver>]
+}
+
pub fn os_input_output(
network_frames: Vec<Box<dyn DataLinkReceiver>>,
sleep_num: usize,
diff --git a/src/tests/cases/ui.rs b/src/tests/cases/ui.rs
index bf2779b..32ac87b 100644
--- a/src/tests/cases/ui.rs
+++ b/src/tests/cases/ui.rs
@@ -3,12 +3,15 @@ use std::{collections::HashMap, iter, net::IpAddr};
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
use insta::assert_snapshot;
use pnet::datalink::DataLinkReceiver;
+use rstest::rstest;
use crate::{
start,
tests::{
cases::test_utils::{
- build_tcp_packet, opts_ui, os_input_output, os_input_output_factory, sample_frames,
+ build_tcp_packet, opts_ui, os_input_output, os_input_output_factory,
+ sample_frames_short, sample_frames_sustained_long,
+ sample_frames_sustained_multiple_processes, sample_frames_sustained_one_process,
sleep_and_quit_events, sleep_resize_and_quit_events, test_backend_factory,
},
fakes::{
@@ -266,12 +269,10 @@ fn basic_only_addresses() {
assert_snapshot!(&terminal_draw_events_mirror[0]);
}
-#[test]
-fn two_packets_only_processes() {
- let network_frames = sample_frames();
-
+#[rstest(sample_frames_short as frames)]
+fn two_packets_only_processes(frames: Vec<Box<dyn DataLinkReceiver>>) {
let (_, terminal_draw_events, backend) = test_backend_factory(190, 50);
- let os_input = os_input_output(network_frames, 2);
+ let os_input = os_input_output(frames, 2);
let opts = Opt {
interface: Some(String::from("interface_name")),
raw: false,
@@ -292,12 +293,10 @@ fn two_packets_only_processes() {
assert_snapshot!(&terminal_draw_events_mirror[1]);
}
-#[test]
-fn two_packets_only_connections() {
- let network_frames = sample_frames();
-
+#[rstest(sample_frames_short as frames)]
+fn two_packets_only_connections(frames: Vec<Box<dyn DataLinkReceiver>>) {
let (_, terminal_draw_events, backend) = test_backend_factory(190, 50);
- let os_input = os_input_output(network_frames, 2);
+ let os_input = os_input_output(frames, 2);
let opts = Opt {
interface: Some(String::from("interface_name")),
raw: false,
@@ -318,12 +317,10 @@ fn two_packets_only_connections() {
assert_snapshot!(&terminal_draw_events_mirror[1]);
}
-#[test]
-fn two_packets_only_addresses() {
- let network_frames = sample_frames();
-
+#[rstest(sample_frames_short as frames)]
+fn two_packets_only_addresses(frames: Vec<Box<dyn DataLinkReceiver>>) {
let (_, terminal_draw_events, backend) = test_backend_factory(190, 50);
- let os_input = os_input_output(network_frames, 2);
+ let os_input = os_input_output(frames, 2);
let opts = Opt {
interface: Some(String::from("interface_name")),
raw: false,
@@ -426,12 +423,10 @@ fn one_packet_of_traffic() {
assert_snapshot!(&terminal_draw_events_mirror[1]);
}
-#[test]
-fn bi_directional_traffic() {
- let network_frames = sample_frames();
-
+#[rstest(sample_frames_short as frames)]
+fn bi_directional_traffic(frames: Vec<Box<dyn DataLinkReceiver>>) {
let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);
- let os_input = os_input_output(network_frames, 2);
+ let os_input = os_input_output(frames, 2);
let opts = opts_ui();
start(backend, os_input, opts);
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
@@ -653,29 +648,11 @@ fn multiple_connections_from_remote_address() {
assert_snapshot!(&terminal_draw_events_mirror[1]);
}
-#[test]
-fn sustained_traffic_from_one_process() {
- let network_frames = vec![NetworkFrames::new(vec![
- Some(build_tcp_packet(
- "1.1.1.1",
- "10.0.0.2",
- 12345,
- 443,
- b"I have come from 1.1.1.1",
- )),
- None, // sleep
- Some(build_tcp_packet(
- "1.1.1.1",
- "10.0.0.2",
- 12345,
- 443,
- b"Same here, but one second later",
- )),
- ]) as Box<dyn DataLinkReceiver>];
-
+#[rstest(sample_frames_sustained_one_process as frames)]
+fn sustained_traffic_from_one_process(frames: Vec<Box<dyn DataLinkReceiver>>) {
let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);
- let os_input = os_input_output(network_frames, 3);
+ let os_input = os_input_output(frames, 3);
let opts = opts_ui();
start(backend, os_input, opts);
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
@@ -694,29 +671,11 @@ fn sustained_traffic_from_one_process() {
assert_snapshot!(&terminal_draw_events_mirror[2]);
}
-#[test]
-fn sustained_traffic_from_one_process_total() {
- let network_frames = vec![NetworkFrames::new(vec![
- Some(build_tcp_packet(
- "1.1.1.1",
- "10.0.0.2",
- 12345,
- 443,
- b"I have come from 1.1.1.1",
- )),
- None, // sleep
- Some(build_tcp_packet(
- "1.1.1.1",
- "10.0.0.2",
- 12345,
- 443,
- b"Same here, but one second later",
- )),
- ]) as Box<dyn DataLinkReceiver>];
-
+#[rstest(sample_frames_sustained_one_process as frames)]
+fn sustained_traffic_from_one_process_total(frames: Vec<Box<dyn DataLinkReceiver>>) {
let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);
- let os_input = os_input_output(network_frames, 3);
+ let os_input = os_input_output(frames, 3);
let mut opts = opts_ui();
opts.render_opts.total_utilization = true;
start(backend, os_input, opts);
@@ -736,43 +695,11 @@ fn sustained_traffic_from_one_process_total() {
assert_snapshot!(&terminal_draw_events_mirror[2].replace("1 \n", "2 \n"));
}
-#[test]
-fn sustained_traffic_from_multiple_processes() {
- let network_frames = vec![NetworkFrames::new(vec![
- Some(build_tcp_packet(
- "1.1.1.1",
- "10.0.0.2",
- 12345,
- 443,
- b"I have come from 1.1.1.1",
- )),
- Some(build_tcp_packet(
- "3.3.3.3",
- "10.0.0.2",
- 1337,
- 4435,
- b"I come from 3.3.3.3",
- )),
- None, // sleep
- Some(build_tcp_packet(
- "1.1.1.1",
- "10.0.0.2",
- 12345,
- 443,
- b"I have come from 1.1.1.1 one second later",
- )),
- Some(build_tcp_packet(
- "3.3.3.3",
- "10.0.0.2",
- 1337,
- 4435,
- b"I come 3.3.3.3 one second later",
- )),
- ]) as Box<dyn DataLinkReceiver>];
-
+#[rstest(sample_frames_sustained_multiple_processes as frames)]
+fn sustained_traffic_from_multiple_processes(frames: Vec<Box<dyn DataLinkReceiver>>) {
let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);
- let os_input = os_input_output(network_frames, 3);
+ let os_input = os_input_output(frames, 3);
let opts = opts_ui();
start(backend, os_input, opts);
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
@@ -791,43 +718,11 @@ fn sustained_traffic_from_multiple_processes() {
assert_snapshot!(&terminal_draw_events_mirror[2]);
}
-#[test]
-fn sustained_traffic_from_multiple_processes_total() {
- let network_frames = vec![NetworkFrames::new(vec![
- Some(build_tcp_packet(
- "1.1.1.1",
- "10.0.0.2",
- 12345,
- 443,
- b"I have come from 1.1.1.1",
- )),
- Some(build_tcp_packet(
- "3.3.3.3",
- "10.0.0.2",
- 1337,
- 4435,
- b"I come from 3.3.3.3",
- )),
- None, // sleep
- Some(build_tcp_packet(
- "1.1.1.1",
- "10.0.0.2",
- 12345,
- 443,
- b"I have come from 1.1.1.1 one second later",
- )),
- Some(build_tcp_packet(
- "3.3.3.3",
- "10.0.0.2",
- 1337,
- 4435,
- b"I come 3.3.3.3 one second later",
- )),
- ]) as Box<dyn DataLinkReceiver>];
-
+#[rstest(sample_frames_sustained_multiple_processes as frames)]
+fn sustained_traffic_from_multiple_processes_total(frames: Vec<Box<dyn DataLinkReceiver>>) {
let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);
- let os_input = os_input_output(network_frames, 3);
+ let os_input = os_input_output(frames, 3);
let mut opts = opts_ui();
opts.render_opts.total_utilization = true;
start(backend, os_input, opts);
@@ -847,71 +742,13 @@ fn sustained_traffic_from_multiple_processes_total() {
assert_snapshot!(&terminal_draw_events_mirror[2].replace("1 \n", "2 \n"));
}
-#[test]
-fn sustained_traffic_from_multiple_processes_bi_directional() {
- let network_frames = vec![NetworkFrames::new(vec![
- Some(build_tcp_packet(
- "10.0.0.2",
- "3.3.3.3",
- 4435,
- 1337,
- b"omw to 3.3.3.3",
- )),
- Some(build_tcp_packet(
- "3.3.3.3",
- "10.0.0.2",
- 1337,
- 4435,
- b"I was just there!",
- )),
- Some(build_tcp_packet(
- "1.1.1.1",
- "10.0.0.2",
- 12345,
- 443,
- b"Is it nice there? I think 1.1.1.1 is dull",
- )),
- Some(build_tcp_packet(
- "10.0.0.2",
- "1.1.1.1",
- 443,
- 12345,
- b"Well, I heard 1.1.1.1 is all the rage",
- )),
- None, // sleep
- Some(build_tcp_packet(
- "10.0.0.2",
- "3.3.3.3",
- 4435,
- 1337,
- b"Wait for me!",
- )),
- Some(build_tcp_packet(
- "3.3.3.3",
- "10.0.0.2",
- 1337,
- 4435,
- b"They're waiting for you...",
- )),
- Some(build_tcp_packet(
- "1.1.1.1",
- "10.0.0.2",
- 12345,
- 443,
- b"1.1.1.1 forever!",
- )),
- Some(build_tcp_packet(
- "10.0.0.2",
- "1.1.1.1",
- 443,
- 12345,
- b"10.0.0.2 forever!",
- )),
- ]) as Box<dyn DataLinkReceiver>];
-
+#[rstest(sample_frames_sustained_long as frames)]
+fn sustained_traffic_from_multiple_processes_bi_directional(
+ frames: Vec<Box<dyn DataLinkReceiver>>,
+) {
let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);
- let os_input = os_input_output(network_frames, 3);
+ let os_input = os_input_output(frames, 3);
let opts = opts_ui();
start(backend, os_input, opts);
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
@@ -930,71 +767,13 @@ fn sustained_traffic_from_multiple_processes_