mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-09 15:19:07 +00:00
Instead, we now have a looser helper called `checkContains(...)` that will match on any occurrence similarly to `std.mem.indexOf()`. While at it, I have cleaned up other combinators to make the entire API more consistent, and so: * `checkStart(phrase)` is now `checkStart()` followed by `checkExact(phrase)` * `checkNext(phrase)` if matching exactly is now `checkExact(phrase)` * `checkNext(phrase)` if matching loosely is now `checkContains(phrase)` * `checkNext(phrase)` if matching exactly with var extractors is now `checkExtract(phrase)` Finally, `ElfDumper` is now dumping contents of `.symtab` and `.dynsym` symbol tables. I have also removed dumping of symtabs as optional - they are now always dumped which cleaned up the implementation even more.
83 lines
3.1 KiB
Zig
83 lines
3.1 KiB
Zig
const std = @import("std");
|
|
|
|
pub const requires_stage2 = true;
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const test_step = b.step("test", "Test it");
|
|
b.default_step = test_step;
|
|
|
|
add(b, test_step, .Debug);
|
|
add(b, test_step, .ReleaseFast);
|
|
add(b, test_step, .ReleaseSmall);
|
|
add(b, test_step, .ReleaseSafe);
|
|
}
|
|
|
|
fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
|
|
const import_table = b.addSharedLibrary(.{
|
|
.name = "import_table",
|
|
.root_source_file = .{ .path = "lib.zig" },
|
|
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
|
|
.optimize = optimize,
|
|
});
|
|
import_table.use_llvm = false;
|
|
import_table.use_lld = false;
|
|
import_table.import_table = true;
|
|
|
|
const export_table = b.addSharedLibrary(.{
|
|
.name = "export_table",
|
|
.root_source_file = .{ .path = "lib.zig" },
|
|
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
|
|
.optimize = optimize,
|
|
});
|
|
export_table.use_llvm = false;
|
|
export_table.use_lld = false;
|
|
export_table.export_table = true;
|
|
|
|
const regular_table = b.addSharedLibrary(.{
|
|
.name = "regular_table",
|
|
.root_source_file = .{ .path = "lib.zig" },
|
|
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
|
|
.optimize = optimize,
|
|
});
|
|
regular_table.use_llvm = false;
|
|
regular_table.use_lld = false;
|
|
|
|
const check_import = import_table.checkObject();
|
|
const check_export = export_table.checkObject();
|
|
const check_regular = regular_table.checkObject();
|
|
|
|
check_import.checkStart();
|
|
check_import.checkExact("Section import");
|
|
check_import.checkExact("entries 1");
|
|
check_import.checkExact("module env");
|
|
check_import.checkExact("name __indirect_function_table");
|
|
check_import.checkExact("kind table");
|
|
check_import.checkExact("type funcref");
|
|
check_import.checkExact("min 1"); // 1 function pointer
|
|
check_import.checkNotPresent("max"); // when importing, we do not provide a max
|
|
check_import.checkNotPresent("Section table"); // we're importing it
|
|
|
|
check_export.checkStart();
|
|
check_export.checkExact("Section export");
|
|
check_export.checkExact("entries 2");
|
|
check_export.checkExact("name __indirect_function_table"); // as per linker specification
|
|
check_export.checkExact("kind table");
|
|
|
|
check_regular.checkStart();
|
|
check_regular.checkExact("Section table");
|
|
check_regular.checkExact("entries 1");
|
|
check_regular.checkExact("type funcref");
|
|
check_regular.checkExact("min 2"); // index starts at 1 & 1 function pointer = 2.
|
|
check_regular.checkExact("max 2");
|
|
|
|
check_regular.checkStart();
|
|
check_regular.checkExact("Section element");
|
|
check_regular.checkExact("entries 1");
|
|
check_regular.checkExact("table index 0");
|
|
check_regular.checkExact("i32.const 1"); // we want to start function indexes at 1
|
|
check_regular.checkExact("indexes 1"); // 1 function pointer
|
|
|
|
test_step.dependOn(&check_import.step);
|
|
test_step.dependOn(&check_export.step);
|
|
test_step.dependOn(&check_regular.step);
|
|
}
|