mirror of
https://github.com/Cacti/spine.git
synced 2026-10-23 03:27:10 +09:00
The three unit binaries in `tests/unit/` do not test the code that ships. `test_safety_fixes.c` says so in its own header: > the functions under test are inlined (or their exact predicate replicated) so this translation unit compiles standalone without linking util.o/ping.o/php.o and dragging in MySQL/SNMP That keeps them cheap, but a fix can land in `util.c` while the test carries on passing against its private copy. The 39 assertions currently guarantee less than they appear to. This adds a fourth binary that links the real translation units. `tests/fuzz/stubs.c` already solves the hard part for the fuzz targets by supplying the globals `spine.c` would define, so the same file is reused here. Everything except `spine.c` is linked as built. **Demonstration.** Reverting `strncopy()` to the issue#447 off-by-one and running the suite: ``` PASS: tests/unit/test_util_strings PASS: tests/unit/test_build_fixes PASS: tests/unit/test_safety_fixes FAIL: tests/unit/test_linked # TOTAL: 4 # PASS: 3 # FAIL: 1 ``` The three existing suites do not notice. Only the linked one does. Seven cases to start, covering `strncopy()` bounds and termination and `regex_replace()` match/no-match/bad-pattern. The point of the PR is the harness rather than the case count: with this in place, future tests can assert against real behaviour, and the existing binaries can migrate over one at a time. Verified in a clean `ubuntu:24.04` container: builds at 4 warnings matching develop, `make check` passes 4/4, `make distcheck` passes. --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>