From d0850ae4dd8688f07c67245ce4e30f90e073a9c1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 29 May 2026 10:09:19 +0300 Subject: test(generate): lock in getpeername exit classification as KindRet Audit of the getpeername(2) syscall confirmed the tracing pipeline already matches the man page: FamilyNetwork + KindFd (sockfd at args[0]) on enter, and a plain ret_event (int 0/-1) on exit. The enter classification was already covered by TestClassifySocketFdSyscallsByName, but the exit path (resolved via the generic 'ret' field matcher) had no dedicated assertion. Add TestClassifyExitGetpeername to pin sys_exit_getpeername -> KindRet so future classifier changes cannot silently regress it. Co-Authored-By: Claude Opus 4.8 --- internal/generate/classify_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'internal') diff --git a/internal/generate/classify_test.go b/internal/generate/classify_test.go index 46947e2..28b4137 100644 --- a/internal/generate/classify_test.go +++ b/internal/generate/classify_test.go @@ -300,6 +300,23 @@ func TestClassifySocketFdSyscallsByName(t *testing.T) { } } +// TestClassifyExitGetpeername locks in that the getpeername exit tracepoint is +// classified as KindRet. getpeername(2) returns int (0 on success, -1 on +// error), so its exit format carries a single "ret" field and must map to a +// plain ret_event, matching the generated sys_exit_getpeername handler. +func TestClassifyExitGetpeername(t *testing.T) { + r := ClassifyFormat(&Format{ + Name: "sys_exit_getpeername", + ExternalFields: []Field{ + {Type: "long", Name: "__syscall_nr"}, + {Type: "long", Name: "ret"}, + }, + }) + if r.Kind != KindRet { + t.Errorf("exit_getpeername: got kind %d, want KindRet", r.Kind) + } +} + func TestClassifySocket(t *testing.T) { r := classifyFromData(t, FormatSocket) if r.Kind != KindSocket { -- cgit v1.2.3