Skip to content

Commit

Permalink
Merge pull request #527 from jphickey/fix-526-osal-stub-scrub
Browse files Browse the repository at this point in the history
Fix #526, scrub OSAL stubs
  • Loading branch information
astrogeco authored Jul 2, 2020
2 parents 57701da + 1731baa commit ac29a87
Show file tree
Hide file tree
Showing 22 changed files with 431 additions and 47 deletions.
22 changes: 22 additions & 0 deletions src/ut-stubs/osapi-utstub-binsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ UT_DEFAULT_STUB(OS_BinSemAPI_Init,(void))
******************************************************************************/
int32 OS_BinSemTake(uint32 sem_id)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_BinSemTake), sem_id);

int32 status = OS_SUCCESS;

status = UT_DEFAULT_IMPL(OS_BinSemTake);
Expand Down Expand Up @@ -83,6 +85,8 @@ int32 OS_BinSemTake(uint32 sem_id)
******************************************************************************/
int32 OS_BinSemFlush(uint32 sem_id)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_BinSemFlush), sem_id);

int32 status;

status = UT_DEFAULT_IMPL(OS_BinSemFlush);
Expand Down Expand Up @@ -116,6 +120,11 @@ int32 OS_BinSemFlush(uint32 sem_id)
int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name,
uint32 sem_initial_value, uint32 options)
{
UT_Stub_RegisterContext(UT_KEY(OS_BinSemCreate), sem_id);
UT_Stub_RegisterContext(UT_KEY(OS_BinSemCreate), sem_name);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_BinSemCreate), sem_initial_value);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_BinSemCreate), options);

int32 status;

status = UT_DEFAULT_IMPL(OS_BinSemCreate);
Expand Down Expand Up @@ -150,6 +159,8 @@ int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name,
******************************************************************************/
int32 OS_BinSemGive(uint32 sem_id)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_BinSemGive), sem_id);

int32 status;

status = UT_DEFAULT_IMPL(OS_BinSemGive);
Expand All @@ -175,6 +186,9 @@ int32 OS_BinSemGive(uint32 sem_id)
******************************************************************************/
int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_BinSemGetInfo), sem_id);
UT_Stub_RegisterContext(UT_KEY(OS_BinSemGetInfo), bin_prop);

int32 status;

status = UT_DEFAULT_IMPL(OS_BinSemGetInfo);
Expand Down Expand Up @@ -214,6 +228,8 @@ int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop)
******************************************************************************/
int32 OS_BinSemDelete(uint32 sem_id)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_BinSemDelete), sem_id);

int32 status;

status = UT_DEFAULT_IMPL(OS_BinSemDelete);
Expand Down Expand Up @@ -247,6 +263,9 @@ int32 OS_BinSemDelete(uint32 sem_id)
******************************************************************************/
int32 OS_BinSemTimedWait(uint32 sem_id, uint32 msecs)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_BinSemTimedWait), sem_id);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_BinSemTimedWait), msecs);

int32 status;

status = UT_DEFAULT_IMPL(OS_BinSemTimedWait);
Expand All @@ -261,6 +280,9 @@ int32 OS_BinSemTimedWait(uint32 sem_id, uint32 msecs)
*****************************************************************************/
int32 OS_BinSemGetIdByName (uint32 *sem_id, const char *sem_name)
{
UT_Stub_RegisterContext(UT_KEY(OS_BinSemGetIdByName), sem_id);
UT_Stub_RegisterContext(UT_KEY(OS_BinSemGetIdByName), sem_name);

int32 status;

status = UT_DEFAULT_IMPL(OS_BinSemGetIdByName);
Expand Down
6 changes: 4 additions & 2 deletions src/ut-stubs/osapi-utstub-clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@
*****************************************************************************/
int32 OS_GetLocalTime(OS_time_t *time_struct)
{
UT_Stub_RegisterContext(UT_KEY(OS_GetLocalTime), time_struct);

int32 status;
uint32 count;

UT_Stub_RegisterContext(UT_KEY(OS_GetLocalTime), time_struct);
status = UT_DEFAULT_IMPL(OS_GetLocalTime);

if (status == OS_SUCCESS &&
Expand All @@ -67,9 +68,10 @@ int32 OS_GetLocalTime(OS_time_t *time_struct)
*****************************************************************************/
int32 OS_SetLocalTime(OS_time_t *time_struct)
{
UT_Stub_RegisterContext(UT_KEY(OS_SetLocalTime), time_struct);

int32 status;

UT_Stub_RegisterContext(UT_KEY(OS_SetLocalTime), time_struct);
status = UT_DEFAULT_IMPL(OS_SetLocalTime);

return status;
Expand Down
5 changes: 4 additions & 1 deletion src/ut-stubs/osapi-utstub-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ int32 OS_API_Init(void)
*****************************************************************************/
void OS_ApplicationExit(int32 Status)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_ApplicationExit), Status);

/* just call the default so a hook can be attached */
UT_DEFAULT_IMPL(OS_ApplicationExit);
}
Expand Down Expand Up @@ -100,7 +102,8 @@ void OS_IdleLoop(void)
*****************************************************************************/
void OS_ApplicationShutdown(uint8 flag)
{
UT_Stub_RegisterContext(UT_KEY(OS_ApplicationShutdown), &flag);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_ApplicationShutdown), flag);

