diff --git a/src/unit-test-coverage/portable/src/coveragetest-bsd-select.c b/src/unit-test-coverage/portable/src/coveragetest-bsd-select.c index 39e8fb3e6..b86fe134a 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-bsd-select.c +++ b/src/unit-test-coverage/portable/src/coveragetest-bsd-select.c @@ -50,7 +50,7 @@ void Test_OS_SelectSingle_Impl(void) SelectFlags = 0; OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (StreamID, &SelectFlags, 0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_select), 0); + UT_SetDefaultReturnValue(UT_KEY(OCS_select), 0); SelectFlags = OS_STREAM_STATE_READABLE | OS_STREAM_STATE_WRITABLE; nowtime.tv_sec = 1; nowtime.tv_nsec = 500000000; @@ -60,7 +60,7 @@ void Test_OS_SelectSingle_Impl(void) UT_SetDataBuffer(UT_KEY(OCS_clock_gettime), &latertime, sizeof(latertime), false); OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (StreamID, &SelectFlags, 999), OS_ERROR_TIMEOUT); - UT_SetForceFail(UT_KEY(OCS_select), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_select), -1); SelectFlags = OS_STREAM_STATE_READABLE | OS_STREAM_STATE_WRITABLE; nowtime.tv_sec = 1; nowtime.tv_nsec = 0; @@ -84,7 +84,7 @@ void Test_OS_SelectMultiple_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_SelectMultiple_Impl, (&ReadSet, &WriteSet, 0), OS_SUCCESS); memset(&ReadSet, 0xff, sizeof(ReadSet)); memset(&WriteSet, 0, sizeof(WriteSet)); - UT_SetForceFail(UT_KEY(OCS_select), 0); + UT_SetDefaultReturnValue(UT_KEY(OCS_select), 0); OSAPI_TEST_FUNCTION_RC(OS_SelectMultiple_Impl, (&ReadSet, &WriteSet, 1), OS_ERROR_TIMEOUT); } /* end OS_SelectMultiple_Impl */ diff --git a/src/unit-test-coverage/portable/src/coveragetest-posix-files.c b/src/unit-test-coverage/portable/src/coveragetest-posix-files.c index 9297ba9d9..372914b28 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-posix-files.c +++ b/src/unit-test-coverage/portable/src/coveragetest-posix-files.c @@ -47,7 +47,7 @@ void Test_OS_FileOpen_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (UT_INDEX_0, "local", 0, -1234), OS_ERROR); /* failure mode */ - UT_SetForceFail(UT_KEY(OCS_open), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1); OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (UT_INDEX_0, "local", 0, OS_READ_ONLY), OS_ERROR); } @@ -61,7 +61,7 @@ void Test_OS_FileStat_Impl(void) struct OCS_stat RefStat; /* failure mode */ - UT_SetForceFail(UT_KEY(OCS_stat), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_stat), -1); OSAPI_TEST_FUNCTION_RC(OS_FileStat_Impl, ("local", &FileStats), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_stat)); @@ -97,17 +97,17 @@ void Test_OS_FileChmod_Impl(void) struct OCS_stat RefStat; /* failure mode 0 (open) */ - UT_SetForceFail(UT_KEY(OCS_open), -1); + 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)); /* failure mode 1 (fstat) */ - UT_SetForceFail(UT_KEY(OCS_fstat), -1); + 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)); /* failure mode 2 (fchmod) */ - UT_SetForceFail(UT_KEY(OCS_fchmod), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_fchmod), -1); OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local", OS_READ_WRITE), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_fchmod)); @@ -142,7 +142,7 @@ void Test_OS_FileRemove_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_FileRemove_Impl, ("local"), OS_SUCCESS); /* failure mode */ - UT_SetForceFail(UT_KEY(OCS_remove), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_remove), -1); OSAPI_TEST_FUNCTION_RC(OS_FileRemove_Impl, ("local"), OS_ERROR); } @@ -155,7 +155,7 @@ void Test_OS_FileRename_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_FileRename_Impl, ("old", "new"), OS_SUCCESS); /* failure mode */ - UT_SetForceFail(UT_KEY(OCS_rename), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_rename), -1); OSAPI_TEST_FUNCTION_RC(OS_FileRename_Impl, ("old", "new"), OS_ERROR); } diff --git a/src/unit-test-coverage/portable/src/coveragetest-posix-gettime.c b/src/unit-test-coverage/portable/src/coveragetest-posix-gettime.c index dc63e8d18..8dc31a951 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-posix-gettime.c +++ b/src/unit-test-coverage/portable/src/coveragetest-posix-gettime.c @@ -40,7 +40,7 @@ void Test_OS_GetLocalTime_Impl(void) timeval.microsecs = 1; OSAPI_TEST_FUNCTION_RC(OS_GetLocalTime_Impl, (&timeval), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_clock_gettime), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_clock_gettime), -1); OSAPI_TEST_FUNCTION_RC(OS_GetLocalTime_Impl, (&timeval), OS_ERROR); } @@ -55,7 +55,7 @@ void Test_OS_SetLocalTime_Impl(void) timeval.microsecs = 1; OSAPI_TEST_FUNCTION_RC(OS_SetLocalTime_Impl, (&timeval), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_clock_settime), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_clock_settime), -1); OSAPI_TEST_FUNCTION_RC(OS_SetLocalTime_Impl, (&timeval), OS_ERROR); } diff --git a/src/unit-test-coverage/portable/src/coveragetest-posix-io.c b/src/unit-test-coverage/portable/src/coveragetest-posix-io.c index a91c4f849..b272d9792 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-posix-io.c +++ b/src/unit-test-coverage/portable/src/coveragetest-posix-io.c @@ -49,7 +49,7 @@ void Test_OS_GenericClose_Impl(void) * Test path where underlying close() fails. * Should still return success. */ - UT_SetForceFail(UT_KEY(OCS_close), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_close), -1); OSAPI_TEST_FUNCTION_RC(OS_GenericClose_Impl, (UT_INDEX_0), OS_SUCCESS); } @@ -61,18 +61,18 @@ void Test_OS_GenericSeek_Impl(void) */ /* note on success this wrapper returns the result of lseek(), not OS_SUCCESS */ - UT_SetForceFail(UT_KEY(OCS_lseek), 111); + UT_SetDefaultReturnValue(UT_KEY(OCS_lseek), 111); OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (UT_INDEX_0, 0, OS_SEEK_CUR), 111); - UT_SetForceFail(UT_KEY(OCS_lseek), 222); + UT_SetDefaultReturnValue(UT_KEY(OCS_lseek), 222); OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (UT_INDEX_0, 0, OS_SEEK_SET), 222); - UT_SetForceFail(UT_KEY(OCS_lseek), 333); + UT_SetDefaultReturnValue(UT_KEY(OCS_lseek), 333); OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (UT_INDEX_0, 0, OS_SEEK_END), 333); /* bad whence */ OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (UT_INDEX_0, 0, 1234), OS_ERROR); /* generic failure of lseek() */ - UT_SetForceFail(UT_KEY(OCS_lseek), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_lseek), -1); OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (UT_INDEX_0, 0, OS_SEEK_END), OS_ERROR); /* The seek implementation also checks for this specific pipe errno */ @@ -102,7 +102,7 @@ void Test_OS_GenericRead_Impl(void) UtAssert_True(UT_GetStubCount(UT_KEY(OS_SelectSingle_Impl)) == 1, "OS_SelectSingle() called"); /* read() failure */ - UT_SetForceFail(UT_KEY(OCS_read), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_read), -1); OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl, (UT_INDEX_0, DestData, sizeof(DestData), 0), OS_ERROR); } @@ -128,7 +128,7 @@ void Test_OS_GenericWrite_Impl(void) UtAssert_True(UT_GetStubCount(UT_KEY(OS_SelectSingle_Impl)) == 1, "OS_SelectSingle() called"); /* write() failure */ - UT_SetForceFail(UT_KEY(OCS_write), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_write), -1); OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl, (UT_INDEX_0, DestData, sizeof(DestData), 0), OS_ERROR); } diff --git a/src/unit-test-coverage/shared/src/coveragetest-binsem.c b/src/unit-test-coverage/shared/src/coveragetest-binsem.c index 28c7c82ea..21bc69803 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-binsem.c +++ b/src/unit-test-coverage/shared/src/coveragetest-binsem.c @@ -62,7 +62,7 @@ void Test_OS_BinSemCreate(void) OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate(NULL, NULL, 0, 0), OS_INVALID_POINTER); - UT_SetForceFail(UT_KEY(OCS_strlen), 10 + OS_MAX_API_NAME); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 10 + OS_MAX_API_NAME); OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate(&objid, "UT", 0, 0), OS_ERR_NAME_TOO_LONG); } @@ -146,7 +146,7 @@ void Test_OS_BinSemGetIdByName(void) int32 actual = ~OS_SUCCESS; osal_id_t objid; - UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_BinSemGetIdByName(&objid, "UT"); UtAssert_True(actual == expected, "OS_BinSemGetIdByName() (%ld) == OS_SUCCESS", (long)actual); OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); diff --git a/src/unit-test-coverage/shared/src/coveragetest-common.c b/src/unit-test-coverage/shared/src/coveragetest-common.c index c200e96be..a8c3d8706 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-common.c +++ b/src/unit-test-coverage/shared/src/coveragetest-common.c @@ -108,17 +108,17 @@ void Test_OS_API_Init(void) /* other error paths */ OS_SharedGlobalVars.Initialized = false; - UT_SetForceFail(UT_KEY(OS_ObjectIdInit), -222); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdInit), -222); OSAPI_TEST_FUNCTION_RC(OS_API_Init(), -222); UT_ResetState(UT_KEY(OS_ObjectIdInit)); OS_SharedGlobalVars.Initialized = false; - UT_SetForceFail(UT_KEY(OS_API_Impl_Init), -333); + UT_SetDefaultReturnValue(UT_KEY(OS_API_Impl_Init), -333); OSAPI_TEST_FUNCTION_RC(OS_API_Init(), -333); UT_ResetState(UT_KEY(OS_API_Impl_Init)); OS_SharedGlobalVars.Initialized = false; - UT_SetForceFail(UT_KEY(OS_TaskAPI_Init), -444); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskAPI_Init), -444); OSAPI_TEST_FUNCTION_RC(OS_API_Init(), -444); UT_ResetState(UT_KEY(OS_TaskAPI_Init)); } @@ -151,7 +151,7 @@ void Test_OS_CleanUpObject(void) while (objtype < OS_OBJECT_TYPE_USER) { UT_ResetState(0); - UT_SetForceFail(UT_KEY(OS_IdentifyObject), objtype); + UT_SetDefaultReturnValue(UT_KEY(OS_IdentifyObject), objtype); switch (objtype) { @@ -195,7 +195,7 @@ void Test_OS_CleanUpObject(void) /* note the return code here is ignored - * the goal is simply to defeat the default * check that the objid was valid (it isn't) */ - UT_SetForceFail(delhandler, OS_ERROR); + UT_SetDefaultReturnValue(delhandler, OS_ERROR); OS_CleanUpObject(OS_OBJECT_ID_UNDEFINED, &ActualObjs); CallCount = UT_GetStubCount(delhandler); diff --git a/src/unit-test-coverage/shared/src/coveragetest-countsem.c b/src/unit-test-coverage/shared/src/coveragetest-countsem.c index 4e59c4062..f5e539f1f 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-countsem.c +++ b/src/unit-test-coverage/shared/src/coveragetest-countsem.c @@ -64,7 +64,7 @@ void Test_OS_CountSemCreate(void) #endif OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate(NULL, NULL, 0, 0), OS_INVALID_POINTER); - UT_SetForceFail(UT_KEY(OCS_strlen), 10 + OS_MAX_API_NAME); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 10 + OS_MAX_API_NAME); OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate(&objid, "UT", 0, 0), OS_ERR_NAME_TOO_LONG); } @@ -134,7 +134,7 @@ void Test_OS_CountSemGetIdByName(void) int32 actual = ~OS_SUCCESS; osal_id_t objid; - UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_CountSemGetIdByName(&objid, "UT"); UtAssert_True(actual == expected, "OS_CountSemGetIdByName() (%ld) == OS_SUCCESS", (long)actual); OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); diff --git a/src/unit-test-coverage/shared/src/coveragetest-file.c b/src/unit-test-coverage/shared/src/coveragetest-file.c index 72b06b924..3cfc7ee23 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-file.c +++ b/src/unit-test-coverage/shared/src/coveragetest-file.c @@ -78,7 +78,7 @@ void Test_OS_OpenCreate(void) UtAssert_True(actual == expected, "OS_OpenCreate() (%ld) == OS_ERROR (bad flags)", (long)actual); /* Test failure to convert path */ - UT_SetForceFail(UT_KEY(OS_TranslatePath), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_TranslatePath), OS_ERROR); 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); @@ -267,19 +267,19 @@ void Test_OS_cp(void) UtAssert_True(actual == expected, "OS_cp() (%ld) == OS_SUCCESS", (long)actual); - UT_SetForceFail(UT_KEY(OS_GenericRead_Impl), -444); + UT_SetDefaultReturnValue(UT_KEY(OS_GenericRead_Impl), -444); 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_SetDataBuffer(UT_KEY(OS_GenericRead_Impl), ReadBuf, sizeof(ReadBuf), false); - UT_SetForceFail(UT_KEY(OS_GenericWrite_Impl), -555); + UT_SetDefaultReturnValue(UT_KEY(OS_GenericWrite_Impl), -555); expected = -555; actual = OS_cp("/cf/file1", "/cf/file2"); UtAssert_True(actual == expected, "OS_cp() (%ld) == -555", (long)actual); - UT_SetForceFail(UT_KEY(OS_TranslatePath), OS_INVALID_POINTER); + UT_SetDefaultReturnValue(UT_KEY(OS_TranslatePath), OS_INVALID_POINTER); expected = OS_INVALID_POINTER; actual = OS_cp("/cf/file1", "/cf/file2"); UtAssert_True(actual == expected, "OS_cp() (%ld) == OS_INVALID_POINTER", (long)actual); @@ -299,7 +299,7 @@ void Test_OS_mv(void) /* In the default case, the implementation tries to rename first. * Force rename to fail so it does a full copy and remove */ - UT_SetForceFail(UT_KEY(OS_FileRename_Impl), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_FileRename_Impl), OS_ERROR); actual = OS_mv("/cf/file1", "/cf/file2"); UtAssert_True(actual == expected, "OS_mv() (%ld) == OS_SUCCESS", (long)actual); } @@ -344,7 +344,7 @@ void Test_OS_FileOpenCheck(void) UtAssert_True(actual == expected, "OS_FileOpenCheck() (%ld) == OS_ERROR", (long)actual); OS_global_stream_table[0].active_id = UT_OBJID_1; - UT_SetForceFail(UT_KEY(OCS_strcmp), 0); + UT_SetDefaultReturnValue(UT_KEY(OCS_strcmp), 0); expected = OS_SUCCESS; actual = OS_FileOpenCheck("/cf/file"); @@ -369,7 +369,7 @@ void Test_OS_CloseFileByName(void) /* setup for success */ expected = OS_SUCCESS; OS_global_stream_table[0].active_id = UT_OBJID_1; - UT_SetForceFail(UT_KEY(OCS_strcmp), 0); + UT_SetDefaultReturnValue(UT_KEY(OCS_strcmp), 0); actual = OS_CloseFileByName("/cf/file"); UtAssert_True(actual == expected, "OS_CloseFileByName() (%ld) == OS_SUCCESS", (long)actual); diff --git a/src/unit-test-coverage/shared/src/coveragetest-filesys.c b/src/unit-test-coverage/shared/src/coveragetest-filesys.c index 2f9234c89..8fd9dc218 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-filesys.c +++ b/src/unit-test-coverage/shared/src/coveragetest-filesys.c @@ -64,7 +64,7 @@ void Test_OS_FileSysAddFixedMap(void) OSAPI_TEST_FUNCTION_RC(OS_FileSysAddFixedMap(&id, "/phys", "/virt"), OS_ERR_NAME_TOO_LONG); UT_ResetState(UT_KEY(OCS_strlen)); - UT_SetForceFail(UT_KEY(OCS_strrchr), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_strrchr), -1); UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 3, 2 + OS_FS_DEV_NAME_LEN); OSAPI_TEST_FUNCTION_RC(OS_FileSysAddFixedMap(&id, "/phys", "/virt"), OS_ERR_NAME_TOO_LONG); UT_ResetState(UT_KEY(OCS_strlen)); @@ -99,7 +99,7 @@ void Test_OS_mkfs(void) actual = OS_mkfs(NULL, NULL, NULL, OSAL_SIZE_C(0), OSAL_BLOCKCOUNT_C(0)); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); 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); @@ -111,13 +111,13 @@ void Test_OS_mkfs(void) UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); /* set up for failure due to formatting */ - UT_SetForceFail(UT_KEY(OS_FileSysFormatVolume_Impl), OS_FS_ERR_DRIVE_NOT_CREATED); + UT_SetDefaultReturnValue(UT_KEY(OS_FileSysFormatVolume_Impl), OS_FS_ERR_DRIVE_NOT_CREATED); expected = OS_FS_ERR_DRIVE_NOT_CREATED; actual = OS_mkfs(TestBuffer, "/ramdev0", "vol", OSAL_SIZE_C(0), OSAL_BLOCKCOUNT_C(0)); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_FS_ERR_DRIVE_NOT_CREATED (format failure)", (long)actual); /* set up for failure due to no free slots */ - UT_SetForceFail(UT_KEY(OS_ObjectIdAllocateNew), OS_ERR_NO_FREE_IDS); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdAllocateNew), OS_ERR_NO_FREE_IDS); expected = OS_FS_ERR_DEVICE_NOT_FREE; actual = OS_mkfs(TestBuffer, "/ramdev0", "vol", OSAL_SIZE_C(0), OSAL_BLOCKCOUNT_C(0)); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_FS_ERR_DEVICE_NOT_FREE", (long)actual); @@ -136,7 +136,7 @@ void Test_OS_rmfs(void) UtAssert_True(actual == expected, "OS_rmfs() (%ld) == OS_SUCCESS", (long)actual); /* check error paths */ - UT_SetForceFail(UT_KEY(OS_ObjectIdGetByName), OS_ERR_NAME_NOT_FOUND); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetByName), OS_ERR_NAME_NOT_FOUND); expected = OS_ERR_NAME_NOT_FOUND; actual = OS_rmfs("/ramdev4"); UtAssert_True(actual == expected, "OS_rmfs() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual); @@ -146,7 +146,7 @@ void Test_OS_rmfs(void) actual = OS_rmfs(NULL); UtAssert_True(actual == expected, "OS_rmfs() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; actual = OS_rmfs("/ramdev4"); UtAssert_True(actual == expected, "OS_rmfs() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); @@ -174,14 +174,14 @@ void Test_OS_initfs(void) actual = OS_initfs(NULL, NULL, NULL, OSAL_SIZE_C(0), OSAL_BLOCKCOUNT_C(0)); UtAssert_True(actual == expected, "OS_initfs() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); 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_strlen)); /* set up for failure */ - UT_SetForceFail(UT_KEY(OS_ObjectIdAllocateNew), OS_ERR_NO_FREE_IDS); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdAllocateNew), OS_ERR_NO_FREE_IDS); expected = OS_FS_ERR_DEVICE_NOT_FREE; actual = OS_initfs(TestBuffer, "/ramdev0", "vol", OSAL_SIZE_C(0), OSAL_BLOCKCOUNT_C(0)); UtAssert_True(actual == expected, "OS_initfs() (%ld) == OS_FS_ERR_DEVICE_NOT_FREE", (long)actual); @@ -217,7 +217,7 @@ void Test_OS_mount(void) actual = OS_mount(NULL, NULL); UtAssert_True(actual == expected, "OS_mount() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; actual = OS_mount("/ramdev0", "/ram0"); UtAssert_True(actual == expected, "OS_mount() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); @@ -247,7 +247,7 @@ void Test_OS_unmount(void) actual = OS_unmount(NULL); UtAssert_True(actual == expected, "OS_unmount() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; actual = OS_unmount("/ram0"); UtAssert_True(actual == expected, "OS_unmount() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); @@ -277,13 +277,13 @@ void Test_OS_fsBlocksFree(void) actual = OS_fsBlocksFree(NULL); UtAssert_True(actual == expected, "OS_fsBlocksFree() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); 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_strlen)); - UT_SetForceFail(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); expected = OS_FS_ERR_PATH_INVALID; actual = OS_fsBlocksFree("invalid"); UtAssert_True(actual == expected, "OS_fsBlocksFree() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); @@ -316,13 +316,13 @@ void Test_OS_fsBytesFree(void) actual = OS_fsBytesFree(NULL, NULL); UtAssert_True(actual == expected, "OS_fsBytesFree() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); 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_strlen)); - UT_SetForceFail(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); expected = OS_FS_ERR_PATH_INVALID; actual = OS_fsBytesFree("invalid", &bytes_free); UtAssert_True(actual == expected, "OS_fsBytesFree() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); @@ -346,14 +346,14 @@ void Test_OS_chkfs(void) actual = OS_chkfs(NULL, false); UtAssert_True(actual == expected, "OS_fsBytesFree() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); 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_strlen)); /* Test Fail due to no matching VolTab entry */ - UT_SetForceFail(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); expected = OS_ERR_NAME_NOT_FOUND; actual = OS_chkfs("none", true); UtAssert_True(actual == expected, "OS_chkfs() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual); @@ -371,7 +371,7 @@ void Test_OS_FS_GetPhysDriveName(void) UtAssert_True(actual == expected, "OS_FS_GetPhysDriveName() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), OS_MAX_PATH_LEN + 10); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), OS_MAX_PATH_LEN + 10); 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); @@ -388,7 +388,7 @@ void Test_OS_FS_GetPhysDriveName(void) UtAssert_True(actual == expected, "OS_FS_GetPhysDriveName() (%ld) == OS_SUCCESS", (long)actual); /* Test Fail due to no matching VolTab entry */ - UT_SetForceFail(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); expected = OS_ERR_NAME_NOT_FOUND; actual = OS_FS_GetPhysDriveName(NameBuf, "none"); UtAssert_True(actual == expected, "OS_FS_GetPhysDriveName() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual); @@ -451,7 +451,7 @@ void Test_OS_TranslatePath(void) actual = OS_TranslatePath(NULL, NULL); UtAssert_True(actual == expected, "OS_TranslatePath(NULL,NULL) (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), OS_MAX_PATH_LEN + 10); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), OS_MAX_PATH_LEN + 10); 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); @@ -472,7 +472,7 @@ void Test_OS_TranslatePath(void) actual = OS_TranslatePath("invalid/", LocalBuffer); UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); - UT_SetForceFail(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); + 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)); diff --git a/src/unit-test-coverage/shared/src/coveragetest-idmap.c b/src/unit-test-coverage/shared/src/coveragetest-idmap.c index 5e3498693..00b537c3d 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-idmap.c +++ b/src/unit-test-coverage/shared/src/coveragetest-idmap.c @@ -96,7 +96,7 @@ void Test_OS_LockUnlockGlobal(void) OS_Lock_Global(55555); OS_Unlock_Global(55555); - UT_SetForceFail(UT_KEY(OS_TaskGetId), 0); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId), 0); OS_Lock_Global(OS_OBJECT_TYPE_OS_BINSEM); OS_Unlock_Global(OS_OBJECT_TYPE_OS_BINSEM); } @@ -294,7 +294,7 @@ void Test_OS_ObjectIdFindByName(void) /* * Pass in a name that is beyond OS_MAX_API_NAME */ - UT_SetForceFail(UT_KEY(OCS_strlen), OS_MAX_API_NAME + 10); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), OS_MAX_API_NAME + 10); expected = OS_ERR_NAME_TOO_LONG; actual = OS_ObjectIdFindByName(OS_OBJECT_TYPE_OS_TASK, TaskName, &objid); UtAssert_True(actual == expected, "OS_ObjectFindIdByName(%s) (%ld) == OS_ERR_NAME_TOO_LONG", TaskName, diff --git a/src/unit-test-coverage/shared/src/coveragetest-module.c b/src/unit-test-coverage/shared/src/coveragetest-module.c index d553629ff..1b69365af 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-module.c +++ b/src/unit-test-coverage/shared/src/coveragetest-module.c @@ -94,13 +94,13 @@ void Test_OS_ModuleLoad(void) expected = OS_INVALID_POINTER; UtAssert_True(actual == expected, "OS_ModuleLoad() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); actual = OS_ModuleLoad(&objid, "UTS", "File2", OS_MODULE_FLAG_GLOBAL_SYMBOLS); expected = OS_ERR_NAME_TOO_LONG; UtAssert_True(actual == expected, "OS_ModuleLoad() (%ld) == OS_ERR_NAME_TOO_LONG", (long)actual); UT_ResetState(UT_KEY(OCS_strlen)); - UT_SetForceFail(UT_KEY(OS_TranslatePath), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_TranslatePath), OS_ERROR); actual = OS_ModuleLoad(&objid, "UT", "FileBad", OS_MODULE_FLAG_GLOBAL_SYMBOLS); expected = OS_ERROR; UtAssert_True(actual == expected, "OS_ModuleLoad() (%ld) == OS_ERROR", (long)actual); @@ -135,7 +135,7 @@ void Test_OS_SymbolLookup(void) UtAssert_True(actual == expected, "OS_SymbolLookup(name=%s) (%ld) == OS_SUCCESS", "uttestsym0", (long)actual); UT_ResetState(UT_KEY(OS_GlobalSymbolLookup_Impl)); - UT_SetForceFail(UT_KEY(OS_GlobalSymbolLookup_Impl), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_GlobalSymbolLookup_Impl), OS_ERROR); /* this lookup should always fail */ symaddr = 0; @@ -217,7 +217,7 @@ void Test_OS_SymbolTableDump(void) actual = OS_SymbolTableDump(NULL, OSAL_SIZE_C(555)); UtAssert_True(actual == expected, "OS_SymbolTableDump() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OS_TranslatePath), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_TranslatePath), OS_ERROR); expected = OS_ERROR; actual = OS_SymbolTableDump("test", OSAL_SIZE_C(555)); UtAssert_True(actual == expected, "OS_SymbolTableDump() (%ld) == OS_ERROR", (long)actual); diff --git a/src/unit-test-coverage/shared/src/coveragetest-mutex.c b/src/unit-test-coverage/shared/src/coveragetest-mutex.c index 4d2cd0728..8fa79469c 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-mutex.c +++ b/src/unit-test-coverage/shared/src/coveragetest-mutex.c @@ -61,7 +61,7 @@ void Test_OS_MutSemCreate(void) OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate(NULL, NULL, 0), OS_INVALID_POINTER); - UT_SetForceFail(UT_KEY(OCS_strlen), 10 + OS_MAX_API_NAME); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 10 + OS_MAX_API_NAME); OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate(&objid, "UT", 0), OS_ERR_NAME_TOO_LONG); } @@ -117,7 +117,7 @@ void Test_OS_MutSemGetIdByName(void) int32 actual = ~OS_SUCCESS; osal_id_t objid; - UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_MutSemGetIdByName(&objid, "UT"); UtAssert_True(actual == expected, "OS_MutSemGetIdByName() (%ld) == OS_SUCCESS", (long)actual); OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); diff --git a/src/unit-test-coverage/shared/src/coveragetest-network.c b/src/unit-test-coverage/shared/src/coveragetest-network.c index 871992d1f..a48a75589 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-network.c +++ b/src/unit-test-coverage/shared/src/coveragetest-network.c @@ -52,7 +52,7 @@ void Test_OS_NetworkGetHostName(void) actual = OS_NetworkGetHostName(Buffer, sizeof(Buffer)); UtAssert_True(actual == expected, "OS_NetworkGetHostName() (%ld) == OS_SUCCESS", (long)actual); - UT_SetForceFail(UT_KEY(OS_NetworkGetHostName_Impl), -4444); + UT_SetDefaultReturnValue(UT_KEY(OS_NetworkGetHostName_Impl), -4444); expected = -4444; actual = OS_NetworkGetHostName(Buffer, sizeof(Buffer)); UtAssert_True(actual == expected, "OS_NetworkGetHostName(impl error) (%ld) == -4444", (long)actual); @@ -79,7 +79,7 @@ void Test_OS_NetworkGetID(void) actual = OS_NetworkGetID(); UtAssert_True(actual == expected, "OS_NetworkGetID(nominal) (%ld) == 42", (long)actual); - UT_SetForceFail(UT_KEY(OS_NetworkGetID_Impl), -5555); + UT_SetDefaultReturnValue(UT_KEY(OS_NetworkGetID_Impl), -5555); expected = -1; actual = OS_NetworkGetID(); UtAssert_True(actual == expected, "OS_NetworkGetID(error) (%ld) == -1", (long)actual); diff --git a/src/unit-test-coverage/shared/src/coveragetest-printf.c b/src/unit-test-coverage/shared/src/coveragetest-printf.c index 8d6a888d6..c7f0fb9ac 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-printf.c +++ b/src/unit-test-coverage/shared/src/coveragetest-printf.c @@ -93,10 +93,10 @@ void Test_OS_printf(void) /* * For coverage, exercise different paths depending on the return value */ - UT_SetForceFail(UT_KEY(OCS_vsnprintf), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_vsnprintf), -1); OS_printf("UnitTest6"); - UT_SetForceFail(UT_KEY(OCS_vsnprintf), OS_BUFFER_SIZE + 10); + UT_SetDefaultReturnValue(UT_KEY(OCS_vsnprintf), OS_BUFFER_SIZE + 10); OS_printf("UnitTest7"); } diff --git a/src/unit-test-coverage/shared/src/coveragetest-queue.c b/src/unit-test-coverage/shared/src/coveragetest-queue.c index 3dd21200f..dc6ccb64d 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-queue.c +++ b/src/unit-test-coverage/shared/src/coveragetest-queue.c @@ -65,7 +65,7 @@ void Test_OS_QueueCreate(void) actual = OS_QueueCreate(NULL, "UT", OSAL_BLOCKCOUNT_C(0), OSAL_SIZE_C(0), 0); UtAssert_True(actual == expected, "OS_QueueCreate() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); expected = OS_ERR_NAME_TOO_LONG; actual = OS_QueueCreate(&objid, "UT", OSAL_BLOCKCOUNT_C(0), OSAL_SIZE_C(0), 0); UtAssert_True(actual == expected, "OS_QueueCreate() (%ld) == OS_ERR_NAME_TOO_LONG", (long)actual); @@ -146,7 +146,7 @@ void Test_OS_QueueGetIdByName(void) int32 actual = ~OS_SUCCESS; osal_id_t objid; - UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); + 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)); diff --git a/src/unit-test-coverage/shared/src/coveragetest-select.c b/src/unit-test-coverage/shared/src/coveragetest-select.c index 79c43f004..bb27e6451 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-select.c +++ b/src/unit-test-coverage/shared/src/coveragetest-select.c @@ -107,7 +107,7 @@ void Test_OS_SelectFdAddClearOps(void) UtAssert_True(!OS_SelectFdIsSet(&UtSet, UT_OBJID_2), "OS_SelectFdIsSet(2) == false"); expected = -42; - UT_SetForceFail(UT_KEY(OS_ObjectIdToArrayIndex), expected); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdToArrayIndex), expected); actual = OS_SelectFdAdd(&UtSet, UT_OBJID_2); UtAssert_True(actual == expected, "OS_SelectFdAdd() (%ld) == %ld", (long)actual, (long)expected); actual = OS_SelectFdClear(&UtSet, UT_OBJID_1); diff --git a/src/unit-test-coverage/shared/src/coveragetest-sockets.c b/src/unit-test-coverage/shared/src/coveragetest-sockets.c index 9c7acd65b..5c9156edd 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-sockets.c +++ b/src/unit-test-coverage/shared/src/coveragetest-sockets.c @@ -60,7 +60,7 @@ void Test_OS_CreateSocketName(void) */ OS_SockAddr_t testaddr; - UT_SetForceFail(UT_KEY(OS_SocketAddrToString_Impl), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_SocketAddrToString_Impl), OS_ERROR); OS_CreateSocketName(0, &testaddr, "ut"); /* @@ -192,7 +192,7 @@ void Test_OS_SocketAccept(void) */ OS_stream_table[1].stream_state = OS_STREAM_STATE_BOUND; expected = -1234; - UT_SetForceFail(UT_KEY(OS_SocketAccept_Impl), -1234); + UT_SetDefaultReturnValue(UT_KEY(OS_SocketAccept_Impl), -1234); actual = OS_SocketAccept(UT_OBJID_1, &connsock_id, &Addr, 0); UtAssert_True(actual == expected, "OS_SocketAccept() underlying failure (%ld) == -1234", (long)actual); } @@ -355,7 +355,7 @@ void Test_OS_SocketGetIdByName(void) int32 actual = ~OS_SUCCESS; osal_id_t objid; - UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_SocketGetIdByName(&objid, "UT"); UtAssert_True(actual == expected, "OS_SocketGetIdByName() (%ld) == OS_SUCCESS", (long)actual); OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); diff --git a/src/unit-test-coverage/shared/src/coveragetest-task.c b/src/unit-test-coverage/shared/src/coveragetest-task.c index 7a0e9c63f..9fa88677d 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-task.c +++ b/src/unit-test-coverage/shared/src/coveragetest-task.c @@ -119,7 +119,7 @@ void Test_OS_TaskCreate(void) OSAPI_TEST_FUNCTION_RC( OS_TaskCreate(&objid, "UT", UT_TestHook, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(0), OSAL_PRIORITY_C(0), 0), OS_ERROR); - UT_SetForceFail(UT_KEY(OCS_strlen), 10 + OS_MAX_API_NAME); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 10 + OS_MAX_API_NAME); OSAPI_TEST_FUNCTION_RC( OS_TaskCreate(&objid, "UT", UT_TestHook, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(128), OSAL_PRIORITY_C(0), 0), OS_ERR_NAME_TOO_LONG); @@ -141,7 +141,7 @@ void Test_OS_TaskDelete(void) UtAssert_True(actual == expected, "OS_TaskDelete() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(UT_TestHook_Count == 1, "UT_TestHook_Count (%lu) == 1", (unsigned long)UT_TestHook_Count); - UT_SetForceFail(UT_KEY(OS_TaskDelete_Impl), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskDelete_Impl), OS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_TaskDelete(UT_OBJID_1), OS_ERROR); UtAssert_True(UT_TestHook_Count == 1, "UT_TestHook_Count (%lu) == 1", (unsigned long)UT_TestHook_Count); @@ -211,11 +211,11 @@ void Test_OS_TaskGetId(void) osal_id_t objid; idbuf.val = 5555; - UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), idbuf.val); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), idbuf.val); objid = OS_TaskGetId(); OSAPI_TEST_OBJID(objid, ==, idbuf.id); - UT_SetForceFail(UT_KEY(OS_ObjectIdGetById), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetById), OS_ERROR); objid = OS_TaskGetId(); OSAPI_TEST_OBJID(objid, ==, OS_OBJECT_ID_UNDEFINED); } @@ -230,7 +230,7 @@ void Test_OS_TaskGetIdByName(void) int32 actual = ~OS_SUCCESS; osal_id_t objid = OS_OBJECT_ID_UNDEFINED; - UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_TaskGetIdByName(&objid, "UT"); UtAssert_True(actual == expected, "OS_TaskGetIdByName() (%ld) == OS_SUCCESS", (long)actual); OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); @@ -287,7 +287,7 @@ void Test_OS_TaskInstallDeleteHandler(void) int32 expected = OS_SUCCESS; int32 actual = ~OS_SUCCESS; - UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), 1); actual = OS_TaskInstallDeleteHandler(UT_TestHook); UtAssert_True(actual == expected, "OS_TaskInstallDeleteHandler() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(OS_task_table[1].delete_hook_pointer == UT_TestHook, @@ -329,14 +329,14 @@ void Test_OS_TaskFindIdBySystemData(void) actual = OS_TaskFindIdBySystemData(NULL, &test_sysdata, sizeof(test_sysdata)); UtAssert_True(actual == expected, "OS_TaskFindIdBySystemData() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OS_TaskValidateSystemData_Impl), expected); + 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)); /* Test search failure */ expected = OS_ERR_NAME_NOT_FOUND; - UT_SetForceFail(UT_KEY(OS_ObjectIdGetBySearch), expected); + 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)); diff --git a/src/unit-test-coverage/shared/src/coveragetest-time.c b/src/unit-test-coverage/shared/src/coveragetest-time.c index 6c3f0b17d..fc9fd125d 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-time.c +++ b/src/unit-test-coverage/shared/src/coveragetest-time.c @@ -81,7 +81,7 @@ void Test_OS_TimerAdd(void) actual = OS_TimerAdd(NULL, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); 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); @@ -91,19 +91,19 @@ void Test_OS_TimerAdd(void) actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, NULL, &arg); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); - UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); 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_SetForceFail(UT_KEY(OS_ObjectIdGetById), OS_ERROR); + 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_SetForceFail(UT_KEY(OS_ObjectIdAllocateNew), OS_ERROR); + 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); @@ -143,13 +143,13 @@ void Test_OS_TimerCreate(void) actual = OS_TimerCreate(&objid, "UT", &accuracy, NULL); UtAssert_True(actual == expected, "OS_TimerSet() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); - UT_SetForceFail(UT_KEY(OS_TimeBaseCreate), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_TimeBaseCreate), OS_ERROR); 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_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); 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); @@ -181,7 +181,7 @@ void Test_OS_TimerSet(void) actual = OS_TimerSet(UT_OBJID_2, UINT32_MAX, UINT32_MAX); UtAssert_True(actual == expected, "OS_TimerSet() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); - UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); 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); @@ -223,7 +223,7 @@ void Test_OS_TimerDelete(void) memset(OS_timecb_table, 0, sizeof(OS_timecb_table)); memset(OS_timebase_table, 0, sizeof(OS_timebase_table)); - UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); 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); @@ -240,7 +240,7 @@ void Test_OS_TimerGetIdByName(void) int32 actual = ~OS_SUCCESS; osal_id_t objid; - UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); + 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)); @@ -253,7 +253,7 @@ void Test_OS_TimerGetIdByName(void) actual = OS_TimerGetIdByName(NULL, "NF"); UtAssert_True(actual == expected, "OS_TimerGetIdByName() (%ld) == %ld", (long)actual, (long)expected); - UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; actual = OS_TimerGetIdByName(&objid, "NF"); UtAssert_True(actual == expected, "OS_TimerGetIdByName() (%ld) == %ld", (long)actual, (long)expected); @@ -293,7 +293,7 @@ void Test_OS_TimerGetInfo(void) actual = OS_TimerGetInfo(UT_OBJID_1, NULL); UtAssert_True(actual == expected, "OS_TimerGetInfo() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); 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); diff --git a/src/unit-test-coverage/shared/src/coveragetest-timebase.c b/src/unit-test-coverage/shared/src/coveragetest-timebase.c index 544b4c052..bfde8cb2e 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-timebase.c +++ b/src/unit-test-coverage/shared/src/coveragetest-timebase.c @@ -99,13 +99,13 @@ void Test_OS_TimeBaseCreate(void) actual = OS_TimeBaseCreate(NULL, NULL, NULL); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); 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_strlen)); - UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; actual = OS_TimeBaseCreate(&objid, "UT", UT_TimerSync); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); @@ -128,7 +128,7 @@ void Test_OS_TimeBaseSet(void) UtAssert_True(actual == expected, "OS_TimeBaseSet() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); /* test error paths */ - UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; actual = OS_TimeBaseSet(UT_OBJID_1, 1000, 1000); UtAssert_True(actual == expected, "OS_TimeBaseSet() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); @@ -146,7 +146,7 @@ void Test_OS_TimeBaseDelete(void) UtAssert_True(actual == expected, "OS_TimeBaseDelete() (%ld) == OS_SUCCESS", (long)actual); /* test error paths */ - UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; actual = OS_TimeBaseDelete(UT_OBJID_1); UtAssert_True(actual == expected, "OS_TimeBaseDelete() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); @@ -162,7 +162,7 @@ void Test_OS_TimeBaseGetIdByName(void) int32 actual = ~OS_SUCCESS; osal_id_t objid; - UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_TimeBaseGetIdByName(&objid, "UT"); UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == OS_SUCCESS", (long)actual); OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); @@ -177,7 +177,7 @@ void Test_OS_TimeBaseGetIdByName(void) actual = OS_TimeBaseGetIdByName(NULL, NULL); UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; actual = OS_TimeBaseGetIdByName(&objid, "NF"); UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); @@ -222,7 +222,7 @@ void Test_OS_TimeBaseGetInfo(void) actual = OS_TimeBaseGetInfo(UT_OBJID_1, NULL); UtAssert_True(actual == expected, "OS_TimeBaseGetInfo() (%ld) == OS_INVALID_POINTER", (long)actual); - UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); + UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; actual = OS_TimeBaseGetInfo(UT_OBJID_1, &timebase_prop); UtAssert_True(actual == expected, "OS_TimeBaseGetInfo() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); @@ -280,7 +280,7 @@ void Test_OS_TimeBase_CallbackThread(void) /* Check that the TimeCB function was called */ UtAssert_True(TimeCB > 0, "TimeCB (%lu) > 0", (unsigned long)TimeCB); - UT_SetForceFail(UT_KEY(OS_ObjectIdGetById), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetById), OS_ERROR); OS_TimeBase_CallbackThread(UT_OBJID_2); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c b/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c index 646205e51..906b4187b 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c @@ -52,7 +52,7 @@ void Test_OS_BinSemCreate_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate_Impl(UT_INDEX_0, 0, 0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_semBInitialize), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_semBInitialize), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate_Impl(UT_INDEX_0, 0, 0), OS_SEM_FAILURE); } @@ -73,7 +73,7 @@ void Test_OS_BinSemGive_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_BinSemGive_Impl(UT_INDEX_0), OS_SUCCESS); - UT_SetForceFail(UT_StubKey_GenericSemGive, OS_SEM_FAILURE); + UT_SetDefaultReturnValue(UT_StubKey_GenericSemGive, OS_SEM_FAILURE); OSAPI_TEST_FUNCTION_RC(OS_BinSemGive_Impl(UT_INDEX_0), OS_SEM_FAILURE); } @@ -85,7 +85,7 @@ void Test_OS_BinSemFlush_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_BinSemFlush_Impl(UT_INDEX_0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_semFlush), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_semFlush), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_BinSemFlush_Impl(UT_INDEX_0), OS_SEM_FAILURE); } @@ -106,10 +106,10 @@ void Test_OS_BinSemTimedWait_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(UT_INDEX_0, 100), OS_SUCCESS); - UT_SetForceFail(UT_StubKey_GenericSemTake, OS_SEM_FAILURE); + UT_SetDefaultReturnValue(UT_StubKey_GenericSemTake, OS_SEM_FAILURE); OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(UT_INDEX_0, 100), OS_SEM_FAILURE); - UT_SetForceFail(UT_KEY(OS_Milli2Ticks), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_Milli2Ticks), OS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(UT_INDEX_0, 100), OS_ERROR); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-common.c b/src/unit-test-coverage/vxworks/src/coveragetest-common.c index 874ac2ae7..e8737479d 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-common.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-common.c @@ -42,7 +42,7 @@ void Test_OS_API_Impl_Init(void) * int32 OS_API_Impl_Init(uint32 idtype) */ OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(0), OS_SUCCESS); - UT_SetForceFail(UT_StubKey_OS_VxWorks_TableMutex_Init, OS_ERROR); + 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); OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS); @@ -85,7 +85,7 @@ void Test_OS_VxWorks_GenericSemGive(void) OCS_SEM_ID SemID = NULL; OSAPI_TEST_FUNCTION_RC(OS_VxWorks_GenericSemGive(SemID), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_semGive), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_semGive), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_VxWorks_GenericSemGive(SemID), OS_SEM_FAILURE); } /* end OS_VxWorks_GenericSemGive */ @@ -98,7 +98,7 @@ void Test_OS_VxWorks_GenericSemTake(void) OCS_SEM_ID SemID = NULL; OSAPI_TEST_FUNCTION_RC(OS_VxWorks_GenericSemTake(SemID, 10), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_semTake), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_semTake), OCS_ERROR); OCS_errno = OCS_S_objLib_OBJ_TIMEOUT; OSAPI_TEST_FUNCTION_RC(OS_VxWorks_GenericSemTake(SemID, 0), OS_SEM_TIMEOUT); OCS_errno = OCS_S_objLib_OBJ_ID_ERROR; diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-console.c b/src/unit-test-coverage/vxworks/src/coveragetest-console.c index c39910841..f3a358f32 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-console.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-console.c @@ -47,7 +47,7 @@ void Test_OS_ConsoleWakeup_Impl(void) OS_ConsoleWakeup_Impl(0); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_semGive)) == 1, "semGive() called in async mode"); - UT_SetForceFail(UT_KEY(OCS_semGive), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_semGive), -1); OS_ConsoleWakeup_Impl(0); UT_ConsoleTest_SetConsoleAsync(0, false); @@ -61,11 +61,11 @@ void Test_OS_ConsoleCreate_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(0), OS_SUCCESS); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_taskSpawn)) == 1, "taskSpawn() called"); - UT_SetForceFail(UT_KEY(OCS_semCInitialize), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_semCInitialize), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(0), OS_SEM_FAILURE); UT_ClearForceFail(UT_KEY(OCS_semCInitialize)); - UT_SetForceFail(UT_KEY(OCS_taskSpawn), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_taskSpawn), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(0), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_taskSpawn)); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c b/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c index 77e3e5a81..daa20093a 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c @@ -48,7 +48,7 @@ void Test_OS_CountSemCreate_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate_Impl(UT_INDEX_0, 0, 0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_semCInitialize), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_semCInitialize), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate_Impl(UT_INDEX_0, 0, 0), OS_SEM_FAILURE); } @@ -87,7 +87,7 @@ void Test_OS_CountSemTimedWait_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_CountSemTimedWait_Impl(UT_INDEX_0, 100), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OS_Milli2Ticks), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_Milli2Ticks), OS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_CountSemTimedWait_Impl(UT_INDEX_0, 100), OS_ERROR); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c b/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c index 62c981df6..f31a0bbe2 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c @@ -53,7 +53,7 @@ void Test_OS_DirCreate_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_DirCreate_Impl("dir", 0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_mkdir), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_mkdir), -1); OSAPI_TEST_FUNCTION_RC(OS_DirCreate_Impl("dir", 0), OS_ERROR); } @@ -64,7 +64,7 @@ void Test_OS_DirOpen_Impl(void) * int32 OS_DirOpen_Impl(uint32 local_id, const char *local_path) */ OSAPI_TEST_FUNCTION_RC(OS_DirOpen_Impl(UT_INDEX_0, "dir"), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_opendir), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_opendir), -1); OSAPI_TEST_FUNCTION_RC(OS_DirOpen_Impl(UT_INDEX_0, "dir"), OS_ERROR); } @@ -87,7 +87,7 @@ void Test_OS_DirRead_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_DirRead_Impl(UT_INDEX_0, &dirent_buff), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_readdir), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_readdir), -1); OSAPI_TEST_FUNCTION_RC(OS_DirRead_Impl(UT_INDEX_0, &dirent_buff), OS_ERROR); } @@ -108,7 +108,7 @@ void Test_OS_DirRemove_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_DirRemove_Impl("dir"), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_rmdir), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_rmdir), -1); OSAPI_TEST_FUNCTION_RC(OS_DirRemove_Impl("dir"), OS_ERROR); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c b/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c index 6cdf934ec..f10632e2b 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c @@ -70,11 +70,11 @@ void Test_OS_FileSysStartVolume_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(2), expected); /* Failure to create XBD layer */ - UT_SetForceFail(UT_KEY(OCS_xbdBlkDevCreateSync), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_xbdBlkDevCreateSync), -1); OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(1), OS_FS_ERR_DRIVE_NOT_CREATED); /* Failure to create low level block dev */ - UT_SetForceFail(UT_KEY(OCS_ramDevCreate), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_ramDevCreate), -1); OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(1), OS_FS_ERR_DRIVE_NOT_CREATED); } @@ -110,7 +110,7 @@ void Test_OS_FileSysFormatVolume_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_FileSysFormatVolume_Impl(0), OS_SUCCESS); /* Failure of the dosFsVolFormat() call */ - UT_SetForceFail(UT_KEY(OCS_dosFsVolFormat), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_dosFsVolFormat), -1); OSAPI_TEST_FUNCTION_RC(OS_FileSysFormatVolume_Impl(0), OS_FS_ERR_DRIVE_NOT_CREATED); } @@ -122,7 +122,7 @@ void Test_OS_FileSysMountVolume_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_FileSysMountVolume_Impl(0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_open), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1); OSAPI_TEST_FUNCTION_RC(OS_FileSysMountVolume_Impl(0), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); } @@ -135,11 +135,11 @@ void Test_OS_FileSysUnmountVolume_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_FileSysUnmountVolume_Impl(0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_open), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1); OSAPI_TEST_FUNCTION_RC(OS_FileSysUnmountVolume_Impl(0), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); - UT_SetForceFail(UT_KEY(OCS_ioctl), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_ioctl), -1); OSAPI_TEST_FUNCTION_RC(OS_FileSysUnmountVolume_Impl(0), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_ioctl)); } @@ -153,7 +153,7 @@ void Test_OS_FileSysStatVolume_Impl(void) OS_statvfs_t stat; OSAPI_TEST_FUNCTION_RC(OS_FileSysStatVolume_Impl(0, &stat), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_statvfs), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_statvfs), -1); OSAPI_TEST_FUNCTION_RC(OS_FileSysStatVolume_Impl(0, &stat), OS_ERROR); } @@ -165,11 +165,11 @@ void Test_OS_FileSysCheckVolume_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(0, true), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_open), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1); OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(0, false), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); - UT_SetForceFail(UT_KEY(OCS_ioctl), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_ioctl), -1); OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(0, false), OS_ERROR); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-heap.c b/src/unit-test-coverage/vxworks/src/coveragetest-heap.c index 10d68a79a..06b04b7a5 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-heap.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-heap.c @@ -40,7 +40,7 @@ void Test_OS_HeapGetInfo_Impl(void) memset(&heap_prop, 0xEE, sizeof(heap_prop)); OSAPI_TEST_FUNCTION_RC(OS_HeapGetInfo_Impl(&heap_prop), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_memPartInfoGet), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_memPartInfoGet), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_HeapGetInfo_Impl(&heap_prop), OS_ERROR); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-idmap.c b/src/unit-test-coverage/vxworks/src/coveragetest-idmap.c index 124f7d322..89f140b4c 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-idmap.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-idmap.c @@ -55,7 +55,7 @@ void Test_OS_Lock_Global_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_Lock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_semTake)) == 1, "semTake() called"); - UT_SetForceFail(UT_KEY(OCS_semTake), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_semTake), -1); OSAPI_TEST_FUNCTION_RC(OS_Lock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_ERROR); } @@ -68,7 +68,7 @@ void Test_OS_Unlock_Global_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_Unlock_Global_Impl(10000), OS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_Unlock_Global_Impl(0), OS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_Unlock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_semGive), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_semGive), -1); OSAPI_TEST_FUNCTION_RC(OS_Unlock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_ERROR); } @@ -79,7 +79,7 @@ void Test_OS_API_Impl_Init(void) * int32 OS_API_Impl_Init(uint32 idtype) */ OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_TableMutex_Init(0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_semMInitialize), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_semMInitialize), -1); OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_TableMutex_Init(OS_OBJECT_TYPE_OS_TASK), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_semMInitialize)); OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_TableMutex_Init(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-loader.c b/src/unit-test-coverage/vxworks/src/coveragetest-loader.c index c22d56229..5c718df1c 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-loader.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-loader.c @@ -51,10 +51,10 @@ void Test_OS_ModuleLoad_Impl(void) * int32 OS_ModuleLoad_Impl ( uint32 module_id, char *translated_path ) */ OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(UT_INDEX_0, "local"), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_open), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1); OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(UT_INDEX_0, "local"), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); - UT_SetForceFail(UT_KEY(OCS_loadModule), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_loadModule), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(UT_INDEX_0, "local"), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_loadModule)); } @@ -65,7 +65,7 @@ void Test_OS_ModuleUnload_Impl(void) * int32 OS_ModuleUnload_Impl ( uint32 module_id ) */ OSAPI_TEST_FUNCTION_RC(OS_ModuleUnload_Impl(UT_INDEX_0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_unldByModuleId), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_unldByModuleId), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_ModuleUnload_Impl(UT_INDEX_0), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_unldByModuleId)); } @@ -86,7 +86,7 @@ void Test_OS_ModuleGetInfo_Impl(void) * but the boolean in the output struct should be false. */ memset(&module_prop, 0, sizeof(module_prop)); - UT_SetForceFail(UT_KEY(OCS_moduleInfoGet), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_moduleInfoGet), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(UT_INDEX_0, &module_prop), OS_SUCCESS); UT_ClearForceFail(UT_KEY(OCS_moduleInfoGet)); UtAssert_True(!module_prop.addr.valid, "addresses in output not valid"); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-mutex.c b/src/unit-test-coverage/vxworks/src/coveragetest-mutex.c index b9bcf518f..2320fb3a1 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-mutex.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-mutex.c @@ -45,7 +45,7 @@ void Test_OS_MutSemCreate_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate_Impl(UT_INDEX_0, 0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_semMInitialize), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_semMInitialize), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate_Impl(UT_INDEX_0, 0), OS_SEM_FAILURE); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-network.c b/src/unit-test-coverage/vxworks/src/coveragetest-network.c index e196dc5cc..e241c74f2 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-network.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-network.c @@ -49,7 +49,7 @@ void Test_OS_NetworkGetHostName_Impl(void) char buffer[16]; OSAPI_TEST_FUNCTION_RC(OS_NetworkGetHostName_Impl(buffer, sizeof(buffer)), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_gethostname), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_gethostname), -1); OSAPI_TEST_FUNCTION_RC(OS_NetworkGetHostName_Impl(buffer, sizeof(buffer)), OS_ERROR); } /* end OS_NetworkGetHostName_Impl */ @@ -63,10 +63,10 @@ void Test_OS_NetworkGetID_Impl(void) */ int32 IdBuf; - UT_SetForceFail(UT_KEY(OCS_hostGetByName), 1234); + UT_SetDefaultReturnValue(UT_KEY(OCS_hostGetByName), 1234); OSAPI_TEST_FUNCTION_RC(OS_NetworkGetID_Impl(&IdBuf), OS_SUCCESS); UtAssert_True(IdBuf == 1234, "IdBuf (%ld) == 1234", (long)IdBuf); - UT_SetForceFail(UT_KEY(OCS_hostGetByName), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_hostGetByName), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_NetworkGetID_Impl(&IdBuf), OS_ERROR); } /* end OS_NetworkGetID_Impl */ diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-no-module.c b/src/unit-test-coverage/vxworks/src/coveragetest-no-module.c index 7983ad49e..ed9b3083d 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-no-module.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-no-module.c @@ -49,10 +49,10 @@ void Test_OS_ModuleLoad_Impl(void) * int32 OS_ModuleLoad_Impl ( uint32 module_id, char *translated_path ) */ OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0, "local"), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_open), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1); OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0, "local"), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); - UT_SetForceFail(UT_KEY(OCS_loadModule), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_loadModule), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0, "local"), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_loadModule)); } @@ -63,7 +63,7 @@ void Test_OS_ModuleUnload_Impl(void) * int32 OS_ModuleUnload_Impl ( uint32 module_id ) */ OSAPI_TEST_FUNCTION_RC(OS_ModuleUnload_Impl(0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_unldByModuleId), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_unldByModuleId), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_ModuleUnload_Impl(0), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_unldByModuleId)); } @@ -84,7 +84,7 @@ void Test_OS_ModuleGetInfo_Impl(void) * but the boolean in the output struct should be false. */ memset(&module_prop, 0, sizeof(module_prop)); - UT_SetForceFail(UT_KEY(OCS_moduleInfoGet), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_moduleInfoGet), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(0, &module_prop), OS_SUCCESS); UT_ClearForceFail(UT_KEY(OCS_moduleInfoGet)); UtAssert_True(!module_prop.addr.valid, "addresses in output not valid"); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-queues.c b/src/unit-test-coverage/vxworks/src/coveragetest-queues.c index 3df7923ad..a752c4e25 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-queues.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-queues.c @@ -49,7 +49,7 @@ void Test_OS_QueueCreate_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_QueueCreate_Impl(UT_INDEX_0, 0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_msgQCreate), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_msgQCreate), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_QueueCreate_Impl(UT_INDEX_0, 0), OS_ERROR); } @@ -61,7 +61,7 @@ void Test_OS_QueueDelete_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_QueueDelete_Impl(UT_INDEX_0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_msgQDelete), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_msgQDelete), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_QueueDelete_Impl(UT_INDEX_0), OS_ERROR); } @@ -78,10 +78,10 @@ void Test_OS_QueueGet_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(UT_INDEX_0, &Data, sizeof(Data), &ActSz, OS_CHECK), OS_SUCCESS); OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(UT_INDEX_0, &Data, sizeof(Data), &ActSz, 100), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OS_Milli2Ticks), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_Milli2Ticks), OS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(UT_INDEX_0, &Data, sizeof(Data), &ActSz, 100), OS_ERROR); - UT_SetForceFail(UT_KEY(OCS_msgQReceive), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_msgQReceive), OCS_ERROR); OCS_errno = OCS_S_objLib_OBJ_TIMEOUT; OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(UT_INDEX_0, &Data, sizeof(Data), &ActSz, OS_CHECK), OS_QUEUE_TIMEOUT); OCS_errno = OCS_S_objLib_OBJ_UNAVAILABLE; @@ -99,7 +99,7 @@ void Test_OS_QueuePut_Impl(void) char Data[16] = "Test"; OSAPI_TEST_FUNCTION_RC(OS_QueuePut_Impl(UT_INDEX_0, Data, sizeof(Data), 0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_msgQSend), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_msgQSend), OCS_ERROR); OCS_errno = OCS_S_objLib_OBJ_UNAVAILABLE; OSAPI_TEST_FUNCTION_RC(OS_QueuePut_Impl(UT_INDEX_0, Data, sizeof(Data), 0), OS_QUEUE_FULL); OCS_errno = 0; diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-shell.c b/src/unit-test-coverage/vxworks/src/coveragetest-shell.c index f60a15d07..b9f547159 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-shell.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-shell.c @@ -53,7 +53,7 @@ void Test_OS_ShellOutputToFile_Impl(void) UtAssert_True(UT_GetStubCount(UT_KEY(OCS_shellGenericInit)) == 1, "shellGenericInit() called"); /* failure to open the output file */ - UT_SetForceFail(UT_KEY(OS_OpenCreate), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); expected = OS_ERROR; actual = OS_ShellOutputToFile_Impl(UT_INDEX_0, "TestCmd"); UtAssert_True(actual == expected, "OS_ShellOutputToFile_Impl() (%ld) == OS_ERROR", (long)actual); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c b/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c index af92067f8..2b2607a2a 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c @@ -42,7 +42,7 @@ void Test_OS_GlobalSymbolLookup_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_GlobalSymbolLookup_Impl(&SymAddr, "symname"), OS_SUCCESS); OSAPI_TEST_FUNCTION_RC(OS_GlobalSymbolLookup_Impl(NULL, NULL), OS_INVALID_POINTER); - UT_SetForceFail(UT_KEY(OCS_symFind), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_symFind), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_GlobalSymbolLookup_Impl(&SymAddr, "symname"), OS_ERROR); } @@ -69,10 +69,10 @@ void Test_OS_SymTableIterator_Impl(void) OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut", &Data, 100, 1000), true); OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut", &Data, 100, 101), false); - UT_SetForceFail(UT_KEY(OCS_strlen), OS_MAX_SYM_LEN + 10); + UT_SetDefaultReturnValue(UT_KEY(OCS_strlen), OS_MAX_SYM_LEN + 10); OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut", &Data, 100, 1000), false); UT_ClearForceFail(UT_KEY(OCS_strlen)); - UT_SetForceFail(UT_KEY(OCS_write), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_write), -1); OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut", &Data, 100, 1000), false); UT_ClearForceFail(UT_KEY(OCS_write)); } @@ -83,7 +83,7 @@ void Test_OS_SymbolTableDump_Impl(void) * int32 OS_SymbolTableDump_Impl ( const char *filename, uint32 SizeLimit ) */ OSAPI_TEST_FUNCTION_RC(OS_SymbolTableDump_Impl("file", 10000), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_open), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1); OSAPI_TEST_FUNCTION_RC(OS_SymbolTableDump_Impl("file", 10000), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c b/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c index f67a8822e..1705b5fc9 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c @@ -70,7 +70,7 @@ void Test_OS_TaskCreate_Impl(void) /* create task with stack size of 250 - this should invoke malloc() to get the stack. * The first call checks the failure path and ensures that a malloc failure gets handled */ OS_task_table[0].stack_size = 250; - UT_SetForceFail(UT_KEY(OCS_malloc), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_malloc), OS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(UT_INDEX_0, 0), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_malloc)); @@ -97,7 +97,7 @@ void Test_OS_TaskCreate_Impl(void) UtAssert_True(UT_GetStubCount(UT_KEY(OCS_taskActivate)) == 3, "taskActivate() called"); /* other failure modes */ - UT_SetForceFail(UT_KEY(OCS_taskInit), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_taskInit), -1); OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(UT_INDEX_0, 0), OS_ERROR); } @@ -122,7 +122,7 @@ void Test_OS_TaskDelete_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_TaskDelete_Impl(UT_INDEX_0), OS_SUCCESS); /* failure mode */ - UT_SetForceFail(UT_KEY(OCS_taskDelete), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_taskDelete), -1); OSAPI_TEST_FUNCTION_RC(OS_TaskDelete_Impl(UT_INDEX_0), OS_ERROR); } @@ -144,10 +144,10 @@ void Test_OS_TaskDelay_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_TaskDelay_Impl(100), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_taskDelay), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_taskDelay), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_TaskDelay_Impl(100), OS_ERROR); - UT_SetForceFail(UT_KEY(OS_Milli2Ticks), OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_Milli2Ticks), OS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_TaskDelay_Impl(100), OS_ERROR); } @@ -159,7 +159,7 @@ void Test_OS_TaskSetPriority_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_TaskSetPriority_Impl(UT_INDEX_0, OSAL_PRIORITY_C(100)), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_taskPrioritySet), OCS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OCS_taskPrioritySet), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_TaskSetPriority_Impl(UT_INDEX_0, OSAL_PRIORITY_C(100)), OS_ERROR); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c b/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c index 36a747985..d001875bd 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c @@ -41,7 +41,7 @@ void Test_OS_VxWorks_TimeBaseAPI_Impl_Init(void) * int32 OS_VxWorks_TimeBaseAPI_Impl_Init(void) */ OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_TimeBaseAPI_Impl_Init(), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_sysClkRateGet), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_sysClkRateGet), -1); OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_TimeBaseAPI_Impl_Init(), OS_ERROR); } @@ -110,17 +110,17 @@ void Test_OS_TimeBaseCreate_Impl(void) memset(&id, 0x01, sizeof(id)); OS_global_timebase_table[1].active_id = id; UT_TimeBaseTest_Setup(UT_INDEX_1, OCS_SIGRTMIN, false); - UT_SetForceFail(UT_KEY(OCS_sigismember), true); + UT_SetDefaultReturnValue(UT_KEY(OCS_sigismember), true); OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(UT_INDEX_0), OS_TIMER_ERR_UNAVAILABLE); UT_ResetState(UT_KEY(OCS_sigismember)); /* fail to initialize the sem */ - UT_SetForceFail(UT_KEY(OCS_semMInitialize), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_semMInitialize), -1); OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(UT_INDEX_0), OS_TIMER_ERR_INTERNAL); UT_ClearForceFail(UT_KEY(OCS_semMInitialize)); /* fail to spawn the task */ - UT_SetForceFail(UT_KEY(OCS_taskSpawn), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_taskSpawn), -1); OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(UT_INDEX_0), OS_TIMER_ERR_INTERNAL); UT_ClearForceFail(UT_KEY(OCS_taskSpawn)); @@ -152,7 +152,7 @@ void Test_OS_TimeBaseCreate_Impl(void) UtAssert_True(UT_TimeBaseTest_CheckTimeBaseRegisteredState(UT_INDEX_0), "timer successfully registered"); UT_TimeBaseTest_ClearTimeBaseRegState(UT_INDEX_0); - UT_SetForceFail(UT_KEY(OCS_timer_create), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_timer_create), -1); UT_TimeBaseTest_CallRegisterTimer(UT_INDEX_0); UtAssert_True(UT_TimeBaseTest_CheckTimeBaseErrorState(UT_INDEX_0), "timer registration failure state"); } @@ -200,7 +200,7 @@ void Test_OS_TimeBaseSet_Impl(void) UT_TimeBaseTest_Setup(UT_INDEX_0, OCS_SIGRTMIN, false); OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(UT_INDEX_0, 1, 1), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_timer_settime), -1); + UT_SetDefaultReturnValue(UT_KEY(OCS_timer_settime), -1); OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(UT_INDEX_0, 1, 1), OS_TIMER_ERR_INVALID_ARGS); } diff --git a/ut_assert/inc/utstubs.h b/ut_assert/inc/utstubs.h index ab8f3810f..79082c8fa 100644 --- a/ut_assert/inc/utstubs.h +++ b/ut_assert/inc/utstubs.h @@ -191,12 +191,30 @@ void UT_GetDataBuffer(UT_EntryKey_t FuncKey, void **DataBuffer, size_t *MaxSize, * \param FuncKey The stub function to add the return code to. * \param Value Arbitrary failure mode value (may or may not be used by the stub) */ +void UT_SetDefaultReturnValue(UT_EntryKey_t FuncKey, int32 Value); + +#ifndef OSAL_OMIT_DEPRECATED +/** + * Enable or disable the forced failure mode for the given stub function + * + * This triggers a constant failure mode from the stub function, if implemented. + * The stub function will invoke a given failure path as defined by + * the stub implementation. + * + * A count of the number of times the failure mode is invoked will be maintained. + * + * \param FuncKey The stub function to add the return code to. + * \param Value Arbitrary failure mode value (may or may not be used by the stub) + * + * @deprecated replaced by UT_SetDefaultReturnValue + */ void UT_SetForceFail(UT_EntryKey_t FuncKey, int32 Value); +#endif /** * Disable the forced failure mode for the given stub function * - * This undoes the action of UT_SetForceFail() + * This undoes the action of UT_SetDefaultReturnValue() * * \param FuncKey The stub function entry to clear. */ @@ -293,11 +311,11 @@ bool UT_Stub_CheckDeferredRetcode(UT_EntryKey_t FuncKey, int32 *Retcode); /** * Check for a forced failure mode entry for the given stub function * - * If a UT_SetForceFail() option is in place for the given function this + * If a UT_SetDefaultReturnValue() option is in place for the given function this * will return true and increment the internal usage counter. * * \param FuncKey The stub function to check the return code. - * \param Value Set to the value supplied to UT_SetForceFail() + * \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); diff --git a/ut_assert/src/utstubs.c b/ut_assert/src/utstubs.c index 9751fb287..87db67fbc 100644 --- a/ut_assert/src/utstubs.c +++ b/ut_assert/src/utstubs.c @@ -308,7 +308,7 @@ bool UT_Stub_CheckDeferredRetcode(UT_EntryKey_t FuncKey, int32 *Retcode) return (Result); } -void UT_SetForceFail(UT_EntryKey_t FuncKey, int32 Value) +void UT_SetDefaultReturnValue(UT_EntryKey_t FuncKey, int32 Value) { UT_StubTableEntry_t *Rc; @@ -335,6 +335,13 @@ void UT_SetForceFail(UT_EntryKey_t FuncKey, int32 Value) } } +#ifndef OSAL_OMIT_DEPRECATED +void UT_SetForceFail(UT_EntryKey_t FuncKey, int32 Value) +{ + UT_SetDefaultReturnValue(FuncKey, Value); +} +#endif + void UT_ClearForceFail(UT_EntryKey_t FuncKey) { UT_StubTableEntry_t *StubPtr;