diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-19 20:29:31 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-19 20:29:31 +0300 |
| commit | 11a8642b7035ff558fb84d7761e93525c84e4908 (patch) | |
| tree | aa1f501fcf8f3a5474d26658731782e061cccc15 /internal/eventloop_polling_test.go | |
| parent | c67b34fca467fc4e5e8aba7a1b8929d8aa55a833 (diff) | |
z6: add KindPoll wiring for poll/select ready counts
Diffstat (limited to 'internal/eventloop_polling_test.go')
| -rw-r--r-- | internal/eventloop_polling_test.go | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/internal/eventloop_polling_test.go b/internal/eventloop_polling_test.go index 9d807d5..5158b53 100644 --- a/internal/eventloop_polling_test.go +++ b/internal/eventloop_polling_test.go @@ -80,4 +80,68 @@ func TestInitRawHandlersRegistersPollingEvents(t *testing.T) { if _, ok := el.rawHandlers[types.ENTER_EPOLL_CTL_EVENT]; !ok { t.Fatal("ENTER_EPOLL_CTL_EVENT handler is not registered") } + if _, ok := el.rawHandlers[types.ENTER_POLL_EVENT]; !ok { + t.Fatal("ENTER_POLL_EVENT handler is not registered") + } +} + +func TestHandlePollExitCarriesCommAndAppliesFilter(t *testing.T) { + t.Run("accepted", func(t *testing.T) { + el := mustNewEventLoop(t, eventLoopConfig{}) + enter := &types.PollEvent{ + EventType: types.ENTER_POLL_EVENT, + TraceId: types.SYS_ENTER_POLL, + Time: 300, + Pid: 120, + Tid: 121, + Nfds: 2, + TimeoutNs: 5_000_000, + } + exit := &types.RetEvent{ + EventType: types.EXIT_RET_EVENT, + TraceId: types.SYS_EXIT_POLL, + Time: 320, + Ret: 1, + Pid: 120, + Tid: 121, + } + ep := &event.Pair{EnterEv: enter, ExitEv: exit} + + if ok := el.handlePollExit(ep, enter); !ok { + t.Fatal("handlePollExit returned false") + } + if ep.Comm != "" { + t.Fatalf("expected empty comm for unresolved tid, got %q", ep.Comm) + } + }) + + t.Run("filtered", func(t *testing.T) { + el := mustNewEventLoop(t, eventLoopConfig{ + filter: globalfilter.Filter{ + Syscall: &globalfilter.StringFilter{Pattern: "openat"}, + }, + }) + enter := &types.PollEvent{ + EventType: types.ENTER_POLL_EVENT, + TraceId: types.SYS_ENTER_POLL, + Time: 300, + Pid: 120, + Tid: 121, + Nfds: 2, + TimeoutNs: 5_000_000, + } + exit := &types.RetEvent{ + EventType: types.EXIT_RET_EVENT, + TraceId: types.SYS_EXIT_POLL, + Time: 320, + Ret: 1, + Pid: 120, + Tid: 121, + } + ep := &event.Pair{EnterEv: enter, ExitEv: exit} + + if ok := el.handlePollExit(ep, enter); ok { + t.Fatal("handlePollExit should reject pair due to filter mismatch") + } + }) } |
