Skip to content

Commit 8bfd286

Browse files
Our C# tests weren't creating and destroying an OgaHandle (#1198)
When I ran the tests locally I would get an abort() exception on exit due to not calling OgaShutdown() The C# OgaHandle type will initialize and shutdown Oga safely but we have to use it for it to work.
1 parent 96344da commit 8bfd286

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/csharp/TestOnnxRuntimeGenAIAPI.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,14 @@ private static string GetDirectoryInTreeThatContains(string currentDirectory, st
8686
});
8787

8888
private static string _adaptersPath => _lazyAdaptersPath.Value;
89-
89+
private static OgaHandle ogaHandle;
9090

9191
public OnnxRuntimeGenAITests(ITestOutputHelper o)
9292
{
93+
// Initialize GenAI and register a handler to dispose it on process exit
94+
ogaHandle = new OgaHandle();
95+
AppDomain.CurrentDomain.ProcessExit += (sender, e) => ogaHandle.Dispose();
96+
9397
this.output = o;
9498
}
9599

0 commit comments

Comments
 (0)