feat: make write_max fill the slots

This commit is contained in:
Kieran Klukas
2026-03-04 11:58:15 -05:00
parent 81e79a20cd
commit 9a3afab14d

View File

@@ -1276,17 +1276,24 @@ As we have seen him in the Capitol, Being cross";
}); });
} }
// ── write_max: fill remaining slots to reach 8 total ── // ── write_max: fill all remaining empty slots to reach 8 total ──
// Slots used: 0 (write_1), 1 (write_all_ascii), 3 (bad_gid), 4 (0-byte)
// Fill: 2, 5, 6, 7
run_test!("write_max", { run_test!("write_max", {
for &i in &[2u8, 5, 6, 7] { // List current files to find which slots are occupied
let resp = timed!(hsm, Opcode::List, pin.as_bytes(), TIME_LIST)?;
let files = unpack_files(&resp.body)?;
let occupied: std::collections::HashSet<u8> = files.iter().map(|(s, _, _)| *s).collect();
for i in 0u8..8 {
if occupied.contains(&i) {
continue;
}
let name = format!("file_{i}.txt"); let name = format!("file_{i}.txt");
let content = format!("This is file number {i}"); let content = format!("This is file number {i}");
let frame = write_frame(pin, i, gid, &name, content.as_bytes()); let frame = write_frame(pin, i, gid, &name, content.as_bytes());
timed!(hsm, Opcode::Write, &frame, TIME_WRITE)?; timed!(hsm, Opcode::Write, &frame, TIME_WRITE)?;
} }
let resp = timed!(hsm, Opcode::List, pin.as_bytes(), TIME_LIST)?; let resp = timed!(hsm, Opcode::List, pin.as_bytes(), TIME_LIST)?;
let files = unpack_files(&resp.body)?; let files = unpack_files(&resp.body)?;
if files.len() != 8 { if files.len() != 8 {