Skip to content

Commit

Permalink
additionally confirm lower bound of bytes written
Browse files Browse the repository at this point in the history
Signed-off-by: Brian L. Troutwine <[email protected]>
  • Loading branch information
blt committed Oct 31, 2024
1 parent 4ab3bef commit 2a279ce
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lading/src/generator/file_gen/logrotate_fs/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down

0 comments on commit 2a279ce

Please sign in to comment.