summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/eventloop.go2
-rw-r--r--internal/eventloop_test.go18
-rw-r--r--internal/file/file.go4
3 files changed, 14 insertions, 10 deletions
diff --git a/internal/eventloop.go b/internal/eventloop.go
index 9a64647..b504920 100644
--- a/internal/eventloop.go
+++ b/internal/eventloop.go
@@ -329,7 +329,7 @@ func (e *eventLoop) tracepointExited(exitEv event.Event, ch chan<- *event.Pair)
switch v.Cmd {
case syscall.F_SETFL:
const canChange = syscall.O_APPEND | syscall.O_ASYNC | syscall.O_DIRECT | syscall.O_NOATIME | syscall.O_NONBLOCK
- fdFile.AddFlags((int32(v.Arg) & int32(canChange)))
+ fdFile.SetFlags((int32(v.Arg) & int32(canChange)))
ep.File = fdFile
e.files[fd] = fdFile
case syscall.F_DUPFD:
diff --git a/internal/eventloop_test.go b/internal/eventloop_test.go
index f3feab4..356dcf9 100644
--- a/internal/eventloop_test.go
+++ b/internal/eventloop_test.go
@@ -52,11 +52,11 @@ func TestEventloop(t *testing.T) {
"Dup3WithCloexecTest": makeDup3WithCloexecTestData(t),
"Dup2Test": makeDup2TestData(t),
// FcntlEvent tests
- "FcntlSetFlagsTest": makeFcntlSetFlagsTestData(t),
- "FcntlDupfdTest": makeFcntlDupfdTestData(t),
- "FcntlDupfdCloexecTest": makeFcntlDupfdCloexecTestData(t),
- "FcntlErrorTest": makeFcntlErrorTestData(t),
- "FcntlInvalidFdTest": makeFcntlInvalidFdTestData(t),
+ "FcntlSetFlagsTest": makeFcntlSetFlagsTestData(t),
+ "FcntlDupfdTest": makeFcntlDupfdTestData(t),
+ "FcntlDupfdCloexecTest": makeFcntlDupfdCloexecTestData(t),
+ "FcntlErrorTest": makeFcntlErrorTestData(t),
+ "FcntlInvalidFdTest": makeFcntlInvalidFdTestData(t),
// FD Lifecycle tests
"FdLifecycleTest": makeFdLifecycleTestData(t),
"FdDupTest": makeFdDupTestData(t),
@@ -1000,8 +1000,8 @@ func makeFcntlSetFlagsTestData(t *testing.T) (td testData) {
// TODO: Investigate why this test is failing - temporarily disabled
// The test fails with panic "expected a file.FdFile" during fcntl event processing
// Returning empty test data to skip this test case
- return td
-
+ // return td
+
fd := uint32(60)
filename := "fcntl_setfl_test.txt"
@@ -1021,7 +1021,7 @@ func makeFcntlSetFlagsTestData(t *testing.T) (td testData) {
verifyFileDescriptor(t, el, int32(fd), filename)
})
- // Step 2: Call fcntl F_SETFL to add O_NONBLOCK and O_APPEND flags
+ // // Step 2: Call fcntl F_SETFL to add O_NONBLOCK and O_APPEND flags
const newFlags = syscall.O_NONBLOCK | syscall.O_APPEND
fcntlEnterEv, fcntlEnterBytes := makeEnterFcntlEvent(t, defaulTime+200, defaultPid, defaultTid, fd, syscall.F_SETFL, uint64(newFlags))
td.rawTracepoints = append(td.rawTracepoints, fcntlEnterBytes)
@@ -1479,7 +1479,7 @@ func makeFcntlInvalidFdTestData(t *testing.T) (td testData) {
// Step 2: Open a real file
realFd := uint32(66)
filename := "fcntl_invalid_test.txt"
-
+
openEnterEv, openEnterBytes := makeEnterOpenEvent(t, defaulTime+200, defaultPid, defaultTid)
copy(openEnterEv.Filename[:], filename)
openEnterBytes, _ = openEnterEv.Bytes()
diff --git a/internal/file/file.go b/internal/file/file.go
index 330ba21..d46e6db 100644
--- a/internal/file/file.go
+++ b/internal/file/file.go
@@ -99,6 +99,10 @@ func (f FdFile) Flags() Flags {
return f.flags
}
+func (f *FdFile) SetFlags(flags int32) {
+ f.flags = Flags(flags)
+}
+
func (f *FdFile) AddFlags(flags int32) {
f.flags = Flags(int32(f.flags) | flags)
}