package main import ( "fmt" "os" "testing" "github.com/kami/maven/internal/router" ) // TestMain holds one ONNX Runtime lease across the model-aware topic and // personal-boundary gates. Each test still owns and closes its model session; // the process-global environment is released only after the final test. func TestMain(m *testing.M) { var lease *router.ONNXRuntimeLease lib := os.Getenv("MAVEN_ONNX_LIB") if lib != "" { if _, err := os.Stat(lib); err == nil { var acquireErr error lease, acquireErr = router.AcquireONNXRuntime(lib) if acquireErr != nil { fmt.Fprintf(os.Stderr, "initialize shared ONNX test runtime: %v\n", acquireErr) os.Exit(2) } } } code := m.Run() if lease != nil { if err := lease.Close(); err != nil { fmt.Fprintf(os.Stderr, "ONNX test runtime cleanup: %v\n", err) code = 1 } } os.Exit(code) }