28c2ffb84f
Reference-count the process-global ONNX Runtime across embedder and routing-head sessions, make close idempotent, and require named proof that both aggregate routing gates executed rather than self-skipped (V-716). Owner explicitly requested direct commits to master.
37 lines
872 B
Go
37 lines
872 B
Go
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)
|
|
}
|