Skip to content

Commit

Permalink
Merge pull request #823 from skliper/fix737-force_fail
Browse files Browse the repository at this point in the history
Fix #737, UT_Stub_CheckForceFail -> UT_Stub_CheckDefaultReturnValue
  • Loading branch information
astrogeco authored Feb 26, 2021
2 parents b7f04a7 + b2447bd commit 2f6e54e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ut_assert/inc/utstubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void UT_Stub_CallOnce(void (*Func)(void));
bool UT_Stub_CheckDeferredRetcode(UT_EntryKey_t FuncKey, int32 *Retcode);

/**
* Check for a forced failure mode entry for the given stub function
* Check for a default return value entry for the given stub function
*
* If a UT_SetDefaultReturnValue() option is in place for the given function this
* will return true and increment the internal usage counter.
Expand All @@ -324,7 +324,7 @@ bool UT_Stub_CheckDeferredRetcode(UT_EntryKey_t FuncKey, int32 *Retcode);
* \param Value Set to the value supplied to UT_SetDefaultReturnValue()
* \returns true if force fail mode is active
*/
bool UT_Stub_CheckForceFail(UT_EntryKey_t FuncKey, int32 *Value);
bool UT_Stub_CheckDefaultReturnValue(UT_EntryKey_t FuncKey, int32 *Value);

/**
* Copies data from a test-supplied buffer to the local buffer
Expand Down
11 changes: 7 additions & 4 deletions ut_assert/src/utstubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,17 +396,20 @@ uint32 UT_GetStubCount(UT_EntryKey_t FuncKey)
return Count;
}

bool UT_Stub_CheckForceFail(UT_EntryKey_t FuncKey, int32 *Value)
bool UT_Stub_CheckDefaultReturnValue(UT_EntryKey_t FuncKey, int32 *Value)
{
bool Result = false;
UT_StubTableEntry_t *StubPtr;

StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_FORCE_FAIL);
if (StubPtr != NULL)
{
/* For "force fail" entries, the count will reflect the number of times it was used */
/* For default return value entries, the count will reflect the number of times it was used */
++StubPtr->Data.Rc.Count;
*Value = StubPtr->Data.Rc.Value;
if (Value != NULL)
{
*Value = StubPtr->Data.Rc.Value;
}
Result = true;
}

Expand Down Expand Up @@ -761,7 +764,7 @@ int32 UT_DefaultStubImplWithArgs(const char *FunctionName, UT_EntryKey_t FuncKey

if (!UT_Stub_CheckDeferredRetcode(FuncKey, &Retcode))
{
if (!UT_Stub_CheckForceFail(FuncKey, &Retcode))
if (!UT_Stub_CheckDefaultReturnValue(FuncKey, &Retcode))
{
Retcode = DefaultRc;
}
Expand Down

0 comments on commit 2f6e54e

Please sign in to comment.