mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
CBE: Get test more useful
This commit is contained in:
parent
aaaebfe97f
commit
2f28ecf946
11
src-self-hosted/cgen.zig
Normal file
11
src-self-hosted/cgen.zig
Normal file
@ -0,0 +1,11 @@
|
||||
const link = @import("link.zig");
|
||||
const Module = @import("Module.zig");
|
||||
|
||||
const C = link.File.C;
|
||||
const Decl = Module.Decl;
|
||||
const CStandard = Module.CStandard;
|
||||
|
||||
pub fn generate(file: *C, decl: *Decl, standard: CStandard) !void {
|
||||
const writer = file.file.?.writer();
|
||||
try writer.print("Generating decl '{}', targeting {}", .{ decl.name, @tagName(standard) });
|
||||
}
|
||||
@ -7,6 +7,7 @@ const Module = @import("Module.zig");
|
||||
const fs = std.fs;
|
||||
const elf = std.elf;
|
||||
const codegen = @import("codegen.zig");
|
||||
const cgen = @import("cgen.zig");
|
||||
|
||||
const default_entry_addr = 0x8000000;
|
||||
|
||||
@ -229,7 +230,7 @@ pub const File = struct {
|
||||
}
|
||||
|
||||
pub fn updateDecl(self: *File.C, module: *Module, decl: *Module.Decl) !void {
|
||||
return error.Unimplemented;
|
||||
try cgen.generate(self, decl, self.options.c_standard.?);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -481,7 +481,10 @@ pub const TestContext = struct {
|
||||
if (case.c_standard) |cstd| {
|
||||
label = @tagName(cstd);
|
||||
var c: *link.File.C = module.bin_file.cast(link.File.C).?;
|
||||
var out = c.file.?.reader().readAllAlloc(allocator, 1024 * 1024) catch @panic("Unable to read C output!");
|
||||
c.file.?.close();
|
||||
var file = try tmp.dir.openFile(bin_name, .{ .read = true });
|
||||
defer file.close();
|
||||
var out = file.reader().readAllAlloc(allocator, 1024 * 1024) catch @panic("Unable to read C output!");
|
||||
defer allocator.free(out);
|
||||
|
||||
if (expected_output.len != out.len) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user