Skip to content

Commit 00b5420

Browse files
committed
tests: align ffi gc trace expectation
1 parent 5bb41dd commit 00b5420

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

notes/ffi-gc-trace-expectation.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# FFI GC Trace Expectation
2+
3+
- `ffi.gc(cd, fn)` and `ffi.gc(cd, nil)` are currently interpreter fallback
4+
paths: `recff_ffi_gc()` raises `LJ_TRERR_NYICONV` rather than recording the
5+
public `ffi.gc` call.
6+
- `tests/t-ffi-gc-trace.lua` still expected three recorder traces, which was
7+
stale after the recorder was made NYI again. The remaining traced coverage is
8+
the metatype `__gc` allocation path, which still records through
9+
`crec_alloc()`/`crec_finalizer()` and emits `lj_cdata_setfin`.
10+
- The test now asserts at least one metatype finalizer trace and keeps direct
11+
`ffi.gc` / clear coverage as semantic checks.
12+
- The M7 suite still dump-checks `lj_cdata_setfin`, so loss of metatype
13+
finalizer recording remains visible.
14+
- Verification:
15+
- `tools/ci/lua_test.sh m7_ffi_finreg`

tests/t-ffi-gc-trace.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,22 @@ for _ = 1, rounds do clear_loop(n) end
5656
for _ = 1, rounds do metatype_loop(n) end
5757

5858
local traces = trace_count(64)
59-
assert(traces >= 3, "expected ffi.gc recorder traces")
59+
assert(traces >= 1, "expected metatype __gc recorder trace")
6060

6161
collectgarbage("restart")
6262
collectgarbage("collect")
6363
collectgarbage("collect")
6464

6565
local expected = rounds * n
6666
assert(direct_finalized == expected,
67-
("direct traced ffi.gc finalized %d, expected %d"):
67+
("direct ffi.gc finalized %d, expected %d"):
6868
format(direct_finalized, expected))
6969
assert(cleared_finalized == 0,
70-
("traced ffi.gc clear finalized %d, expected 0"):
70+
("ffi.gc clear finalized %d, expected 0"):
7171
format(cleared_finalized))
7272
assert(mt_finalized == expected,
7373
("traced ctype __gc finalized %d, expected %d"):
7474
format(mt_finalized, expected))
7575

76-
print(("t-ffi-gc-trace OK: %d traces, %d direct finalizers, %d metatype finalizers"):
76+
print(("t-ffi-gc-trace OK: %d metatype traces, %d direct finalizers, %d metatype finalizers"):
7777
format(traces, direct_finalized, mt_finalized))

0 commit comments

Comments
 (0)