| 30 | #include <cstdio> |
| 31 | |
| 32 | int main(int argc, char** argv) { |
| 33 | NEED_ALL_DEFAULT_MODULES; // statement-form macro — must be inside a function body |
| 34 | NEED_MODULE(Module_JobQue); // ensure the JobQue module is linked in even if no test pulls it |
| 35 | |
| 36 | das::Module::Initialize(); |
| 37 | |
| 38 | doctest::Context dctx; |
| 39 | dctx.applyCommandLine(argc, argv); |
| 40 | int rc = dctx.run(); |
| 41 | |
| 42 | // ── Suite-end leak verification: detect AND fail on every layer ───────── |
| 43 | int leak_rc = 0; |
| 44 | |
| 45 | // gc_node check: thread-local root only — gc_node tracking is per-thread, and |
| 46 | // this samples just the suite-runner thread. Tests that allocate gc_nodes on |
| 47 | // worker threads without joining-and-collecting before the test ends will not |
| 48 | // surface here. None of the current small/ tests do that; revisit (per-thread |
| 49 | // aggregation) when the first multi-threaded gc_node test lands. |
| 50 | auto & root = das::gc_root::gc_get_thread_root(); |
| 51 | if ( root.gc_count != 0 ) { |
| 52 | printf("\n[FAIL] gc_node leaks (suite thread): %llu node(s) still alive at suite end\n", |
| 53 | (unsigned long long)root.gc_count); |
| 54 | root.gc_report(); |
| 55 | leak_rc = 1; |
| 56 | } |
| 57 | |
| 58 | if ( uint64_t n = das::JobStatus::CountJobQueLeaks() ) { |
| 59 | printf("\n[FAIL] jobque leaks: %llu tracked object(s) still alive\n", |
| 60 | (unsigned long long)n); |
| 61 | das::JobStatus::DumpJobQueLeaks(); |
| 62 | leak_rc = 1; |
| 63 | } |
| 64 | |
| 65 | if ( uint64_t n = das::Module::CountHandleLeaks() ) { |
| 66 | printf("\n[FAIL] handle leaks: %llu module-tracked resource(s) still alive\n", |
| 67 | (unsigned long long)n); |
| 68 | leak_rc = 1; |
| 69 | // The actual per-type dump comes out of Module::Shutdown(true) below. |
| 70 | } |
| 71 | |
| 72 | das::Module::Shutdown(/*dumpHandleLeaks*/ true); |
| 73 | |
| 74 | return rc != 0 ? rc : leak_rc; |
| 75 | } |
nothing calls this directly
no test coverage detected