summaryrefslogtreecommitdiff
path: root/internal/eventloop_test.go
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 /internal/eventloop_test.go
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>
Diffstat (limited to 'internal/eventloop_test.go')
-rw-r--r--internal/eventloop_test.go73
1 files changed, 73 insertions, 0 deletions
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"