UT_DEFAULT_IMPL(OS_ApplicationShutdown);
}

20 changes: 20 additions & 0 deletions src/ut-stubs/osapi-utstub-countsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ UT_DEFAULT_STUB(OS_CountSemAPI_Init,(void))
int32 OS_CountSemCreate(uint32 *sem_id, const char *sem_name,
uint32 sem_initial_value, uint32 options)
{
UT_Stub_RegisterContext(UT_KEY(OS_CountSemCreate), sem_id);
UT_Stub_RegisterContext(UT_KEY(OS_CountSemCreate), sem_name);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_CountSemCreate), sem_initial_value);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_CountSemCreate), options);

int32 status;

status = UT_DEFAULT_IMPL(OS_CountSemCreate);
Expand Down Expand Up @@ -83,6 +88,8 @@ int32 OS_CountSemCreate(uint32 *sem_id, const char *sem_name,
******************************************************************************/
int32 OS_CountSemDelete(uint32 sem_id)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_CountSemDelete), sem_id);

int32 status;

status = UT_DEFAULT_IMPL(OS_CountSemDelete);
Expand All @@ -103,6 +110,8 @@ int32 OS_CountSemDelete(uint32 sem_id)
*****************************************************************************/
int32 OS_CountSemGive ( uint32 sem_id )
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_CountSemGive), sem_id);

int32 status;

status = UT_DEFAULT_IMPL(OS_CountSemGive);
Expand All @@ -117,6 +126,8 @@ int32 OS_CountSemGive ( uint32 sem_id )
*****************************************************************************/
int32 OS_CountSemTake ( uint32 sem_id )
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_CountSemTake), sem_id);

int32 status;

status = UT_DEFAULT_IMPL(OS_CountSemTake);
Expand All @@ -131,6 +142,9 @@ int32 OS_CountSemTake ( uint32 sem_id )
*****************************************************************************/
int32 OS_CountSemTimedWait ( uint32 sem_id, uint32 msecs )
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_CountSemTimedWait), sem_id);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_CountSemTimedWait), msecs);

int32 status;

status = UT_DEFAULT_IMPL(OS_CountSemTimedWait);
Expand All @@ -145,6 +159,9 @@ int32 OS_CountSemTimedWait ( uint32 sem_id, uint32 msecs )
*****************************************************************************/
int32 OS_CountSemGetIdByName (uint32 *sem_id, const char *sem_name)
{
UT_Stub_RegisterContext(UT_KEY(OS_CountSemGetIdByName), sem_id);
UT_Stub_RegisterContext(UT_KEY(OS_CountSemGetIdByName), sem_name);

int32 status;

status = UT_DEFAULT_IMPL(OS_CountSemGetIdByName);
Expand Down Expand Up @@ -177,6 +194,9 @@ int32 OS_CountSemGetIdByName (uint32 *sem_id, const char *sem_name)
******************************************************************************/
int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_CountSemGetInfo), sem_id);
UT_Stub_RegisterContext(UT_KEY(OS_CountSemGetInfo), count_prop);

