Conversation
- Map block: size BlockInfo entries from the Map's block_size instead of trusting block_count, whose convention varies by vendor and issue (Issue 2 counts the Map block; Issue 1 does not; Anritsu MT9090A mixes them). - Make the per-block 'BlockName\0' prefix optional: Issue 2 (rev 2.50) writes it, Issue 1 (rev 2.00) files from older/simpler equipment omit it.
Synthesises an Issue 1 style file from the EXFO MaxTester fixture by decrementing block_count so it no longer includes the Map block, and checks that every BlockInfo entry is still read and the parsed content matches the unmodified fixture. Fails on the previous count-based Map parsing, passes with block_size-based sizing.
|
good good |
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.
Summary
Makes the parser accept SR-4731 files whose Map block follows the Issue 1 conventions, without changing behaviour for the Issue 2 files the test suite already covers.
Two related changes in
src/parser.rs:Size the Map's BlockInfo table from
block_size, notblock_count.block_countis not consistent across vendors and issues: Issue 2 (rev ≥ 2.50) files count the Map block itself, Issue 1 (rev 2.00) files count only the blocks that follow, and some Issue 1 vendor files use the Issue 2 convention anyway. The current code readsblock_count - 1entries, which under-reads by one on files that use the Issue 1 convention; the unread entry (usuallyCksum) is then encountered whereGenParamsis expected and parsing fails.block_size, on the other hand, has been the total byte length of the Map block in every file I have seen, so the table is now consumed until that length is exhausted (stopping at trailing zero padding).block_countis still parsed and retained verbatim inMapBlockfor fidelity.Treat the per-block
BlockName\0prefix as optional.Issue 2 prefixes each data block with the same identifier the Map already carries; Issue 1 files from older or simpler equipment omit it.
maybe_block_headerconsumes the prefix when present and no-ops when absent, so one code path handles both. The following fields are still parsed strictly, so a genuinely misplaced block still fails.Motivation
Six EXFO FTB-series rev 2.00 traces from a production fibre plant fail to parse on 1.1.1 with
Their Map has
block_count = 7and seven BlockInfo entries after the Map (GenParams, SupParams, FxdParams, KeyEvents, DataPts, a proprietary EXFO block, Cksum) inside ablock_sizeof 135, i.e. the Issue 1 convention. With this change all six parse, and every fixture indata/produces identical output before and after.I can't redistribute those traces, so the regression test synthesises the same shape from the existing
example2-exfo-maxtester730c.sorfixture by decrementingblock_count(the BlockInfo table andblock_sizeare untouched, which is exactly what the failing files look like). The test fails onmainand passes with this change.Testing
cargo test: 23 passed (22 existing + newtest_map_block_count_excluding_map_block).data/fixtures plus a Viavi/JDSU rev 2.50 file with 15 blocks before and after; identicalMapBlock, key-event and data-point output.Happy to adjust naming or split the two changes into separate commits if you'd prefer to take only the Map sizing.