diff --git a/src/controller/testsuite/test.c b/src/controller/testsuite/test.c index 013fe1e..88da3ba 100644 --- a/src/controller/testsuite/test.c +++ b/src/controller/testsuite/test.c @@ -3757,6 +3757,22 @@ static int worker_house_keeping(void* arg) return rc; } +/* bug-XXXX (disk fill): the persist_* / config_repl / HA test fixtures create + * their WAL/snapshot scratch dirs via mkdtemp("/tmp/xce_..._XXXXXX") but their + * teardown only frees the persist_t — the directory is never removed. A full + * controller_unit_test run therefore leaves ~28G behind in /tmp in under a + * minute, filling a 62G root filesystem. Remove only xce_* DIRECTORIES (never + * files — the user's /tmp/xce-mcp binary and the suite's own /tmp/xce_test.log + * must survive). Run at suite start (stale leftovers from prior runs) and on + * exit via atexit (this run). */ +static void clean_test_scratch_dirs(void) +{ + if (system("find /tmp -maxdepth 1 -type d -name 'xce_*' " + "-exec rm -rf {} + 2>/dev/null") != 0) { + /* non-zero only if find is unavailable; cleanup is best-effort */ + } +} + int main(int argc, char* argv[]) { struct arguments arguments; @@ -3769,6 +3785,11 @@ int main(int argc, char* argv[]) memset(&arguments, 0x0, sizeof(arguments)); argp_parse(&argp, argc, argv, 0, 0, &arguments); + /* Bug-XXXX: remove stale test scratch dirs from prior runs, then ensure + * this run's scratch dirs are cleaned on exit. */ + clean_test_scratch_dirs(); + atexit(clean_test_scratch_dirs); + if (arguments.verbose != 0) { loglevel = verbose_to_loglevel(arguments.verbose); }