Skip to content

Commit

Permalink
Fix nasa#724, Refactor UT_ClearForceFail to UT_ClearDefaultReturnValue
Browse files Browse the repository at this point in the history
  • Loading branch information
zanzaben committed Jan 13, 2021
1 parent eef2a3a commit a53e27c
Show file tree
Hide file tree
Showing 24 changed files with 88 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void Test_OS_FileStat_Impl(void)
/* failure mode */
UT_SetDefaultReturnValue(UT_KEY(OCS_stat), -1);
OSAPI_TEST_FUNCTION_RC(OS_FileStat_Impl, ("local", &FileStats), OS_ERROR);
UT_ClearForceFail(UT_KEY(OCS_stat));
UT_ClearDefaultReturnValue(UT_KEY(OCS_stat));

/* nominal, no permission bits */
memset(&FileStats, 0, sizeof(FileStats));
Expand Down Expand Up @@ -108,12 +108,12 @@ void Test_OS_FileChmod_Impl(void)
/* failure mode 0 (open) */
UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1);
OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local", OS_READ_WRITE), OS_ERROR);
UT_ClearForceFail(UT_KEY(OCS_open));
UT_ClearDefaultReturnValue(UT_KEY(OCS_open));

/* failure mode 1 (fstat) */
UT_SetDefaultReturnValue(UT_KEY(OCS_fstat), -1);
OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local", OS_READ_WRITE), OS_ERROR);
UT_ClearForceFail(UT_KEY(OCS_fstat));
UT_ClearDefaultReturnValue(UT_KEY(OCS_fstat));

/* failure mode 2 (fchmod) */
UT_SetDefaultReturnValue(UT_KEY(OCS_fchmod), -1);
Expand All @@ -122,7 +122,7 @@ void Test_OS_FileChmod_Impl(void)
/* non implemented error, e.g. such as DOS Filesystem with no perms */
OCS_errno = OCS_ENOTSUP;
OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local", OS_READ_WRITE), OS_ERR_NOT_IMPLEMENTED);
UT_ClearForceFail(UT_KEY(OCS_fchmod));
UT_ClearDefaultReturnValue(UT_KEY(OCS_fchmod));

/* all permission bits with uid/gid match */
RefStat.st_uid = UT_PortablePosixFileTest_GetSelfEUID();
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/shared/src/coveragetest-binsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void Test_OS_BinSemGetIdByName(void)
actual = OS_BinSemGetIdByName(&objid, "UT");
UtAssert_True(actual == expected, "OS_BinSemGetIdByName() (%ld) == OS_SUCCESS", (long)actual);
OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED);
UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName));

expected = OS_ERR_NAME_NOT_FOUND;
actual = OS_BinSemGetIdByName(&objid, "NF");
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/shared/src/coveragetest-countsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void Test_OS_CountSemGetIdByName(void)
actual = OS_CountSemGetIdByName(&objid, "UT");
UtAssert_True(actual == expected, "OS_CountSemGetIdByName() (%ld) == OS_SUCCESS", (long)actual);
OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED);
UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName));

expected = OS_ERR_NAME_NOT_FOUND;
actual = OS_CountSemGetIdByName(&objid, "NF");
Expand Down
6 changes: 3 additions & 3 deletions src/unit-test-coverage/shared/src/coveragetest-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void Test_OS_OpenCreate(void)
expected = OS_ERROR;
actual = OS_OpenCreate(&filedes, "/cf/file", OS_FILE_FLAG_NONE, OS_READ_WRITE);
UtAssert_True(actual == OS_ERROR, "OS_OpenCreate() (%ld) == OS_ERROR (bad path)", (long)actual);
UT_ClearForceFail(UT_KEY(OS_TranslatePath));
UT_ClearDefaultReturnValue(UT_KEY(OS_TranslatePath));
}

void Test_OS_close(void)
Expand Down Expand Up @@ -271,7 +271,7 @@ void Test_OS_cp(void)
expected = -444;
actual = OS_cp("/cf/file1", "/cf/file2");
UtAssert_True(actual == expected, "OS_cp() (%ld) == -444", (long)actual);
UT_ClearForceFail(UT_KEY(OS_GenericRead_Impl));
UT_ClearDefaultReturnValue(UT_KEY(OS_GenericRead_Impl));

