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

Add int32 UT assert macro #502

Closed
jphickey opened this issue Jun 15, 2020 · 0 comments · Fixed by #503 or #513
Closed

Add int32 UT assert macro #502

jphickey opened this issue Jun 15, 2020 · 0 comments · Fixed by #503 or #513
Assignees
Labels
enhancement unit-test Tickets related to the OSAL unit testing (functional and/or coverage)
Milestone

Comments

@jphickey
Copy link
Contributor

Is your feature request related to a problem? Please describe.
A very common use case in unit testing is to assert on an int32 value, as this is a common return value type for error codes and status values.

UT Assert provides a generic UtAssert_True() macro which can certainly test for integer equality, but it is still very repetitive and test cases may not include all the relevant information. For instance, the framework should encourage/require that the actual values are printed in addition to the pass/fail status, and the generic macro being totally free-form does not enforce this at all.

Describe the solution you'd like
Add a macro UtAssert_INT32_EQ() to check for equality of two values as int32 types.

Other types could be added too, but int32 is by far the most commonly needed as it is the return type of many API calls across OSAL and CFE.

Describe alternatives you've considered
Continue using the generic UtAssert_True() macro.

Additional context
Many test programs already use their own macros for testing return values. They've already evolved to be similar but different (e.g. CFE SB has ASSERT_EQ, and OSAL coverage testing has OSAPI_TEST_FUNCTION_RC()).

It would be worthwhile to put more of these in UT assert itself so these don't need to continue being duplicated.

Requester Info
Joseph Hickey, Vantage Systems, Inc.

jphickey added a commit to jphickey/osal that referenced this issue Jun 16, 2020
Add the following macros for UT assert:

UtAssert_INT32_EQ - check equality as 32 bit signed int
UtAssert_UINT32_EQ - check equality as 32 bit unsigned int
UtAssert_NOT_NULL - check pointer not null
UtAssert_NULL - check pointer is null
UtAssert_NONZERO - check integer is nonzero
UtAssert_ZERO - check integer is zero
UtAssert_STUB_COUNT - check stub count

These are all just wrappers around UtAssert_True for
commonly-used asserts.  The description message is
auto generated so it is consistent.
@jphickey jphickey self-assigned this Jun 16, 2020
astrogeco added a commit that referenced this issue Jun 17, 2020
@astrogeco astrogeco added this to the v5.1.0 milestone Sep 21, 2020
@astrogeco astrogeco added the unit-test Tickets related to the OSAL unit testing (functional and/or coverage) label Sep 28, 2020
jphickey added a commit to jphickey/osal that referenced this issue Aug 10, 2022
There is no need to store the main task name a second time in
the app record, as it is already stored in the task record.
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement unit-test Tickets related to the OSAL unit testing (functional and/or coverage)
Projects
None yet
2 participants