group names are sentinel-terminated
This commit is contained in:
@@ -275,10 +275,27 @@ test "getgrgid_r and getgrnam_r" {
|
||||
);
|
||||
try testing.expectEqual(@as(c_int, 0), errno);
|
||||
try testVidmantasGroup(group);
|
||||
|
||||
group = undefined;
|
||||
try testing.expectEqual(
|
||||
c.NSS_STATUS_SUCCESS,
|
||||
_nss_turbo_getgrnam_r("vidmantas", &group, &buffer, buffer.len, &errno),
|
||||
);
|
||||
try testing.expectEqual(@as(c_int, 0), errno);
|
||||
try testVidmantasGroup(group);
|
||||
|
||||
group = undefined;
|
||||
try testing.expectEqual(
|
||||
c.NSS_STATUS_NOTFOUND,
|
||||
_nss_turbo_getgrnam_r("does not exist", &group, &buffer, buffer.len, &errno),
|
||||
);
|
||||
try testing.expectEqual(@enumToInt(os.E.NOENT), @intCast(u16, errno));
|
||||
}
|
||||
|
||||
fn testVidmantasGroup(g: CGroup) !void {
|
||||
try testing.expectEqual(@as(u32, 128), g.gid);
|
||||
try testing.expectEqualStrings("vidmantas", mem.sliceTo(g.name, 0));
|
||||
const members = g.members;
|
||||
try testing.expect(members[0] != null);
|
||||
try testing.expectEqualStrings("vidmantas", mem.sliceTo(members[0].?, 0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user