summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/kernel.zig25
1 files changed, 24 insertions, 1 deletions
diff --git a/build/kernel.zig b/build/kernel.zig
index d3c7eb3..48c920f 100644
--- a/build/kernel.zig
+++ b/build/kernel.zig
@@ -1,5 +1,28 @@
+//! 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 {
- _ = ctx;
+ 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);
}