UT_SetDataBuffer(UT_KEY(OS_GenericRead_Impl), ReadBuf, sizeof(ReadBuf), false);
UT_SetDefaultReturnValue(UT_KEY(OS_GenericWrite_Impl), -555);
Expand All @@ -283,7 +283,7 @@ void Test_OS_cp(void)
expected = OS_INVALID_POINTER;
actual = OS_cp("/cf/file1", "/cf/file2");
UtAssert_True(actual == expected, "OS_cp() (%ld) == OS_INVALID_POINTER", (long)actual);
UT_ClearForceFail(UT_KEY(OS_TranslatePath));
UT_ClearDefaultReturnValue(UT_KEY(OS_TranslatePath));
}

void Test_OS_mv(void)
Expand Down
18 changes: 9 additions & 9 deletions src/unit-test-coverage/shared/src/coveragetest-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void Test_OS_mkfs(void)
expected = OS_FS_ERR_PATH_TOO_LONG;
actual = OS_mkfs(TestBuffer, "/ramdev0", "vol", OSAL_SIZE_C(0), OSAL_BLOCKCOUNT_C(0));
UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual);
UT_ClearForceFail(UT_KEY(OCS_memchr));
UT_ClearDefaultReturnValue(UT_KEY(OCS_memchr));

/* set up for failure due to empty strings */
expected = OS_FS_ERR_PATH_INVALID;
Expand Down Expand Up @@ -140,7 +140,7 @@ void Test_OS_rmfs(void)
expected = OS_ERR_NAME_NOT_FOUND;
actual = OS_rmfs("/ramdev4");
UtAssert_True(actual == expected, "OS_rmfs() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual);
UT_ClearForceFail(UT_KEY(OS_ObjectIdGetByName));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdGetByName));

expected = OS_INVALID_POINTER;
actual = OS_rmfs(NULL);
Expand Down Expand Up @@ -178,7 +178,7 @@ void Test_OS_initfs(void)
expected = OS_FS_ERR_PATH_TOO_LONG;
actual = OS_initfs(TestBuffer, "/ramdev0", "vol", OSAL_SIZE_C(0), OSAL_BLOCKCOUNT_C(0));
UtAssert_True(actual == expected, "OS_initfs() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual);
UT_ClearForceFail(UT_KEY(OCS_memchr));
UT_ClearDefaultReturnValue(UT_KEY(OCS_memchr));

/* set up for failure */
UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdAllocateNew), OS_ERR_NO_FREE_IDS);
Expand Down Expand Up @@ -281,7 +281,7 @@ void Test_OS_fsBlocksFree(void)
expected = OS_FS_ERR_PATH_TOO_LONG;
actual = OS_fsBlocksFree("/cf");
UtAssert_True(actual == expected, "OS_fsBlocksFree() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual);
UT_ClearForceFail(UT_KEY(OCS_memchr));
UT_ClearDefaultReturnValue(UT_KEY(OCS_memchr));

UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND);
expected = OS_FS_ERR_PATH_INVALID;
Expand Down Expand Up @@ -320,7 +320,7 @@ void Test_OS_fsBytesFree(void)
expected = OS_FS_ERR_PATH_TOO_LONG;
actual = OS_fsBytesFree("/cf", &bytes_free);
UtAssert_True(actual == expected, "OS_fsBytesFree() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual);
UT_ClearForceFail(UT_KEY(OCS_memchr));
UT_ClearDefaultReturnValue(UT_KEY(OCS_memchr));

UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND);
expected = OS_FS_ERR_PATH_INVALID;
Expand Down Expand Up @@ -401,7 +401,7 @@ void Test_OS_chkfs(void)
expected = OS_FS_ERR_PATH_TOO_LONG;
actual = OS_chkfs("/cf", false);
UtAssert_True(actual == expected, "OS_fsBytesFree() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual);
UT_ClearForceFail(UT_KEY(OCS_memchr));
UT_ClearDefaultReturnValue(UT_KEY(OCS_memchr));

/* Test Fail due to no matching VolTab entry */
UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND);
Expand All @@ -426,7 +426,7 @@ void Test_OS_FS_GetPhysDriveName(void)
expected = OS_FS_ERR_PATH_TOO_LONG;
actual = OS_FS_GetPhysDriveName(NameBuf, "none");
UtAssert_True(actual == expected, "OS_FS_GetPhysDriveName() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual);
UT_ClearForceFail(UT_KEY(OCS_memchr));
UT_ClearDefaultReturnValue(UT_KEY(OCS_memchr));

expected = OS_ERR_INCORRECT_OBJ_STATE;
actual = OS_FS_GetPhysDriveName(NameBuf, "none");
Expand Down Expand Up @@ -510,7 +510,7 @@ void Test_OS_TranslatePath(void)
expected = OS_FS_ERR_PATH_TOO_LONG;
actual = OS_TranslatePath("/cf/test", LocalBuffer);
UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual);
UT_ClearForceFail(UT_KEY(OCS_strlen));
UT_ClearDefaultReturnValue(UT_KEY(OCS_strlen));

