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

Incorrect loop bounds in UT_CheckEventHistoryFromFunc #1090

Closed
jphickey opened this issue Jan 12, 2021 · 0 comments · Fixed by #1091 or #1109
Closed

Incorrect loop bounds in UT_CheckEventHistoryFromFunc #1090

jphickey opened this issue Jan 12, 2021 · 0 comments · Fixed by #1091 or #1109
Assignees
Milestone

Comments

@jphickey
Copy link
Contributor

Describe the bug
Incorrect check for events in Unit test code in UT_CheckEventHistoryFromFunc() helper routine. The event storage is an array of event IDs (uint16) but stored in a generic byte buffer. This forgets to divide the Position (which is in bytes) by sizeof(uint16) when reading this, so it ends up checking double the number of entries it is supposed to.

After fixing this issue, it also exposes that some tests in TBL unit tests are also broken.

To Reproduce
Found by inspection.

Expected behavior
Should check the correct number of events.

Code snips
Loop at issue is here:

while (Position > 0)
{
if (*EvBuf == EventIDToSearchFor)
{
Result = true;
break;
}
++EvBuf;
--Position;
}

System observed on:
Ubuntu 20.04

Reporter Info
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey self-assigned this Jan 12, 2021
@jphickey jphickey added the bug label Jan 12, 2021
jphickey added a commit to jphickey/cFE that referenced this issue Jan 12, 2021
Divide the "position" (in bytes) by the size of the event IDs
to get the number of events.

Also correct bad event checks in TBL UT.
astrogeco added a commit that referenced this issue Jan 21, 2021
@astrogeco astrogeco added this to the 7.0.0 milestone Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants