Fix for TailQueue and std.log changes
This commit is contained in:
parent
fb66e2795f
commit
b7c3084f09
24 changed files with 137 additions and 112 deletions
|
@ -5,6 +5,7 @@ const expect = std.testing.expect;
|
|||
const expectEqual = std.testing.expectEqual;
|
||||
const expectError = std.testing.expectError;
|
||||
const expectEqualSlices = std.testing.expectEqualSlices;
|
||||
const log = std.log.scoped(.initrd);
|
||||
const build_options = @import("build_options");
|
||||
const mock_path = build_options.mock_path;
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
@ -150,8 +151,8 @@ pub const InitrdFS = struct {
|
|||
/// allocated will be freed.
|
||||
///
|
||||
pub fn init(stream: *std.io.FixedBufferStream([]u8), allocator: *Allocator) (Error || error{EndOfStream} || Allocator.Error)!*InitrdFS {
|
||||
std.log.info(.initrd, "Init\n", .{});
|
||||
defer std.log.info(.initrd, "Done\n", .{});
|
||||
log.info("Init\n", .{});
|
||||
defer log.info("Done\n", .{});
|
||||
|
||||
// First @sizeOf(usize) bytes is the number of files
|
||||
const num_of_files = try stream.reader().readIntNative(usize);
|
||||
|
@ -658,7 +659,7 @@ fn rt_openReadClose(allocator: *Allocator) void {
|
|||
error.NoSuchFileOrDir => {},
|
||||
else => panic(@errorReturnTrace(), "FAILURE: Expected error\n", .{}),
|
||||
};
|
||||
std.log.info(.initrd, "Opened, read and closed\n", .{});
|
||||
log.info("Opened, read and closed\n", .{});
|
||||
}
|
||||
|
||||
///
|
||||
|
|
|
@ -446,23 +446,26 @@ const TestFS = struct {
|
|||
}
|
||||
// Form a list containing all directory nodes to check via a breadth-first search
|
||||
// This is inefficient but good for testing as it's clear and easy to modify
|
||||
var to_check = TailQueue(*TreeNode).init();
|
||||
var root_node = try to_check.createNode(&test_fs.tree, test_fs.allocator);
|
||||
var to_check = TailQueue(*TreeNode){};
|
||||
var root_node = try test_fs.allocator.create(TailQueue(*TreeNode).Node);
|
||||
root_node.* = .{ .data = &test_fs.tree };
|
||||
to_check.append(root_node);
|
||||
|
||||
while (to_check.popFirst()) |queue_node| {
|
||||
var tree_node = queue_node.data;
|
||||
to_check.destroyNode(queue_node, test_fs.allocator);
|
||||
test_fs.allocator.destroy(queue_node);
|
||||
if ((@TypeOf(node) == *const FileNode and tree_node.val.isFile() and &tree_node.val.File == node) or (@TypeOf(node) == *const DirNode and tree_node.val.isDir() and &tree_node.val.Dir == node) or (@TypeOf(node) == *const Node and &tree_node.val == node)) {
|
||||
// Clean up any unused queue nodes
|
||||
while (to_check.popFirst()) |t_node| {
|
||||
to_check.destroyNode(t_node, test_fs.allocator);
|
||||
test_fs.allocator.destroy(t_node);
|
||||
}
|
||||
return tree_node;
|
||||
}
|
||||
for (tree_node.children.items) |child| {
|
||||
// It's not the parent so add its children to the list for checking
|
||||
to_check.append(try to_check.createNode(child, test_fs.allocator));
|
||||
var n = try test_fs.allocator.create(TailQueue(*TreeNode).Node);
|
||||
n.* = .{ .data = child };
|
||||
to_check.append(n);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue