summaryrefslogtreecommitdiff
path: root/internal/generate/classify_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-29 22:32:55 +0300
committerPaul Buetow <paul@buetow.org>2026-05-29 22:32:55 +0300
commit18c8e8f5f3d7cc9bbbcb9b8b9be65477110363a7 (patch)
tree5a27462787e0591991558056fc3f152ca6bbe260 /internal/generate/classify_test.go
parent5aadfad3a145de9967120065587d830f09ad87aa (diff)
test(generate): lock in access/faccessat path classification
Audit of access(2) found the tracing implementation already correct: FS family, KindPathname capturing the real path, and an UNCLASSIFIED int 0/-1 ret_event on exit. access(2) captures its path from args[0] (no dirfd), while siblings faccessat(2)/faccessat2(2) capture from args[1] (dfd precedes the path). mage generate produces no diff and the docs/integration coverage already match. Add unit lock-in tests mirroring prior syscall audits: - FormatAccess/FormatFaccessat tracepoint fixtures (real kernel formats). - classify tests asserting both classify as KindPathname/"filename". - family_test cluster asserting access/faccessat/faccessat2 stay FamilyFS. - codegen test proving access reads ctx->args[0] while faccessat reads ctx->args[1], guarding against a wrong-arg or dropped-path regression. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'internal/generate/classify_test.go')
-rw-r--r--internal/generate/classify_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/generate/classify_test.go b/internal/generate/classify_test.go
index 838d643..25f1960 100644
--- a/internal/generate/classify_test.go
+++ b/internal/generate/classify_test.go
@@ -103,6 +103,37 @@ func TestClassifyPathnameUtime(t *testing.T) {
}
}
+// TestClassifyPathnameAccess locks in that access(2)'s args[0] argument
+// (kernel field "filename") is captured as a real filesystem path. access(2)
+// checks the calling process's permissions for a file by path; the path is at
+// args[0] (there is no dirfd), so it must classify as KindPathname with the
+// path wired to the "filename" field. If this regresses to a non-path kind,
+// access's pathname would silently stop being captured.
+func TestClassifyPathnameAccess(t *testing.T) {
+ r := classifyFromData(t, FormatAccess)
+ if r.Kind != KindPathname {
+ t.Errorf("access: got kind %d, want KindPathname", r.Kind)
+ }
+ if r.PathnameField != "filename" {
+ t.Errorf("access: PathnameField = %q, want filename", r.PathnameField)
+ }
+}
+
+// TestClassifyPathnameFaccessat locks in that faccessat(2) — access(2)'s
+// dirfd-relative sibling — also classifies as KindPathname with the path wired
+// to the "filename" field. The path is at args[1] (args[0] is the dirfd); the
+// argument-index difference from access(2) is verified separately in the
+// codegen tests (TestGenerateAccessFaccessatHandlers).
+func TestClassifyPathnameFaccessat(t *testing.T) {
+ r := classifyFromData(t, FormatFaccessat)
+ if r.Kind != KindPathname {
+ t.Errorf("faccessat: got kind %d, want KindPathname", r.Kind)
+ }
+ if r.PathnameField != "filename" {
+ t.Errorf("faccessat: PathnameField = %q, want filename", r.PathnameField)
+ }
+}
+
func TestClassifyNameRename(t *testing.T) {
r := classifyFromData(t, FormatRename)
if r.Kind != KindName {