Expand description
§native-ipc-testkit
Deterministic hostile-input generators and golden-message helpers for testing
protocols built on native-ipc-core.
The helpers are deliberately bounded so they are suitable for ordinary unit tests and CI, not only fuzzing jobs.
§Example
use native_ipc_testkit::{
HOSTILE_U64_BOUNDARIES, bounded_bit_mutations, every_truncation,
};
let canonical = b"NIPC";
let truncations: Vec<_> = every_truncation(canonical).collect();
assert_eq!(truncations.first().unwrap().len(), 0);
assert_eq!(truncations.last().unwrap(), canonical);
let mutations = bounded_bit_mutations(canonical, 2);
assert_eq!(mutations.len(), 2);
assert_ne!(mutations[0], canonical);
assert_eq!(HOSTILE_U64_BOUNDARIES.last(), Some(&u64::MAX));Additional helpers produce fixed-field shared-layout mutations and exactly
sized encoded golden vectors. The committed cross-platform fixtures are in the
golden_vectors integration test.
The same bounded corpus API is runnable as the
hostile_inputs example.
Licensed under MIT or Apache-2.0.
Constants§
- HOSTILE_
U64_ BOUNDARIES - Boundary values for hostile relative-offset and declared-length corpora.
Functions§
- bounded_
bit_ mutations - Produces at most
limitdeterministic one-bit hostile mutations. - every_
truncation - Produces truncations of
input, including the empty and complete input. - golden_
message - Encodes a message into an exactly sized owned golden vector.
- hostile_
layout_ mutations - Produces bounded hostile region-header/layout mutations at fixed fields.