From 878b4ee8113638e20a20e9f8aebdf6f0e99cd145 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:33:06 +0000 Subject: [PATCH] image-codecs tests: the gate flips and overwrites one value per sampled byte, rotating --- crates/image-codecs/tests/it/malformed.rs | 7 +++++-- crates/image-codecs/tests/it/tiff_pages.rs | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/image-codecs/tests/it/malformed.rs b/crates/image-codecs/tests/it/malformed.rs index 7ccb7819b..bd6bd605b 100644 --- a/crates/image-codecs/tests/it/malformed.rs +++ b/crates/image-codecs/tests/it/malformed.rs @@ -99,9 +99,12 @@ fn byte_overwrites_in_header_never_panic() { let step = craft_media_testkit::hostile::divisor(); for (k, (f, bytes)) in samples().into_iter().enumerate() { for i in (0..bytes.len().min(64)).filter(|i| (i + k) % step == 0) { - for v in [0x00, 0x7F, 0xFF] { + // nightly writes every value to each byte; the gate one per byte, rotating, so the sampled bytes together see all + let values = [0x00, 0x7F, 0xFF]; + let one = [values[(i / step) % 3]]; + for v in if step == 1 { &values[..] } else { &one[..] } { let mut b = bytes.clone(); - b[i] = v; + b[i] = *v; no_panic(f, &b); } } diff --git a/crates/image-codecs/tests/it/tiff_pages.rs b/crates/image-codecs/tests/it/tiff_pages.rs index a01523191..ec30eff2c 100644 --- a/crates/image-codecs/tests/it/tiff_pages.rs +++ b/crates/image-codecs/tests/it/tiff_pages.rs @@ -840,7 +840,11 @@ fn zoo_decodes_and_never_panics_when_cut_or_corrupted() { poke(&f[..cut]); } for i in (0..f.len()).filter(|i| (i + k) % step == 0) { - for flip in [0xffu8, 0x80, 0x01] { + // nightly flips each byte three ways; the gate one way per byte, rotating, so the sampled bytes together see all + let flips = [0xffu8, 0x80, 0x01]; + let one = [flips[(i / step) % 3]]; + for flip in if step == 1 { &flips[..] } else { &one[..] } { + let flip = *flip; let mut g = f.clone(); g[i] ^= flip; poke(&g);