Skip to content

Commit

Permalink
Merge pull request #497 from jphickey/fix-494-add-fixedmap-stub
Browse files Browse the repository at this point in the history
Fix #494, add missing stub functions for OSAL API
  • Loading branch information
astrogeco authored Jun 17, 2020
2 parents 96fcad7 + b6b1ad8 commit 4efd29f
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/ut-stubs/osapi-utstub-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,27 @@ int32 OS_write(uint32 filedes, const void *buffer, uint32 nbytes)
return UT_GenericWriteStub(__func__,UT_KEY(OS_write),buffer,nbytes);
}

/*****************************************************************************
*
* Stub function for OS_TimedRead()
*
*****************************************************************************/
int32 OS_TimedRead(uint32 filedes, void *buffer, uint32 nbytes, int32 timeout)
{
return UT_GenericReadStub(__func__,UT_KEY(OS_TimedRead),buffer,nbytes);
}

/*****************************************************************************
*
* Stub function for OS_TimedWrite()
*
*****************************************************************************/
int32 OS_TimedWrite(uint32 filedes, const void *buffer, uint32 nbytes, int32 timeout)
{
return UT_GenericWriteStub(__func__,UT_KEY(OS_TimedWrite),buffer,nbytes);
}


/*****************************************************************************
*
* Stub function for OS_chmod()
Expand Down
27 changes: 27 additions & 0 deletions src/ut-stubs/osapi-utstub-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,33 @@
UT_DEFAULT_STUB(OS_FileSysAPI_Init,(void))


/*****************************************************************************
*
* Stub function for OS_FileSysAddFixedMap()
*
*****************************************************************************/
int32 OS_FileSysAddFixedMap(uint32 *filesys_id, const char *phys_path,
const char *virt_path)
{
int32 status;

status = UT_DEFAULT_IMPL(OS_FileSysAddFixedMap);

if (status == OS_SUCCESS)
{
*filesys_id = UT_AllocStubObjId(UT_OBJTYPE_FILESYS);
}
else
{
*filesys_id = 0xDEADBEEFU;
}



return status;
}


/*****************************************************************************
*
* Stub function for OS_mkfs()
Expand Down
11 changes: 11 additions & 0 deletions src/ut-stubs/osapi-utstub-printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ int32 OS_ConsoleAPI_Init(void)
return UT_DEFAULT_IMPL(OS_ConsoleAPI_Init);
}

/*****************************************************************************
*
* Stub function for OS_ConsoleWrite()
*
*****************************************************************************/
int32 OS_ConsoleWrite(uint32 console_id, const char *Str)
{
UT_Stub_RegisterContext(UT_KEY(OS_ConsoleWrite), Str);
return UT_DEFAULT_IMPL(OS_ConsoleWrite);
}

/*****************************************************************************
*
* Stub function for OS_printf()
Expand Down
29 changes: 28 additions & 1 deletion src/ut-stubs/osapi-utstub-task.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop)
status = UT_DEFAULT_IMPL(OS_TaskGetInfo);

if (status == OS_SUCCESS &&
UT_Stub_CopyToLocal(UT_KEY(OS_MutSemGetInfo), task_prop, sizeof(*task_prop)) < sizeof(*task_prop))
UT_Stub_CopyToLocal(UT_KEY(OS_TaskGetInfo), task_prop, sizeof(*task_prop)) < sizeof(*task_prop))
{
task_prop->creator = 1;
UT_FIXUP_ID(task_prop->creator, UT_OBJTYPE_TASK);
Expand All @@ -273,6 +273,33 @@ int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop)
return status;
}

/*****************************************************************************/
/**
** \brief OS_TaskGetInfo stub function
**
** \par Description
** This function is used to mimic the response of the OS API function
** OS_TaskFindIdBySystemData.
**
** \returns
** The return value instructed by the test case setup
**
******************************************************************************/
int32 OS_TaskFindIdBySystemData(uint32 *task_id, const void *sysdata, size_t sysdata_size)
{
int32 status;

status = UT_DEFAULT_IMPL(OS_TaskFindIdBySystemData);

if (status == OS_SUCCESS &&
UT_Stub_CopyToLocal(UT_KEY(OS_TaskFindIdBySystemData), task_id, sizeof(*task_id)) < sizeof(*task_id))
{
*task_id = 1;
UT_FIXUP_ID(*task_id, UT_OBJTYPE_TASK);
}

return status;
}

/*****************************************************************************
*
Expand Down

0 comments on commit 4efd29f

Please sign in to comment.