Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #1055 - CFE_SB_ReceiveBuffer stub returns timeout or empty if buffer #1061

Conversation

CDKnightNASA
Copy link
Contributor

Closes #1055

This changes the return value returned by the CFE_SB_ReceiveBuffer() stub when there has not been a buffer defined.

Testing performed
Tested with SB and SBN unit tests.

Contributor Info - All information REQUIRED for consideration of pull request
Christopher.D.Knight@nasa.gov

@CDKnightNASA CDKnightNASA self-assigned this Jan 5, 2021
@CDKnightNASA CDKnightNASA added the CCB:Ready Ready for discussion at the Configuration Control Board (CCB) label Jan 5, 2021
@skliper
Copy link
Contributor

skliper commented Jan 5, 2021

How about only setting the return codes if status is != 0?

I'd expect if I force the return code (non-zero) it should always work... currently it would override any non-zero forced return code.

@CDKnightNASA
Copy link
Contributor Author

How about only setting the return codes if status is != 0?

I'd expect if I force the return code (non-zero) it should always work... currently it would override any non-zero forced return code.

Good question, I can see if I can figure out if the default return value has been changed or deferred and not override the return value if it has...But are there cases where someone would override the return value and not provide a buffer?

@skliper
Copy link
Contributor

skliper commented Jan 5, 2021

How about only setting the return codes if status is != 0?
I'd expect if I force the return code (non-zero) it should always work... currently it would override any non-zero forced return code.

Good question, I can see if I can figure out if the default return value has been changed or deferred and not override the return value if it has...But are there cases where someone would override the return value and not provide a buffer?

All I was thinking is for the if (UT_Stub_CopyToLocal <= 0), add && status == 0 prior to modifying the return status code locally

@jphickey
Copy link
Contributor

jphickey commented Jan 5, 2021

FYI - When a stub needs to "know" if a return code was explicitly set by the test case or not, easiest way is to use a "sentinel" value that differs from the default or any other known error, i.e. INT32_MAX or something like that. Use the UT_DEFAULT_IMPL_RC() macro to do this. If the status comes back as that same sentinel value, it means the test case did not set a status.

@skliper
Copy link
Contributor

skliper commented Jan 5, 2021

After letting it sink in a bit - I'm actually OK with it as is if you want. Like it was said, there probably isn't a valid use case for a >= 0 forced return value if the buffer wasn't set.

Copy link
Contributor

@jphickey jphickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My recommendation is to minimize the amount of "special sauce" in the stubs, such as special return codes, whenever possible. This special info should be in the test case setup, not in the stub. The exceptions to this are where we had existing test cases that depended on the stub behaving a certain way (such as several TIMEOUT responses, in the case of the old CFE_SB_RcvMsg). But since this is a new stub, we shouldn't have to do that hack.

In cases where there is an output data buffer required then the stub just contains an internal one (i.e. a static local variable) and that is output/returned if the test case didn't register one. It can be just zeroed out.

But at the end of the day, returning CFE_SUCCESS is fine, if the test case didn't register anything. By definition, if the test case actually cares about having a specific/non-success error code from this function, it should register that status code in its setup.

@astrogeco astrogeco added CCB-20210106 CCB:Approved Indicates code review and approval by community CCB unit-test and removed CCB:Approved Indicates code review and approval by community CCB labels Jan 6, 2021
@astrogeco
Copy link
Contributor

CCB 2021-01-06 MODIFY

  • Avoid having "special sauce" in stubs and keep them as generic as possible and only do what the test requires

@CDKnightNASA
Copy link
Contributor Author

20200106 - CCB rejected, suggested correcting documentation to remove reference to timeout, cdknight will re-create pull to correct comments.

@CDKnightNASA CDKnightNASA removed the CCB:Ready Ready for discussion at the Configuration Control Board (CCB) label Jan 6, 2021
@CDKnightNASA CDKnightNASA force-pushed the fix-1055-receivebuffer_stub_returnval branch from 32381af to 54e1187 Compare January 6, 2021 17:17
@skliper skliper added the CCB:Ignore Pull Request can be ignored. Will be re-examined at by next CCB. label Jan 26, 2021
@astrogeco
Copy link
Contributor

@CDKnightNASA have you worked on refactoring this?

@skliper
Copy link
Contributor

skliper commented Jun 29, 2021

This is OBE, erroneous documentation was removed as part of stub refactor (update to stub/handler model).

@skliper skliper closed this Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCB:Ignore Pull Request can be ignored. Will be re-examined at by next CCB. duplicate unit-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

return value of CFE_SB_ReceiveBuffer stub does not match documentation
4 participants