diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-30 16:35:39 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-30 16:35:39 +0300 |
| commit | a74da2f75d8088793ee6f7e2cc46ba19803a350f (patch) | |
| tree | 0368c226edc4f53c0fb98ddd94e98646a7a69404 /internal/generate/family_test.go | |
| parent | 5210f20b16a224f58117ffb71b2a0691c02a50ed (diff) | |
test(generate): lock in bind syscall classification
Audit of bind(2): int bind(int sockfd, const struct sockaddr *addr,
socklen_t addrlen). Verified the existing classification is correct and
consistent with its socket-setup siblings connect/listen/accept/
getsockname/getpeername:
- KindFd, capturing ev->fd = args[0] (the sockfd); the addr pointer and
addrlen are not captured.
- FamilyNetwork.
- Exit is UNCLASSIFIED (returns 0/-1, no transferred byte count).
No implementation or doc changes were needed (docs/syscall-tracing-plan.md
already lists bind under Network and fd; drift test green). Added
regression coverage:
- FormatBind/FormatExitBind fixtures mirroring the real kernel tracepoint.
- TestGenerateBindHandler with negative guards (no probe_read on the
sockaddr, no fd capture from args[1]/args[2], exit stays UNCLASSIFIED).
- bind + connect/listen/getsockname/getpeername added to the
family (FamilyNetwork) and ret-classification (UNCLASSIFIED) lock-in
lists.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'internal/generate/family_test.go')
| -rw-r--r-- | internal/generate/family_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/generate/family_test.go b/internal/generate/family_test.go index ee92740..d86cc4a 100644 --- a/internal/generate/family_test.go +++ b/internal/generate/family_test.go @@ -9,6 +9,17 @@ func TestClassifySyscallFamily(t *testing.T) { }{ {"sys_enter_accept", FamilyNetwork}, {"sys_exit_accept", FamilyNetwork}, + // bind(2) assigns an address to a socket; it is a socket-setup syscall and + // shares FamilyNetwork with its connect/listen/accept/getsockname/ + // getpeername siblings. Assert both enter and exit (and the closest + // siblings) so a stray reclassification of any one trips this test. Keep in + // sync with the Network list in docs/syscall-tracing-plan.md. + {"sys_enter_bind", FamilyNetwork}, + {"sys_exit_bind", FamilyNetwork}, + {"sys_enter_connect", FamilyNetwork}, + {"sys_enter_listen", FamilyNetwork}, + {"sys_enter_getsockname", FamilyNetwork}, + {"sys_enter_getpeername", FamilyNetwork}, {"sys_enter_pipe2", FamilyIPC}, {"sys_enter_munmap", FamilyMemory}, // process_madvise(2) gives memory advice (MADV_COLD/PAGEOUT/...) about |
