link-tests: extract values into variables

We can then collect multiple variables (currently assumed always
in global scope) and run a comparison with some very basic
arithmetic on the values.
This commit is contained in:
Jakub Konka
2022-06-22 00:49:20 +02:00
parent 3bb4d65b2f
commit b5601a2da6
2 changed files with 182 additions and 20 deletions

View File

@@ -14,8 +14,17 @@ pub fn build(b: *Builder) void {
exe.entry_symbol_name = "_non_main";
const check_exe = exe.checkMachO();
check_exe.check("segname __TEXT");
check_exe.checkNextExtract("vmaddr {vmaddr}");
check_exe.check("cmd MAIN");
check_exe.checkNext("entryoff {x}");
check_exe.checkNextExtract("entryoff {entryoff}");
check_exe.checkInSymtab();
check_exe.checkNextExtract("_non_main {n_value}");
check_exe.checkCompare("{vmaddr entryoff +}", .{ .varr = "n_value" });
test_step.dependOn(&check_exe.step);