tests: every temporary path is removed by a guard; no leftovers in /tmp

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>
This commit is contained in:
2026-09-26 01:29:32 -07:00
co-authored by Claude Opus 5.5
parent 53532e04ff
commit a15c428ea6
19 changed files with 230 additions and 51 deletions
+5 -5
View File
@@ -1,15 +1,16 @@
//! `toolkit egress-proxy` takes exactly `--socket <path> --allow <list>`: with anything after
//! them it is not the proxy, and exits 2 at once rather than listening (M3b review). Do not edit.
#[path = "support/mod.rs"]
mod support;
use std::process::{Command, Stdio};
use std::time::{Duration, Instant};
#[test]
fn trailing_arguments_are_not_the_proxy_form() {
let dir = std::env::temp_dir().join(format!("tk-egress-form-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
let socket = dir.join("egress.sock");
let dir = support::TempDir::new("egress-form");
let socket = dir.path().join("egress.sock");
let mut child = Command::new(env!("CARGO_BIN_EXE_toolkit"))
.args([
"egress-proxy",
@@ -38,5 +39,4 @@ fn trailing_arguments_are_not_the_proxy_form() {
};
assert_eq!(status.code(), Some(2));
assert!(!socket.exists(), "no socket was made");
let _ = std::fs::remove_dir_all(&dir);
}