diff options
Diffstat (limited to 'integrationtests')
| -rw-r--r-- | integrationtests/cmd/ioworkload/scenarios.go | 15 | ||||
| -rw-r--r-- | integrationtests/open_test.go | 2 | ||||
| -rw-r--r-- | integrationtests/rename_test.go | 6 |
3 files changed, 15 insertions, 8 deletions
diff --git a/integrationtests/cmd/ioworkload/scenarios.go b/integrationtests/cmd/ioworkload/scenarios.go index 1ca7328..cb9f455 100644 --- a/integrationtests/cmd/ioworkload/scenarios.go +++ b/integrationtests/cmd/ioworkload/scenarios.go @@ -85,7 +85,9 @@ func openBasic() error { return syscall.Close(fd) } -// openCreat uses the creat syscall to create a file. +// openCreat creates a file via raw SYS_CREAT. +// Go's syscall.Creat wraps Open which delegates to openat on amd64, +// so we use the raw syscall to actually exercise the creat tracepoint. func openCreat() error { dir, cleanup, err := makeTempDir("open-creat") if err != nil { @@ -94,11 +96,16 @@ func openCreat() error { defer cleanup() path := filepath.Join(dir, "creatfile.txt") - fd, err := syscall.Creat(path, 0o644) + pathBytes, err := syscall.BytePtrFromString(path) if err != nil { - return fmt.Errorf("creat: %w", err) + return fmt.Errorf("path bytes: %w", err) } - return syscall.Close(fd) + fd, _, errno := syscall.Syscall(syscall.SYS_CREAT, uintptr(unsafe.Pointer(pathBytes)), 0o644, 0) + runtime.KeepAlive(pathBytes) + if errno != 0 { + return fmt.Errorf("creat: %w", errno) + } + return syscall.Close(int(fd)) } // readwriteBasic opens a file, writes data, seeks to start, reads it back. diff --git a/integrationtests/open_test.go b/integrationtests/open_test.go index 3f07ae3..917ce79 100644 --- a/integrationtests/open_test.go +++ b/integrationtests/open_test.go @@ -17,7 +17,7 @@ func TestOpenCreat(t *testing.T) { runScenario(t, "open-creat", []ExpectedEvent{ { PathContains: "creatfile.txt", - Tracepoint: "enter_openat", + Tracepoint: "enter_creat", Comm: "ioworkload", MinCount: 1, }, diff --git a/integrationtests/rename_test.go b/integrationtests/rename_test.go index 8e3238d..0ae1d47 100644 --- a/integrationtests/rename_test.go +++ b/integrationtests/rename_test.go @@ -5,7 +5,7 @@ import "testing" func TestRenameBasic(t *testing.T) { runScenario(t, "rename-basic", []ExpectedEvent{ { - PathContains: "oldname.txt", + PathContains: "newname.txt", Tracepoint: "enter_rename", Comm: "ioworkload", MinCount: 1, @@ -16,7 +16,7 @@ func TestRenameBasic(t *testing.T) { func TestRenameRenameat(t *testing.T) { runScenario(t, "rename-renameat", []ExpectedEvent{ { - PathContains: "renameat-old.txt", + PathContains: "renameat-new.txt", Tracepoint: "enter_renameat", Comm: "ioworkload", MinCount: 1, @@ -27,7 +27,7 @@ func TestRenameRenameat(t *testing.T) { func TestRenameRenameat2(t *testing.T) { runScenario(t, "rename-renameat2", []ExpectedEvent{ { - PathContains: "renameat2-old.txt", + PathContains: "renameat2-new.txt", Tracepoint: "enter_renameat2", Comm: "ioworkload", MinCount: 1, |
