Fix #832 Override default stub logic #839
Closed
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
This is a new set hook function that allows a test designer to bypass the remaining default stub implementation after the hook is called. Test designers can do this as needed, but current tests will be unaffected because it must be set in a test to be used. Current tests will never set the override and their expectations of the stub code running after the hook are still valid. Stubs will need updated to make the check for the override, but that is all that will need to change in them.
Testing performed
I have written 7 unit type tests to show that the behavior without the override set continues to be the same. Each of these tests is doubled with a control test, for a total of 14 tests. The tests are run with no changes, with cFS commit 5ca472a and using my working version of cfs_cf (unit-test-cf-3.0), this shows that the results of each pair of tests are the same; which is the expectation as they are duplicates. The repo for cfs_cf is given the new UT_SetHookOverrideStubFunction instead of UT_SetHookFunction in 7 of the tests with each duplicate test left untouched as the control test. A build is attempted showing that the function does not exist. The repo, osal, is updated with the changes implementing the override and the repo, cfe, gets a two stubs updated to allow the bypass (CFE_MSG_GetSize, CFE_MSG_GetMsgId). After a successful full rebuild, the 14 tests are run again. The results confirm the changes have provided the desired behavior. While the control tests all still receive the same results as the no updates test run, all of the override tests have their expected changes.
Details of the specific tests:
1 Test_GetSize_Returns_1 & Test_GetSize_Returns_1_Control
2 Test_GetSize_wUTSDB_Returns_1 & Test_GetSize_wUTSDB_Returns_1_Control
3 Test_GetSize_Returns_0 & Test_GetSize_Returns_0_Control
4 Test_GetSize_wUTSDB_Returns_0 & Test_GetSize_wUTSDB_Returns_0_Control
5 Test_GetSize_Returns_neg1 & Test_GetSize_Returns_neg1_Control
6 Test_GetSize_wUTSDB_Returns_neg1 & Test_GetSize_wUTSDB_Returns_neg1_Control
7 Test_GetSize_OtherKey &Test_GetSize_OtherKey_Control
OverrideExperiment.txt
do-no-harm.txt
Expected behavior changes
Test designers will have the option to use UT_SetHookOverrideStubFunction instead of UT_SetHookFunction.
When this is selected any stub behavior that appears after the hook function is called can be bypassed; as long as the stub checks for the override and allows it.
No other behavior will be changed, as it was a requirement that the change have no impact to current operations.
System(s) tested on
Additional context
The override control tests show there is no behavioral changes unless the new override function is used. The override updated tests show that the desired outcome is achieved in each instance.
Contributor Info - All information REQUIRED for consideration of pull request
Alan Gibson NASA/GSFC 587