int32 status;

status = UT_DEFAULT_IMPL(OS_CountSemGetInfo);
Expand Down
23 changes: 23 additions & 0 deletions src/ut-stubs/osapi-utstub-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ UT_DEFAULT_STUB(OS_DirAPI_Init,(void))
*****************************************************************************/
int32 OS_mkdir (const char *path, uint32 access)
{
UT_Stub_RegisterContext(UT_KEY(OS_mkdir), path);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_mkdir), access);

int32 Status;

Status = UT_DEFAULT_IMPL(OS_mkdir);
Expand All @@ -58,6 +61,8 @@ int32 OS_mkdir (const char *path, uint32 access)
*****************************************************************************/
int32 OS_rmdir (const char *path)
{
UT_Stub_RegisterContext(UT_KEY(OS_rmdir), path);

int32 Status;

Status = UT_DEFAULT_IMPL(OS_rmdir);
Expand All @@ -74,6 +79,9 @@ int32 OS_rmdir (const char *path)
*****************************************************************************/
int32 OS_DirectoryOpen(uint32 *dir_id, const char *path)
{
UT_Stub_RegisterContext(UT_KEY(OS_DirectoryOpen), dir_id);
UT_Stub_RegisterContext(UT_KEY(OS_DirectoryOpen), path);

int32 Status;

Status = UT_DEFAULT_IMPL(OS_DirectoryOpen);
Expand All @@ -98,6 +106,8 @@ int32 OS_DirectoryOpen(uint32 *dir_id, const char *path)
*****************************************************************************/
int32 OS_DirectoryClose(uint32 dir_id)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_DirectoryClose), dir_id);

int32 Status;

Status = UT_DEFAULT_IMPL(OS_DirectoryClose);
Expand All @@ -117,6 +127,8 @@ int32 OS_DirectoryClose(uint32 dir_id)
*****************************************************************************/
int32 OS_DirectoryRewind(uint32 dir_id)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_DirectoryRewind), dir_id);

int32 Status;

Status = UT_DEFAULT_IMPL(OS_DirectoryRewind);
Expand All @@ -131,6 +143,9 @@ int32 OS_DirectoryRewind(uint32 dir_id)
*****************************************************************************/
int32 OS_DirectoryRead(uint32 dir_id, os_dirent_t *dirent)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_DirectoryRead), dir_id);
UT_Stub_RegisterContext(UT_KEY(OS_DirectoryRead), dirent);

int32 Status;
uint32 CopySize;

Expand Down Expand Up @@ -159,6 +174,8 @@ int32 OS_DirectoryRead(uint32 dir_id, os_dirent_t *dirent)
*****************************************************************************/
os_dirp_t OS_opendir (const char *path)
{
UT_Stub_RegisterContext(UT_KEY(OS_opendir), path);

int32 Status;
os_dirp_t Dirp;

Expand Down Expand Up @@ -191,6 +208,8 @@ os_dirp_t OS_opendir (const char *path)
*****************************************************************************/
int32 OS_closedir (os_dirp_t directory)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_closedir), directory);

int32 Status;

Status = UT_DEFAULT_IMPL(OS_closedir);
Expand All @@ -206,6 +225,8 @@ int32 OS_closedir (os_dirp_t directory)
*****************************************************************************/
os_dirent_t * OS_readdir (os_dirp_t directory)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_readdir), directory);

static os_dirent_t DefaultEntry;
os_dirent_t *DirentPtr;
int32 Status;
Expand Down Expand Up @@ -241,6 +262,8 @@ os_dirent_t * OS_readdir (os_dirp_t directory)
*****************************************************************************/
void OS_rewinddir(os_dirp_t directory)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_rewinddir), directory);

/* Call the default impl so hooks will work */
UT_DEFAULT_IMPL(OS_rewinddir);
}
Expand Down
3 changes: 3 additions & 0 deletions src/ut-stubs/osapi-utstub-errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_GetErrorName), error_num);
UT_Stub_RegisterContext(UT_KEY(OS_GetErrorName), err_name);

int32 status;

status = UT_DEFAULT_IMPL(OS_GetErrorName);
Expand Down
Loading

0 comments on commit ac29a87

Please sign in to comment.