unit tests: extract "private" prototypes at build time

In order to do unit tests for private functions, functions that are
marked UNITTEST but without a global scope in the library, functions
that do not have prototypes in their corresponding header file, unit
tests previously brought their own private prototype *copy* into the
unit test.

This was error-prone when the internal function changes but the change
might be missed in the unit test which then uses an outdated prototype
copy for testing.

This change removes the private prototypes from unit tests and instead
introduces a C file parser that parses the specific C files and extracts
the necessary unit test prototypes into a generated header file for unit
tests to use. This geneated lib/unitprotos.h header is then included by
unit tests that need private prototypes.

Assisted-by: Viktor Szakats
Closes #17750
This commit is contained in:
Daniel Stenberg 2025-06-29 14:33:13 +02:00
parent 48d3407d7c
commit c9bb9cd165
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
10 changed files with 125 additions and 13 deletions

View file

@ -25,7 +25,7 @@
EXTRA_DIST = coverage.sh completion.pl firefox-db2pem.sh checksrc.pl checksrc-all.sh \
mk-ca-bundle.pl mk-unity.pl schemetable.c cd2nroff nroff2cd cdall cd2cd managen \
dmaketgz maketgz release-tools.sh verify-release cmakelint.sh mdlinkcheck \
CMakeLists.txt pythonlint.sh randdisable wcurl top-complexity
CMakeLists.txt pythonlint.sh randdisable wcurl top-complexity extract-unit-protos
dist_bin_SCRIPTS = wcurl