diff --git a/lib/DB.zig b/lib/DB.zig index 9b7f668..0a94175 100644 --- a/lib/DB.zig +++ b/lib/DB.zig @@ -548,35 +548,6 @@ test "read/write via iovec" { var db = try DB.fromCorpus(allocator, &corpus); defer db.deinit(allocator); - // TODO: replace with an integration test when high-level - // reader API is present - //const blob = sections.groupmembers.blob; - //var i: usize = 0; - //while (i < corpus.groups.len) : (i += 1) { - //const offset = sections.groupmembers.idx2offset[i]; - //var vit = try compress.VarintSliceIterator(blob[offset..]); - //var it = compress.DeltaDecompressionIterator(&vit); - //for (corpus.group2users[i]) |user_idx| { - // const got_user_offset = (try it.next()).?; - // const want_user_offset = sections.users.idx2offset[user_idx]; - // try testing.expectEqual(got_user_offset, want_user_offset); - //} - //try testing.expectEqual(it.next(), null); - //} - - //var it = PackedUser.iterator(sections.users.blob, sections.shell_reader); - //i = 0; - //while (i < corpus.users.len) : (i += 1) { - // const got = (try it.next()).?; - // const user = corpus.users.get(i); - // try testing.expectEqual(user.uid, got.uid()); - // try testing.expectEqual(user.gid, got.gid()); - // try testing.expectEqualStrings(user.name, got.name()); - // try testing.expectEqualStrings(user.gecos, got.gecos()); - // try testing.expectEqualStrings(user.home, got.home()); - // try testing.expectEqualStrings(user.shell, got.shell(sections.shell_reader)); - //} - const fd = try os.memfd_create("test_turbonss_db", 0); defer os.close(fd); @@ -594,7 +565,7 @@ test "read/write via iovec" { try testing.expectEqualSlices(u32, db.idx_uid2user, db2.idx_uid2user[0..num_users]); } -test "high-level API" { +test "getgrnam/getgrgid" { var corpus = try Corpus.testCorpus(testing.allocator); defer corpus.deinit(); var db = try DB.fromCorpus(testing.allocator, &corpus); @@ -627,12 +598,11 @@ test "high-level API" { } test "getgr_bufsize" { - var corpus = try Corpus.testCorpus(testing.allocator); - defer corpus.deinit(); - var db = try DB.fromCorpus(testing.allocator, &corpus); - defer db.deinit(testing.allocator); - var buf = try testing.allocator.alloc(u8, db.header.getgr_bufsize); - defer testing.allocator.free(buf); + var arena = ArenaAllocator.init(testing.allocator); + defer arena.deinit(); + var corpus = try Corpus.testCorpus(arena.allocator()); + var db = try DB.fromCorpus(arena.allocator(), &corpus); + var buf = try arena.allocator().alloc(u8, db.header.getgr_bufsize); _ = try db.getgrnam("all", &buf); buf.len -= 1; diff --git a/lib/cgroup.zig b/lib/cgroup.zig index bb98020..31bc05d 100644 --- a/lib/cgroup.zig +++ b/lib/cgroup.zig @@ -3,7 +3,7 @@ const meta = @import("std").meta; // Name type should be 0-terminated, members should be null-terminated, but // sentinel is not part of the type (but is always there). Adding sentinel // crashes zig compiler in pre-0.10. https://github.com/ziglang/zig/issues/7517 -pub const CGroup = struct { +pub const CGroup = extern struct { gid: u32, // should be [*:0]const u8 name: [*]const u8,