prefix test cases with context

This commit is contained in:
Motiejus Jakštys 2022-07-12 12:59:47 +03:00
parent c4e8f1f02c
commit 2cdc2ae6c6
15 changed files with 44 additions and 44 deletions

View File

@ -285,7 +285,7 @@ pub fn testCorpus(allocator: Allocator) !Corpus {
return result;
}
test "test corpus" {
test "corpus smoke test" {
var corpus = try testCorpus(testing.allocator);
defer corpus.deinit();

View File

@ -760,7 +760,7 @@ fn assertDefinedLayout(comptime T: type) void {
const testing = std.testing;
test "read/write via iovec" {
test "DB read/write via iovec" {
const allocator = testing.allocator;
var corpus = try Corpus.testCorpus(allocator);
defer corpus.deinit();
@ -787,7 +787,7 @@ test "read/write via iovec" {
try testing.expectEqualStrings("", errc.unwrap().constSlice());
}
test "getgrnam/getgrgid" {
test "DB getgrnam/getgrgid" {
var corpus = try Corpus.testCorpus(testing.allocator);
defer corpus.deinit();
var errc = ErrCtx{};
@ -829,7 +829,7 @@ test "getgrnam/getgrgid" {
try testing.expectError(error.BufferTooSmall, db.getgrnam("all", buf, false));
}
test "getpwnam/getpwuid" {
test "DB getpwnam/getpwuid" {
var corpus = try Corpus.testCorpus(testing.allocator);
defer corpus.deinit();
var errc = ErrCtx{};
@ -863,7 +863,7 @@ test "getpwnam/getpwuid" {
try testing.expectError(error.BufferTooSmall, db.getpwnam("Name" ** 8, buf));
}
test "additionalGids" {
test "DB additionalGids" {
const allocator = testing.allocator;
var corpus = try Corpus.testCorpus(allocator);
defer corpus.deinit();
@ -892,7 +892,7 @@ test "additionalGids" {
}
}
test "pack gids" {
test "DB pack gids" {
const allocator = testing.allocator;
var corpus = try Corpus.testCorpus(allocator);
defer corpus.deinit();
@ -922,7 +922,7 @@ fn expectUsedHashes(allocator: Allocator, arr: []const u32) !void {
try testing.expect(used.get(item) != null);
}
test "bdzIdx on u32" {
test "DB bdzIdx on u32" {
const keys = [_]u32{ 42, 1, 2, 3 };
const mphf = try cmph.packU32(testing.allocator, keys[0..]);
defer testing.allocator.free(mphf);
@ -931,7 +931,7 @@ test "bdzIdx on u32" {
try expectUsedHashes(testing.allocator, result);
}
test "bdzIdx on str" {
test "DB bdzIdx on str" {
const keys = [_][]const u8{ "42", "1", "2", "3" };
const mphf = try cmph.packStr(testing.allocator, keys[0..]);
defer testing.allocator.free(mphf);
@ -940,7 +940,7 @@ test "bdzIdx on str" {
try expectUsedHashes(testing.allocator, result);
}
test "nblocks" {
test "DB nblocks" {
const tests = .{
.{ 0, &[_]u8{} },
.{ 1, &[_]u8{ 1, 2, 42 } },

View File

@ -104,7 +104,7 @@ pub fn unwrap(self: *const ErrCtx) BoundedArray(u8, capacity * 2) {
const testing = std.testing;
test "basics" {
test "ErrCtx basics" {
var ctx = ErrCtx{};
var wr = ctx.writer();
@ -128,7 +128,7 @@ test "basics" {
try testing.expectEqualSlices(u8, it_rev.next().?, "0" ** 10);
}
test "almost overflow" {
test "ErrCtx almost overflow" {
var ctx = ErrCtx{};
var wr = ctx.writer();
@ -146,7 +146,7 @@ test "almost overflow" {
try testing.expectEqual(it.next(), null);
}
test "rev" {
test "ErrCtx rev" {
var ctx = ErrCtx{};
ctx.print("yadda {s}", .{"xx"});

View File

@ -141,7 +141,7 @@ pub const ptr_size = @sizeOf(meta.Child(meta.fieldInfo(CGroup, .members).field_t
const testing = std.testing;
test "Group.clone" {
test "Group clone" {
// TODO: how to do this on stack?
var member1 = mem.sliceTo(try testing.allocator.dupeZ(u8, "member1"), 0);
defer testing.allocator.free(member1);

View File

@ -116,7 +116,7 @@ test "PackedGroup alignment" {
try testing.expectEqual(@sizeOf(PackedGroup) * 8, @bitSizeOf(PackedGroup));
}
test "construct PackedGroups" {
test "PackedGroup construct" {
var buf = ArrayList(u8).init(testing.allocator);
defer buf.deinit();

View File

@ -247,7 +247,7 @@ const test_shell_reader = ShellReader{
.index = &[_]u16{ 0, 9, 17 },
};
test "pack max_user" {
test "PackedUser pack max_user" {
var arr = ArrayList(u8).init(testing.allocator);
defer arr.deinit();
@ -257,7 +257,7 @@ test "pack max_user" {
try packTo(&arr, User.max_user, 0, idx_noop);
}
test "construct PackedUser section" {
test "PackedUser construct section" {
var buf = ArrayList(u8).init(testing.allocator);
defer buf.deinit();

View File

@ -234,7 +234,7 @@ test "User.fromLine" {
}
}
test "max_user and max_str_len are consistent" {
test "User max_user and max_str_len are consistent" {
const total_len = max_user.name.len +
max_user.gecos.len +
max_user.home.len +

View File

@ -89,7 +89,7 @@ fn samplePack(allocator: Allocator) ![]const u8 {
return pack(allocator, vector.items);
}
test "basic pack/unpack" {
test "cmph basic pack/unpack" {
const buf = try samplePack(testing.allocator);
defer testing.allocator.free(buf);
try testing.expect(buf.len < 100);
@ -111,7 +111,7 @@ pub fn unzeroZ(x: u32) [6]u8 {
return buf;
}
test "unzeroZ" {
test "cmph unzeroZ" {
const result = unzeroZ(0);
try testing.expect(result[0] != 0);
try testing.expect(result[1] != 0);
@ -121,7 +121,7 @@ test "unzeroZ" {
try testing.expect(result[5] == 0);
}
test "pack u32" {
test "cmph pack u32" {
const keys = &[_]u32{ 42, 1, math.maxInt(u32), 2 };
const packed_mphf = try packU32(testing.allocator, keys);
defer testing.allocator.free(packed_mphf);
@ -133,7 +133,7 @@ test "pack u32" {
try testing.expectEqual(i, hash);
}
test "pack str" {
test "cmph pack str" {
const keys = &[_][]const u8{ "foo", "bar", "baz", "1", "2", "3" };
const packed_mphf = try packStr(testing.allocator, keys[0..]);
defer testing.allocator.free(packed_mphf);

View File

@ -209,7 +209,7 @@ const uvarint_tests = [_]u64{
1 << 63 - 1,
};
test "putUvarint/uvarint" {
test "compress putUvarint/uvarint" {
for (uvarint_tests) |x| {
var buf: [maxVarintLen64]u8 = undefined;
const n = putUvarint(buf[0..], x);
@ -220,7 +220,7 @@ test "putUvarint/uvarint" {
}
}
test "varintSliceIterator" {
test "compress varintSliceIterator" {
var buf = ArrayList(u8).init(testing.allocator);
defer buf.deinit();
try appendUvarint(&buf, uvarint_tests.len);
@ -235,7 +235,7 @@ test "varintSliceIterator" {
try testing.expectEqual(i, uvarint_tests.len);
}
test "delta compress/decompress" {
test "compress delta compress/decompress" {
const tests = [_]struct { input: []const u8, want: []const u8 }{
.{ .input = &[_]u8{}, .want = &[_]u8{} },
.{ .input = &[_]u8{0}, .want = &[_]u8{0} },
@ -260,7 +260,7 @@ test "delta compress/decompress" {
}
}
test "delta compression with varint tests" {
test "compress delta compression with varint tests" {
var scratch: [uvarint_tests.len]u64 = undefined;
std.mem.copy(u64, scratch[0..], uvarint_tests[0..]);
try deltaCompress(u64, scratch[0..]);
@ -268,7 +268,7 @@ test "delta compression with varint tests" {
try testing.expectEqualSlices(u64, uvarint_tests[0..], scratch[0..]);
}
test "delta compression negative tests" {
test "compress delta compression negative tests" {
for ([_][]const u8{
&[_]u8{ 0, 0 },
&[_]u8{ 0, 1, 1 },
@ -281,7 +281,7 @@ test "delta compression negative tests" {
}
}
test "delta decompress overflow" {
test "compress delta decompress overflow" {
for ([_][]const u8{
&[_]u8{ 255, 0 },
&[_]u8{ 0, 128, 127 },
@ -293,7 +293,7 @@ test "delta decompress overflow" {
}
}
test "delta decompression with an iterator" {
test "compress delta decompression with an iterator" {
var compressed: [uvarint_tests.len]u64 = undefined;
std.mem.copy(u64, compressed[0..], uvarint_tests[0..]);
try deltaCompress(u64, compressed[0..]);
@ -314,7 +314,7 @@ test "delta decompression with an iterator" {
try testing.expectEqual(i, uvarint_tests.len);
}
test "appendUvarint" {
test "compress appendUvarint" {
for (uvarint_tests) |x| {
var buf = ArrayList(u8).init(testing.allocator);
defer buf.deinit();
@ -326,7 +326,7 @@ test "appendUvarint" {
}
}
test "overflow" {
test "compress overflow" {
for ([_][]const u8{
&[_]u8{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x2 },
&[_]u8{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x1, 0, 0 },

View File

@ -75,15 +75,15 @@ pub const Header = packed struct {
const testing = std.testing;
test "Section length is a power of two" {
test "header Section length is a power of two" {
try testing.expect(std.math.isPowerOfTwo(section_length));
}
test "Header fits into two sections" {
test "header fits into two sections" {
try testing.expect(@sizeOf(Header) == 2 * section_length);
}
test "bit header size is equal to @sizeOf(Header)" {
test "header bit header size is equal to @sizeOf(Header)" {
try testing.expectEqual(@sizeOf(Header) * 8, @bitSizeOf(Header));
}

View File

@ -492,7 +492,7 @@ fn getDBErrno(errnop: *c_int) ?DB {
const testing = std.testing;
test "getpwuid_r and getpwnam_r" {
test "libnss getpwuid_r and getpwnam_r" {
var tf = try File.TestDB.init(testing.allocator);
defer tf.deinit();
const state = State{
@ -544,7 +544,7 @@ fn testVidmantas(u: CUser) !void {
try testing.expectEqualStrings("/bin/bash", mem.sliceTo(u.pw_shell, 0));
}
test "getgrgid_r and getgrnam_r" {
test "libnss getgrgid_r and getgrnam_r" {
var tf = try File.TestDB.init(testing.allocator);
defer tf.deinit();
const turbonss_db_path_old = turbonss_db_path;
@ -579,7 +579,7 @@ test "getgrgid_r and getgrnam_r" {
try testing.expectEqual(@enumToInt(os.E.NOENT), @intCast(u16, errno));
}
test "initgroups_dyn" {
test "libnss initgroups_dyn" {
const allocator = testing.allocator;
var tf = try File.TestDB.init(allocator);

View File

@ -39,7 +39,7 @@ test "padding" {
try testing.expectEqual(until(u12, 2, 4092), 0);
}
test "arrayList" {
test "padding arrayList" {
var buf = try ArrayList(u8).initCapacity(testing.allocator, 16);
defer buf.deinit();

View File

@ -148,7 +148,7 @@ pub const ShellWriter = struct {
const testing = std.testing;
test "basic shellpopcon" {
test "shell basic shellpopcon" {
var popcon = ShellWriter.init(testing.allocator);
const bash = "/bin/bash"; // 9 chars

View File

@ -159,7 +159,7 @@ fn execute(
const testing = std.testing;
test "trivial error: db file" {
test "turbo-analyze trivial error: db file" {
const args = &[_][*:0]const u8{"/does/not/exist.turbo"};
const allocator = testing.allocator;
var stderr = ArrayList(u8).init(allocator);
@ -190,7 +190,7 @@ fn splitInt(n: u64) BoundedArray(u8, max_len) {
return result;
}
test "separators" {
test "turbo-analyze separators" {
const tests = [_]struct {
input: u64,
want: []const u8,

View File

@ -129,7 +129,7 @@ fn fail(errc: *ErrCtx, stderr: anytype, err: anytype) u8 {
const testing = std.testing;
test "invalid argument" {
test "turbo-unix2db invalid argument" {
const allocator = testing.allocator;
const args = &[_][*:0]const u8{"--invalid-argument"};
var stderr = ArrayList(u8).init(allocator);
@ -146,7 +146,7 @@ test "invalid argument" {
));
}
test "trivial error: missing passwd file" {
test "turbo-unix2db trivial error: missing passwd file" {
const allocator = testing.allocator;
const args = &[_][*:0]const u8{};
var stderr = ArrayList(u8).init(allocator);
@ -159,7 +159,7 @@ test "trivial error: missing passwd file" {
try testing.expectEqualStrings(stderr.items, "ERROR FileNotFound: open 'passwd'\n");
}
test "fail" {
test "turbo-unix2db fail" {
var errc = ErrCtx{};
var buf = ArrayList(u8).init(testing.allocator);
defer buf.deinit();
@ -169,7 +169,7 @@ test "fail" {
try testing.expectEqualStrings(buf.items, "ERROR NotSure: invalid user 'foo'\n");
}
test "smoke test" {
test "turbo-unix2db smoke test" {
const allocator = testing.allocator;
var stderr = ArrayList(u8).init(allocator);
defer stderr.deinit();