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

Lengthen allowable unit test names #553

Open
asgibson opened this issue Jul 28, 2020 · 6 comments
Open

Lengthen allowable unit test names #553

asgibson opened this issue Jul 28, 2020 · 6 comments
Labels
enhancement question unit-test Tickets related to the OSAL unit testing (functional and/or coverage)

Comments

@asgibson
Copy link
Contributor

Describe the bug
Not sure if it is a bug, but why is the TestName length based upon OS_MAX_API_NAME*2 in utglobal.h?

To Reproduce
Steps to reproduce the behavior:

  1. Write a unit test with a name longer than OS_MAX_API_NAME*2
  2. Run tests and see that the test name is truncated

Expected behavior
Provide enough space for long (descriptive) test names.

Code snips

char TestName[OS_MAX_API_NAME*2];

char    TestName[OS_MAX_API_NAME*2];

System observed on:

  • PC
  • RHEl 7.6
  • current 'master' branch

Additional context
This is only an issue because I use long descriptive test names.

Reporter Info
Alan Gibson
GSFC, Code 587

@skliper
Copy link
Contributor

skliper commented Jul 28, 2020

Make it 120 and submit a PR?

@asgibson
Copy link
Contributor Author

That will solve my issue.

I am still curious if there is reasoning behind the setting. If there is a reason, then setting it to 120 may be breaking that. If there is not a reason then, I'll do it for sure.

@skliper
Copy link
Contributor

skliper commented Jul 28, 2020

Make it 128 to match CompleteTestName used in cFE for UT_AddSubTest. They don't have to match (safely truncates), but no point making it smaller.
Note

static char CurrentSegment[64];
should also be 128.
It's also 128 at
char ReportBuffer[128];

@asgibson
Copy link
Contributor Author

Excellent. Thank you for the review. I will change both and PR.

@asgibson
Copy link
Contributor Author

I cannot make the change because there is a conflict and we're entering a seesaw situation.
I request this be elevated to a higher level design discussion.

Blame reveals there was already a change to

static char CurrentSegment[64];

in #534 it changed from 128 to 64, also changed was this

char ReportBuffer[144];

ReportBuffer went from 128 to 144, but this is not

char ReportBuffer[128];

that was mentioned in this discussion.

@jphickey
Copy link
Contributor

I was responsible for making some of those size tweaks, and the reason is that newer GCC versions (e.g. 9+) are very aggressive about warning even the slightest possibility of a string truncation, even where the code handles the truncation perfectly fine.

Basically, the buffer has to get bigger at each step to accommodate the extra info added.

Nonetheless, this is the main risk of extending what seems like an unrelated buffer size - if it is copied or snprintf'ed into another buffer, then it might trigger a truncation warning where there was none before. Whatever change is made should be validated in either Ubuntu 20.04 or RHEL/CentOS 8 with BUILDTYPE=release to make sure it complies cleanly.

Perhaps these should all be converted to #define values in the header files to make it easier tweak in the future when needed.

@skliper skliper changed the title Unit test name allowable length too short Lengthen allowable unit test names Sep 9, 2020
@skliper skliper added the unit-test Tickets related to the OSAL unit testing (functional and/or coverage) label Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement question unit-test Tickets related to the OSAL unit testing (functional and/or coverage)
Projects
None yet
Development

No branches or pull requests

3 participants