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

UT_SetDeferredRetcode doesn't work as explained in ut_support.c #997

Closed
skliper opened this issue Nov 3, 2020 · 1 comment · Fixed by #1112 or #1150
Closed

UT_SetDeferredRetcode doesn't work as explained in ut_support.c #997

skliper opened this issue Nov 3, 2020 · 1 comment · Fixed by #1112 or #1150
Labels
bug docs This change only affects documentation. unit-test
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Nov 3, 2020

Describe the bug

/*
* Set up for the CFE_SB_RcvMsg() call.
*
* The existing test cases assume that this will return success once,
* followed by a timeout response followed by a different error.
*
* Specific test cases may provide an actual message buffer to return for
* the first call, or they may override this default behavior entirely.
*
* The default behavior of the CFE_SB_RcvMsg stub is to return success with a zero-ed out
* buffer returned to the caller.
*/
UT_SetDeferredRetcode(UT_KEY(CFE_SB_RcvMsg), 2, CFE_SB_TIME_OUT);
UT_SetDeferredRetcode(UT_KEY(CFE_SB_RcvMsg), 3, -1);

Description above makes it sound like calls to CFE_SB_RcvMsg will return: 0, CFE_SB_TIME_OUT, -1. In practice it returns 0, CFE_SB_TIME_OUT, 0, 0, -1 since each call to UT_SetDeferredRetcode sets up another entry in the table, and each entry is processed until complete before moving on to the next (which restarts the counter).

The osal description is clear, it's just not used correctly in cFE:
https://github.com/nasa/osal/blob/5a8f0afa3a6ef6945661d6fc893d4592d9360b5a/ut_assert/inc/utstubs.h#L120-L139

To Reproduce
Set more than one UT_SetDeferredRetcode on the same key, observe response.

Expected behavior
Set up so it will do 0, CFE_SB_TIME_OUT, -1:

    UT_SetDeferredRetcode(UT_KEY(CFE_SB_RcvMsg), 2, CFE_SB_TIME_OUT);
    UT_SetDeferredRetcode(UT_KEY(CFE_SB_RcvMsg), 1, -1);

Code snips
See above

System observed on:

  • Hardware: cFS Dev Server
  • OS: Ubuntu 18.04
  • Versions Bundle main

Additional context
None.

Reporter Info
Jacob Hageman - NASA/GSFC

@skliper
Copy link
Contributor Author

skliper commented Nov 3, 2020

Turns out nothing actually depended on the 0, CFE_SB_TIME_OUT, -1 behavior, it's just misleading. Alternative solution could be to delete the -1 (if nothing uses it).

@skliper skliper changed the title UT_SetDefferedRetcode doesn't work as explained in ut_support.c UT_SetDeferedRetcode doesn't work as explained in ut_support.c Nov 3, 2020
@skliper skliper changed the title UT_SetDeferedRetcode doesn't work as explained in ut_support.c UT_SetDeferredRetcode doesn't work as explained in ut_support.c Nov 3, 2020
skliper added a commit to skliper/cFE that referenced this issue Jan 21, 2021
skliper added a commit to skliper/cFE that referenced this issue Jan 27, 2021
@astrogeco astrogeco added bug docs This change only affects documentation. unit-test and removed enhancement labels Jan 27, 2021
@astrogeco astrogeco added this to the 7.0.0 milestone Jan 27, 2021
astrogeco added a commit that referenced this issue Jan 27, 2021
Fix #997, Simplify UT_InitData SB setup
astrogeco added a commit that referenced this issue Feb 3, 2021
Fix #997, Simplify UT_InitData SB setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug docs This change only affects documentation. unit-test
Projects
None yet
2 participants