diff options
| -rw-r--r-- | integrationtests/cmd/ioworkload/scenarios.go | 43 | ||||
| -rw-r--r-- | integrationtests/iouring_test.go | 20 |
2 files changed, 60 insertions, 3 deletions
diff --git a/integrationtests/cmd/ioworkload/scenarios.go b/integrationtests/cmd/ioworkload/scenarios.go index f25b8a4..0344999 100644 --- a/integrationtests/cmd/ioworkload/scenarios.go +++ b/integrationtests/cmd/ioworkload/scenarios.go @@ -90,9 +90,11 @@ var scenarios = map[string]func() error{ "truncate-ftruncate": truncateFtruncate, "truncate-enoent": truncateEnoent, "truncate-ftruncate-ebadf": truncateFtruncateEbadf, - "iouring-setup": iouringSetup, - "iouring-enter": iouringEnter, - "iouring-register": iouringRegister, + "iouring-setup": iouringSetup, + "iouring-enter": iouringEnter, + "iouring-register": iouringRegister, + "iouring-enter-ebadf": iouringEnterEbadf, + "iouring-register-ebadf": iouringRegisterEbadf, } func makeTempDir(prefix string) (string, func(), error) { @@ -2434,6 +2436,41 @@ func iouringRegister() error { return nil } +// iouringEnterEbadf calls io_uring_enter on an invalid fd. +// The syscall fails with EBADF, but ior captures the enter_io_uring_enter tracepoint. +func iouringEnterEbadf() error { + _, _, errno := syscall.Syscall6( + sysIoUringEnter, + 99999, // invalid fd + 0, // to_submit + 0, // min_complete + 0, // flags + 0, // sig + 0, // sz + ) + if errno == 0 { + return fmt.Errorf("expected EBADF, but io_uring_enter succeeded") + } + return nil +} + +// iouringRegisterEbadf calls io_uring_register on an invalid fd. +// The syscall fails with EBADF, but ior captures the enter_io_uring_register tracepoint. +func iouringRegisterEbadf() error { + _, _, errno := syscall.Syscall6( + sysIoUringRegister, + 99999, // invalid fd + ioringRegisterProbe, + 0, // arg (NULL) + 0, // nr_args + 0, 0, + ) + if errno == 0 { + return fmt.Errorf("expected EBADF, but io_uring_register succeeded") + } + return nil +} + // ioUringSetupRing calls io_uring_setup(2) and returns the ring fd. func ioUringSetupRing(entries uint32) (int, error) { var params [ioUringParamsSize]byte diff --git a/integrationtests/iouring_test.go b/integrationtests/iouring_test.go index 20c156c..02d7a16 100644 --- a/integrationtests/iouring_test.go +++ b/integrationtests/iouring_test.go @@ -31,3 +31,23 @@ func TestIouringRegister(t *testing.T) { }, }) } + +func TestIouringEnterEbadf(t *testing.T) { + runScenario(t, "iouring-enter-ebadf", []ExpectedEvent{ + { + Tracepoint: "enter_io_uring_enter", + Comm: "ioworkload", + MinCount: 1, + }, + }) +} + +func TestIouringRegisterEbadf(t *testing.T) { + runScenario(t, "iouring-register-ebadf", []ExpectedEvent{ + { + Tracepoint: "enter_io_uring_register", + Comm: "ioworkload", + MinCount: 1, + }, + }) +} |
