Ryan Liptak 47343f9bcf Add self_exe_symlink standalone test
Tests that fs.selfExePath follows symlinks by comparing it to the path of the File returned from fs.openSelfExe
2023-08-19 17:48:19 -07:00

18 lines
563 B
Zig

const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer std.debug.assert(gpa.deinit() == .ok);
const allocator = gpa.allocator();
const self_path = try std.fs.selfExePathAlloc(allocator);
defer allocator.free(self_path);
var self_exe = try std.fs.openSelfExe(.{});
defer self_exe.close();
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const self_exe_path = try std.os.getFdPath(self_exe.handle, &buf);
try std.testing.expectEqualStrings(self_exe_path, self_path);
}