-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from worm-blossom/slice_helpers
Add slice helpers, start cleaning up some bits and pieces
- Loading branch information
Showing
58 changed files
with
5,428 additions
and
3,720 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#![no_main] | ||
|
||
use either::{Left, Right}; | ||
use libfuzzer_sys::fuzz_target; | ||
use ufotofu::local_nb::producer::{bulk_pipe_into_slice, TestProducer}; | ||
|
||
fuzz_target!(|data: (TestProducer<u16, u8, u8>, usize)| { | ||
let (mut producer, length) = data; | ||
|
||
let clamped_length = length.clamp(0, 512); | ||
|
||
let mut v: Vec<u16> = vec![0; clamped_length]; | ||
|
||
let producer_data = producer.peek_slice().to_vec(); | ||
|
||
// peek termination here. | ||
|
||
async { | ||
match bulk_pipe_into_slice(&mut v[0..clamped_length], &mut producer).await { | ||
Ok(_) => { | ||
// Were the bytes successfully piped? | ||
|
||
// refactor as assert_eq | ||
if producer_data[0..clamped_length] != v[0..clamped_length] { | ||
panic!("Bytes piped into slice did not match!") | ||
} | ||
} | ||
Err(err) => { | ||
// let producer_data = producer.peek_slice(); | ||
|
||
// If the filled property is not equal to the inner slice, panic. | ||
// assertion macro | ||
if err.filled != producer_data { | ||
panic!("Filled was not the same as the producer slice.") | ||
} | ||
|
||
// Do we need to check if the error produced was the right kind? e.g. by inspecting the producer's termination field? | ||
} | ||
} | ||
}; | ||
}); |
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,43 @@ | ||
#![no_main] | ||
|
||
use core::mem::MaybeUninit; | ||
use either::{Left, Right}; | ||
use libfuzzer_sys::fuzz_target; | ||
use ufotofu::local_nb::producer::{bulk_pipe_into_slice_uninit, TestProducer}; | ||
|
||
fuzz_target!(|data: (TestProducer<u16, u8, u8>, usize)| { | ||
let (mut producer, length) = data; | ||
|
||
let clamped_length = length.clamp(0, 512); | ||
|
||
let mut v: Vec<u16> = vec![0; clamped_length]; | ||
|
||
let producer_data = producer.peek_slice().to_vec(); | ||
|
||
let producer_data_maybe_uninit = | ||
unsafe { &mut *(&mut v[0..clamped_length] as *mut [u16] as *mut [MaybeUninit<u16>]) }; | ||
|
||
async { | ||
match bulk_pipe_into_slice_uninit(producer_data_maybe_uninit, &mut producer).await { | ||
Ok(_) => { | ||
// Were the bytes successfully piped? | ||
|
||
// refactor as assert_eq | ||
if producer_data[0..clamped_length] != v[0..clamped_length] { | ||
panic!("Bytes piped into slice did not match!") | ||
} | ||
} | ||
Err(err) => { | ||
// let producer_data = producer.peek_slice(); | ||
|
||
// If the filled property is not equal to the inner slice, panic. | ||
// assertion macro | ||
if err.filled != producer_data { | ||
panic!("Filled was not the same as the producer slice.") | ||
} | ||
|
||
// Do we need to check if the error produced was the right kind? e.g. by inspecting the producer's termination field? | ||
} | ||
} | ||
}; | ||
}); |
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,41 @@ | ||
#![no_main] | ||
|
||
use either::{Left, Right}; | ||
use libfuzzer_sys::fuzz_target; | ||
use ufotofu::local_nb::producer::{pipe_into_slice, TestProducer}; | ||
|
||
fuzz_target!(|data: (TestProducer<u16, u8, u8>, usize)| { | ||
let (mut producer, length) = data; | ||
|
||
let clamped_length = length.clamp(0, 512); | ||
|
||
let mut v: Vec<u16> = vec![0; clamped_length]; | ||
|
||
let producer_data = producer.peek_slice().to_vec(); | ||
|
||
// peek termination here. | ||
|
||
async { | ||
match pipe_into_slice(&mut v[0..clamped_length], &mut producer).await { | ||
Ok(_) => { | ||
// Were the bytes successfully piped? | ||
|
||
// refactor as assert_eq | ||
if producer_data[0..clamped_length] != v[0..clamped_length] { | ||
panic!("Bytes piped into slice did not match!") | ||
} | ||
} | ||
Err(err) => { | ||
// let producer_data = producer.peek_slice(); | ||
|
||
// If the filled property is not equal to the inner slice, panic. | ||
// assertion macro | ||
if err.filled != producer_data { | ||
panic!("Filled was not the same as the producer slice.") | ||
} | ||
|
||
// Do we need to check if the error produced was the right kind? e.g. by inspecting the producer's termination field? | ||
} | ||
} | ||
}; | ||
}); |
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,43 @@ | ||
#![no_main] | ||
|
||
use core::mem::MaybeUninit; | ||
use either::{Left, Right}; | ||
use libfuzzer_sys::fuzz_target; | ||
use ufotofu::local_nb::producer::{pipe_into_slice_uninit, TestProducer}; | ||
|
||
fuzz_target!(|data: (TestProducer<u16, u8, u8>, usize)| { | ||
let (mut producer, length) = data; | ||
|
||
let clamped_length = length.clamp(0, 512); | ||
|
||
let mut v: Vec<u16> = vec![0; clamped_length]; | ||
|
||
let producer_data = producer.peek_slice().to_vec(); | ||
|
||
let producer_data_maybe_uninit = | ||
unsafe { &mut *(&mut v[0..clamped_length] as *mut [u16] as *mut [MaybeUninit<u16>]) }; | ||
|
||
async { | ||
match pipe_into_slice_uninit(producer_data_maybe_uninit, &mut producer).await { | ||
Ok(_) => { | ||
// Were the bytes successfully piped? | ||
|
||
// refactor as assert_eq | ||
if producer_data[0..clamped_length] != v[0..clamped_length] { | ||
panic!("Bytes piped into slice did not match!") | ||
} | ||
} | ||
Err(err) => { | ||
// let producer_data = producer.peek_slice(); | ||
|
||
// If the filled property is not equal to the inner slice, panic. | ||
// assertion macro | ||
if err.filled != producer_data { | ||
panic!("Filled was not the same as the producer slice.") | ||
} | ||
|
||
// Do we need to check if the error produced was the right kind? e.g. by inspecting the producer's termination field? | ||
} | ||
} | ||
}; | ||
}); |
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,39 @@ | ||
#![no_main] | ||
|
||
use either::{Left, Right}; | ||
use libfuzzer_sys::fuzz_target; | ||
use ufotofu::sync::producer::{bulk_pipe_into_slice, TestProducer}; | ||
|
||
fuzz_target!(|data: (TestProducer<u16, u8, u8>, usize)| { | ||
let (mut producer, length) = data; | ||
|
||
let clamped_length = length.clamp(0, 512); | ||
|
||
let mut v: Vec<u16> = vec![0; clamped_length]; | ||
|
||
let producer_data = producer.peek_slice().to_vec(); | ||
|
||
// peek termination here. | ||
|
||
match bulk_pipe_into_slice(&mut v[0..clamped_length], &mut producer) { | ||
Ok(_) => { | ||
// Were the bytes successfully piped? | ||
|
||
// refactor as assert_eq | ||
if producer_data[0..clamped_length] != v[0..clamped_length] { | ||
panic!("Bytes piped into slice did not match!") | ||
} | ||
} | ||
Err(err) => { | ||
// let producer_data = producer.peek_slice(); | ||
|
||
// If the filled property is not equal to the inner slice, panic. | ||
// assertion macro | ||
if err.filled != producer_data { | ||
panic!("Filled was not the same as the producer slice.") | ||
} | ||
|
||
// Do we need to check if the error produced was the right kind? e.g. by inspecting the producer's termination field? | ||
} | ||
} | ||
}); |
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,41 @@ | ||
#![no_main] | ||
|
||
use core::mem::MaybeUninit; | ||
use either::{Left, Right}; | ||
use libfuzzer_sys::fuzz_target; | ||
use ufotofu::sync::producer::{bulk_pipe_into_slice_uninit, TestProducer}; | ||
|
||
fuzz_target!(|data: (TestProducer<u16, u8, u8>, usize)| { | ||
let (mut producer, length) = data; | ||
|
||
let clamped_length = length.clamp(0, 512); | ||
|
||
let mut v: Vec<u16> = vec![0; clamped_length]; | ||
|
||
let producer_data = producer.peek_slice().to_vec(); | ||
|
||
let producer_data_maybe_uninit = | ||
unsafe { &mut *(&mut v[0..clamped_length] as *mut [u16] as *mut [MaybeUninit<u16>]) }; | ||
|
||
match bulk_pipe_into_slice_uninit(producer_data_maybe_uninit, &mut producer) { | ||
Ok(_) => { | ||
// Were the bytes successfully piped? | ||
|
||
// refactor as assert_eq | ||
if producer_data[0..clamped_length] != v[0..clamped_length] { | ||
panic!("Bytes piped into slice did not match!") | ||
} | ||
} | ||
Err(err) => { | ||
// let producer_data = producer.peek_slice(); | ||
|
||
// If the filled property is not equal to the inner slice, panic. | ||
// assertion macro | ||
if err.filled != producer_data { | ||
panic!("Filled was not the same as the producer slice.") | ||
} | ||
|
||
// Do we need to check if the error produced was the right kind? e.g. by inspecting the producer's termination field? | ||
} | ||
} | ||
}); |
Oops, something went wrong.