| 1 |
//! Fuzzy testing. |
| 2 |
//! Tries to discover panics with random bytes. |
| 3 |
//! This test is expensive and therefore marked with `#[ignore]`. To run this test, use `cargo test -- --ignored`. |
| 4 |
|
| 5 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std panic/::{catch_unwindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std panic/catch_unwind().}; |
| 6 |
use randrust-analyzer cargo rand 0.8.5 crate/::rngsrust-analyzer cargo rand 0.8.5 rngs/::{StdRngrust-analyzer cargo rand 0.8.5 rngs/std/StdRng#}; |
| 7 |
use randrust-analyzer cargo rand 0.8.5 crate/::{Rngrust-analyzer cargo rand 0.8.5 rng/Rng#}; |
| 8 |
|
| 9 |
extern crate exrrust-analyzer cargo exr 1.74.0 exr/; |
| 10 |
use exrrust-analyzer cargo exr 1.74.0 crate/::preluderust-analyzer cargo exr 1.74.0 prelude/::*; |
| 11 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#; |
| 12 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#; |
| 13 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#; |
| 14 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#}; |
| 15 |
use exrrust-analyzer cargo exr 1.74.0 crate/::imagerust-analyzer cargo exr 1.74.0 image/::readrust-analyzer cargo exr 1.74.0 image/read/::read_first_rgba_layer_from_filerust-analyzer cargo exr 1.74.0 image/read/read_first_rgba_layer_from_file().; |
| 16 |
use exrrust-analyzer cargo exr 1.74.0 crate/::imagerust-analyzer cargo exr 1.74.0 image/::pixel_vecrust-analyzer cargo exr 1.74.0 image/pixel_vec/::PixelVecrust-analyzer cargo exr 1.74.0 image/pixel_vec/PixelVec#; |
| 17 |
|
| 18 |
fn exr_filesrust-analyzer cargo exr 1.74.0 exr_files().(path: &'static str, filter: bool) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#=PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#> { |
| 19 |
walkdirrust-analyzer cargo walkdir 2.5.0 crate/::WalkDirrust-analyzer cargo walkdir 2.5.0 WalkDir#::newrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir]new().(path).into_iterrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#::unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().) |
| 20 |
.filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|entry| entry.pathrust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]path().().is_filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]is_file().()) |
| 21 |
|
| 22 |
.filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(move |entry| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().filter || entry.pathrust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]path().().extensionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]extension().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]new().("exr"))) |
| 23 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(walkdirrust-analyzer cargo walkdir 2.5.0 crate/::DirEntryrust-analyzer cargo walkdir 2.5.0 dent/DirEntry#::into_pathrust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]into_path().) |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
/// Just don't panic. |
| •28 |
#[ignore] |
| 29 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 30 |
pub fn fuzzedrust-analyzer cargo exr 1.74.0 fuzzed().(){ |
| 31 |
for ref file in exr_filesrust-analyzer cargo exr 1.74.0 exr_files().("tests/images/fuzzed", false) { |
| 32 |
let _ = readrust-analyzer cargo exr 1.74.0 image/read/read().().no_deep_datarust-analyzer cargo exr 1.74.0 image/read/impl#[ReadBuilder]no_deep_data().().largest_resolution_levelrust-analyzer cargo exr 1.74.0 image/read/samples/impl#[ReadFlatSamples]largest_resolution_level().().all_channelsrust-analyzer cargo exr 1.74.0 image/read/levels/impl#[`ReadLargestLevel<DeepOrFlatSamples>`]all_channels().() |
| 33 |
.first_valid_layerrust-analyzer cargo exr 1.74.0 image/read/layers/ReadChannels#first_valid_layer().().all_attributesrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#all_attributes().().pedanticrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]pedantic().().from_filerust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_file().(file); |
| 34 |
|
| 35 |
let _ = readrust-analyzer cargo exr 1.74.0 image/read/read().().no_deep_datarust-analyzer cargo exr 1.74.0 image/read/impl#[ReadBuilder]no_deep_data().().all_resolution_levelsrust-analyzer cargo exr 1.74.0 image/read/samples/impl#[ReadFlatSamples]all_resolution_levels().().all_channelsrust-analyzer cargo exr 1.74.0 image/read/levels/impl#[`ReadAllLevels<ReadDeepOrFlatSamples>`]all_channels().() |
| 36 |
.all_layersrust-analyzer cargo exr 1.74.0 image/read/layers/ReadChannels#all_layers().().all_attributesrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#all_attributes().().pedanticrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]pedantic().().from_filerust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_file().(file); |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
/// Require an error but no panic. |
| •41 |
#[ignore] |
| 42 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 43 |
pub fn damagedrust-analyzer cargo exr 1.74.0 damaged().(){ |
| 44 |
let mut passed = true; |
| 45 |
|
| 46 |
for ref file in exr_filesrust-analyzer cargo exr 1.74.0 exr_files().("tests/images/invalid", false) { |
| 47 |
let result = catch_unwindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std panic/catch_unwind().(move || { |
| 48 |
let _meta_data = MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#::read_from_filerust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_from_file().(file, false)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 49 |
|
| 50 |
{ |
| 51 |
let _minimal = readrust-analyzer cargo exr 1.74.0 image/read/read().().no_deep_datarust-analyzer cargo exr 1.74.0 image/read/impl#[ReadBuilder]no_deep_data().() |
| 52 |
.largest_resolution_levelrust-analyzer cargo exr 1.74.0 image/read/samples/impl#[ReadFlatSamples]largest_resolution_level().() |
| 53 |
.rgba_channelsrust-analyzer cargo exr 1.74.0 image/read/levels/impl#[`ReadLargestLevel<DeepOrFlatSamples>`]rgba_channels().( |
| 54 |
|_size, _channels| (), |
| 55 |
|_: &mut (), _position: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, _pixel: (Samplerust-analyzer cargo exr 1.74.0 block/samples/Sample#, Samplerust-analyzer cargo exr 1.74.0 block/samples/Sample#, Samplerust-analyzer cargo exr 1.74.0 block/samples/Sample#, Samplerust-analyzer cargo exr 1.74.0 block/samples/Sample#)| {} |
| 56 |
) |
| 57 |
.first_valid_layerrust-analyzer cargo exr 1.74.0 image/read/layers/ReadChannels#first_valid_layer().().all_attributesrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#all_attributes().() |
| 58 |
.from_filerust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_file().(&file)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 59 |
} |
| 60 |
|
| 61 |
{ |
| 62 |
let _minimal = readrust-analyzer cargo exr 1.74.0 image/read/read().().no_deep_datarust-analyzer cargo exr 1.74.0 image/read/impl#[ReadBuilder]no_deep_data().() |
| 63 |
.largest_resolution_levelrust-analyzer cargo exr 1.74.0 image/read/samples/impl#[ReadFlatSamples]largest_resolution_level().() // TODO all levels |
| 64 |
.rgba_channelsrust-analyzer cargo exr 1.74.0 image/read/levels/impl#[`ReadLargestLevel<DeepOrFlatSamples>`]rgba_channels().( |
| 65 |
|_size, _channels| (), |
| 66 |
|_: &mut (), _position: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, _pixel: (Samplerust-analyzer cargo exr 1.74.0 block/samples/Sample#, Samplerust-analyzer cargo exr 1.74.0 block/samples/Sample#, Samplerust-analyzer cargo exr 1.74.0 block/samples/Sample#, Samplerust-analyzer cargo exr 1.74.0 block/samples/Sample#)| {} |
| 67 |
) |
| 68 |
.all_layersrust-analyzer cargo exr 1.74.0 image/read/layers/ReadChannels#all_layers().().all_attributesrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#all_attributes().() |
| 69 |
.pedanticrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]pedantic().() |
| 70 |
.from_filerust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_file().(&file)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 71 |
} |
| 72 |
|
| 73 |
{ |
| 74 |
let _rgba = read_first_rgba_layer_from_filerust-analyzer cargo exr 1.74.0 image/read/read_first_rgba_layer_from_file().( |
| 75 |
file, |
| 76 |
PixelVecrust-analyzer cargo exr 1.74.0 image/pixel_vec/PixelVec#::<(Samplerust-analyzer cargo exr 1.74.0 block/samples/Sample#, Samplerust-analyzer cargo exr 1.74.0 block/samples/Sample#, Samplerust-analyzer cargo exr 1.74.0 block/samples/Sample#, Samplerust-analyzer cargo exr 1.74.0 block/samples/Sample#)>::constructorrust-analyzer cargo exr 1.74.0 image/pixel_vec/impl#[`PixelVec<Pixel>`]constructor()., |
| 77 |
PixelVecrust-analyzer cargo exr 1.74.0 image/pixel_vec/PixelVec#::set_pixelrust-analyzer cargo exr 1.74.0 image/pixel_vec/impl#[`PixelVec<Pixel>`]set_pixel(). |
| 78 |
)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 79 |
} |
| 80 |
|
| 81 |
{ |
| 82 |
let _full = read_all_data_from_filerust-analyzer cargo exr 1.74.0 image/read/read_all_data_from_file().(file)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 83 |
} |
| 84 |
|
| 85 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 86 |
}); |
| 87 |
|
| 88 |
// this should not panic, only err: |
| 89 |
passed = passed && match result { |
| 90 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::Invalidrust-analyzer cargo exr 1.74.0 error/Error#Invalid#(message))) => { |
| 91 |
printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("✓ Recognized as invalid ({}): {:?}", message, file); |
| 92 |
true |
| 93 |
}, |
| 94 |
|
| 95 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::NotSupportedrust-analyzer cargo exr 1.74.0 error/Error#NotSupported#(message))) => { |
| 96 |
printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("- Unsupported ({}): {:?}", message, file); |
| 97 |
true |
| 98 |
}, |
| 99 |
|
| 100 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::Iorust-analyzer cargo exr 1.74.0 error/Error#Io#(error))) => { |
| 101 |
printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("✗ Unexpected IO Error: {:?}, {:?}", file, error); |
| 102 |
false |
| 103 |
}, |
| 104 |
|
| 105 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => { |
| 106 |
printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("✗ Not recognized as invalid: {:?}", file); |
| 107 |
false |
| 108 |
}, |
| 109 |
|
| 110 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(_)) => { |
| 111 |
let meta_data = MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#::read_from_filerust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_from_file().(file, true); |
| 112 |
|
| 113 |
if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) = meta_data { |
| 114 |
printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("✓ Recognized as invalid when pedantic ({}): {:?}", error, file); |
| 115 |
true |
| 116 |
} |
| 117 |
else { |
| 118 |
printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("✗ Oh no, there is nothing wrong with: {:#?}", file); |
| 119 |
false |
| 120 |
} |
| 121 |
}, |
| 122 |
|
| 123 |
_ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 124 |
}; |
| 125 |
} |
| 126 |
|
| 127 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(passed, "A damaged file was not handled correctly"); |
| 128 |
} |
| 129 |
|
| 130 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 131 |
#[ignore] |
| 132 |
pub fn fuzzrust-analyzer cargo exr 1.74.0 fuzz().(){ |
| 133 |
printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("started fuzzing"); |
| 134 |
let files: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#> = exr_filesrust-analyzer cargo exr 1.74.0 exr_files().("tests/images", true).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 135 |
|
| 136 |
let seed = [92,1,0,130,211,8,21,70,74,4,9,5,0,23,0,3,20,25,6,5,229,30,0,34,218,0,40,7,5,2,7,0,]; |
| 137 |
let mut random: StdRngrust-analyzer cargo rand 0.8.5 rngs/std/StdRng# = randrust-analyzer cargo rand 0.8.5 crate/::SeedableRngrust-analyzer cargo rand_core 0.6.4 SeedableRng#::from_seedrust-analyzer cargo rand 0.8.5 rngs/std/impl#[StdRng][SeedableRng]from_seed().(seed); |
| 138 |
|
| 139 |
let mut records = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().("tests/images/fuzzed/list.txt").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 140 |
records.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("seed = {:?}", seed).as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 141 |
|
| 142 |
let start_index = 0; // default is 0. increase this integer for debugging a specific fuzz case |
| 143 |
for fuzz_index in 0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1024_u64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().2048 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().4 { |
| 144 |
|
| 145 |
let file_1_name = &files[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().random.gen_rangerust-analyzer cargo rand 0.8.5 rng/Rng#gen_range().(0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#files.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().())]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 146 |
let mutation_point = random.genrust-analyzer cargo rand 0.8.5 rng/Rng#gen().::<f32>().powirust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]powi().(3); |
| 147 |
let mutation = random.genrust-analyzer cargo rand 0.8.5 rng/Rng#gen().::<u8>(); |
| 148 |
|
| 149 |
if fuzz_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge().start_index { |
| 150 |
let mut file = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/read().(file_1_name).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 151 |
let index = ((mutation_point rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().file.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() as f32) as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().4) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().file.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(); |
| 152 |
file[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().index]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = mutation; |
| 153 |
|
| 154 |
let file = file.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().(); |
| 155 |
let result = catch_unwindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std panic/catch_unwind().(move || { |
| 156 |
let read_all_data = readrust-analyzer cargo exr 1.74.0 image/read/read().().no_deep_datarust-analyzer cargo exr 1.74.0 image/read/impl#[ReadBuilder]no_deep_data().() |
| 157 |
.all_resolution_levelsrust-analyzer cargo exr 1.74.0 image/read/samples/impl#[ReadFlatSamples]all_resolution_levels().().all_channelsrust-analyzer cargo exr 1.74.0 image/read/levels/impl#[`ReadAllLevels<ReadDeepOrFlatSamples>`]all_channels().().all_layersrust-analyzer cargo exr 1.74.0 image/read/layers/ReadChannels#all_layers().().all_attributesrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#all_attributes().(); |
| 158 |
|
| 159 |
match read_all_data.from_bufferedrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_buffered().(Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(file)) { |
| 160 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::Invalidrust-analyzer cargo exr 1.74.0 error/Error#Invalid#(error)) => printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("✓ No Panic. [{}]: Invalid: {}.", fuzz_index, error), |
| 161 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::NotSupportedrust-analyzer cargo exr 1.74.0 error/Error#NotSupported#(error)) => printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("- No Panic. [{}]: Unsupported: {}.", fuzz_index, error), |
| 162 |
_ => {}, |
| 163 |
} |
| 164 |
}); |
| 165 |
|
| 166 |
if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) = result { |
| 167 |
records.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(fuzz_index.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 168 |
records.flushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File][Write]flush().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 169 |
|
| 170 |
let seed = seed.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|num| num.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>().joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("-"); |
| 171 |
let mut saved = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("tests/images/fuzzed/fuzz_{}_{}.exr", fuzz_index, seed)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 172 |
saved.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(file).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 173 |
|
| 174 |
printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("✗ PANIC! [{}]", fuzz_index); |
| 175 |
} |
| 176 |
} |
| 177 |
} |
| 178 |
} |