turbonss-makecorpus: larger defaults

This commit is contained in:
Motiejus Jakštys 2022-08-06 23:54:35 -07:00
parent 5178149852
commit f5131ebe70

View File

@ -21,7 +21,7 @@ const usage =
\\Options: \\Options:
\\ -h Print this help message and exit \\ -h Print this help message and exit
\\ --directory Write files to given directory (default: .) \\ --directory Write files to given directory (default: .)
\\ --num-users Number of users (default: 20000) \\ --num-users Number of users (default: 100000)
\\ --num-groups Number of groups (default: 10000) \\ --num-groups Number of groups (default: 10000)
\\ --avg-members Average members per group (default: 1000) \\ --avg-members Average members per group (default: 1000)
\\ \\
@ -75,9 +75,9 @@ fn execute(
return error.User; return error.User;
} }
const num_users = parseInt(stderr, myflags, "--num-users", 20000) orelse return error.User; const num_users = parseInt(stderr, myflags, "--num-users", 100000) orelse return error.User;
const num_groups = parseInt(stderr, myflags, "--num-groups", 5000) orelse return error.User; const num_groups = parseInt(stderr, myflags, "--num-groups", 10000) orelse return error.User;
const avg_members = parseInt(stderr, myflags, "--avg-members", 20) orelse return error.User; const avg_members = parseInt(stderr, myflags, "--avg-members", 1000) orelse return error.User;
// longest possible path name: 16k? dunno. // longest possible path name: 16k? dunno.
var buf: [1 << 14]u8 = undefined; var buf: [1 << 14]u8 = undefined;
@ -91,7 +91,7 @@ fn execute(
}, },
}; };
const open_flags = std.fs.File.CreateFlags{ .mode = 0o644, .exclusive = true }; const open_flags = std.fs.File.CreateFlags{ .mode = 0o644 };
var passwdf = fs.cwd().createFile(passwd_path, open_flags) catch |err| { var passwdf = fs.cwd().createFile(passwd_path, open_flags) catch |err| {
stderr.print("ERROR: create passwd: {s}\n", .{@errorName(err)}) catch {}; stderr.print("ERROR: create passwd: {s}\n", .{@errorName(err)}) catch {};
return error.User; return error.User;
@ -113,12 +113,12 @@ fn execute(
try dump_group(group_wr.writer(), num_users, num_groups, avg_members); try dump_group(group_wr.writer(), num_users, num_groups, avg_members);
group_wr.flush() catch return error.IO; group_wr.flush() catch return error.IO;
std.debug.print("wrote users={d} groups={d} avg-members={d} to {s}\n", .{ stderr.print("wrote users={d} groups={d} avg-members={d} to {s}\n", .{
num_users, num_users,
num_groups, num_groups,
avg_members, avg_members,
dir, dir,
}); }) catch {};
} }
fn dump_passwd(wr: anytype, num_users: u64) error{IO}!void { fn dump_passwd(wr: anytype, num_users: u64) error{IO}!void {
@ -246,7 +246,7 @@ test "turbonss-makecorpus: simple OK case" {
}; };
try execute(stdout.writer(), stderr.writer(), args); try execute(stdout.writer(), stderr.writer(), args);
try testing.expectEqualStrings(stderr.items, ""); try testing.expectStringStartsWith(stderr.items, "wrote users=1 groups=1 avg-members=1 to /");
try testing.expectEqualStrings(stdout.items, ""); try testing.expectEqualStrings(stdout.items, "");
const passwd_fname = try fs.path.join(allocator, &[_][]const u8{ tmp_path, "passwd" }); const passwd_fname = try fs.path.join(allocator, &[_][]const u8{ tmp_path, "passwd" });