summaryrefslogtreecommitdiff
path: root/integrationtests/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'integrationtests/cmd')
-rw-r--r--integrationtests/cmd/ioworkload/scenario_open.go29
-rw-r--r--integrationtests/cmd/ioworkload/scenarios.go1
2 files changed, 30 insertions, 0 deletions
diff --git a/integrationtests/cmd/ioworkload/scenario_open.go b/integrationtests/cmd/ioworkload/scenario_open.go
index 449549c..d86e53b 100644
--- a/integrationtests/cmd/ioworkload/scenario_open.go
+++ b/integrationtests/cmd/ioworkload/scenario_open.go
@@ -6,6 +6,7 @@ import (
"path/filepath"
"runtime"
"syscall"
+ "time"
"unsafe"
)
@@ -226,3 +227,31 @@ func openByHandleAtSyscall(mountFD int, handle []byte, flags int) (int, error) {
}
return int(fd), nil
}
+
+// openDurationGap creates two openat syscalls separated by a deliberate sleep.
+// Integration tests use this to assert durationToPrev captures inter-syscall gaps.
+func openDurationGap() error {
+ dir, cleanup, err := makeTempDir("open-duration-gap")
+ if err != nil {
+ return err
+ }
+ defer cleanup()
+
+ first := filepath.Join(dir, "gap-first.txt")
+ fd1, err := syscall.Open(first, syscall.O_RDWR|syscall.O_CREAT, 0o644)
+ if err != nil {
+ return fmt.Errorf("open first: %w", err)
+ }
+ if err := syscall.Close(fd1); err != nil {
+ return fmt.Errorf("close first: %w", err)
+ }
+
+ time.Sleep(800 * time.Millisecond)
+
+ second := filepath.Join(dir, "gap-second.txt")
+ fd2, err := syscall.Open(second, syscall.O_RDWR|syscall.O_CREAT, 0o644)
+ if err != nil {
+ return fmt.Errorf("open second: %w", err)
+ }
+ return syscall.Close(fd2)
+}
diff --git a/integrationtests/cmd/ioworkload/scenarios.go b/integrationtests/cmd/ioworkload/scenarios.go
index a6e7a5f..6910314 100644
--- a/integrationtests/cmd/ioworkload/scenarios.go
+++ b/integrationtests/cmd/ioworkload/scenarios.go
@@ -11,6 +11,7 @@ var scenarios = map[string]func() error{
"open-basic": openBasic,
"open-creat": openCreat,
"open-by-handle-at": openByHandleAt,
+ "open-duration-gap": openDurationGap,
"open-enoent": openEnoent,
"open-rdonly-write": openRdonlyWrite,
"open-pid-filter": openPidFilter,