Would the tests notice a planted change in the MAVLink C parser?

Hi all, I ran a small experiment on the MAVLink C parser (c_library_v2, commit 56f6435e). I planted 40 small changes into the code and checked which of them the existing tests notice. 22 were noticed and 18 were missed, and I documented every missed one. The 2019 Auterion work on fuzzing this parser asks whether random input finds a bug. My question is a different one: if a bug appeared in a pull request, would the tests notice it? I would like honest criticism of my method. Is a planted change a fair way to measure this, and which of the missed ones would you call equivalent and not worth a test? I am also curious how teams here check the quality of their parser tests today. The report and the tests I added as a pull request are public, and I can share the links.

Hi Yannik,

Thanks for sharing this experiment. I think the question you are asking is particularly valuable for a protocol parser.

Fuzzing and mutation testing provide complementary evidence.

Fuzzing asks whether generated inputs expose unexpected behavior. Mutation testing asks whether the existing test suite can distinguish the intended implementation from plausible faulty implementations.

Your result of 22 detected changes out of 40 is interesting, but I would be careful about interpreting the raw 55% detection rate without first classifying the surviving mutants.

I would suggest separating the results into four categories:

  1. Killed by behavioral assertions: A test detected an incorrect parser result.

  2. Killed by compilation or runtime failure: The mutation was detected, but not necessarily through a meaningful protocol assertion.

  3. Survived with observable behavioral differences: A strong candidate for an additional regression test.

  4. Equivalent or effectively unobservable: A mutation that may not justify another test.

For the surviving mutants, I would pay particular attention to:

  • MAVLink v1/v2 framing and payload-length validation.

  • CRC verification and malformed frames.

  • Parser state transitions after incomplete or corrupted messages.

  • Sequence handling and recovery after errors.

  • MAVLink 2 signing-related behavior, where applicable.

One methodological question: were all 40 mutations evaluated independently against the same baseline, with the same build configuration and test environment?

It would also be useful to know whether your experiment included mutation-specific behavioral assertions or relied entirely on the existing test suite.

My recommendation would be to publish a small mutation matrix containing the modified condition, expected behavioral difference, observed test result, and equivalence assessment.

That would make the findings reproducible and help maintainers prioritize the most meaningful missing tests.

I’d be interested in reviewing the report and your test PR if you share the links.

Best regards,
Yiğitcan Öztürk
PAMILANGA LIMITED

Hi Yiğitcan,

thank you, this is useful. Your four categories are close to how I sorted the 18 missed ones, so I will use them in the next update.

To your questions:

  1. Yes, each of the 40 changes was built on its own from the same baseline commit (56f6435e), with the same container, compiler (clang 18.1.3) and sanitizer setting. The build configuration is in thread 49575.
  2. The 22 of 40 comes only from the existing tests, no mutation specific assertions. The tests I wrote afterwards are a separate measurement (different compiler, no sanitizer) and are not mixed into the 22.

On the 18 missed ones: 15 now have a test that fails on the changed code and passes on the original (10 of them are in the PR), 2 look equivalent after a full comparison, and 1 is still open.

Links:

Report and build configuration: How do you check that your tests notice changes in MAVLink input handling?

Test PR: generator: C: add extended-header runtime regression tests by b6bs62fhys-jpg · Pull Request #1305 · ArduPilot/pymavlink · GitHub

A mutation matrix is a good idea. I will add it when I update the report.

Best regards,

Yannik

Hi Yannik,

Thanks for the detailed follow-up. The clarification about the independent baseline builds and the separation between the original test results and the subsequently added regression tests is particularly valuable.

The progress on the 18 surviving mutations is encouraging: 15 now have distinguishing tests, two appear equivalent, and one remains unresolved.

I also reviewed ArduPilot/pymavlink PR #1305. It’s good to see the regression tests integrated into the pytest workflow and the earlier review blockers addressed.

For the next mutation matrix, I think it would be useful to distinguish:

  • Detected by the original test suite

  • Detected by newly added regression tests

  • Equivalent or likely equivalent, with supporting justification

  • Still unresolved

This would preserve the original 22/40 baseline while showing how the follow-up work improves effective detection coverage.

