summaryrefslogtreecommitdiff
path: root/internal/generate/classify_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-30 17:04:13 +0300
committerPaul Buetow <paul@buetow.org>2026-05-30 17:04:13 +0300
commit231938bc6a768953cca1d0b77298f9199fb8bc61 (patch)
treecb50deae9cb6ca8f5ba48de5eddd3a628dcdaf35 /internal/generate/classify_test.go
parentd071a75f44bc14dce364142483b072272c81313e (diff)
test(getsockname): lock in KindFd/FamilyNetwork/UNCLASSIFIED classification
Audit of getsockname(2) confirmed correct tracing: enter is KindFd with the sockfd captured from args[0], family is FamilyNetwork, and the exit ret_event is UNCLASSIFIED (0/-1, no byte count) — matching the man page and its bind/connect/listen/accept/getpeername siblings. Integration coverage already exists (ioworkload calls Getsockname; TestSocketIntro- spection asserts enter_getsockname). Add lock-in tests symmetric with the existing getpeername coverage: - TestClassifyExitGetsockname: exit tracepoint maps to KindRet. - TestGenerateGetsocknameHandler: enter captures fd=args[0]; the addr output pointer (args[1]) and addrlen in/out pointer (args[2]) are not captured, and the exit stays UNCLASSIFIED. - FormatGetsockname/FormatExitGetsockname fixtures copied verbatim from the real kernel tracepoint format (third arg is a pointer, unlike bind's by-value addrlen). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'internal/generate/classify_test.go')
-rw-r--r--internal/generate/classify_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/generate/classify_test.go b/internal/generate/classify_test.go
index 4efdaee..b562689 100644
--- a/internal/generate/classify_test.go
+++ b/internal/generate/classify_test.go
@@ -696,6 +696,24 @@ func TestClassifyExitGetpeername(t *testing.T) {
}
}
+// TestClassifyExitGetsockname locks in that the getsockname exit tracepoint is
+// classified as KindRet. getsockname(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_getsockname handler — just
+// like its sibling getpeername (see TestClassifyExitGetpeername).
+func TestClassifyExitGetsockname(t *testing.T) {
+ r := ClassifyFormat(&Format{
+ Name: "sys_exit_getsockname",
+ ExternalFields: []Field{
+ {Type: "long", Name: "__syscall_nr"},
+ {Type: "long", Name: "ret"},
+ },
+ })
+ if r.Kind != KindRet {
+ t.Errorf("exit_getsockname: got kind %d, want KindRet", r.Kind)
+ }
+}
+
func TestClassifySocket(t *testing.T) {
r := classifyFromData(t, FormatSocket)
if r.Kind != KindSocket {