//! The kernel area: perf events, USDT, BPF. Its targets, and its tests on them. const std = @import("std"); const Ctx = @import("../build.zig").Ctx; pub fn add(ctx: Ctx) void { const b = ctx.b; const step = ctx.areaTest("test-kernel", "Perf events on real targets, USDT notes against readelf, BPF programs offline"); // The tests run these: they get the paths as `@import("targets")`. const paths = b.addOptions(); inline for (.{ .{ "spin", &.{"kernel_spin.c"} }, .{ "touch", &.{"kernel_touch.c"} }, .{ "usdt", &.{ "kernel_usdt.c", "kernel_usdt_tick.c" } }, }) |t| { const exe = ctx.cTarget("kernel_" ++ t[0], t[1]); paths.addOptionPath(t[0], exe.getEmittedBin()); // ... and `zig build` leaves them in zig-out/targets to try things on. b.getInstallStep().dependOn(&b.addInstallArtifact(exe, .{ .dest_dir = .{ .override = .{ .custom = "targets" } } }).step); } const tests = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/trace/kernel_test.zig"), .target = ctx.target, .optimize = ctx.optimize, .imports = &.{ .{ .name = "ztrace", .module = ctx.ztrace }, .{ .name = "targets", .module = paths.createModule() } }, }) }); step.dependOn(&b.addRunArtifact(tests).step); }