For the remaining unresolved mutation, a minimal reproducer showing the mutated code path, expected observable behavior, and whether the input can reach that path would be especially useful.

One additional consideration is maintaining comparable compiler and sanitizer configurations when reporting before/after improvements.

Thanks again for sharing such a reproducible investigation. This is a valuable contribution to MAVLink parser testing.

Best regards,
Yiğitcan Öztürk
PAMILANGA LIMITED

Here is the matrix. All counts are for the same target: MAVLink c_library_v2, commit 56f6435e, 40 planted changes.

Detected by the original test suite: 22 (clang 18.1.3, sanitizer on, corpus_seeds)

Detected only by newly added tests: 15 (gcc, assertions, no sanitizer, original green and changed version red in 3 of 3 runs, 10 of these tests are in pymavlink PR 1305)

Equivalent: 2 (lines 591 and 596, compared in full)

Still open: 1 (line 418, so far only reasoned about, no reproducer yet)

Please note that the 15 come from a different build than the 22, so the two numbers should not be added up as one measurement. The 22 also depends on the corpus used. A minimal reproducer for line 418 is the next thing I will work on.

Hi Yannik,

Thanks for the update. That sounds like a good approach.

Keeping the existing library results as the baseline and confirming the appropriate location with the maintainers before submitting new tests should make the contribution easier to review and maintain.

I’d be happy to review your pull request once it’s ready.

In particular, I can help check the raw-byte test coverage, expected parser behavior, regression assertions, and whether the tests clearly distinguish the original implementation from the modified behavior.

Please share the PR link when you open it.

Looking forward to collaborating on this.

Best regards,
Yiğitcan Öztürk
PAMILANGA LIMITED

Thanks, that would help a lot. The PR is already open: generator: C: add extended-header runtime regression tests by b6bs62fhys-jpg · Pull Request #1305 · ArduPilot/pymavlink · GitHub (one commit, C tests under generator/C/test/mutation_parser and a pytest runner, tests/test_c_parser_regression.py). The automated ArduPilot review has run on the current head and its blocker is resolved. One small comment fix is still to follow.

Where I would value your eyes most: the raw byte cases, whether the expected parser behaviour is right, and whether the assertions really separate the original from the mutated behaviour.

I am still working on the minimal reproducer for the open mutation at line 418 and will post it here.

Hi Yannik,

Thanks for sharing PR #1305. I’ve reviewed the current diff, including both C test files and the pytest runner.

The approach looks promising. In particular, constructing raw MAVLink frames, using a separate CRC implementation, and exercising mavlink_parse_char() byte by byte provides a useful regression-testing foundation.

I also confirmed that the runner covers both configurations of MAVLINK_CHECK_MESSAGE_LENGTH, which is important because different mutations are detected by different configurations.

A few suggestions from my review:

  1. For the malformed CRC and unknown-message cases, consider checking the expected framing outcome more explicitly, rather than relying only on parse_error > 0. This would help demonstrate that the intended parser behavior is being tested.

  2. For mutation evidence, a compact mapping of each mutation to its triggering input, expected assertion, and observed original-versus-mutant outcome would make the results easier to reproduce and independently review.

  3. In convenience_sender_test.c, adding an output-buffer capacity assertion before memcpy() would make the test harness more robust against unexpected sender behavior.

These are review suggestions rather than confirmed blockers. I haven’t independently executed the tests yet.

I also saw that the latest automated review no longer reports a blocker. The remaining sender-function comment correction looks straightforward.

For the open mutation at line 418, please share the minimal reproducer when ready. I would be particularly interested in confirming the exact input, the parser state transition, and whether the mutation produces an observable behavioral difference.

Thanks for involving me. I’m glad to contribute to the technical review.

Best regards,
Yiğitcan Öztürk
PAMILANGA LIMITED

Thanks, this is very useful. I will fold your points into a follow-up commit on the PR: explicit framing assertions for the CRC and unknown message cases instead of only checking parse_error > 0, a capacity check before the memcpy in convenience_sender_test.c, and the comment fix I mentioned. I will also add a table that maps each mutation to its input, assertion and result. The minimal reproducer for line 418, with exact input, parser state transition and observable difference, will follow in this thread when it is ready. Understood that none of this is a confirmed blocker and that you have not run the tests yet.