Repository navigation
test: sweep the decode paths a single instantiation leaves unrun (77% -> 93%) - #113
Merged
Merged
Conversation
… -> 93%) gcovr reported 77.1% line coverage of include/sofab/sofab.hpp. Almost all of the gap was one shape of hole: the header is templates, gcov counts every instantiation separately, and a case written once for one destination type leaves the same case unexecuted for every other one. So the additions here are swept rather than enumerated -- written once, run per type. - readArray / readIntElements: the whole §7 decision matrix per element type and destination shape. The tag (§7.3), the declared `count` (§7.1, INVALID), the configured policy cap (#102, LimitExceeded and deliberately not INVALID), the destination's own capacity (#81, and which of the two verdicts it earns), the declared element width applied per element, a >64-bit varint (§4.1) both in a stored element and out in the surplus, a payload cut mid-array and cut inside an element's varint, and every one of it again one byte at a time -- which is what runs the checked element loops instead of the windowed ones. - IStreamObject::reset(): destinationReuse() pinned it for one message type; reset() is a template that re-initialises the owned message, so every message type the suite declares now gets the contract checked on its own instantiation -- the buffered partial field dropped, the latched terminal INVALID cleared (§5.2). - §7.2 item 4: a set of real messages -- every wrapper-array collector and both nesting forms in one, a nested sub-message field, a gapped sub-message array, every scalar wire form, a varint and a fixlen array -- fed at every split point and one byte at a time, each restart landing on the same values. - §6.4 across chunk boundaries: the invalid sequence begins at an offset at or past everything fed so far, which the shared invalid_utf8 vectors never reach. A validator that only looks at the chunk in hand, or resumes from the wrong offset, reports COMPLETE there. Swept over both destination kinds (std::string and FixedString), with a blob and a skipped string as the controls §6.4 exempts. Line coverage 77.1% -> 93.4%, functions 90.2% -> 99.7%, branches 52.0% -> 67.6%. What is left is dominated by per-instantiation dead code: the element bound in a dispatch for a callback that publishes none, the SequenceEnd reject in a level that is never the top one, and MAX_DEPTH in a message type that is not the one nested 255 deep. No library change.
Member
Author
|
Note on the two coverage numbers, since the CI log and the PR body disagree. Both are
The per-instantiation view is the one this PR is written against: it is what makes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
gcovrreported 77.1 % line coverage ofinclude/sofab/sofab.hpp. Almost all ofthe gap had one shape: the header is templates, gcov counts every instantiation
separately, and a case written once for one destination type leaves the same case
unexecuted for every other one. The additions here are therefore swept rather
than enumerated — written once, run per type.
Measured with this repo's own tooling, exactly as
.github/workflows/coverage.yamlruns it.
The four sweeps
arrayDecodeSweep()—readArray/readIntElementsdriven through the whole§7 decision matrix, per element type and destination shape: the tag (§7.3), the
declared
count(§7.1 →INVALID), the configured policy cap (generator#102 →LimitExceeded, deliberately notINVALID), the destination's own capacity(issue MESSAGE_SPEC 3: readArray silently truncates an unbounded array to the destination's capacity and still reports COMPLETE #81, including which of the two verdicts it earns), the declared element
width applied per element, a >64-bit varint (§4.1) both in a stored element and out
in the surplus, a payload cut mid-array and cut inside an element's varint — and
each of them again one byte at a time, which is what runs the checked element loops
instead of the windowed ones.
checkStreamReuse<M>()—destinationReuse()pinnedreset()for one messagetype.
IStreamObject::reset()is a template that re-initialises the owned message,so every message type the suite declares now gets the contract checked on its own
instantiation: the buffered partial field dropped, the latched terminal
INVALIDcleared (§5.2 — terminal for the message, not for the object).
chunkIndependence()— §7.2 item 4. Real messages (every wrapper-arraycollector and both nesting forms in one, a nested sub-message field, a gapped
sub-message array, every scalar wire form, a varint array and a fixlen array) fed at
every split point and one byte at a time, each restart landing on the same
values. A cut inside a sub-message abandons the level where it began and the whole
top-level field is re-delivered, and that restart is instantiated per callback type.
utf8AcrossChunkBoundaries()— the known gap. The sharedinvalid_utf8vectorsnever place the invalid sequence at a chunk offset at or beyond the total fed so
far; a validator that only looks at the bytes in hand, or resumes a payload from the
wrong offset, reports
COMPLETEthere. Swept over both destination kinds(
std::stringand the heap-freeFixedString), with the blob payload and theskipped string as the controls §6.4 exempts, and a valid 4-byte sequence in the same
position as the control that says the verdict comes from the bytes and not from the
chunking.
What is still uncovered, and why
The remaining ~6.6 % is dominated by code that is dead per instantiation and cannot
be reached by feeding bytes:
dispatchLevel's element-index bound (elemBound_ >= 0 && elemWire_ >= 0) in adispatch instantiated for a callback that publishes neither — a plain nested message
sets both to −1 before descending;
SequenceEndreject, which only fires withstopAtEnd == false, i.e. only inthe top-level instantiation;
MAX_DEPTHguard inread<T>for every message type that is not the onemaxDepth()nests 255 deep;readArray's grow clamp in the instantiations whose elementtype is never fixlen-framed.
Padding those would mean 255-deep wires per message type and collectors declared only
to reach a branch, which is not worth having.
Notes
include/sofab/sofab.hppis untouched. Every new check passes onmain's header — they cover behaviour that was right and untested.build; the fixlen-array test wire is written little-endian explicitly, so the
big-endian ppc64 leg sees the same bytes.
test_roundtripdescription gained a paragraph on the four sweeps.