diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-23 13:23:23 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-23 13:23:23 +0200 |
| commit | 4bdb0505635e66e07aa7edd9d1f842f860aa581c (patch) | |
| tree | 433e464e36aeb23cbe966c5796bdb164ec04c597 /integrationtests/cmd/ioworkload | |
| parent | 2b1c849422973cf926e2bfda31703f4bfef5563d (diff) | |
tests: cover durationToPrev gap semantics
Diffstat (limited to 'integrationtests/cmd/ioworkload')
| -rw-r--r-- | integrationtests/cmd/ioworkload/scenario_open.go | 29 | ||||
| -rw-r--r-- | integrationtests/cmd/ioworkload/scenarios.go | 1 |
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, |
