Add unit tests for cansdo module#49
Merged
jsphuebner merged 2 commits intomasterfrom Apr 27, 2026
Merged
Conversation
Agent-Logs-Url: https://github.com/jsphuebner/libopeninv/sessions/64be9f23-b2d8-422e-8274-172a7d783561 Co-authored-by: jsphuebner <3882041+jsphuebner@users.noreply.github.com>
Agent-Logs-Url: https://github.com/jsphuebner/libopeninv/sessions/64be9f23-b2d8-422e-8274-172a7d783561 Co-authored-by: jsphuebner <3882041+jsphuebner@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
jsphuebner
April 27, 2026 10:25
View session
Owner
|
@davefiddes What do you think about these? |
Contributor
|
Not bad. I've not found AI generated tests up till now very good. It usually goes off and generates fragile nonsense. These look OK. Not massively deep but a solid basis for any future regressions. |
Owner
|
Alright, thanks for checking! |
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.
No tests existed for the
CanSdoSDO protocol implementation. This adds 26 test cases covering the full request/reply surface.New files
test/test_cansdo.cpp— test suite using the sameUnitTest/CanStubpattern astest_canmap.cpptest/test-include/errormessage_prj.h— minimal project header (ERROR_MESSAGE_LISTempty,ERROR_BUF_SIZE=10) required to compileerrormessage.cppin the host test environmentMakefile
Added
test_cansdo.o cansdo.o errormessage.o printf.otoOBJS.Test coverage
SDO_ERR_RANGE, invalid index →SDO_ERR_INVIDXSendSdoReplyclears itSetNodeIdactivates new IDGetPrintRequest()set on readInclude ordering workaround
The libopeninv
printf.hdeclaresprintf/sprintfwithoutextern "C", which conflicts with systemstdio.h(pulled in via<iostream>) on modern host compilers. The test file resolves this by including<cstdio>and forward-declaringIPutCharbeforecansdo.h, then settingPRINTF_H_INCLUDEDto prevent the problematic header from being re-processed:RX map verification
Because the test stub stores only the last-registered
CanCallback(CanSdo), delivering a raw CAN frame viacanStub->HandleRxwould not invoke CanMap's receive path. RX mapping acceptance is therefore verified withcanMap->FindMap()instead.