Skip to content

Commit 744fc9a

Browse files
committed
test(webzockets): use gpa allocator for autobahn client
1 parent aa9cb5c commit 744fc9a

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/rpc/webzockets/autobahn/client/client.zig

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,7 @@ const AutobahnClientHandler = struct {
402402
}
403403
};
404404

405-
// ============================================================================
406-
// main
407-
// ============================================================================
408-
409-
pub fn main() !void {
410-
const allocator = std.heap.c_allocator;
411-
405+
fn run(allocator: std.mem.Allocator) !void {
412406
// Wait for Docker fuzzingserver to start
413407
log.info("Waiting for fuzzingserver on port 9001...", .{});
414408
const max_retries = 60;
@@ -453,3 +447,19 @@ pub fn main() !void {
453447
log.info("Autobahn client test run complete.", .{});
454448
log.info("Check autobahn/client/reports/index.html for results.", .{});
455449
}
450+
451+
pub fn main() !void {
452+
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
453+
const allocator = gpa.allocator();
454+
455+
run(allocator) catch |err| {
456+
if (gpa.deinit() == .leak) {
457+
log.err("GPA detected memory leaks while exiting with error: {}", .{err});
458+
}
459+
return err;
460+
};
461+
462+
if (gpa.deinit() == .leak) {
463+
return error.MemoryLeakDetected;
464+
}
465+
}

0 commit comments

Comments
 (0)