diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-06 09:25:20 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-06 09:25:20 +0300 |
| commit | 00ea2b26510c225977609620800c1989c4fefd8a (patch) | |
| tree | 8c18a0a196aea49c801a40e6516e0a4bc1d6f0e2 /integrationtests | |
| parent | 178ca1f256b1e345cad2f506b6b244fb50d8d281 (diff) | |
test(priority): add end-to-end coverage for getpriority/setpriority
getpriority/setpriority (FamilyProcess, KindNull enter, UNCLASSIFIED ret)
were untested end-to-end: no ioworkload scenario invoked them. Add a safe,
unprivileged, non-disruptive priority-basic scenario that reads the current
nice value via getpriority(PRIO_PROCESS, 0) and re-applies that exact value
via setpriority(PRIO_PROCESS, 0, currentNice) — a byte-for-byte no-op,
mirroring the existing schedRoundtripAffinity round-trip. Note getpriority
returns 20-nice, so the value is converted back before re-applying.
Register the scenario in scenarios.go and add TestPriorityBasic, which
asserts enter_getpriority and enter_setpriority appear as null_event enters
attributed to the ioworkload process. Enter-tracepoint presence is the right
check given KindNull/UNCLASSIFIED (no fd/path/bytes to assert). Coverage
only — classification verified correct in audits 6u and pz.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'integrationtests')
| -rw-r--r-- | integrationtests/priority_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/integrationtests/priority_test.go b/integrationtests/priority_test.go new file mode 100644 index 0000000..9e41185 --- /dev/null +++ b/integrationtests/priority_test.go @@ -0,0 +1,33 @@ +package integrationtests + +import "testing" + +// priorityTraceArgs restricts tracing to the two priority-family syscalls the +// priority-basic workload issues. The tracer names each tracepoint after the +// underlying kernel syscall, so the names below match the syscall names +// verbatim. +var priorityTraceArgs = []string{"-trace-syscalls", "getpriority,setpriority"} + +// TestPriorityBasic verifies the getpriority/setpriority pair is traced +// end-to-end. The priority-basic workload self-targets both calls +// (PRIO_PROCESS, who 0 == the calling process): it reads the current nice value +// with getpriority and re-applies the IDENTICAL value with setpriority (a +// byte-for-byte no-op), so the process's priority is never altered and no +// privilege is required. Both syscalls classify as FamilyProcess with a KindNull +// enter (PRIO_PROCESS is an opcode, not an fd) and an UNCLASSIFIED return (the +// value is a nice value, not a byte count), so asserting the enter tracepoints +// appear — attributed to the ioworkload process — is the right end-to-end check. +func TestPriorityBasic(t *testing.T) { + h := newTestHarness(t) + result, pid, err := h.RunWithIorArgs("priority-basic", defaultDuration, priorityTraceArgs) + if err != nil { + t.Fatalf("run scenario priority-basic: %v", err) + } + + AssertNoUnexpectedPID(t, result, pid) + AssertNoUnexpectedComm(t, result, "ioworkload") + AssertEventsPresent(t, result, []ExpectedEvent{ + {Tracepoint: "enter_getpriority", Comm: "ioworkload", MinCount: 1}, + {Tracepoint: "enter_setpriority", Comm: "ioworkload", MinCount: 1}, + }) +} |
