imeghar2408-max opened a new pull request, #3771:
URL: https://github.com/apache/nuttx-apps/pull/3771
## 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 with `len == 0` while an odd byte is pending, the
previous implementation could read `data[0]` even though the current fragment
contained 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 EE`
and verifies that the chained checksum matches the checksum of the equivalent
contiguous data:
`AA BB CC DD EE`
This verifies that an empty fragment does not affect the checksum and that
the pending odd-byte state is preserved across the empty fragment.
## Changes
- Add `test_others_chksum()` regression test.
- Register the test in `testing/nettest/others/test_others.c`.
- Add its declaration to `testing/nettest/others/test_others.h`.
- Add the test source to `testing/nettest/Makefile`.
- Add the test source to `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:
```text
[ RUN ] test_others_chksum
[ ERROR ] --- 30617 != 30396
[ LINE ] --- others/test_others_chksum.c:52
[ FAILED ] test_others_chksum
Regression test with the fix applied
````
With the len == 0 handling fix restored, the test passed:
```text
nsh: mount: mount failed: 20
nsh> cmocka_net_others
[==========] others_tests: Running 2 test(s).
[ RUN ] test_others_bufpool
[ OK ] test_others_bufpool
[ RUN ] test_others_chksum
[ OK ] test_others_chksum
[==========] others_tests: 2 test(s) run.
[ PASSED ] 2 test(s).
````
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:
````text
1: .codespellrc
✔️ All checks pass.
````
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]