summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-10 08:39:44 +0300
committerPaul Buetow <paul@buetow.org>2025-07-10 08:39:44 +0300
commit519d2370495975bc104e7b94952ee939aec4d8bf (patch)
treeeb315898904ea38a1e4cad83d00113c6272ae187
parent34e9665b837abd718b2da5c5fbedd47d9af0d201 (diff)
Add remaining helper functions for eventloop tests
- Implement makeEnterNameEvent for NameEvent syscalls (rename, link, symlink) - Implement makeEnterNullEvent/makeExitNullEvent for NullEvent syscalls (sync, io_uring_setup) - Implement makeEnterDup3Event for Dup3Event syscalls (dup3) - Update TODO.md to mark helper functions as completed All helper functions are now implemented and tests pass successfully. This provides the foundation for comprehensive syscall testing across all event types supported by ior. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
-rw-r--r--TODO.md51
-rw-r--r--internal/eventloop_test.go73
2 files changed, 122 insertions, 2 deletions
diff --git a/TODO.md b/TODO.md
index f48865b..58f57f0 100644
--- a/TODO.md
+++ b/TODO.md
@@ -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"