dust off fuzz tests

* make them build again
* reformat
* check those things on CI. probably too expensive to actually run them.
This commit is contained in:
Scott Lamb 2021-08-19 13:16:16 -07:00
parent 782029a1ca
commit d29129792e
4 changed files with 27 additions and 142 deletions

View File

@ -37,9 +37,12 @@ jobs:
components: ${{ matrix.extra_components }}
- name: Test
run: cargo test --all-features
- name: Check fuzz tests
run: cd fuzz && cargo check
- name: Check formatting
if: matrix.rust == 'stable'
run: cargo fmt -- --check
run: cd fuzz && cargo fmt -- --check
license:
name: Check copyright/license headers
runs-on: ubuntu-20.04

136
fuzz/Cargo.lock generated
View File

@ -2,21 +2,6 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "addr2line"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a"
dependencies = [
"gimli",
]
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "arbitrary"
version = "1.0.1"
@ -29,48 +14,12 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "async-stream"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "171374e7e3b2504e0e5236e3b59260560f9fe94bfe9ac39ba5e4e929c5590625"
dependencies = [
"async-stream-impl",
"futures-core",
]
[[package]]
name = "async-stream-impl"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "backtrace"
version = "0.3.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7815ea54e4d821e791162e078acbebfd6d8c8939cd559c9335dceb1c8ca7282"
dependencies = [
"addr2line",
"cc",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
]
[[package]]
name = "base64"
version = "0.13.0"
@ -168,28 +117,6 @@ dependencies = [
"sha2",
]
[[package]]
name = "failure"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
dependencies = [
"backtrace",
"failure_derive",
]
[[package]]
name = "failure_derive"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [
"proc-macro2",
"quote",
"syn",
"synstructure",
]
[[package]]
name = "form_urlencoded"
version = "1.0.1"
@ -327,12 +254,6 @@ dependencies = [
"wasi",
]
[[package]]
name = "gimli"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189"
[[package]]
name = "h264-reader"
version = "0.5.0"
@ -424,16 +345,6 @@ version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
[[package]]
name = "miniz_oxide"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
dependencies = [
"adler",
"autocfg",
]
[[package]]
name = "mio"
version = "0.7.11"
@ -493,15 +404,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "object"
version = "0.25.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8bc1d42047cf336f0f939c99e97183cf31551bf0f2865a2ec9c8d91fd4ffb5e"
dependencies = [
"memchr",
]
[[package]]
name = "once_cell"
version = "1.7.2"
@ -642,14 +544,12 @@ dependencies = [
[[package]]
name = "retina"
version = "0.0.1"
version = "0.2.0"
dependencies = [
"async-stream",
"base64",
"bitreader",
"bytes",
"digest_auth",
"failure",
"futures",
"h264-reader",
"hex",
@ -657,11 +557,11 @@ dependencies = [
"once_cell",
"pin-project",
"pretty-hex",
"rtcp",
"rtp-rs",
"rtsp-types",
"sdp",
"smallvec",
"thiserror",
"time",
"tokio",
"tokio-util",
@ -688,21 +588,11 @@ dependencies = [
"mpeg4-audio-const",
]
[[package]]
name = "rtcp"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5fb4431b04a948fd91622a75d65a95da3ed2f0be26c902f3d027a23b78fbc96"
dependencies = [
"bytes",
"thiserror",
]
[[package]]
name = "rtp-rs"
version = "0.5.0"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1110d695193d446e901de09921ffbf2d86ae351bbfde9c5b53863ce177e17f5"
checksum = "d4ed274a5b3d36c4434cff6a4de1b42f43e64ae326b1cfa72d13d9037a314355"
[[package]]
name = "rtsp-types"
@ -716,12 +606,6 @@ dependencies = [
"url",
]
[[package]]
name = "rustc-demangle"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce"
[[package]]
name = "ryu"
version = "1.0.5"
@ -781,18 +665,6 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "synstructure"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
dependencies = [
"proc-macro2",
"quote",
"syn",
"unicode-xid",
]
[[package]]
name = "tap"
version = "1.0.1"

View File

@ -12,7 +12,8 @@ fuzz_target!(|data: &[u8]| {
"video", "h264", 90_000, None, Some("packetization-mode=1;profile-level-id=64001E;sprop-parameter-sets=Z2QAHqwsaoLA9puCgIKgAAADACAAAAMD0IAA,aO4xshsA")).unwrap();
let mut timestamp = retina::Timestamp::new(0, NonZeroU32::new(90_000).unwrap(), 0).unwrap();
let mut sequence_number: u16 = 0;
let ctx = retina::Context::dummy();
let conn_ctx = retina::ConnectionContext::dummy();
let msg_ctx = retina::RtspMessageContext::dummy();
while data.has_remaining() {
let hdr = data.get_u8();
let ts_change = (hdr & 0b001) != 0;
@ -29,9 +30,11 @@ fuzz_target!(|data: &[u8]| {
timestamp = timestamp.try_add(1).unwrap();
}
let pkt = retina::client::rtp::Packet {
rtsp_ctx: ctx,
ctx: msg_ctx,
channel_id: 0,
stream_id: 0,
timestamp,
ssrc: 0,
sequence_number,
loss: u16::from(loss),
mark,
@ -41,7 +44,7 @@ fuzz_target!(|data: &[u8]| {
if depacketizer.push(pkt).is_err() {
return;
}
while let Some(item) = depacketizer.pull().transpose() {
while let Some(item) = depacketizer.pull(&conn_ctx).transpose() {
if item.is_err() {
return;
}

View File

@ -15,17 +15,24 @@ fuzz_target!(|data: &[u8]| {
if data.len() < 2 {
return;
}
let conn_ctx = retina::ConnectionContext::dummy();
let max_payload_size = u16::from_be_bytes([data[0], data[1]]);
let mut p = match retina::codec::h264::Packetizer::new(max_payload_size, 0, 0) {
Ok(p) => p,
Err(_) => return,
};
let mut d = retina::codec::Depacketizer::new(
"video", "h264", 90_000, None,
"video",
"h264",
90_000,
None,
Some("packetization-mode=1;sprop-parameter-sets=J01AHqkYGwe83gDUBAQG2wrXvfAQ,KN4JXGM4"),
).unwrap();
)
.unwrap();
let timestamp = retina::Timestamp::new(0, NonZeroU32::new(90_000).unwrap(), 0).unwrap();
if p.push(timestamp, Bytes::copy_from_slice(&data[2..])).is_err() {
if p.push(timestamp, Bytes::copy_from_slice(&data[2..]))
.is_err()
{
return;
}
let frame = loop {
@ -35,12 +42,12 @@ fuzz_target!(|data: &[u8]| {
if d.push(pkt).is_err() {
return;
}
match d.pull() {
match d.pull(&conn_ctx) {
Err(_) => return,
Ok(Some(retina::codec::CodecItem::VideoFrame(f))) => {
assert!(mark);
break f
},
break f;
}
Ok(Some(_)) => panic!(),
Ok(None) => assert!(!mark),
}
@ -50,6 +57,6 @@ fuzz_target!(|data: &[u8]| {
}
};
assert_eq!(&data[2..], &frame.data()[..]);
assert!(matches!(d.pull(), Ok(None)));
assert!(matches!(d.pull(&conn_ctx), Ok(None)));
assert!(matches!(p.pull(), Ok(None)));
});