diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-30 17:16:09 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-30 17:16:09 +0300 |
| commit | 8b64d566300b7e952da63e11cba7575d7b06e7e2 (patch) | |
| tree | c218d42c3d0bcb027e9cc91410d18f1608d7f408 /internal/generate/family_test.go | |
| parent | e462a4d9963a2949f0670a00a013dd362b5219d1 (diff) | |
test(generate): lock in lseek classification (offset, not byte count)
Audit of lseek(2) confirmed the tracing implementation is already correct:
enter is a KindFd fd_event capturing the fd from args[0], the syscall is
FamilyFS alongside its read/write/fsync siblings, and the exit is a plain
ret_event that stays UNCLASSIFIED. lseek returns the RESULTING file offset
(off_t, bytes from the start of the file), which is a file position, NOT a
count of bytes transferred — so it must never be READ/WRITE/TRANSFER
classified, which would wrongly inflate I/O byte totals.
Add lock-in tests pinning that behaviour so a future reclassification trips:
- FormatLseek/FormatExitLseek tracepoint fixtures.
- TestClassifyFdLseek: enter resolves to KindFd (fd at args[0]).
- TestClassifyRetExitLseek: exit is KindRet and ClassifyRet stays UNCLASSIFIED.
- lseek entry in TestClassifySyscallPairAccepted (end-to-end pair).
- FS-family asserts for sys_enter/exit_lseek in family_test.
- Enriched UNCLASSIFIED comment in retclassify_test explaining offset != bytes.
No generated-artifact changes (mage generate produces no diff); no in-scope
bugs and no out-of-scope follow-ups found.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'internal/generate/family_test.go')
| -rw-r--r-- | internal/generate/family_test.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/generate/family_test.go b/internal/generate/family_test.go index 9dd9a8b..9fe3ecf 100644 --- a/internal/generate/family_test.go +++ b/internal/generate/family_test.go @@ -92,6 +92,13 @@ func TestClassifySyscallFamily(t *testing.T) { {"sys_exit_times", FamilyTime}, {"sys_enter_sched_yield", FamilySched}, {"sys_enter_openat", FamilyFS}, + // lseek(2) repositions the file offset of an open fd; it is a per-file + // positioning syscall and shares FamilyFS with its fd-based I/O siblings + // read/write/fsync (also FamilyFS). Assert both enter and exit so a stray + // reclassification trips this test. Keep in sync with the FS list in + // docs/syscall-tracing-plan.md. + {"sys_enter_lseek", FamilyFS}, + {"sys_exit_lseek", FamilyFS}, // access(2) checks the calling process's permissions for a file named by // a real filesystem path (pathname at args[0]; no dirfd). Its siblings // faccessat(2)/faccessat2(2) perform the same check relative to a dirfd |
