About 10,000 test leftovers had built up in titan's /tmp. loopd's Home and FakeServer, its fake broker's socket, bxctl's temp sockets, fake loopd and command homes, inferproxy's socket, and a few brokerd and toolkit tests created uniquely named directories or sockets and never removed them, or removed them by hand at the end, which a failing test skips. Each is now a guard removed on drop (bxctl gains tests/support/temp.rs). Two races also left gatewayd homes behind: the test Running only signalled its server to stop, and two Stage structs declared the home first, so it was removed while the server could still write into it. Running's drop now waits for the thread (with a 5-second limit), and every home is declared last. Checked: make gate twice, then the gate and three rounds of gatewayd and loopd tests; no new entry in /tmp; 944 tests pass. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
40 lines
1.4 KiB
Rust
40 lines
1.4 KiB
Rust
//! `bxctl audit verify` says which files in `audit/` it did not read: a file that looks like a
|
|
//! log but is not named as one is ignored by `brokerd` too, and "ok" must not seem to cover it.
|
|
|
|
#[path = "support/temp.rs"]
|
|
mod temp;
|
|
use std::path::PathBuf;
|
|
|
|
fn home(tag: &str) -> temp::TempDir {
|
|
let dir = temp::TempDir::new(&format!("bx-verify-skip-{tag}"));
|
|
std::fs::create_dir_all(dir.join("audit")).unwrap();
|
|
let fixture =
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../proto/tests/fixtures/audit/good");
|
|
for entry in std::fs::read_dir(fixture).unwrap() {
|
|
let entry = entry.unwrap();
|
|
std::fs::copy(entry.path(), dir.join("audit").join(entry.file_name())).unwrap();
|
|
}
|
|
dir
|
|
}
|
|
|
|
#[test]
|
|
fn a_stray_jsonl_file_is_named_and_the_log_still_verifies() {
|
|
let dir = home("stray");
|
|
std::fs::write(dir.join("audit/2026-0x-19.jsonl"), "x\n").unwrap();
|
|
std::fs::write(dir.join("audit/notes.txt"), "not a log\n").unwrap();
|
|
let mut out = Vec::new();
|
|
let ok = bxctl::verify::run(&dir, &mut out).unwrap();
|
|
let text = String::from_utf8(out).unwrap();
|
|
assert!(ok, "{text}");
|
|
assert!(text.starts_with("audit: ok, 10 records"), "{text}");
|
|
assert!(
|
|
text.contains("not an audit log file, not checked: 2026-0x-19.jsonl"),
|
|
"{text}"
|
|
);
|
|
assert!(
|
|
!text.contains("notes.txt"),
|
|
"only files that look like logs: {text}"
|
|
);
|
|
let _ = std::fs::remove_dir_all(&dir);
|
|
}
|