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

Fix #737, UT_Stub_CheckForceFail -> UT_Stub_CheckDefaultReturnValue #823

Merged
merged 1 commit into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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