diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-01 15:00:44 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-01 15:00:44 +0300 |
| commit | 6a872804d93b822d530e9df93547f2fec0a8ea50 (patch) | |
| tree | 4665b0aec25491cb094b71a099fedcdb15c03928 /integrationtests | |
| parent | 55aa404fc93deeff27205b3cc9af407ab071be4b (diff) | |
test(integration): add Sched family tracing coverage
Add a self-targeted, non-disruptive sched-basic ioworkload scenario and a
dedicated TestSchedBasic integration test. The scenario pins to one OS thread
(LockOSThread) and exercises only safe Sched syscalls: sched_yield;
sched_getaffinity then sched_setaffinity re-applying the identical mask (a
no-op); and read-only sched_getscheduler, sched_getparam, sched_getattr,
sched_get_priority_max/min, and sched_rr_get_interval. sched_setscheduler,
sched_setattr, and sched_setparam are intentionally excluded.
The test scopes -trace-syscalls to the sched_* family, guards on PID and comm,
and asserts enter_ tracepoints fire (MinCount>=1) for sched_yield,
sched_getaffinity, sched_getscheduler, and sched_getparam.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'integrationtests')
| -rw-r--r-- | integrationtests/sched_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/integrationtests/sched_test.go b/integrationtests/sched_test.go new file mode 100644 index 0000000..74cd545 --- /dev/null +++ b/integrationtests/sched_test.go @@ -0,0 +1,39 @@ +package integrationtests + +import "testing" + +// schedTraceArgs restricts tracing to the Sched-family syscalls the sched-basic +// workload issues, so the captured output is dominated by those calls. The +// tracer names each tracepoint after the underlying kernel syscall, so the +// names below match the sched_* syscall names verbatim. sched_setscheduler and +// sched_setattr are intentionally absent: the scenario never invokes them (they +// would require CAP_SYS_NICE and would disrupt real-time scheduling). +var schedTraceArgs = []string{ + "-trace-syscalls", + "sched_yield,sched_getaffinity,sched_setaffinity,sched_getscheduler,sched_getparam,sched_getattr,sched_get_priority_max,sched_get_priority_min,sched_rr_get_interval", +} + +// TestSchedBasic verifies the Sched syscall family is traced end-to-end. The +// sched-basic workload self-targets every call (pid 0 == the calling thread, +// pinned with LockOSThread): it yields once, reads its CPU affinity mask and +// re-applies the IDENTICAL mask (a byte-for-byte no-op), then queries — but +// never modifies — its scheduling policy, parameters, extended attributes, +// priority range, and round-robin interval. Nothing alters the process's +// scheduling state, so the calls are safe and unprivileged. Each required +// syscall must appear as an enter event attributed to the ioworkload process. +func TestSchedBasic(t *testing.T) { + h := newTestHarness(t) + result, pid, err := h.RunWithIorArgs("sched-basic", defaultDuration, schedTraceArgs) + if err != nil { + t.Fatalf("run scenario sched-basic: %v", err) + } + + AssertNoUnexpectedPID(t, result, pid) + AssertNoUnexpectedComm(t, result, "ioworkload") + AssertEventsPresent(t, result, []ExpectedEvent{ + {Tracepoint: "enter_sched_yield", Comm: "ioworkload", MinCount: 1}, + {Tracepoint: "enter_sched_getaffinity", Comm: "ioworkload", MinCount: 1}, + {Tracepoint: "enter_sched_getscheduler", Comm: "ioworkload", MinCount: 1}, + {Tracepoint: "enter_sched_getparam", Comm: "ioworkload", MinCount: 1}, + }) +} |
