-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_runner.zig
More file actions
48 lines (42 loc) · 1.4 KB
/
test_runner.zig
File metadata and controls
48 lines (42 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const std = @import("std");
const builtin = @import("builtin");
const onnx = @import("onnxruntime");
pub fn main() !void {
const test_fns: []const std.builtin.TestFn = builtin.test_functions;
std.debug.print("--- Initializing ONNX Runtime ---\n\n", .{});
try onnx.Api.init(.{
.log_level = .warning,
.log_id = "zig-ort-tests",
.editor = true,
.compiler = true,
.ep = true,
.training = true,
.error_log_fn = &struct {
fn log(status: *const onnx.Error.Status) void {
std.debug.print("Error code: {d}, message: {s}\n", .{ status.getErrorCode(), status.getErrorMessage() });
}
}.log,
}, .{});
var passed: usize = 0;
var failed: usize = 0;
var skipped: usize = 0;
for (test_fns) |test_fn| {
if (test_fn.func()) |_| {
std.debug.print("{s} => OK\n", .{test_fn.name});
passed += 1;
} else |err| {
if (err == error.SkipZigTest) {
std.debug.print("{s} => SKIPPED\n", .{test_fn.name});
skipped += 1;
} else {
std.debug.print("{s} => FAILED ({s})\n", .{test_fn.name, @errorName(err)});
std.debug.dumpStackTrace(@errorReturnTrace().?.*);
failed += 1;
}
}
}
std.debug.print("\n--- Deinitializing ONNX Runtime ---\n", .{});
onnx.Api.deinit();
std.debug.print("\nTest Summary: {} passed, {} failed, {} skipped\n", .{ passed, failed, skipped });
if (failed > 0) std.process.exit(1);
}