diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-29 10:09:19 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-29 10:09:19 +0300 |
| commit | d0850ae4dd8688f07c67245ce4e30f90e073a9c1 (patch) | |
| tree | fc07c0e64721e1a22d3a58e61be4dbd8a274831f | |
| parent | 5eeef7f56c453dd831cf16c9f5342ded8fcb4680 (diff) | |
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 <noreply@anthropic.com>
| -rw-r--r-- | internal/generate/classify_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
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 { |
