From e44475525894cb5a184e7fecd449c258f204f189 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Jun 2026 09:16:11 +0300 Subject: test(chmod): add end-to-end coverage for chmod/fchmod/fchmodat family chmod/fchmod/fchmodat/fchmodat2 previously had no integration coverage: no scenario in cmd/ioworkload/ and no test in integrationtests/. All four are correctly classified (chmod KindPathname args[0]; fchmodat/fchmodat2 KindPathname args[1]; fchmod KindFd args[0]; all FamilyFS, all UNCLASSIFIED ret) but nothing exercised them end-to-end. Add a chmod-basic scenario that, on a temp file the caller owns (so all calls are unprivileged), issues raw chmod(path, 0640), fchmodat(AT_FDCWD, path, 0644, 0), fchmod(fd, 0644), and best-effort fchmodat2(AT_FDCWD, path, 0640, 0) (raw syscall 452, ENOSYS tolerated on kernels < 6.6). Raw syscalls are used so each distinct tracepoint fires rather than glibc redirecting chmod to fchmodat. TestChmodBasic asserts enter_chmod and enter_fchmodat capture the file path (chmodfile.txt) and enter_fchmod fires (KindFd, no path). fchmodat2 is not asserted since it is version-gated, though it does fire on current kernels. Mirrors the utime coverage (scenario_utime.go / utime_test.go). Co-Authored-By: Claude Opus 4.8 --- integrationtests/chmod_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 integrationtests/chmod_test.go (limited to 'integrationtests') diff --git a/integrationtests/chmod_test.go b/integrationtests/chmod_test.go new file mode 100644 index 0000000..7c08be8 --- /dev/null +++ b/integrationtests/chmod_test.go @@ -0,0 +1,32 @@ +package integrationtests + +import "testing" + +// TestChmodBasic verifies ior captures the chmod permission-change family +// end-to-end. chmod and fchmodat take a real filesystem path (args[0] and +// args[1] respectively), so both must be path-classified (KindPathname) and +// the file path captured. fchmod operates on an open fd (KindFd) and carries +// no path, so we only assert the tracepoint fired. fchmodat2 is best-effort +// (ENOSYS on kernels < 6.6) and not asserted; the running kernel is 6.x+, so +// it does fire in practice, but the older siblings are the stable assertions. +func TestChmodBasic(t *testing.T) { + runScenario(t, "chmod-basic", []ExpectedEvent{ + { + PathContains: "chmodfile.txt", + Tracepoint: "enter_chmod", + Comm: "ioworkload", + MinCount: 1, + }, + { + PathContains: "chmodfile.txt", + Tracepoint: "enter_fchmodat", + Comm: "ioworkload", + MinCount: 1, + }, + { + Tracepoint: "enter_fchmod", + Comm: "ioworkload", + MinCount: 1, + }, + }) +} -- cgit v1.2.3