/* Invalid no '/' */
expected = OS_FS_ERR_PATH_INVALID;
Expand All @@ -530,7 +530,7 @@ void Test_OS_TranslatePath(void)
UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND);
actual = OS_TranslatePath("/cf/test", LocalBuffer);
UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual);
UT_ClearForceFail(UT_KEY(OS_ObjectIdGetBySearch));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdGetBySearch));

/* VirtPathLen < VirtPathBegin */
UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 4, OS_MAX_PATH_LEN);
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/shared/src/coveragetest-idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void Test_OS_ObjectIdFindByName(void)
actual = OS_ObjectIdFindByName(OS_OBJECT_TYPE_OS_TASK, TaskName, &objid);
UtAssert_True(actual == expected, "OS_ObjectFindIdByName(%s) (%ld) == OS_ERR_NAME_TOO_LONG", TaskName,
(long)actual);
UT_ClearForceFail(UT_KEY(OCS_memchr));
UT_ClearDefaultReturnValue(UT_KEY(OCS_memchr));

/*
* Pass in a name that is actually not found
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/shared/src/coveragetest-mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void Test_OS_MutSemGetIdByName(void)
actual = OS_MutSemGetIdByName(&objid, "UT");
UtAssert_True(actual == expected, "OS_MutSemGetIdByName() (%ld) == OS_SUCCESS", (long)actual);
OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED);
UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName));

expected = OS_ERR_NAME_NOT_FOUND;
actual = OS_MutSemGetIdByName(&objid, "NF");
Expand Down
4 changes: 2 additions & 2 deletions src/unit-test-coverage/shared/src/coveragetest-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void Test_OS_QueueCreate(void)
expected = OS_ERR_NAME_TOO_LONG;
actual = OS_QueueCreate(&objid, "UT", OSAL_BLOCKCOUNT_C(0), OSAL_SIZE_C(4), 0);
UtAssert_True(actual == expected, "OS_QueueCreate() (%ld) == OS_ERR_NAME_TOO_LONG", (long)actual);
UT_ClearForceFail(UT_KEY(OCS_memchr));
UT_ClearDefaultReturnValue(UT_KEY(OCS_memchr));

expected = OS_QUEUE_INVALID_SIZE;
actual = OS_QueueCreate(&objid, "UT", OSAL_BLOCKCOUNT_C(1 + OS_QUEUE_MAX_DEPTH), OSAL_SIZE_C(4), 0);
Expand Down Expand Up @@ -153,7 +153,7 @@ void Test_OS_QueueGetIdByName(void)
UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS);
actual = OS_QueueGetIdByName(&objid, "UT");
UtAssert_True(actual == expected, "OS_QueueGetIdByName() (%ld) == OS_SUCCESS", (long)actual);
UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName));

expected = OS_ERR_NAME_NOT_FOUND;
actual = OS_QueueGetIdByName(&objid, "NF");
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/shared/src/coveragetest-select.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void Test_OS_SelectFdAddClearOps(void)
UtAssert_True(!OS_SelectFdIsSet(&UtSet, UT_OBJID_1), "OS_SelectFdIsSet(1) == false");
UtAssert_True(!OS_SelectFdIsSet(&UtSet, UT_OBJID_2), "OS_SelectFdIsSet(2) == false");

UT_ClearForceFail(UT_KEY(OS_ObjectIdToArrayIndex));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdToArrayIndex));
UtAssert_True(OS_SelectFdIsSet(&UtSet, UT_OBJID_1), "OS_SelectFdIsSet(1) == true");
UtAssert_True(!OS_SelectFdIsSet(&UtSet, UT_OBJID_2), "OS_SelectFdIsSet(2) == false");
}
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/shared/src/coveragetest-sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void Test_OS_SocketGetIdByName(void)
actual = OS_SocketGetIdByName(&objid, "UT");
UtAssert_True(actual == expected, "OS_SocketGetIdByName() (%ld) == OS_SUCCESS", (long)actual);
OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED);
UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName));

expected = OS_ERR_NAME_NOT_FOUND;
actual = OS_SocketGetIdByName(&objid, "NF");
Expand Down
6 changes: 3 additions & 3 deletions src/unit-test-coverage/shared/src/coveragetest-task.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void Test_OS_TaskGetIdByName(void)
actual = OS_TaskGetIdByName(&objid, "UT");
UtAssert_True(actual == expected, "OS_TaskGetIdByName() (%ld) == OS_SUCCESS", (long)actual);
OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED);
UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName));

expected = OS_ERR_NAME_NOT_FOUND;
actual = OS_TaskGetIdByName(&objid, "NF");
Expand Down Expand Up @@ -318,14 +318,14 @@ void Test_OS_TaskFindIdBySystemData(void)
UT_SetDefaultReturnValue(UT_KEY(OS_TaskValidateSystemData_Impl), expected);
actual = OS_TaskFindIdBySystemData(&task_id, &test_sysdata, sizeof(test_sysdata));
UtAssert_True(actual == expected, "OS_TaskFindIdBySystemData() (%ld) == OS_INVALID_POINTER", (long)actual);
UT_ClearForceFail(UT_KEY(OS_TaskValidateSystemData_Impl));
UT_ClearDefaultReturnValue(UT_KEY(OS_TaskValidateSystemData_Impl));

/* Test search failure */
expected = OS_ERR_NAME_NOT_FOUND;
UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetBySearch), expected);
actual = OS_TaskFindIdBySystemData(&task_id, &test_sysdata, sizeof(test_sysdata));
UtAssert_True(actual == expected, "OS_TaskFindIdBySystemData() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual);
UT_ClearForceFail(UT_KEY(OS_ObjectIdGetBySearch));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdGetBySearch));
}

