the test seems to work

This commit is contained in:
Motiejus Jakštys 2022-07-06 16:46:24 +03:00
parent a2893a366e
commit 4a3d43561f
2 changed files with 4 additions and 8 deletions

View File

@ -66,7 +66,7 @@ pub const TestDB = struct {
const full_path = try fs.path.join(allocator, &[_][]const u8{ const full_path = try fs.path.join(allocator, &[_][]const u8{
base_path, base_path,
"turbo.db\x00", "db.turbo\x00",
}); });
allocator.free(base_path); allocator.free(base_path);

View File

@ -22,7 +22,7 @@ const ENV_DB = "TURBONSS_DB";
const ENV_LOGLEVEL = "TURBONSS_LOGLEVEL"; const ENV_LOGLEVEL = "TURBONSS_LOGLEVEL";
const ENV_OMIT_MEMBERS = "TURBONSS_OMIT_MEMBERS"; const ENV_OMIT_MEMBERS = "TURBONSS_OMIT_MEMBERS";
var turbonss_db_path: [:0]const u8 = "/etc/turbonss/db.turbo"; export var turbonss_db_path: [:0]const u8 = "/etc/turbonss/db.turbo";
pub var log_level: std.log.Level = .err; pub var log_level: std.log.Level = .err;
@ -80,7 +80,7 @@ fn init() void {
}; };
log.debug("omitting members from getgr* calls: {any}\n", .{omit_members}); log.debug("omitting members from getgr* calls: {any}\n", .{omit_members});
const fname = os.getenvZ(ENV_DB) orelse turbonss_db_path[0..]; const fname = os.getenvZ(ENV_DB) orelse turbonss_db_path;
log.debug("opening '{s}'", .{fname}); log.debug("opening '{s}'", .{fname});
const file = File.open(fname) catch |err| { const file = File.open(fname) catch |err| {
@ -165,12 +165,9 @@ fn get_db(errnop: *c_int) ?DB {
const testing = std.testing; const testing = std.testing;
test "nss_turbo_getpwuid_r" { test "nss_turbo_getpwuid_r" {
const allocator = testing.allocator;
var errc = ErrCtx{}; var errc = ErrCtx{};
var tf = try File.TestDB.init(allocator, &errc); var tf = try File.TestDB.init(testing.allocator, &errc);
defer tf.deinit(); defer tf.deinit();
std.debug.print("tf.path: {s}\n", .{tf.path});
turbonss_db_path = tf.path; turbonss_db_path = tf.path;
var passwd: CUser = undefined; var passwd: CUser = undefined;
@ -178,7 +175,6 @@ test "nss_turbo_getpwuid_r" {
var errno: c_int = 0; var errno: c_int = 0;
const status = _nss_turbo_getpwuid_r(0, &passwd, &buffer, buffer.len, &errno); const status = _nss_turbo_getpwuid_r(0, &passwd, &buffer, buffer.len, &errno);
if (true) return error.SkipZigTest;
try testing.expectEqual(@as(c_int, 0), errno); try testing.expectEqual(@as(c_int, 0), errno);
try testing.expectEqual(c.NSS_STATUS_SUCCESS, status); try testing.expectEqual(c.NSS_STATUS_SUCCESS, status);
} }