Skip to content

Commit d8fc3cb

Browse files
committed
feat(ir matirx): add three new FFI detection passes and test suite
1 parent 6efb0d8 commit d8fc3cb

14 files changed

Lines changed: 3635 additions & 15 deletions

Makefile

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ ZIG_IR = $(EXAMPLES_DIR)/zig_cffi/target
6363
viz visualize \
6464
cross-lang-test cross-lang-build cross-lang-run cross-lang-report \
6565
reports-json reports-sarif \
66-
test-issues test-stability test-stress
66+
test-issues test-stability test-stress test-inline-ir-matrix \
67+
test-ffi-layout test-ffi-string test-ffi-unwind
6768

6869
# ========================================
6970
# Default Target - Run All Tests
@@ -78,6 +79,7 @@ all: test-all bench
7879
@echo "║ Integration Tests: ✓ Passed ║"
7980
@echo "║ Issue Verification:✓ Passed ║"
8081
@echo "║ Stability Tests: ✓ Passed ║"
82+
@echo "║ Inline IR Matrix: ✓ Passed ║"
8183
@echo "║ Benchmarks: ✓ Completed ║"
8284
@echo "╚════════════════════════════════════════════════════════════════╝"
8385

@@ -124,7 +126,29 @@ test-inline-ir-matrix:
124126
@echo "╚════════════════════════════════════════════════════════════════╝"
125127
$(ZIG) build test-inline-ir-matrix
126128

127-
test-all: test-unit test-int test-issues test-stability test-stress test-inline-ir-matrix
129+
test-ffi-layout:
130+
@echo ""
131+
@echo "╔════════════════════════════════════════════════════════════════╗"
132+
@echo "║ FFI LAYOUT MISMATCH TESTS ║"
133+
@echo "╚════════════════════════════════════════════════════════════════╝"
134+
$(ZIG) build test-ffi-layout
135+
136+
test-ffi-string:
137+
@echo ""
138+
@echo "╔════════════════════════════════════════════════════════════════╗"
139+
@echo "║ FFI STRING SAFETY TESTS ║"
140+
@echo "╚════════════════════════════════════════════════════════════════╝"
141+
$(ZIG) build test-ffi-string
142+
143+
test-ffi-unwind:
144+
@echo ""
145+
@echo "╔════════════════════════════════════════════════════════════════╗"
146+
@echo "║ FFI UNWIND BOUNDARY TESTS ║"
147+
@echo "╚════════════════════════════════════════════════════════════════╝"
148+
$(ZIG) build test-ffi-unwind
149+
150+
test-all: test-unit test-int test-issues test-stability test-stress test-inline-ir-matrix \
151+
test-ffi-layout test-ffi-string test-ffi-unwind
128152
@echo ""
129153
@echo "╔════════════════════════════════════════════════════════════════╗"
130154
@echo "║ ALL TESTS PASSED ║"
@@ -846,7 +870,11 @@ help:
846870
@echo " make test-issues Run issue verification tests"
847871
@echo " make test-stability Run stability tests"
848872
@echo " make test-stress Run stress tests"
849-
@echo " make test-all Run all tests"
873+
@echo " make test-inline-ir-matrix Run inline IR matrix tests (all languages × scenarios)"
874+
@echo " make test-ffi-layout Run FFI layout mismatch tests"
875+
@echo " make test-ffi-string Run FFI string safety tests"
876+
@echo " make test-ffi-unwind Run FFI unwind boundary tests"
877+
@echo " make test-all Run all tests"
850878
@echo " make bench Run performance benchmarks"
851879
@echo ""
852880
@echo "Corpus Commands:"

build.zig

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,48 @@ pub fn build(b: *std.Build) void {
482482
inline_ir_matrix_step.dependOn(&run_inline_ir_matrix_tests.step);
483483
test_step.dependOn(&run_inline_ir_matrix_tests.step);
484484

485+
// ── FFI Layout Mismatch Tests ──
486+
const ffi_layout_step = b.step("test-ffi-layout", "Run FFI layout mismatch detection tests");
487+
const ffi_layout_mod = b.addModule("test_ffi_layout", .{
488+
.root_source_file = b.path("tests/integration/test_ffi_layout.zig"),
489+
.target = target,
490+
});
491+
ffi_layout_mod.addImport("OmniScope", lib_mod);
492+
ffi_layout_mod.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ llvm_path, "include" }) });
493+
const ffi_layout_tests = b.addTest(.{ .root_module = ffi_layout_mod });
494+
configureLLVM(b, ffi_layout_tests, llvm_path, llvm_version);
495+
const run_ffi_layout_tests = b.addRunArtifact(ffi_layout_tests);
496+
run_ffi_layout_tests.step.dependOn(b.getInstallStep());
497+
ffi_layout_step.dependOn(&run_ffi_layout_tests.step);
498+
499+
// ── FFI String Safety Tests ──
500+
const ffi_string_step = b.step("test-ffi-string", "Run FFI string safety detection tests");
501+
const ffi_string_mod = b.addModule("test_ffi_string", .{
502+
.root_source_file = b.path("tests/integration/test_ffi_string.zig"),
503+
.target = target,
504+
});
505+
ffi_string_mod.addImport("OmniScope", lib_mod);
506+
ffi_string_mod.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ llvm_path, "include" }) });
507+
const ffi_string_tests = b.addTest(.{ .root_module = ffi_string_mod });
508+
configureLLVM(b, ffi_string_tests, llvm_path, llvm_version);
509+
const run_ffi_string_tests = b.addRunArtifact(ffi_string_tests);
510+
run_ffi_string_tests.step.dependOn(b.getInstallStep());
511+
ffi_string_step.dependOn(&run_ffi_string_tests.step);
512+
513+
// ── FFI Unwind Boundary Tests ──
514+
const ffi_unwind_step = b.step("test-ffi-unwind", "Run FFI unwind boundary detection tests");
515+
const ffi_unwind_mod = b.addModule("test_ffi_unwind", .{
516+
.root_source_file = b.path("tests/integration/test_ffi_unwind.zig"),
517+
.target = target,
518+
});
519+
ffi_unwind_mod.addImport("OmniScope", lib_mod);
520+
ffi_unwind_mod.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ llvm_path, "include" }) });
521+
const ffi_unwind_tests = b.addTest(.{ .root_module = ffi_unwind_mod });
522+
configureLLVM(b, ffi_unwind_tests, llvm_path, llvm_version);
523+
const run_ffi_unwind_tests = b.addRunArtifact(ffi_unwind_tests);
524+
run_ffi_unwind_tests.step.dependOn(b.getInstallStep());
525+
ffi_unwind_step.dependOn(&run_ffi_unwind_tests.step);
526+
485527
// Help information
486528
const help_step = b.step("help", "Show build options");
487529
help_step.dependOn(&b.addSystemCommand(&.{

0 commit comments

Comments
 (0)