From 8f6f81d829cb5c92a8549c547f426ba4cdf87ce8 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Thu, 26 Mar 2020 13:45:52 -0400 Subject: [PATCH] Fix #385, Deprecate interrupt related APIs Removes coverage test code completely Marks OS_Int* API's as deprecated and implementations removed if OSAL_OMIT_DEPRECATED defined --- src/os/inc/osapi-os-core.h | 37 +- src/os/posix/osapi.c | 34 +- src/os/rtems/osapi.c | 59 +-- src/os/shared/os-impl.h | 3 + src/os/shared/osapi-interrupts.c | 3 + src/os/vxworks/osapi.c | 57 +-- .../posix/src/coveragetest-osapi.c | 63 --- .../shared/src/coveragetest-interrupts.c | 164 ------- .../ut-stubs/src/osapi-base-impl-stubs.c | 11 - .../vxworks/src/coveragetest-osapi.c | 81 ---- src/unit-tests/oscore-test/CMakeLists.txt | 1 - .../oscore-test/ut_oscore_interrupt_test.c | 452 ------------------ src/unit-tests/oscore-test/ut_oscore_test.c | 6 - 13 files changed, 114 insertions(+), 857 deletions(-) delete mode 100644 src/unit-test-coverage/shared/src/coveragetest-interrupts.c delete mode 100644 src/unit-tests/oscore-test/ut_oscore_interrupt_test.c diff --git a/src/os/inc/osapi-os-core.h b/src/os/inc/osapi-os-core.h index d6d89d4b0..7696a405b 100644 --- a/src/os/inc/osapi-os-core.h +++ b/src/os/inc/osapi-os-core.h @@ -1180,13 +1180,18 @@ int32 OS_FPUExcSetMask (uint32 mask); int32 OS_FPUExcGetMask (uint32 *mask); /**@}*/ +#ifndef OSAL_OMIT_DEPRECATED + /** @defgroup OSAPIInterrupt OSAL Interrupt APIs * @{ + * @deprecated Platform dependencies */ /*-------------------------------------------------------------------------------------*/ /** - * @brief Associate an interrupt number to a specified handler routine + * @brief DEPRECATED; Associate an interrupt number to a specified handler routine + * + * @deprecated platform dependencies, removing from OSAL * * The call associates a specified C routine to a specified interrupt * number. Upon occurring of the InterruptNumber, the InerruptHandler @@ -1205,7 +1210,9 @@ int32 OS_IntAttachHandler (uint32 InterruptNumber, osal_task_entry InterruptHan /*-------------------------------------------------------------------------------------*/ /** - * @brief Enable interrupts + * @brief DEPRECATED; Enable interrupts + * + * @deprecated platform dependencies, removing from OSAL * * @param[in] IntLevel value from previous call to OS_IntLock() * @@ -1217,7 +1224,9 @@ int32 OS_IntUnlock (int32 IntLevel); /*-------------------------------------------------------------------------------------*/ /** - * @brief Disable interrupts + * @brief DEPRECATED; Disable interrupts + * + * @deprecated platform dependencies, removing from OSAL * * @return An key value to be passed to OS_IntUnlock() to restore interrupts or error * status, see @ref OSReturnCodes @@ -1228,7 +1237,9 @@ int32 OS_IntLock (void); /*-------------------------------------------------------------------------------------*/ /** - * @brief Enables interrupts through Level + * @brief DEPRECATED; Enables interrupts through Level + * + * @deprecated platform dependencies, removing from OSAL * * @param[in] Level the interrupts to enable * @@ -1240,7 +1251,9 @@ int32 OS_IntEnable (int32 Level); /*-------------------------------------------------------------------------------------*/ /** - * @brief Disable interrupts through Level + * @brief DEPRECATED; Disable interrupts through Level + * + * @deprecated platform dependencies, removing from OSAL * * @param[in] Level the interrupts to disable * @@ -1252,7 +1265,9 @@ int32 OS_IntDisable (int32 Level); /*-------------------------------------------------------------------------------------*/ /** - * @brief Set the CPU interrupt mask register + * @brief DEPRECATED; Set the CPU interrupt mask register + * + * @deprecated platform dependencies, removing from OSAL * * @note The interrupt bits are architecture-specific. * @@ -1266,7 +1281,9 @@ int32 OS_IntSetMask (uint32 mask); /*-------------------------------------------------------------------------------------*/ /** - * @brief Get the CPU interrupt mask register + * @brief DEPRECATED; Get the CPU interrupt mask register + * + * @deprecated platform dependencies, removing from OSAL * * @note The interrupt bits are architecture-specific. * @@ -1280,7 +1297,9 @@ int32 OS_IntGetMask (uint32 *mask); /*-------------------------------------------------------------------------------------*/ /** - * @brief Acknowledge the corresponding interrupt number. + * @brief DEPRECATED; Acknowledge the corresponding interrupt number. + * + * @deprecated platform dependencies, removing from OSAL * * @note: placeholder; not currently implemented in sample implementations * @@ -1294,6 +1313,8 @@ int32 OS_IntGetMask (uint32 *mask); int32 OS_IntAck (int32 InterruptNumber); /**@}*/ +#endif /* OSAL_OMIT_DEPRECATED */ + /** * @defgroup OSAPIShMem OSAL Shared memory APIs * @deprecated Not in current implementations diff --git a/src/os/posix/osapi.c b/src/os/posix/osapi.c index a26b010b9..5a73f141e 100644 --- a/src/os/posix/osapi.c +++ b/src/os/posix/osapi.c @@ -2131,6 +2131,7 @@ int32 OS_MutSemGetInfo_Impl (uint32 sem_id, OS_mut_sem_prop_t *mut_prop) } /* end OS_MutSemGetInfo_Impl */ +#ifndef OSAL_OMIT_DEPRECATED /**************************************************************************************** INT API @@ -2208,48 +2209,49 @@ int32 OS_IntDisable_Impl(int32 Level) /*---------------------------------------------------------------- * - * Function: OS_HeapGetInfo_Impl + * Function: OS_IntSetMask_Impl * * Purpose: Implemented per internal OSAL API * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_HeapGetInfo_Impl(OS_heap_prop_t *heap_prop) +int32 OS_IntSetMask_Impl ( uint32 MaskSetting ) { - /* - ** Not implemented yet - */ - return (OS_ERR_NOT_IMPLEMENTED); -} /* end OS_HeapGetInfo_Impl */ + return(OS_ERR_NOT_IMPLEMENTED); +} /* end OS_IntSetMask_Impl */ /*---------------------------------------------------------------- * - * Function: OS_IntSetMask_Impl + * Function: OS_IntGetMask_Impl * * Purpose: Implemented per internal OSAL API * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_IntSetMask_Impl ( uint32 MaskSetting ) +int32 OS_IntGetMask_Impl ( uint32 * MaskSettingPtr ) { + *MaskSettingPtr = 0; return(OS_ERR_NOT_IMPLEMENTED); -} /* end OS_IntSetMask_Impl */ +} /* end OS_IntGetMask_Impl */ + +#endif /* OSAL_OMIT_DEPRECATED */ - /*---------------------------------------------------------------- * - * Function: OS_IntGetMask_Impl + * Function: OS_HeapGetInfo_Impl * * Purpose: Implemented per internal OSAL API * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_IntGetMask_Impl ( uint32 * MaskSettingPtr ) +int32 OS_HeapGetInfo_Impl(OS_heap_prop_t *heap_prop) { - *MaskSettingPtr = 0; - return(OS_ERR_NOT_IMPLEMENTED); -} /* end OS_IntGetMask_Impl */ + /* + ** Not implemented yet + */ + return (OS_ERR_NOT_IMPLEMENTED); +} /* end OS_HeapGetInfo_Impl */ /*---------------------------------------------------------------- * diff --git a/src/os/rtems/osapi.c b/src/os/rtems/osapi.c index 7e4be24f8..62b672c04 100644 --- a/src/os/rtems/osapi.c +++ b/src/os/rtems/osapi.c @@ -1410,6 +1410,8 @@ int32 OS_MutSemGetInfo_Impl (uint32 sem_id, OS_mut_sem_prop_t *mut_prop) TICK API ***************************************************************************************/ +#ifndef OSAL_OMIT_DEPRECATED + /**************************************************************************************** INT API ***************************************************************************************/ @@ -1539,60 +1541,61 @@ int32 OS_IntDisable_Impl (int32 Level) /*---------------------------------------------------------------- * - * Function: OS_HeapGetInfo_Impl + * Function: OS_IntSetMask_Impl * * Purpose: Implemented per internal OSAL API * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_HeapGetInfo_Impl (OS_heap_prop_t *heap_prop) +int32 OS_IntSetMask_Impl ( uint32 MaskSetting ) { - region_information_block info; - int status; - - status = malloc_info( &info ); - - if ( status != 0 ) - { - return(OS_ERROR); - } - - heap_prop->free_bytes = (uint32) info.Free.total; - heap_prop->free_blocks = (uint32) info.Free.number; - heap_prop->largest_free_block = (uint32) info.Free.largest; - - return (OS_SUCCESS); -} /* end OS_HeapGetInfo_Impl */ + return(OS_ERR_NOT_IMPLEMENTED); +} /* end OS_IntSetMask_Impl */ /*---------------------------------------------------------------- * - * Function: OS_IntSetMask_Impl + * Function: OS_IntGetMask_Impl * * Purpose: Implemented per internal OSAL API * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_IntSetMask_Impl ( uint32 MaskSetting ) +int32 OS_IntGetMask_Impl ( uint32 * MaskSettingPtr ) { + *MaskSettingPtr = 0; return(OS_ERR_NOT_IMPLEMENTED); -} /* end OS_IntSetMask_Impl */ +} /* end OS_IntGetMask_Impl */ + +#endif /* OSAL_OMIT_DEPRECATED */ - /*---------------------------------------------------------------- * - * Function: OS_IntGetMask_Impl + * Function: OS_HeapGetInfo_Impl * * Purpose: Implemented per internal OSAL API * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_IntGetMask_Impl ( uint32 * MaskSettingPtr ) +int32 OS_HeapGetInfo_Impl (OS_heap_prop_t *heap_prop) { - *MaskSettingPtr = 0; - return(OS_ERR_NOT_IMPLEMENTED); -} /* end OS_IntGetMask_Impl */ - + region_information_block info; + int status; + + status = malloc_info( &info ); + + if ( status != 0 ) + { + return(OS_ERROR); + } + + heap_prop->free_bytes = (uint32) info.Free.total; + heap_prop->free_blocks = (uint32) info.Free.number; + heap_prop->largest_free_block = (uint32) info.Free.largest; + + return (OS_SUCCESS); +} /* end OS_HeapGetInfo_Impl */ + /*---------------------------------------------------------------- * * Function: OS_FPUExcAttachHandler_Impl diff --git a/src/os/shared/os-impl.h b/src/os/shared/os-impl.h index aba3434d6..02cabb57b 100644 --- a/src/os/shared/os-impl.h +++ b/src/os/shared/os-impl.h @@ -1786,6 +1786,7 @@ int32 OS_SocketAddrGetPort_Impl(uint16 *PortNum, const OS_SockAddr_t *Addr); ------------------------------------------------------------------*/ int32 OS_SocketAddrSetPort_Impl(OS_SockAddr_t *Addr, uint16 PortNum); +#ifndef OSAL_OMIT_DEPRECATED /**************************************************************************************** INTERRUPT API LOW-LEVEL IMPLEMENTATION FUNCTIONS @@ -1866,6 +1867,8 @@ int32 OS_IntSetMask_Impl ( uint32 MaskSetting ); ------------------------------------------------------------------*/ int32 OS_IntGetMask_Impl ( uint32 * MaskSettingPtr ); +#endif /* OSAL_OMIT_DEPRECATED */ + /**************************************************************************************** FLOATING POINT CONFIG/EXCEPTION API LOW-LEVEL IMPLEMENTATION FUNCTIONS ****************************************************************************************/ diff --git a/src/os/shared/osapi-interrupts.c b/src/os/shared/osapi-interrupts.c index 86ce5080d..86d804580 100644 --- a/src/os/shared/osapi-interrupts.c +++ b/src/os/shared/osapi-interrupts.c @@ -32,6 +32,8 @@ #include "common_types.h" #include "os-impl.h" +#ifndef OSAL_OMIT_DEPRECATED /* Remove file and remove from build when deleted */ + /* Optionally remove from sources once source selection is in cmake options */ /*---------------------------------------------------------------- * @@ -135,3 +137,4 @@ int32 OS_IntGetMask ( uint32 * MaskSettingPtr ) return OS_IntGetMask_Impl(MaskSettingPtr); } /* end OS_IntGetMask */ +#endif /* OSAL_OMIT_DEPRECATED */ diff --git a/src/os/vxworks/osapi.c b/src/os/vxworks/osapi.c index 66eeacb9a..8bf49d6c2 100644 --- a/src/os/vxworks/osapi.c +++ b/src/os/vxworks/osapi.c @@ -1363,6 +1363,8 @@ int32 OS_MutSemGetInfo_Impl (uint32 sem_id, OS_mut_sem_prop_t *mut_prop) TICK API ****************************************************************************************/ +#ifndef OSAL_OMIT_DEPRECATED + /**************************************************************************************** INT API ****************************************************************************************/ @@ -1476,59 +1478,60 @@ int32 OS_IntDisable_Impl (int32 Level) /*---------------------------------------------------------------- * - * Function: OS_HeapGetInfo_Impl + * Function: OS_IntSetMask_Impl * * Purpose: Implemented per internal OSAL API * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_HeapGetInfo_Impl (OS_heap_prop_t *heap_prop) +int32 OS_IntSetMask_Impl ( uint32 MaskSetting ) { - MEM_PART_STATS stats; - STATUS status; - - status = memPartInfoGet(memSysPartId, &stats); - - if (status != OK) - { - return OS_ERROR; - } - - heap_prop->free_bytes = stats.numBytesFree; - heap_prop->free_blocks = stats.numBlocksFree; - heap_prop->largest_free_block = stats.maxBlockSizeFree; - - return (OS_SUCCESS); -} /* end OS_HeapGetInfo_Impl */ + return(OS_ERR_NOT_IMPLEMENTED); +} /* end OS_IntSetMask_Impl */ /*---------------------------------------------------------------- * - * Function: OS_IntSetMask_Impl + * Function: OS_IntGetMask_Impl * * Purpose: Implemented per internal OSAL API * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_IntSetMask_Impl ( uint32 MaskSetting ) +int32 OS_IntGetMask_Impl ( uint32 * MaskSettingPtr ) { + *MaskSettingPtr = 0; return(OS_ERR_NOT_IMPLEMENTED); -} /* end OS_IntSetMask_Impl */ +} /* end OS_IntGetMask_Impl */ + +#endif /* OSAL_OMIT_DEPRECATED */ - /*---------------------------------------------------------------- * - * Function: OS_IntGetMask_Impl + * Function: OS_HeapGetInfo_Impl * * Purpose: Implemented per internal OSAL API * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_IntGetMask_Impl ( uint32 * MaskSettingPtr ) +int32 OS_HeapGetInfo_Impl (OS_heap_prop_t *heap_prop) { - *MaskSettingPtr = 0; - return(OS_ERR_NOT_IMPLEMENTED); -} /* end OS_IntGetMask_Impl */ + MEM_PART_STATS stats; + STATUS status; + + status = memPartInfoGet(memSysPartId, &stats); + + if (status != OK) + { + return OS_ERROR; + } + + heap_prop->free_bytes = stats.numBytesFree; + heap_prop->free_blocks = stats.numBlocksFree; + heap_prop->largest_free_block = stats.maxBlockSizeFree; + + return (OS_SUCCESS); +} /* end OS_HeapGetInfo_Impl */ /*---------------------------------------------------------------- * diff --git a/src/unit-test-coverage/posix/src/coveragetest-osapi.c b/src/unit-test-coverage/posix/src/coveragetest-osapi.c index 50e8103e3..79f11c479 100644 --- a/src/unit-test-coverage/posix/src/coveragetest-osapi.c +++ b/src/unit-test-coverage/posix/src/coveragetest-osapi.c @@ -392,46 +392,6 @@ void Test_OS_MutSemGetInfo_Impl(void) */ } -void Test_OS_IntAttachHandler_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntAttachHandler_Impl (uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter) - */ -} - -void Test_OS_IntUnlock_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntUnlock_Impl (int32 IntLevel) - */ -} - -void Test_OS_IntLock_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntLock_Impl ( void ) - */ -} - -void Test_OS_IntEnable_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntEnable_Impl(int32 Level) - */ -} - -void Test_OS_IntDisable_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntDisable_Impl(int32 Level) - */ -} - void Test_OS_HeapGetInfo_Impl(void) { /* @@ -440,22 +400,6 @@ void Test_OS_HeapGetInfo_Impl(void) */ } -void Test_OS_IntSetMask_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntSetMask_Impl ( uint32 MaskSetting ) - */ -} - -void Test_OS_IntGetMask_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntGetMask_Impl ( uint32 * MaskSettingPtr ) - */ -} - void Test_OS_CompAbsDelayTime(void) { /* @@ -582,14 +526,7 @@ void UtTest_Setup(void) ADD_TEST(OS_MutSemGive_Impl); ADD_TEST(OS_MutSemTake_Impl); ADD_TEST(OS_MutSemGetInfo_Impl); - ADD_TEST(OS_IntAttachHandler_Impl); - ADD_TEST(OS_IntUnlock_Impl); - ADD_TEST(OS_IntLock_Impl); - ADD_TEST(OS_IntEnable_Impl); - ADD_TEST(OS_IntDisable_Impl); ADD_TEST(OS_HeapGetInfo_Impl); - ADD_TEST(OS_IntSetMask_Impl); - ADD_TEST(OS_IntGetMask_Impl); ADD_TEST(OS_CompAbsDelayTime); ADD_TEST(OS_FPUExcAttachHandler_Impl); ADD_TEST(OS_FPUExcEnable_Impl); diff --git a/src/unit-test-coverage/shared/src/coveragetest-interrupts.c b/src/unit-test-coverage/shared/src/coveragetest-interrupts.c deleted file mode 100644 index fe608bf76..000000000 --- a/src/unit-test-coverage/shared/src/coveragetest-interrupts.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Filename: osapi_testcase_common.c - * - * Purpose: This file contains unit test cases for items in the "osapi-common" file - * - * Notes: - * - */ - - -/* - * Includes - */ - -#include "os-shared-coveragetest.h" -#include "ut-osapi-interrupts.h" - -void dummy_inthandler(void) -{ -} - -/***************************************************************************** - * - * Test Case for OS_IntAttachHandler() - * int32 OS_IntAttachHandler (uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter) - * - *****************************************************************************/ -void Test_OS_IntAttachHandler (void) -{ - int32 expected = OS_SUCCESS; - int32 actual = OS_IntAttachHandler(0, &dummy_inthandler, 0); - - UtAssert_True(actual == expected, "OS_IntAttachHandler() (%ld) == OS_SUCCESS", (long)actual); - - expected = OS_INVALID_POINTER; - actual = OS_IntAttachHandler(0, NULL, 0); - UtAssert_True(actual == expected, "OS_IntAttachHandler() (%ld) == OS_INVALID_POINTER", (long)actual); -} - -/***************************************************************************** - * - * Test Case for Test_OS_IntLock() - * int32 OS_IntLock(void) - * - *****************************************************************************/ -void Test_OS_IntLock(void) -{ - int32 expected = OS_SUCCESS; - int32 actual = OS_IntLock(); - - UtAssert_True(actual == expected, "OS_IntLock() (%ld) == OS_SUCCESS", (long)actual); -} - -/***************************************************************************** - * - * Test Case for Test_OS_IntUnlock() - * int32 OS_IntUnlock(int32 IntFlags) - * - *****************************************************************************/ -void Test_OS_IntUnlock(void) -{ - int32 expected = OS_SUCCESS; - int32 actual = OS_IntUnlock(0); - - UtAssert_True(actual == expected, "OS_IntUnlock() (%ld) == OS_SUCCESS", (long)actual); -} - -/***************************************************************************** - * - * Test Case for: - * int32 OS_IntEnable(int32 Level) - * - *****************************************************************************/ -void Test_OS_IntEnable(void) -{ - int32 expected = OS_SUCCESS; - int32 actual = OS_IntEnable(1); - - UtAssert_True(actual == expected, "OS_IntEnable() (%ld) == OS_SUCCESS", (long)actual); -} - -/***************************************************************************** - * - * Test Case for: - * int32 OS_IntDisable(int32 Level) - * - *****************************************************************************/ -void Test_OS_IntDisable(void) -{ - int32 expected = OS_SUCCESS; - int32 actual = OS_IntDisable(1); - - UtAssert_True(actual == expected, "OS_IntDisable() (%ld) == OS_SUCCESS", (long)actual); -} - -/***************************************************************************** - * - * Test Case for: - * int32 OS_IntSetMask ( uint32 MaskSetting ) - * - *****************************************************************************/ -void Test_OS_IntSetMask (void) -{ - int32 expected = OS_SUCCESS; - int32 actual = OS_IntSetMask(0x10); - - UtAssert_True(actual == expected, "OS_IntSetMask() (%ld) == OS_SUCCESS", (long)actual); -} - -/***************************************************************************** - * - * Test Case for: - * int32 OS_IntGetMask ( uint32 * MaskSettingPtr ) - * - *****************************************************************************/ -void Test_OS_IntGetMask (void) -{ - uint32 mask; - int32 expected = OS_SUCCESS; - int32 actual = OS_IntGetMask(&mask); - - UtAssert_True(actual == expected, "OS_IntGetMask() (%ld) == OS_SUCCESS", (long)actual); -} - - -/* Osapi_Task_Setup - * - * Purpose: - * Called by the unit test tool to set up the app prior to each test - */ -void Osapi_Task_Setup(void) -{ - UT_ResetState(0); -} - -/* - * Osapi_TearDown - * - * Purpose: - * Called by the unit test tool to tear down the app after each test - */ -void Osapi_TearDown(void) -{ - -} - - -/* - * Register the test cases to execute with the unit test tool - */ -void UtTest_Setup(void) -{ - ADD_TEST(OS_IntAttachHandler); - ADD_TEST(OS_IntLock); - ADD_TEST(OS_IntUnlock); - ADD_TEST(OS_IntEnable); - ADD_TEST(OS_IntDisable); - ADD_TEST(OS_IntSetMask); - ADD_TEST(OS_IntGetMask); -} - - - - diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-base-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-base-impl-stubs.c index cb660a5a0..4aa7a0edf 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-base-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-base-impl-stubs.c @@ -144,17 +144,6 @@ void OS_ApplicationExit_Impl(int32 Status) UT_DEFAULT_IMPL(OS_ApplicationExit_Impl); } -/* - * Interrupt API low-level handlers - */ -UT_DEFAULT_STUB(OS_IntAttachHandler_Impl,(uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter)) -UT_DEFAULT_STUB(OS_IntUnlock_Impl,(int32 IntLevel)) -UT_DEFAULT_STUB(OS_IntLock_Impl,( void )) -UT_DEFAULT_STUB(OS_IntEnable_Impl,(int32 Level)) -UT_DEFAULT_STUB(OS_IntDisable_Impl,(int32 Level)) -UT_DEFAULT_STUB(OS_IntSetMask_Impl,( uint32 MaskSetting )) -UT_DEFAULT_STUB(OS_IntGetMask_Impl,( uint32 * MaskSettingPtr )) - /* * Heap API low-level handler */ diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-osapi.c b/src/unit-test-coverage/vxworks/src/coveragetest-osapi.c index d384b47af..e37cba1cd 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-osapi.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-osapi.c @@ -574,61 +574,6 @@ void Test_OS_MutSemGetInfo_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_MutSemGetInfo_Impl(0,&mut_prop), OS_SUCCESS); } -void Test_OS_IntAttachHandler_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntAttachHandler_Impl (uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter) - */ - OSAPI_TEST_FUNCTION_RC(OS_IntAttachHandler_Impl(0,NULL,0), OS_SUCCESS); - - UT_SetForceFail(UT_KEY(OCS_intConnect), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_IntAttachHandler_Impl(0,NULL,0), OS_ERROR); -} - -void Test_OS_IntUnlock_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntUnlock_Impl (int32 IntLevel) - */ - OSAPI_TEST_FUNCTION_RC(OS_IntUnlock_Impl(0), OS_SUCCESS); -} - -void Test_OS_IntLock_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntLock_Impl ( void ) - */ - UT_SetForceFail(UT_KEY(OCS_intLock), 0x1111); - OSAPI_TEST_FUNCTION_RC(OS_IntLock_Impl(), 0x1111); -} - -void Test_OS_IntEnable_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntEnable_Impl(int32 Level) - */ - OSAPI_TEST_FUNCTION_RC(OS_IntEnable_Impl(0), OS_SUCCESS); - - UT_SetForceFail(UT_KEY(OCS_intEnable), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_IntEnable_Impl(0), OS_ERROR); -} - -void Test_OS_IntDisable_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntDisable_Impl(int32 Level) - */ - OSAPI_TEST_FUNCTION_RC(OS_IntDisable_Impl(0), OS_SUCCESS); - - UT_SetForceFail(UT_KEY(OCS_intDisable), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_IntDisable_Impl(0), OS_ERROR); -} - void Test_OS_HeapGetInfo_Impl(void) { /* @@ -644,25 +589,6 @@ void Test_OS_HeapGetInfo_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_HeapGetInfo_Impl(&heap_prop), OS_ERROR); } -void Test_OS_IntSetMask_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntSetMask_Impl ( uint32 MaskSetting ) - */ - OSAPI_TEST_FUNCTION_RC(OS_IntSetMask_Impl(0x1111), OS_ERR_NOT_IMPLEMENTED); -} - -void Test_OS_IntGetMask_Impl(void) -{ - /* - * Test Case For: - * int32 OS_IntGetMask_Impl ( uint32 * MaskSettingPtr ) - */ - uint32 Mask = 0x1111; - OSAPI_TEST_FUNCTION_RC(OS_IntGetMask_Impl(&Mask), OS_ERR_NOT_IMPLEMENTED); -} - void Test_OS_FPUExcAttachHandler_Impl(void) { /* @@ -783,14 +709,7 @@ void UtTest_Setup(void) ADD_TEST(OS_MutSemGive_Impl); ADD_TEST(OS_MutSemTake_Impl); ADD_TEST(OS_MutSemGetInfo_Impl); - ADD_TEST(OS_IntAttachHandler_Impl); - ADD_TEST(OS_IntUnlock_Impl); - ADD_TEST(OS_IntLock_Impl); - ADD_TEST(OS_IntEnable_Impl); - ADD_TEST(OS_IntDisable_Impl); ADD_TEST(OS_HeapGetInfo_Impl); - ADD_TEST(OS_IntSetMask_Impl); - ADD_TEST(OS_IntGetMask_Impl); ADD_TEST(OS_FPUExcAttachHandler_Impl); ADD_TEST(OS_FPUExcEnable_Impl); ADD_TEST(OS_FPUExcDisable_Impl); diff --git a/src/unit-tests/oscore-test/CMakeLists.txt b/src/unit-tests/oscore-test/CMakeLists.txt index 0ed5ba38b..b4252d9c0 100644 --- a/src/unit-tests/oscore-test/CMakeLists.txt +++ b/src/unit-tests/oscore-test/CMakeLists.txt @@ -7,7 +7,6 @@ set(TEST_MODULE_FILES ut_oscore_countsem_test.c ut_oscore_mutex_test.c ut_oscore_task_test.c - ut_oscore_interrupt_test.c ut_oscore_exception_test.c ut_oscore_test.c ) diff --git a/src/unit-tests/oscore-test/ut_oscore_interrupt_test.c b/src/unit-tests/oscore-test/ut_oscore_interrupt_test.c deleted file mode 100644 index 489c7ecbc..000000000 --- a/src/unit-tests/oscore-test/ut_oscore_interrupt_test.c +++ /dev/null @@ -1,452 +0,0 @@ -/*================================================================================* -** File: ut_oscore_interrupt_test.c -** Owner: Tam Ngo -** Date: June 2015 -**================================================================================*/ - -/*--------------------------------------------------------------------------------* -** Includes -**--------------------------------------------------------------------------------*/ - -#include "ut_oscore_interrupt_test.h" - -/*--------------------------------------------------------------------------------* -** Macros -**--------------------------------------------------------------------------------*/ - -/*--------------------------------------------------------------------------------* -** Data types -**--------------------------------------------------------------------------------*/ - -/*--------------------------------------------------------------------------------* -** External global variables -**--------------------------------------------------------------------------------*/ - -/*--------------------------------------------------------------------------------* -** Global variables -**--------------------------------------------------------------------------------*/ - -/*--------------------------------------------------------------------------------* -** Local function prototypes -**--------------------------------------------------------------------------------*/ - -void UT_myInterruptFunc(void); - -/*--------------------------------------------------------------------------------* -** Local function definitions -**--------------------------------------------------------------------------------*/ - -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - /* Call these macros at the very end of the function to close out the test variables - * and get it added to the global list being tracked. */ - return; - -} -#endif - -/*--------------------------------------------------------------------------------*/ - -void UT_myInterruptFunc(void) -{ - static int32 iCounter=0; - - iCounter++; -} - -/*--------------------------------------------------------------------------------* -** Syntax: int32 OS_IntAttachHandler(uint32 InterruptNumber, -** osal_task_entry InterruptHandler, int32 parameter) -** Purpose: Associates a specified C routine to a specified interrupt number. -** Upon occurring of the InterruptNumber, the InterruptHandler routine - will be called and passed the parameter. -** Parameters: InterruptNumber - interrupt number that will cause the start of ISR -** InterruptHandler - the ISR associated with this interrupt -** parameter - the parameter that is passed to the ISR -** Returns: OS_INVALID_POINTER if passing in null pointer -** OS_ERROR if OS call failed -** OS_SUCCESS if succeeded -**-------------------------------------------------------------------------------- -** Test #0: Not-implemented condition -** 1) Call this routine -** 2) If the returned value is OS_ERR_NOT_IMPLEMENTED, then exit test -** 3) Otherwise, continue -** ----------------------------------------------------- -** Test #1: Null-pointer-argument condition -** 1) Call this routine with a null-pointer argument -** 2) Expect the returned value to be -** (a) OS_INVALID_POINTER -** ----------------------------------------------------- -** Test #2: OS-call-failure condition -** 1) Setup test to cause the OS call to fail inside this routine -** 2) Call this routine -** 3) Expect the returned value to be -** (a) OS_ERROR -** ----------------------------------------------------- -** Test #3: Nominal condition -** 1) Call this routine with valid argument -** 2) Expect the returned value to be -** (a) OS_SUCCESS -**--------------------------------------------------------------------------------*/ -void UT_os_int_attachhandler_test() -{ - int32 res = 0; - const char* testDesc; - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - res = OS_IntAttachHandler(1, UT_myInterruptFunc, 100); - if (res == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_int_attachhandler_exit_tag; - } - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - res = OS_IntAttachHandler(1, NULL, 0); - if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /*-----------------------------------------------------*/ - testDesc = "#2 OS-call-failure"; - - res = OS_IntAttachHandler(100, UT_myInterruptFunc, 0); - if (res == OS_ERROR) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - res = OS_IntAttachHandler(1, UT_myInterruptFunc, 0); - if (res == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - -UT_os_int_attachhandler_exit_tag: - return; - -} - -/*--------------------------------------------------------------------------------* -** Syntax: int32 OS_IntEnable(int32 Level) -** Purpose: Enables interrupt -** Parameters: Level - the interrupt vectors to be enabled -** Returns: OS_ERROR if OS call failed -** OS_SUCCESS if succeeded -**-------------------------------------------------------------------------------- -** Test #0: Not-implemented condition -** 1) Call this routine -** 2) If the returned value is OS_ERR_NOT_IMPLEMENTED, then exit test -** 3) Otherwise, continue -** ----------------------------------------------------- -** Test #1: OS-call-failure condition -** 1) Setup test to cause the OS call to fail inside this routine -** 2) Call this routine -** 3) Expect the returned value to be -** (a) OS_ERROR -** ----------------------------------------------------- -** Test #2: Nominal condition -** 1) Call this routine with valid argument -** 2) Expect the returned value to be -** (a) OS_SUCCESS -**--------------------------------------------------------------------------------*/ -void UT_os_int_enable_test() -{ - int32 res = 0; - const char* testDesc; - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - res = OS_IntEnable(1); - if (res == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_int_enable_exit_tag; - } - - /* Reset test environment */ - OS_IntDisable(1); - - /*-----------------------------------------------------*/ - testDesc = "#1 OS-call-failure"; - - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); - - /*-----------------------------------------------------*/ - testDesc = "#2 Nominal"; - - res = OS_IntEnable(1); - if (res == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* Reset test environment */ - OS_IntDisable(1); - -UT_os_int_enable_exit_tag: - return; - -} - -/*--------------------------------------------------------------------------------* -** Syntax: int32 OS_IntDisable(int32 Level) -** Purpose: Disables interrupt -** Parameters: Level - the interrupt vectors to be disabled -** Returns: OS_ERROR if OS call failed -** OS_SUCCESS if succeeded -**-------------------------------------------------------------------------------- -** Test #0: Not-implemented condition -** 1) Call this routine -** 2) If the returned value is OS_ERR_NOT_IMPLEMENTED, then exit test -** 3) Otherwise, continue -** ----------------------------------------------------- -** Test #1: OS-call-failure condition -** 1) Setup test to cause the OS call to fail inside this routine -** 2) Call this routine -** 3) Expect the returned value to be -** (a) OS_ERROR -** ----------------------------------------------------- -** Test #2: Nominal condition -** 1) Call this routine with valid argument -** 2) Expect the returned value to be -** (a) OS_SUCCESS -**--------------------------------------------------------------------------------*/ -void UT_os_int_disable_test() -{ - int32 res = 0; - const char* testDesc; - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - res = OS_IntDisable(1); - if (res == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_int_disable_exit_tag; - } - - /*-----------------------------------------------------*/ - testDesc = "#1 OS-call-failure"; - - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); - - /*-----------------------------------------------------*/ - testDesc = "#2 Nominal"; - - if (OS_IntEnable(1) == OS_SUCCESS) - { - res = OS_IntDisable(1); - if (res == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - } - else - { - testDesc = "#2 Nominal - Interrupt-Enable failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); - } - -UT_os_int_disable_exit_tag: - return; - -} - -/*--------------------------------------------------------------------------------* -** Syntax: int32 OS_IntLock(void) -** Purpose: Locks out all interrupts -** Parameters: none -** Returns: Interrupt level before OS_IntLock() call -**-------------------------------------------------------------------------------- -** Test #0: Not-implemented condition -** 1) Call this routine -** 2) If the returned value is OS_ERR_NOT_IMPLEMENTED, then exit test -** 3) Otherwise, continue -** ----------------------------------------------------- -** Test #1: OS-call-failure condition -** 1) Setup test to cause the OS call to fail inside this routine -** 2) Call this routine -** 3) Expect the returned value to be -** (a) OS_ERROR -** ----------------------------------------------------- -** Test #2: Nominal condition -** 1) Call this routine with valid argument -** 2) Expect the returned value to be -** (a) OS_SUCCESS -**--------------------------------------------------------------------------------*/ -void UT_os_int_lock_test() -{ - int32 res = 0; - const char* testDesc; - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - if (OS_IntLock() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_int_lock_exit_tag; - } - - /*-----------------------------------------------------*/ - testDesc = "#1 OS-call-failure"; - - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); - - /*-----------------------------------------------------*/ - testDesc = "#2 Nominal"; - - res = OS_IntLock(); - /* Note: Could check for more evidence here; only checking API for now. */ - if (OS_IntUnlock(res) == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - -UT_os_int_lock_exit_tag: - return; - -} - -/*--------------------------------------------------------------------------------* -** Syntax: int32 OS_IntUnlock(int32 IntLevel) -** Purpose: Enable all interrupts -** Parameters: IntLevel - interrupt vectors to be unlocked -** Returns: OS_ERROR if call to OS system call failed -** OS_SUCCESS if succeeded -**-------------------------------------------------------------------------------- -** Test #0: Not-implemented condition -** 1) Call this routine -** 2) If the returned value is OS_ERR_NOT_IMPLEMENTED, then exit test -** 3) Otherwise, continue -** ----------------------------------------------------- -** Test #1: OS-call-failure condition -** 1) Setup test to cause the OS call to fail inside this routine -** 2) Call this routine -** 3) Expect the returned value to be -** (a) OS_ERROR -** ----------------------------------------------------- -** Test #2: Nominal condition -** 1) Call this routine with valid argument -** 2) Expect the returned value to be -** (a) OS_SUCCESS -**--------------------------------------------------------------------------------*/ -void UT_os_int_unlock_test() -{ - int32 res = 0; - const char* testDesc; - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - if (OS_IntUnlock(0) == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_int_unlock_exit_tag; - } - - /*-----------------------------------------------------*/ - testDesc = "#1 OS-call-failure"; - - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); - - /*-----------------------------------------------------*/ - testDesc = "#2 Nominal"; - - res = OS_IntLock(); - if (OS_IntUnlock(res) == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - -UT_os_int_unlock_exit_tag: - return; - -} - -/*================================================================================* -** End of File: ut_oscore_interrupt_test.c -**================================================================================*/ diff --git a/src/unit-tests/oscore-test/ut_oscore_test.c b/src/unit-tests/oscore-test/ut_oscore_test.c index 6b7b75ae7..de57cefea 100644 --- a/src/unit-tests/oscore-test/ut_oscore_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_test.c @@ -271,12 +271,6 @@ void UtTest_Setup(void) UtTest_Add(UT_os_heapgetinfo_test, NULL, NULL, "OS_HeapGetInfo"); - UtTest_Add(UT_os_int_attachhandler_test, NULL, NULL, "OS_IntAttachHandler"); - UtTest_Add(UT_os_int_enable_test, NULL, NULL, "OS_IntEnable"); - UtTest_Add(UT_os_int_disable_test, NULL, NULL, "OS_IntDisable"); - UtTest_Add(UT_os_int_lock_test, NULL, NULL, "OS_IntLock"); - UtTest_Add(UT_os_int_unlock_test, NULL, NULL, "OS_IntUnlock"); - UtTest_Add(UT_os_fpuexc_setmask_test, NULL, NULL, "OS_FPUExcSetMask"); UtTest_Add(UT_os_fpuexc_getmask_test, NULL, NULL, "OS_FPUExcGetMask");