summaryrefslogtreecommitdiff
path: root/integrationtests/cmd/ioworkload
diff options
context:
space:
mode:
Diffstat (limited to 'integrationtests/cmd/ioworkload')
-rw-r--r--integrationtests/cmd/ioworkload/scenario_dir.go30
-rw-r--r--integrationtests/cmd/ioworkload/scenarios.go1
2 files changed, 31 insertions, 0 deletions
diff --git a/integrationtests/cmd/ioworkload/scenario_dir.go b/integrationtests/cmd/ioworkload/scenario_dir.go
index 0c48d54..282c903 100644
--- a/integrationtests/cmd/ioworkload/scenario_dir.go
+++ b/integrationtests/cmd/ioworkload/scenario_dir.go
@@ -6,6 +6,7 @@ import (
"path/filepath"
"runtime"
"syscall"
+ "time"
"unsafe"
)
@@ -83,6 +84,35 @@ func dirChdir() error {
return nil
}
+// dirGetcwd changes into a temp directory and calls getcwd(2) directly.
+func dirGetcwd() error {
+ origDir, err := os.Getwd()
+ if err != nil {
+ return fmt.Errorf("getwd: %w", err)
+ }
+
+ dir, cleanup, err := makeTempDir("dir-getcwd")
+ if err != nil {
+ return err
+ }
+ defer cleanup()
+ defer syscall.Chdir(origDir)
+
+ if err := syscall.Chdir(dir); err != nil {
+ return fmt.Errorf("chdir: %w", err)
+ }
+
+ buf := make([]byte, 4096)
+ _, _, errno := syscall.Syscall(syscall.SYS_GETCWD, uintptr(unsafe.Pointer(&buf[0])), uintptr(len(buf)), 0)
+ runtime.KeepAlive(buf)
+ if errno != 0 {
+ return fmt.Errorf("getcwd: %w", errno)
+ }
+ // Keep cwd unchanged long enough for ior to process enter/exit pairing.
+ time.Sleep(300 * time.Millisecond)
+ return nil
+}
+
// dirGetdents opens a directory and reads its entries via getdents64(2).
func dirGetdents() error {
dir, cleanup, err := makeTempDir("dir-getdents")
diff --git a/integrationtests/cmd/ioworkload/scenarios.go b/integrationtests/cmd/ioworkload/scenarios.go
index f9a8e47..a1c32f7 100644
--- a/integrationtests/cmd/ioworkload/scenarios.go
+++ b/integrationtests/cmd/ioworkload/scenarios.go
@@ -60,6 +60,7 @@ var scenarios = map[string]func() error{
"dir-basic": dirBasic,
"dir-mkdirat": dirMkdirat,
"dir-chdir": dirChdir,
+ "dir-getcwd": dirGetcwd,
"dir-getdents": dirGetdents,
"dir-mkdir-eexist": dirMkdirEexist,
"dir-chdir-enoent": dirChdirEnoent,