testing/nettest: add checksum zero-length regression test - #3771
Open
imeghar2408-max wants to merge 1 commit into
Open
testing/nettest: add checksum zero-length regression test#3771imeghar2408-max wants to merge 1 commit into
imeghar2408-max wants to merge 1 commit into
Conversation
Add a CMocka regression test for zero-length checksum fragments. The test verifies that an empty IOB between fragments does not affect the checksum calculation or pending odd-byte state. Assisted by: GitHub Copilot
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
Add a CMocka regression test for the zero-length fragment handling issue in
checksum()reported in Apache NuttX issue #20010.When
checksum()is called withlen == 0while an odd byte is pending, theprevious implementation could read
data[0]even though the current fragmentcontained no valid bytes. It could also clear the pending odd-byte state.
The regression test covers this through the public
chksum_iob()path using:AA BB CC | empty fragment | DD EEand verifies that the chained checksum matches the checksum of the equivalent
contiguous data:
AA BB CC DD EEThis verifies that an empty fragment does not affect the checksum and that
the pending odd-byte state is preserved across the empty fragment.
Changes
test_others_chksum()regression test.testing/nettest/others/test_others.c.testing/nettest/others/test_others.h.testing/nettest/Makefile.testing/nettest/CMakeLists.txt.Impact
This change only adds a regression test to
nuttx-apps.It does not change runtime behavior or production code.
Validation
Regression test with the buggy implementation
The regression test was verified against the implementation without the
zero-length guard and failed as expected:
With the len == 0 handling fix restored, the test passed:
The mount failed: 20 message occurs during simulator startup and did not
prevent cmocka_net_others from running successfully.
Checkpatch
The corresponding NuttX fix was checked with the CI-style command:
Used config files: