test: M4.0 allocator-threading regression coverage
Two regression tests pinning down the silent-error surface in M4.0:
ffi-objc-arc-00 — single sx-defined-class instance round-trips
through a TrackingAllocator-wrapped GPA. Captures alloc/dealloc
deltas around the lifecycle, verifies (+1, +1). Pre-M4.0 the +alloc
IMP used libc malloc and -dealloc used libc free; tracker would
have observed (+0, +0) and missed the leak silently.
ffi-objc-arc-00b — three instances alloc'd and released. Catches
bugs where:
- the captured allocator becomes shared (one global slot vs
per-instance);
- alloc captures the wrong allocator on the 2nd+ instance;
- dealloc reads garbage if state[0] is overwritten between
instances.
Both tests are macos-only (libobjc + NSObject must be present at
runtime). Both wrap the lifecycle in `push Context.{ allocator =
xx tracker }` so the threading path is exercised.
Important authoring note: `print` inside the push-block also routes
through tracker (string formatting allocs), polluting the leak
delta. Tests capture before/after counts WITHOUT any prints between
alloc and release, then verify the BALANCE — every alloc paired
with a dealloc — rather than absolute counts. Discovered while
writing 00: an initial naive "leak_count() == 0" assertion failed
not because M4.0 was broken but because print's string allocs
weren't freed at scope exit.
187/187 example tests pass.
This commit is contained in:
1
tests/expected/ffi-objc-arc-00-allocator-thread.exit
Normal file
1
tests/expected/ffi-objc-arc-00-allocator-thread.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
1
tests/expected/ffi-objc-arc-00-allocator-thread.txt
Normal file
1
tests/expected/ffi-objc-arc-00-allocator-thread.txt
Normal file
@@ -0,0 +1 @@
|
||||
allocator round-trip: ok
|
||||
1
tests/expected/ffi-objc-arc-00b-multi-instance.exit
Normal file
1
tests/expected/ffi-objc-arc-00b-multi-instance.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
1
tests/expected/ffi-objc-arc-00b-multi-instance.txt
Normal file
1
tests/expected/ffi-objc-arc-00b-multi-instance.txt
Normal file
@@ -0,0 +1 @@
|
||||
multi-instance round-trip: ok
|
||||
Reference in New Issue
Block a user