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 Assert argument name association #479

Closed
jphickey opened this issue May 20, 2020 · 0 comments · Fixed by #480 or #487
Closed

Ut Assert argument name association #479

jphickey opened this issue May 20, 2020 · 0 comments · Fixed by #480 or #487
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.
UT assert passes "static" function arguments to hook functions as an array of opaque pointers, based on the order of calls to the UT_Stub_RegisterContext() API inside the stub. This is basically equivalent to argc/argv on a command line.

This requires test cases to "know" which position the argument they need to access is in, and basically hard-code that number. This could become more problematic if hook functions are used more frequently.

Describe the solution you'd like
Offer a variant of UT_Stub_RegisterContext() that also stores the argument name, and offer a "getter" that a hook function can use in order to get by that name.

Registering and retrieving values by name will provide greater stability as the APIs and test cases evolve over time.

The downside is that its slower and uses more memory to look up based on name, but that doesn't matter much for UT.

Describe alternatives you've considered
Leave as is using number/sequence based args. It works but concerned it's too easy to get out of sync.

Additional context
Could also use some macros to make both the register (stub-side) and get (hook-side) operations a little more user-friendly.

Requester Info
Joseph Hickey, Vantage Systems, Inc.

jphickey added a commit to jphickey/osal that referenced this issue May 21, 2020
Add the capability to store parameter names in addtion
to pointers as part of the stub argument context data.

Macroize the UT_Stub_RegisterContext function utstubs.h to
also pass the parameter name in addition to the pointer.

Also add hook-side accessor functions/macros to make it
easier and more reliable to get this information from
the context data.
astrogeco added a commit that referenced this issue Jun 2, 2020
Fix #479, add name association to stub arguments
@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 pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
Integration Candidate 20200108
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
3 participants