summaryrefslogtreecommitdiff
path: root/integrationtests/open_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-21 20:53:07 +0200
committerPaul Buetow <paul@buetow.org>2026-02-21 20:53:07 +0200
commitcd516e1577ad97d5c8b1603657b13d110557e1b2 (patch)
treeaf13921fff67f173d4e9ff97e48c54812dc1ca81 /integrationtests/open_test.go
parent4e287fd01d5057d0345183b6845dcc58683a46e4 (diff)
Add negative integration tests for open syscalls
- openEnoent: verifies ior captures enter_openat even when syscall fails (ENOENT) - openRdonlyWrite: verifies tracing of open + failed write to read-only fd - openPidFilter: verifies child process I/O is excluded by PID filtering - AssertEventsAbsent helper with zero-value guard and 6 unit tests Task: 348 Amp-Thread-ID: https://ampcode.com/threads/T-019c8185-55f4-72f0-8ddb-3be5e4002c0d Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'integrationtests/open_test.go')
-rw-r--r--integrationtests/open_test.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/integrationtests/open_test.go b/integrationtests/open_test.go
index 917ce79..8dfbba6 100644
--- a/integrationtests/open_test.go
+++ b/integrationtests/open_test.go
@@ -34,3 +34,59 @@ func TestOpenByHandleAt(t *testing.T) {
},
})
}
+
+func TestOpenEnoent(t *testing.T) {
+ runScenario(t, "open-enoent", []ExpectedEvent{
+ {
+ PathContains: "enoentfile.txt",
+ Tracepoint: "enter_openat",
+ Comm: "ioworkload",
+ MinCount: 1,
+ },
+ })
+}
+
+func TestOpenRdonlyWrite(t *testing.T) {
+ runScenario(t, "open-rdonly-write", []ExpectedEvent{
+ {
+ PathContains: "rdonlyfile.txt",
+ Tracepoint: "enter_openat",
+ Comm: "ioworkload",
+ MinCount: 1,
+ },
+ {
+ PathContains: "rdonlyfile.txt",
+ Tracepoint: "enter_write",
+ Comm: "ioworkload",
+ MinCount: 1,
+ },
+ })
+}
+
+func TestOpenPidFilter(t *testing.T) {
+ h := newTestHarness(t)
+ result, pid, err := h.Run("open-pid-filter", defaultDuration)
+ if err != nil {
+ t.Fatalf("run scenario open-pid-filter: %v", err)
+ }
+
+ AssertNoUnexpectedPID(t, result, pid)
+ AssertNoUnexpectedComm(t, result, "ioworkload")
+
+ // Parent's file should be captured.
+ AssertEventsPresent(t, result, []ExpectedEvent{
+ {
+ PathContains: "parentfile.txt",
+ Tracepoint: "enter_openat",
+ Comm: "ioworkload",
+ MinCount: 1,
+ },
+ })
+
+ // Child's file should NOT be captured (different PID).
+ AssertEventsAbsent(t, result, []ExpectedEvent{
+ {
+ PathContains: "childfile.txt",
+ },
+ })
+}