Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe the contribution
Fix #8
In order to make a useful library unit test example, the sample_lib itself needs to perform some more interesting work.
In particular it needs at least one external function call on which a code path decision is made, such that the example UT code will have more than one code path to demonstrate.
Additionally, the library should have some internal "global" structure (like real libs would) that contains its state, that the UT can also test/query.
Both objectives can be accomplished with a small string buffer that gets populated with a
strncpy()
call during init, and printed with the "process" command.Other minor updates for correctness:
SAMPLE_LibInit
) is not really a "private" function. It is called from ES when starting up. As such it should be considered part of the public API. This moves the prototype to the public API and corrects the comments so it is not labeled as a private function. Note this is also relevant for unit tests, because the UT will invoke the entry point too.Testing performed
Built code using SIMULATION=native ENABLE_UNIT_TESTS=TRUE
Confirmed no build issues, execute CFE and confirm that SAMPLE_Lib starts up as normal.
Force a call to the "SAMPLE_Function()" API and confirm that the printf now includes the buffer contents, as such:
SAMPLE_Function called, buffer='SAMPLE DATA'
Expected behavior changes
No changes of substance. Added display of the buffer contents to the OS_printf.
System(s) tested on:
Ubuntu 18.04 LTS 64-bit
Contributor Info
Joseph Hickey, Vantage Systems. Inc.
Community contributors
You must attach a signed CLA (required for acceptance) or reference one already submitted