From 27d221b6d01e7119560aa128af11066eb4244261 Mon Sep 17 00:00:00 2001 From: "Brian L. Troutwine" Date: Tue, 29 Oct 2024 13:16:12 -0700 Subject: [PATCH] additionally confirm lower bound of bytes written Signed-off-by: Brian L. Troutwine --- .../generator/file_gen/logrotate_fs/model.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lading/src/generator/file_gen/logrotate_fs/model.rs b/lading/src/generator/file_gen/logrotate_fs/model.rs index a98dfe8d6..b9f931486 100644 --- a/lading/src/generator/file_gen/logrotate_fs/model.rs +++ b/lading/src/generator/file_gen/logrotate_fs/model.rs @@ -1186,6 +1186,26 @@ mod test { ); } } + + // Property 9: Rotated files have bytes_written within acceptable range + // + // For a rotated file (read_only == true), bytes_written should be + // within (max_bytes_per_file - bytes_per_tick) <= bytes_written < + // (max_bytes_per_file + bytes_per_tick). + for node in state.nodes.values() { + if let Node::File { file } = node { + if !file.read_only { + continue; + } + let min_size = state.max_bytes_per_file.saturating_sub(file.bytes_per_tick); + let max_size = state.max_bytes_per_file.saturating_add(file.bytes_per_tick); + assert!( + file.bytes_written >= min_size && file.bytes_written < max_size, + "Rotated file size {bytes_written} not in expected range [{min_size}, {max_size})", + bytes_written = file.bytes_written + ); + } + } } proptest! {