diff --git a/crates/pcap/tests/dns_discovery_answers.rs b/crates/pcap/tests/it/dns_discovery_answers.rs similarity index 96% rename from crates/pcap/tests/dns_discovery_answers.rs rename to crates/pcap/tests/it/dns_discovery_answers.rs index 97d9dc0dc..1465235e1 100644 --- a/crates/pcap/tests/dns_discovery_answers.rs +++ b/crates/pcap/tests/it/dns_discovery_answers.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{dns_query, eth, ipv4_pkt, udp}; use craft_pcap::{Dns, decode}; -use support::{dns_query, eth, ipv4_pkt, udp}; fn answer(kind: u16, rd: &[u8]) -> Dns { let mut msg = dns_query(); diff --git a/crates/pcap/tests/dns_question_class.rs b/crates/pcap/tests/it/dns_question_class.rs similarity index 95% rename from crates/pcap/tests/dns_question_class.rs rename to crates/pcap/tests/it/dns_question_class.rs index b6583f7f3..baf748997 100644 --- a/crates/pcap/tests/dns_question_class.rs +++ b/crates/pcap/tests/it/dns_question_class.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{dns_query, eth, ipv4_pkt, pcap, udp}; use craft_pcap::{decode, summarize}; -use support::{dns_query, eth, ipv4_pkt, pcap, udp}; fn packet(message: &[u8]) -> Vec { eth(0x0800, &ipv4_pkt(17, [192, 0, 2, 1], [192, 0, 2, 2], &udp(51000, 53, message))) diff --git a/crates/pcap/tests/dns_rdata_names.rs b/crates/pcap/tests/it/dns_rdata_names.rs similarity index 99% rename from crates/pcap/tests/dns_rdata_names.rs rename to crates/pcap/tests/it/dns_rdata_names.rs index 7e8542a0a..3b87c4dd5 100644 --- a/crates/pcap/tests/dns_rdata_names.rs +++ b/crates/pcap/tests/it/dns_rdata_names.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{dns_query, eth, ipv4_pkt, pcap, udp}; use craft_pcap::{decode, summarize}; -use support::{dns_query, eth, ipv4_pkt, pcap, udp}; fn response(record_type: u16, rdata: &[u8], declared_length: usize) -> Vec { let mut message = dns_query(); diff --git a/crates/pcap/tests/it/main.rs b/crates/pcap/tests/it/main.rs new file mode 100644 index 000000000..cb3173b34 --- /dev/null +++ b/crates/pcap/tests/it/main.rs @@ -0,0 +1,22 @@ +//! Integration tests for craft-pcap. + +mod dns_discovery_answers; +mod dns_question_class; +mod dns_rdata_names; +mod pcap_dns_name_limit; +mod pcap_dns_txt_lengths; +mod pcap_flow_time_range; +mod pcap_http_host_boundary; +mod pcap_http_methods; +mod pcap_ipv4_lengths; +mod pcap_ipv6_fragments; +mod pcap_ipv6_no_next_header; +mod pcap_ipv6_version; +mod pcap_tcp_ecn; +mod pcapng_simple_payload; +mod regression_pcapng_framing; +mod regression_tcp_dns_framing; +mod regression_tcp_header_length; +mod regression_tls_bounds; +#[path = "../support/mod.rs"] +mod support; diff --git a/crates/pcap/tests/pcap_dns_name_limit.rs b/crates/pcap/tests/it/pcap_dns_name_limit.rs similarity index 98% rename from crates/pcap/tests/pcap_dns_name_limit.rs rename to crates/pcap/tests/it/pcap_dns_name_limit.rs index 82fc4e9f0..e1d77febf 100644 --- a/crates/pcap/tests/pcap_dns_name_limit.rs +++ b/crates/pcap/tests/it/pcap_dns_name_limit.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{ipv4_pkt, udp}; use craft_pcap::{Dns, decode}; -use support::{ipv4_pkt, udp}; fn query(last: usize, compressed: bool) -> Dns { let mut msg = vec![0, 1, 1, 0, 0, if compressed { 2 } else { 1 }, 0, 0, 0, 0, 0, 0]; diff --git a/crates/pcap/tests/pcap_dns_txt_lengths.rs b/crates/pcap/tests/it/pcap_dns_txt_lengths.rs similarity index 99% rename from crates/pcap/tests/pcap_dns_txt_lengths.rs rename to crates/pcap/tests/it/pcap_dns_txt_lengths.rs index 56312df41..76d7dc7e7 100644 --- a/crates/pcap/tests/pcap_dns_txt_lengths.rs +++ b/crates/pcap/tests/it/pcap_dns_txt_lengths.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{ipv4_pkt, udp}; use craft_pcap::{Dns, decode}; -use support::{ipv4_pkt, udp}; fn response(data: &[u8]) -> Dns { let mut msg = vec![0, 1, 0x81, 0x80, 0, 0, 0, 1, 0, 0, 0, 0]; diff --git a/crates/pcap/tests/pcap_flow_time_range.rs b/crates/pcap/tests/it/pcap_flow_time_range.rs similarity index 93% rename from crates/pcap/tests/pcap_flow_time_range.rs rename to crates/pcap/tests/it/pcap_flow_time_range.rs index 722121f4b..bd1009c29 100644 --- a/crates/pcap/tests/pcap_flow_time_range.rs +++ b/crates/pcap/tests/it/pcap_flow_time_range.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{block, eth, ipv4_pkt, pcap, pcapng, udp}; use craft_pcap::summarize; -use support::{block, eth, ipv4_pkt, pcap, pcapng, udp}; fn frame() -> Vec { eth(0x0800, &ipv4_pkt(17, [1; 4], [2; 4], &udp(100, 200, b"body"))) diff --git a/crates/pcap/tests/pcap_http_host_boundary.rs b/crates/pcap/tests/it/pcap_http_host_boundary.rs similarity index 97% rename from crates/pcap/tests/pcap_http_host_boundary.rs rename to crates/pcap/tests/it/pcap_http_host_boundary.rs index 5baa58fee..494661cac 100644 --- a/crates/pcap/tests/pcap_http_host_boundary.rs +++ b/crates/pcap/tests/it/pcap_http_host_boundary.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{ipv4_pkt, tcp}; use craft_pcap::{Http, decode}; -use support::{ipv4_pkt, tcp}; fn request(data: &[u8]) -> Http { decode(101, &ipv4_pkt(6, [1; 4], [2; 4], &tcp(100, 80, 0x18, data))).http.unwrap() diff --git a/crates/pcap/tests/pcap_http_methods.rs b/crates/pcap/tests/it/pcap_http_methods.rs similarity index 94% rename from crates/pcap/tests/pcap_http_methods.rs rename to crates/pcap/tests/it/pcap_http_methods.rs index 57eb4e548..b5e60f559 100644 --- a/crates/pcap/tests/pcap_http_methods.rs +++ b/crates/pcap/tests/it/pcap_http_methods.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{ipv4_pkt, tcp}; use craft_pcap::decode; -use support::{ipv4_pkt, tcp}; /// WebDAV and extension methods retain the same HTTP evidence as core methods. #[test] diff --git a/crates/pcap/tests/pcap_ipv4_lengths.rs b/crates/pcap/tests/it/pcap_ipv4_lengths.rs similarity index 96% rename from crates/pcap/tests/pcap_ipv4_lengths.rs rename to crates/pcap/tests/it/pcap_ipv4_lengths.rs index e1ea930a0..665de6c11 100644 --- a/crates/pcap/tests/pcap_ipv4_lengths.rs +++ b/crates/pcap/tests/it/pcap_ipv4_lengths.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{ipv4_pkt, udp}; use craft_pcap::decode; -use support::{ipv4_pkt, udp}; #[test] fn incomplete_ipv4_base_headers_explain_why_decoding_stopped() { diff --git a/crates/pcap/tests/pcap_ipv6_fragments.rs b/crates/pcap/tests/it/pcap_ipv6_fragments.rs similarity index 95% rename from crates/pcap/tests/pcap_ipv6_fragments.rs rename to crates/pcap/tests/it/pcap_ipv6_fragments.rs index 1c413f4b3..68d5a045b 100644 --- a/crates/pcap/tests/pcap_ipv6_fragments.rs +++ b/crates/pcap/tests/it/pcap_ipv6_fragments.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{eth, udp}; use craft_pcap::decode; -use support::{eth, udp}; fn packet(offset: u16, next: u8, payload: &[u8]) -> Vec { let mut ip = vec![0u8; 40]; diff --git a/crates/pcap/tests/pcap_ipv6_no_next_header.rs b/crates/pcap/tests/it/pcap_ipv6_no_next_header.rs similarity index 100% rename from crates/pcap/tests/pcap_ipv6_no_next_header.rs rename to crates/pcap/tests/it/pcap_ipv6_no_next_header.rs diff --git a/crates/pcap/tests/pcap_ipv6_version.rs b/crates/pcap/tests/it/pcap_ipv6_version.rs similarity index 95% rename from crates/pcap/tests/pcap_ipv6_version.rs rename to crates/pcap/tests/it/pcap_ipv6_version.rs index f69766321..ee24503c2 100644 --- a/crates/pcap/tests/pcap_ipv6_version.rs +++ b/crates/pcap/tests/it/pcap_ipv6_version.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{eth, ipv4_pkt}; use craft_pcap::decode; -use support::{eth, ipv4_pkt}; fn raw_packets() -> (Vec, Vec) { let ipv4 = ipv4_pkt(17, [1; 4], [2; 4], &[0; 20]); diff --git a/crates/pcap/tests/pcap_tcp_ecn.rs b/crates/pcap/tests/it/pcap_tcp_ecn.rs similarity index 100% rename from crates/pcap/tests/pcap_tcp_ecn.rs rename to crates/pcap/tests/it/pcap_tcp_ecn.rs diff --git a/crates/pcap/tests/pcapng_simple_payload.rs b/crates/pcap/tests/it/pcapng_simple_payload.rs similarity index 96% rename from crates/pcap/tests/pcapng_simple_payload.rs rename to crates/pcap/tests/it/pcapng_simple_payload.rs index ee4743020..c045e5eaa 100644 --- a/crates/pcap/tests/pcapng_simple_payload.rs +++ b/crates/pcap/tests/it/pcapng_simple_payload.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{block, pcapng}; use craft_pcap::Capture; -use support::{block, pcapng}; fn capture(original: u32, snaplen: u32, payload: &[u8]) -> Vec { let mut out = pcapng(&[]); diff --git a/crates/pcap/tests/regression_pcapng_framing.rs b/crates/pcap/tests/it/regression_pcapng_framing.rs similarity index 97% rename from crates/pcap/tests/regression_pcapng_framing.rs rename to crates/pcap/tests/it/regression_pcapng_framing.rs index 1ba8d2878..8c78905c3 100644 --- a/crates/pcap/tests/regression_pcapng_framing.rs +++ b/crates/pcap/tests/it/regression_pcapng_framing.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{block, pcapng, sample_frames}; use craft_pcap::summarize; -use support::{block, pcapng, sample_frames}; #[test] fn mismatched_block_footers_stop_the_capture_with_a_warning() { diff --git a/crates/pcap/tests/regression_tcp_dns_framing.rs b/crates/pcap/tests/it/regression_tcp_dns_framing.rs similarity index 95% rename from crates/pcap/tests/regression_tcp_dns_framing.rs rename to crates/pcap/tests/it/regression_tcp_dns_framing.rs index e85c987aa..951c1e5d7 100644 --- a/crates/pcap/tests/regression_tcp_dns_framing.rs +++ b/crates/pcap/tests/it/regression_tcp_dns_framing.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{dns_query, dns_response, ipv4_pkt, tcp}; use craft_pcap::{Decoded, decode}; -use support::{dns_query, dns_response, ipv4_pkt, tcp}; fn decoded(payload: &[u8]) -> Decoded { decode(101, &ipv4_pkt(6, [192, 0, 2, 1], [192, 0, 2, 2], &tcp(53, 51000, 0x18, payload))) diff --git a/crates/pcap/tests/regression_tcp_header_length.rs b/crates/pcap/tests/it/regression_tcp_header_length.rs similarity index 96% rename from crates/pcap/tests/regression_tcp_header_length.rs rename to crates/pcap/tests/it/regression_tcp_header_length.rs index d931f97b2..3ffef2b54 100644 --- a/crates/pcap/tests/regression_tcp_header_length.rs +++ b/crates/pcap/tests/it/regression_tcp_header_length.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{ipv4_pkt, tcp}; use craft_pcap::{Decoded, decode}; -use support::{ipv4_pkt, tcp}; fn decoded(segment: &[u8]) -> Decoded { decode(101, &ipv4_pkt(6, [192, 0, 2, 1], [192, 0, 2, 2], segment)) diff --git a/crates/pcap/tests/regression_tls_bounds.rs b/crates/pcap/tests/it/regression_tls_bounds.rs similarity index 98% rename from crates/pcap/tests/regression_tls_bounds.rs rename to crates/pcap/tests/it/regression_tls_bounds.rs index 92a710fc4..7306c11c8 100644 --- a/crates/pcap/tests/regression_tls_bounds.rs +++ b/crates/pcap/tests/it/regression_tls_bounds.rs @@ -1,8 +1,5 @@ -#[path = "support/mod.rs"] -mod support; - +use super::support::{client_hello, ipv4_pkt, tcp}; use craft_pcap::{Decoded, decode}; -use support::{client_hello, ipv4_pkt, tcp}; fn decoded(record: &[u8]) -> Decoded { decode(101, &ipv4_pkt(6, [192, 0, 2, 1], [192, 0, 2, 2], &tcp(51000, 443, 0x18, record)))