Skip to content

Commit dad6f82

Browse files
committed
additionally confirm lower bound of bytes written
Signed-off-by: Brian L. Troutwine <[email protected]>
1 parent dc376f8 commit dad6f82

File tree

1 file changed

+20
-0
lines changed
  • lading/src/generator/file_gen/logrotate_fs

1 file changed

+20
-0
lines changed

lading/src/generator/file_gen/logrotate_fs/model.rs

+20
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,26 @@ mod test {
11861186
);
11871187
}
11881188
}
1189+
1190+
// Property 9: Rotated files have bytes_written within acceptable range
1191+
//
1192+
// For a rotated file (read_only == true), bytes_written should be
1193+
// within (max_bytes_per_file - bytes_per_tick) <= bytes_written <
1194+
// (max_bytes_per_file + bytes_per_tick).
1195+
for node in state.nodes.values() {
1196+
if let Node::File { file } = node {
1197+
if !file.read_only {
1198+
continue;
1199+
}
1200+
let min_size = state.max_bytes_per_file.saturating_sub(file.bytes_per_tick);
1201+
let max_size = state.max_bytes_per_file.saturating_add(file.bytes_per_tick);
1202+
assert!(
1203+
file.bytes_written >= min_size && file.bytes_written < max_size,
1204+
"Rotated file size {bytes_written} not in expected range [{min_size}, {max_size})",
1205+
bytes_written = file.bytes_written
1206+
);
1207+
}
1208+
}
11891209
}
11901210

11911211
proptest! {

0 commit comments

Comments
 (0)