diff options
| -rw-r--r-- | TODO.md | 51 | ||||
| -rw-r--r-- | internal/eventloop_test.go | 73 |
2 files changed, 122 insertions, 2 deletions
@@ -1,3 +1,50 @@ -# Ideas/to-do's +# TODO - Eventloop Test Coverage -* put p +## Remaining Helper Functions +- [x] Create helper functions for NameEvent (makeEnterNameEvent/makeExitNameEvent) +- [x] Create helper functions for NullEvent (makeEnterNullEvent/makeExitNullEvent) +- [x] Create helper functions for Dup3Event (makeEnterDup3Event/makeExitDup3Event) + +## Remaining Test Cases + +### FdEvent Syscalls +- [ ] Add test case for fsync syscall +- [ ] Add test case for ftruncate syscall + +### PathEvent Syscalls +- [ ] Add test case for unlink syscall +- [ ] Add test case for creat syscall +- [ ] Add test case for stat syscall +- [ ] Add test case for access syscall + +### NameEvent Syscalls +- [ ] Add test case for rename syscall +- [ ] Add test case for link syscall +- [ ] Add test case for symlink syscall + +### NullEvent Syscalls +- [ ] Add test case for sync syscall +- [ ] Add test case for io_uring_setup syscall + +### Dup3Event Syscalls +- [ ] Add test case for dup3 syscall + +## Advanced Test Cases + +### File Descriptor Lifecycle +- [ ] Test that fd from openat is properly tracked in subsequent read/write/close operations +- [ ] Test dup/dup2/dup3 creating new file descriptors +- [ ] Test close removing fd from tracking +- [ ] Test multiple file descriptors being tracked simultaneously + +### Edge Cases +- [ ] Test missing enter events (only exit event received) +- [ ] Test missing exit events (only enter event received) +- [ ] Test mismatched enter/exit pairs +- [ ] Test out-of-order events +- [ ] Test events from different threads/processes + +### Filtering and Comm Tracking +- [ ] Test that comm names are properly propagated across syscalls +- [ ] Test filter behavior for each event type +- [ ] Test comm filter enable/disable functionality
\ No newline at end of file diff --git a/internal/eventloop_test.go b/internal/eventloop_test.go index a07c511..2f5e692 100644 --- a/internal/eventloop_test.go +++ b/internal/eventloop_test.go @@ -313,6 +313,79 @@ func makeEnterPathEvent(t *testing.T, time uint64, pid, tid uint32, pathname str return ev, bytes } +// Helper functions for NameEvent +func makeEnterNameEvent(t *testing.T, time uint64, pid, tid uint32, oldname, newname string, traceId types.TraceId) (types.NameEvent, []byte) { + ev := types.NameEvent{ + EventType: types.ENTER_NAME_EVENT, + TraceId: traceId, + Time: time, + Pid: pid, + Tid: tid, + Oldname: [types.MAX_FILENAME_LENGTH]byte{}, + Newname: [types.MAX_FILENAME_LENGTH]byte{}, + } + copy(ev.Oldname[:], oldname) + copy(ev.Newname[:], newname) + + bytes, err := ev.Bytes() + if err != nil { + t.Error(err) + } + return ev, bytes +} + +// Helper functions for NullEvent +func makeEnterNullEvent(t *testing.T, time uint64, pid, tid uint32, traceId types.TraceId) (types.NullEvent, []byte) { + ev := types.NullEvent{ + EventType: types.ENTER_NULL_EVENT, + TraceId: traceId, + Time: time, + Pid: pid, + Tid: tid, + } + + bytes, err := ev.Bytes() + if err != nil { + t.Error(err) + } + return ev, bytes +} + +func makeExitNullEvent(t *testing.T, time uint64, pid, tid uint32, traceId types.TraceId) (types.NullEvent, []byte) { + ev := types.NullEvent{ + EventType: types.EXIT_NULL_EVENT, + TraceId: traceId, + Time: time, + Pid: pid, + Tid: tid, + } + + bytes, err := ev.Bytes() + if err != nil { + t.Error(err) + } + return ev, bytes +} + +// Helper functions for Dup3Event +func makeEnterDup3Event(t *testing.T, time uint64, pid, tid uint32, fd int32, flags int32) (types.Dup3Event, []byte) { + ev := types.Dup3Event{ + EventType: types.ENTER_DUP3_EVENT, + TraceId: types.SYS_ENTER_DUP3, + Time: time, + Pid: pid, + Tid: tid, + Fd: fd, + Flags: flags, + } + + bytes, err := ev.Bytes() + if err != nil { + t.Error(err) + } + return ev, bytes +} + // Test data functions for PathEvent syscalls func makeMkdirEventTestData(t *testing.T) (td testData) { pathname := "/tmp/testdir" |