/* Osapi_Test_Setup
Expand Down
22 changes: 11 additions & 11 deletions src/unit-test-coverage/shared/src/coveragetest-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void Test_OS_TimerAdd(void)
expected = OS_ERR_NAME_TOO_LONG;
actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg);
UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_ERR_NAME_TOO_LONG", (long)actual);
UT_ClearForceFail(UT_KEY(OCS_memchr));
UT_ClearDefaultReturnValue(UT_KEY(OCS_memchr));

expected = OS_INVALID_POINTER;
actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, NULL, &arg);
Expand All @@ -95,19 +95,19 @@ void Test_OS_TimerAdd(void)
expected = OS_ERR_INCORRECT_OBJ_STATE;
actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg);
UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual);
UT_ClearForceFail(UT_KEY(OS_TaskGetId_Impl));
UT_ClearDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl));

UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetById), OS_ERROR);
expected = OS_ERROR;
actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg);
UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_ERROR", (long)actual);
UT_ClearForceFail(UT_KEY(OS_ObjectIdGetById));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdGetById));

UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdAllocateNew), OS_ERROR);
expected = OS_ERROR;
actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg);
UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_ERROR", (long)actual);
UT_ClearForceFail(UT_KEY(OS_ObjectIdAllocateNew));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdAllocateNew));
}

void Test_OS_TimerCreate(void)
Expand Down Expand Up @@ -147,13 +147,13 @@ void Test_OS_TimerCreate(void)
expected = OS_ERROR;
actual = OS_TimerCreate(&objid, "UT", &accuracy, UT_TimerCallback);
UtAssert_True(actual == expected, "OS_TimerCreate() (%ld) == OS_ERROR", (long)actual);
UT_ClearForceFail(UT_KEY(OS_TimeBaseCreate));
UT_ClearDefaultReturnValue(UT_KEY(OS_TimeBaseCreate));

UT_SetDefaultReturnValue(UT_KEY(OCS_memchr), OS_ERROR);
expected = OS_ERR_NAME_TOO_LONG;
actual = OS_TimerCreate(&objid, "UT", &accuracy, UT_TimerCallback);
UtAssert_True(actual == expected, "OS_TimerCreate() (%ld) == OS_ERR_NAME_TOO_LONG", (long)actual);
UT_ClearForceFail(UT_KEY(OCS_memchr));
UT_ClearDefaultReturnValue(UT_KEY(OCS_memchr));
}

void Test_OS_TimerSet(void)
Expand Down Expand Up @@ -186,7 +186,7 @@ void Test_OS_TimerSet(void)
expected = OS_ERR_INCORRECT_OBJ_STATE;
actual = OS_TimerSet(UT_OBJID_2, 0, 1);
UtAssert_True(actual == expected, "OS_TimerSet() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual);
UT_ClearForceFail(UT_KEY(OS_TaskGetId_Impl));
UT_ClearDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl));
}

void Test_OS_TimerDelete(void)
Expand Down Expand Up @@ -234,7 +234,7 @@ void Test_OS_TimerDelete(void)
expected = OS_ERR_INCORRECT_OBJ_STATE;
actual = OS_TimerDelete(UT_OBJID_2);
UtAssert_True(actual == expected, "OS_TimerDelete() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual);
UT_ClearForceFail(UT_KEY(OS_TaskGetId_Impl));
UT_ClearDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl));
}

void Test_OS_TimerGetIdByName(void)
Expand All @@ -250,7 +250,7 @@ void Test_OS_TimerGetIdByName(void)
UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS);
actual = OS_TimerGetIdByName(&objid, "UT");
UtAssert_True(actual == expected, "OS_TimerGetIdByName() (%ld) == OS_SUCCESS", (long)actual);
UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName));

expected = OS_ERR_NAME_NOT_FOUND;
actual = OS_TimerGetIdByName(&objid, "NF");
Expand All @@ -264,7 +264,7 @@ void Test_OS_TimerGetIdByName(void)
expected = OS_ERR_INCORRECT_OBJ_STATE;
actual = OS_TimerGetIdByName(&objid, "NF");
UtAssert_True(actual == expected, "OS_TimerGetIdByName() (%ld) == %ld", (long)actual, (long)expected);
UT_ClearForceFail(UT_KEY(OS_TaskGetId_Impl));
UT_ClearDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl));
}

void Test_OS_TimerGetInfo(void)
Expand Down Expand Up @@ -301,7 +301,7 @@ void Test_OS_TimerGetInfo(void)
expected = OS_ERR_INCORRECT_OBJ_STATE;
actual = OS_TimerGetInfo(UT_OBJID_1, &timer_prop);
UtAssert_True(actual == expected, "OS_TimerGetInfo() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual);
UT_ClearForceFail(UT_KEY(OS_TaskGetId_Impl));
UT_ClearDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl));
}

/* Osapi_Test_Setup
Expand Down
4 changes: 2 additions & 2 deletions src/unit-test-coverage/shared/src/coveragetest-timebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void Test_OS_TimeBaseCreate(void)
expected = OS_ERR_NAME_TOO_LONG;
actual = OS_TimeBaseCreate(&objid, "UT", UT_TimerSync);
UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_ERR_NAME_TOO_LONG", (long)actual);
UT_ClearForceFail(UT_KEY(OCS_memchr));
UT_ClearDefaultReturnValue(UT_KEY(OCS_memchr));

UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT));
expected = OS_ERR_INCORRECT_OBJ_STATE;
Expand Down Expand Up @@ -166,7 +166,7 @@ void Test_OS_TimeBaseGetIdByName(void)
actual = OS_TimeBaseGetIdByName(&objid, "UT");
UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == OS_SUCCESS", (long)actual);
OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED);
UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName));
UT_ClearDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName));

expected = OS_ERR_NAME_NOT_FOUND;
actual = OS_TimeBaseGetIdByName(&objid, "NF");
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/vxworks/src/coveragetest-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void Test_OS_API_Impl_Init(void)
OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(0), OS_SUCCESS);
UT_SetDefaultReturnValue(UT_StubKey_OS_VxWorks_TableMutex_Init, OS_ERROR);
OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_TASK), OS_ERROR);
UT_ClearForceFail(UT_StubKey_OS_VxWorks_TableMutex_Init);
UT_ClearDefaultReturnValue(UT_StubKey_OS_VxWorks_TableMutex_Init);
OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS);
OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_QUEUE), OS_SUCCESS);
OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_BINSEM), OS_SUCCESS);
Expand Down
4 changes: 2 additions & 2 deletions src/unit-test-coverage/vxworks/src/coveragetest-console.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ void Test_OS_ConsoleCreate_Impl(void)

UT_SetDefaultReturnValue(UT_KEY(OCS_semCInitialize), OCS_ERROR);
OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(&token), OS_SEM_FAILURE);
UT_ClearForceFail(UT_KEY(OCS_semCInitialize));
UT_ClearDefaultReturnValue(UT_KEY(OCS_semCInitialize));

UT_SetDefaultReturnValue(UT_KEY(OCS_taskSpawn), OCS_ERROR);
OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(&token), OS_ERROR);
UT_ClearForceFail(UT_KEY(OCS_taskSpawn));
UT_ClearDefaultReturnValue(UT_KEY(OCS_taskSpawn));

token.obj_idx = OS_MAX_CONSOLES + 1;
OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(&token), OS_ERR_NOT_IMPLEMENTED);
Expand Down
Loading

0 comments on commit a53e27c

Please sign in to comment.