Update & improve coverage: add mapport tests #232
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improved Mapport Coverage
mapport: add hook-based seam for PCP/UPnP, expand unit tests, improve coverage; exclude seam header from coverage
Motivation / Context
mapportthread manages NAT traversal (PCP/NAT-PMP/UPnP) and historically had limited, flaky coverage because tests could trigger real network I/O and OS firewalls.mapportlifecycle and PCP control-flow without opening sockets, and a clean coverage report without noise from glue code.What’s changed
mapport_hookswith function-pointer variables that default to real implementations.mapport_hooks::QueryDefaultGatewayFnmapport_hooks::PCPRequestPortMapFnmapport_hooks::NATPMPRequestPortMapFnmapport_hooks::GetLocalAddressesFnsrc/mapport.cppnow invokes these hooks instead of calling the functions directly insideProcessPCP()and related logic. No behavior change in production: the hooks point to the real functions by default.mapport:StartMapPort,InterruptMapPort,StopMapPort), dispatch toggling, idempotent starts, and key branches inProcessPCP().BasicTestingSetupfixture for required global initialization.src/mapport_hooks.hfiltered incmake/script/CoverageInclude.cmake.in.--output-on-failureand explicitly ensuresmapport_testsexecute during coverage, so unit-test hits always contribute to the HTML reports.Before
After