From a1eb580aa5b80e913dc722ccf97e42c6987152e8 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 23 Feb 2026 10:34:37 +0200 Subject: Add getcwd tracing support and stabilize comm propagation test --- integrationtests/cmd/ioworkload/scenario_dir.go | 30 +++++++++++++++++++++++++ integrationtests/cmd/ioworkload/scenarios.go | 1 + integrationtests/dir_test.go | 11 +++++++++ 3 files changed, 42 insertions(+) (limited to 'integrationtests') 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, diff --git a/integrationtests/dir_test.go b/integrationtests/dir_test.go index 585f03f..d759abd 100644 --- a/integrationtests/dir_test.go +++ b/integrationtests/dir_test.go @@ -35,6 +35,17 @@ func TestDirChdir(t *testing.T) { }) } +func TestDirGetcwd(t *testing.T) { + runScenario(t, "dir-getcwd", []ExpectedEvent{ + { + PathContains: "dir-getcwd", + Tracepoint: "enter_getcwd", + Comm: "ioworkload", + MinCount: 1, + }, + }) +} + func TestDirGetdents(t *testing.T) { runScenario(t, "dir-getdents", []ExpectedEvent{ { -- cgit v1.2.3