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 logic to sample_lib for UT #10

Merged
merged 1 commit into from
Dec 30, 2019
Merged

Conversation

jphickey
Copy link
Contributor

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:

  • The entry point (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.
  • Corrects a missing newline on the OS_printf during startup. This was a long-standing pet peeve.

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

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.
@skliper skliper added the CCB:Approved Indicates code review and approval by community CCB label Dec 18, 2019
@skliper
Copy link
Contributor

skliper commented Dec 18, 2019

CCB 20191218 - Reviewed and approved for IC

@skliper skliper changed the base branch from master to ic-20191230 December 30, 2019 18:21
@skliper skliper merged commit da4f56d into ic-20191230 Dec 30, 2019
@skliper skliper deleted the fix-8-add-conditionals branch December 30, 2019 18:22
@skliper skliper added this to the 1.2.0 milestone Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCB:Approved Indicates code review and approval by community CCB
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants