diff --git a/src/os/inc/osapi-binsem.h b/src/os/inc/osapi-binsem.h index 51f849eb0..1b91ebde1 100644 --- a/src/os/inc/osapi-binsem.h +++ b/src/os/inc/osapi-binsem.h @@ -180,14 +180,44 @@ int32 OS_BinSemGetIdByName(osal_id_t *sem_id, const char *sem_name); /*-------------------------------------------------------------------------------------*/ /** - * @brief Fill a property object buffer with details regarding the resource + * @brief Get the name of the binary semaphore * - * This function will pass back a pointer to structure that contains - * all of the relevant info( name and creator) about the specified binary - * semaphore. + * This function retrieves the name of the specified binary semaphore. * * @param[in] sem_id The object ID to operate on - * @param[out] bin_prop The property object buffer to fill @nonnull + * @param[out] bin_prop The property object buffer to fill @nonnull + * + * @return Execution status, see @ref OSReturnCodes + * @retval #OS_SUCCESS @copybrief OS_SUCCESS + * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid semaphore + * @retval #OS_INVALID_POINTER if the bin_prop pointer is null + */ +int32 OS_BinSemGetName(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop); + +/*-------------------------------------------------------------------------------------*/ +/** + * @brief Get the creator of the binary semaphore + * + * This function retrieves the creator of the specified binary semaphore. + * + * @param[in] sem_id The object ID to operate on + * @param[out] bin_prop The property object buffer to fill @nonnull + * + * @return Execution status, see @ref OSReturnCodes + * @retval #OS_SUCCESS @copybrief OS_SUCCESS + * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid semaphore + * @retval #OS_INVALID_POINTER if the bin_prop pointer is null + */ +int32 OS_BinSemGetCreator(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop); + +/*-------------------------------------------------------------------------------------*/ +/** + * @brief Get the value of the binary semaphore + * + * This function retrieves the value of the specified binary semaphore. + * + * @param[in] sem_id The object ID to operate on + * @param[out] bin_prop The property object buffer to fill @nonnull * * @return Execution status, see @ref OSReturnCodes * @retval #OS_SUCCESS @copybrief OS_SUCCESS @@ -195,7 +225,7 @@ int32 OS_BinSemGetIdByName(osal_id_t *sem_id, const char *sem_name); * @retval #OS_INVALID_POINTER if the bin_prop pointer is null * @retval #OS_ERR_NOT_IMPLEMENTED @copybrief OS_ERR_NOT_IMPLEMENTED */ -int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop); +int32 OS_BinSemGetValue(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop); /**@}*/ diff --git a/src/os/posix/src/os-impl-binsem.c b/src/os/posix/src/os-impl-binsem.c index 8c2bb954e..5ae82cc2b 100644 --- a/src/os/posix/src/os-impl-binsem.c +++ b/src/os/posix/src/os-impl-binsem.c @@ -472,7 +472,7 @@ int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *sem_prop) +int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *sem_prop) { OS_impl_binsem_internal_record_t *sem; diff --git a/src/os/rtems/src/os-impl-binsem.c b/src/os/rtems/src/os-impl-binsem.c index 971e5b6d6..c7430c63b 100644 --- a/src/os/rtems/src/os-impl-binsem.c +++ b/src/os/rtems/src/os-impl-binsem.c @@ -272,7 +272,7 @@ int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop) +int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop) { /* RTEMS has no API for obtaining the current value of a semaphore */ return OS_ERR_NOT_IMPLEMENTED; diff --git a/src/os/shared/inc/os-shared-binsem.h b/src/os/shared/inc/os-shared-binsem.h index 906b6ddd0..b435f7ad0 100644 --- a/src/os/shared/inc/os-shared-binsem.h +++ b/src/os/shared/inc/os-shared-binsem.h @@ -111,6 +111,6 @@ int32 OS_BinSemDelete_Impl(const OS_object_token_t *token); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop); +int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop); #endif /* OS_SHARED_BINSEM_H */ diff --git a/src/os/shared/src/osapi-binsem.c b/src/os/shared/src/osapi-binsem.c index 9bab028d8..53cfba04e 100644 --- a/src/os/shared/src/osapi-binsem.c +++ b/src/os/shared/src/osapi-binsem.c @@ -249,7 +249,7 @@ int32 OS_BinSemGetIdByName(osal_id_t *sem_id, const char *sem_name) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) +int32 OS_BinSemGetName(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) { OS_common_record_t *record; OS_object_token_t token; @@ -267,8 +267,66 @@ int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) record = OS_OBJECT_TABLE_GET(OS_global_bin_sem_table, token); strncpy(bin_prop->name, record->name_entry, sizeof(bin_prop->name) - 1); + bin_prop->name[sizeof(bin_prop->name) - 1] = '\0'; /* Ensure null termination */ + + OS_ObjectIdRelease(&token); + } + + return return_code; +} + +/*---------------------------------------------------------------- + * + * Purpose: Implemented per public OSAL API + * See description in API and header file for detail + * + *-----------------------------------------------------------------*/ +int32 OS_BinSemGetCreator(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) +{ + OS_common_record_t *record; + OS_object_token_t token; + int32 return_code; + + /* Check parameters */ + OS_CHECK_POINTER(bin_prop); + + memset(bin_prop, 0, sizeof(OS_bin_sem_prop_t)); + + /* Check Parameters */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sem_id, &token); + if (return_code == OS_SUCCESS) + { + record = OS_OBJECT_TABLE_GET(OS_global_bin_sem_table, token); + bin_prop->creator = record->creator; - return_code = OS_BinSemGetInfo_Impl(&token, bin_prop); + + OS_ObjectIdRelease(&token); + } + + return return_code; +} + +/*---------------------------------------------------------------- + * + * Purpose: Implemented per public OSAL API + * See description in API and header file for detail + * + *-----------------------------------------------------------------*/ +int32 OS_BinSemGetValue(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) +{ + OS_object_token_t token; + int32 return_code; + + /* Check parameters */ + OS_CHECK_POINTER(bin_prop); + + memset(bin_prop, 0, sizeof(OS_bin_sem_prop_t)); + + /* Check Parameters */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sem_id, &token); + if (return_code == OS_SUCCESS) + { + return_code = OS_BinSemGetValue_Impl(&token, bin_prop); OS_ObjectIdRelease(&token); } diff --git a/src/os/vxworks/src/os-impl-binsem.c b/src/os/vxworks/src/os-impl-binsem.c index 28f0b9bc3..6b415df95 100644 --- a/src/os/vxworks/src/os-impl-binsem.c +++ b/src/os/vxworks/src/os-impl-binsem.c @@ -190,8 +190,8 @@ int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop) +int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop) { /* VxWorks has no API for obtaining the current value of a semaphore */ - return OS_SUCCESS; + return OS_ERR_NOT_IMPLEMENTED; } diff --git a/src/tests/bin-sem-test/bin-sem-test.c b/src/tests/bin-sem-test/bin-sem-test.c index e02de461c..6a4f112a1 100644 --- a/src/tests/bin-sem-test/bin-sem-test.c +++ b/src/tests/bin-sem-test/bin-sem-test.c @@ -77,13 +77,15 @@ void Test_BinSem(void) char long_name[OS_MAX_API_NAME + 1]; OS_bin_sem_prop_t sem_prop; uint32 test_val; - bool get_info_implemented; + bool get_value_implemented; memset(&sem_prop, 0, sizeof(sem_prop)); memset(task_counter, 0, sizeof(task_counter)); /* Invalid id checks */ - UtAssert_INT32_EQ(OS_BinSemGetInfo(OS_OBJECT_ID_UNDEFINED, &sem_prop), OS_ERR_INVALID_ID); + UtAssert_INT32_EQ(OS_BinSemGetName(OS_OBJECT_ID_UNDEFINED, &sem_prop), OS_ERR_INVALID_ID); + UtAssert_INT32_EQ(OS_BinSemGetCreator(OS_OBJECT_ID_UNDEFINED, &sem_prop), OS_ERR_INVALID_ID); + UtAssert_INT32_EQ(OS_BinSemGetValue(OS_OBJECT_ID_UNDEFINED, &sem_prop), OS_ERR_INVALID_ID); UtAssert_INT32_EQ(OS_BinSemFlush(OS_OBJECT_ID_UNDEFINED), OS_ERR_INVALID_ID); UtAssert_INT32_EQ(OS_BinSemGive(OS_OBJECT_ID_UNDEFINED), OS_ERR_INVALID_ID); UtAssert_INT32_EQ(OS_BinSemTake(OS_OBJECT_ID_UNDEFINED), OS_ERR_INVALID_ID); @@ -93,7 +95,9 @@ void Test_BinSem(void) /* Null checks */ UtAssert_INT32_EQ(OS_BinSemCreate(NULL, "Test_Sem", 0, 0), OS_INVALID_POINTER); UtAssert_INT32_EQ(OS_BinSemCreate(&sem_id[0], NULL, 0, 0), OS_INVALID_POINTER); - UtAssert_INT32_EQ(OS_BinSemGetInfo(sem_id[0], NULL), OS_INVALID_POINTER); + UtAssert_INT32_EQ(OS_BinSemGetName(sem_id[0], NULL), OS_INVALID_POINTER); + UtAssert_INT32_EQ(OS_BinSemGetCreator(sem_id[0], NULL), OS_INVALID_POINTER); + UtAssert_INT32_EQ(OS_BinSemGetValue(sem_id[0], NULL), OS_INVALID_POINTER); UtAssert_INT32_EQ(OS_BinSemGetIdByName(NULL, "Test_Sem"), OS_INVALID_POINTER); UtAssert_INT32_EQ(OS_BinSemGetIdByName(&sem_id[0], NULL), OS_INVALID_POINTER); @@ -109,15 +113,15 @@ void Test_BinSem(void) /* Nonzero create */ UtAssert_INT32_EQ(OS_BinSemCreate(&sem_id[1], "Test_Sem_Nonzero", 1, 0), OS_SUCCESS); - /* Check get info implementation */ - get_info_implemented = (OS_BinSemGetInfo(sem_id[0], &sem_prop) != OS_ERR_NOT_IMPLEMENTED); + /* Check get value implementation */ + get_value_implemented = (OS_BinSemGetValue(sem_id[0], &sem_prop) != OS_ERR_NOT_IMPLEMENTED); /* Validate values */ - if (get_info_implemented) + if (get_value_implemented) { - UtAssert_INT32_EQ(OS_BinSemGetInfo(sem_id[0], &sem_prop), OS_SUCCESS); + UtAssert_INT32_EQ(OS_BinSemGetValue(sem_id[0], &sem_prop), OS_SUCCESS); UtAssert_INT32_EQ(sem_prop.value, 0); - UtAssert_INT32_EQ(OS_BinSemGetInfo(sem_id[1], &sem_prop), OS_SUCCESS); + UtAssert_INT32_EQ(OS_BinSemGetValue(sem_id[1], &sem_prop), OS_SUCCESS); UtAssert_INT32_EQ(sem_prop.value, 1); } @@ -141,11 +145,11 @@ void Test_BinSem(void) UtAssert_INT32_EQ(OS_BinSemTimedWait(sem_id[1], 0), OS_SUCCESS); /* Validate zeros */ - if (get_info_implemented) + if (get_value_implemented) { - UtAssert_INT32_EQ(OS_BinSemGetInfo(sem_id[0], &sem_prop), OS_SUCCESS); + UtAssert_INT32_EQ(OS_BinSemGetValue(sem_id[0], &sem_prop), OS_SUCCESS); UtAssert_INT32_EQ(sem_prop.value, 0); - UtAssert_INT32_EQ(OS_BinSemGetInfo(sem_id[1], &sem_prop), OS_SUCCESS); + UtAssert_INT32_EQ(OS_BinSemGetValue(sem_id[1], &sem_prop), OS_SUCCESS); UtAssert_INT32_EQ(sem_prop.value, 0); } else @@ -162,9 +166,9 @@ void Test_BinSem(void) UtAssert_INT32_EQ(OS_TaskDelete(task_id[0]), OS_SUCCESS); UtAssert_UINT32_EQ(task_counter[0], 0); - if (get_info_implemented) + if (get_value_implemented) { - UtAssert_INT32_EQ(OS_BinSemGetInfo(sem_id[0], &sem_prop), OS_SUCCESS); + UtAssert_INT32_EQ(OS_BinSemGetValue(sem_id[0], &sem_prop), OS_SUCCESS); UtAssert_INT32_EQ(sem_prop.value, 0); } else diff --git a/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c b/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c index 81410afb1..8e6dcf384 100644 --- a/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c +++ b/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c @@ -98,7 +98,7 @@ void task_1(void) if (status == OS_SUCCESS) { OS_printf("TASK 1: Doing some work: %d\n", (int)counter++); - status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); + status = OS_BinSemGetValue(bin_sem_id, &bin_sem_prop); if (status == OS_SUCCESS) { if (bin_sem_prop.value > 1) diff --git a/src/tests/select-test/select-test.c b/src/tests/select-test/select-test.c index 9a3e23503..79627f8fb 100644 --- a/src/tests/select-test/select-test.c +++ b/src/tests/select-test/select-test.c @@ -73,7 +73,7 @@ void BinSemSetup(void) UtAssert_INT32_EQ(OS_BinSemCreate(&bin_sem_id, "BinSem1", 0, 0), OS_SUCCESS); UtAssert_True(OS_ObjectIdDefined(bin_sem_id), "bin_sem_id (%lu) != UNDEFINED", OS_ObjectIdToInteger(bin_sem_id)); - UtAssert_INT32_EQ(OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop), OS_SUCCESS); + UtAssert_INT32_EQ(OS_BinSemGetValue(bin_sem_id, &bin_sem_prop), OS_SUCCESS); UtPrintf("BinSem1 value=%d", (int)bin_sem_prop.value); } diff --git a/src/unit-test-coverage/shared/src/coveragetest-binsem.c b/src/unit-test-coverage/shared/src/coveragetest-binsem.c index d8df019ca..d4a5955ef 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-binsem.c +++ b/src/unit-test-coverage/shared/src/coveragetest-binsem.c @@ -147,11 +147,11 @@ void Test_OS_BinSemGetIdByName(void) OSAPI_TEST_FUNCTION_RC(OS_BinSemGetIdByName(&objid, NULL), OS_INVALID_POINTER); } -void Test_OS_BinSemGetInfo(void) +void Test_OS_BinSemGetName(void) { /* * Test Case For: - * int32 OS_BinSemGetInfo (uint32 sem_id, OS_bin_sem_prop_t *bin_prop) + * int32 OS_BinSemGetName (osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) */ int32 expected = OS_SUCCESS; int32 actual = ~OS_SUCCESS; @@ -161,16 +161,64 @@ void Test_OS_BinSemGetInfo(void) OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_BINSEM, UT_INDEX_1, "ABC", UT_OBJID_OTHER); - actual = OS_BinSemGetInfo(UT_OBJID_1, &prop); + actual = OS_BinSemGetName(UT_OBJID_1, &prop); - UtAssert_True(actual == expected, "OS_BinSemGetInfo() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(prop.creator, ==, UT_OBJID_OTHER); + UtAssert_True(actual == expected, "OS_BinSemGetName() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(strcmp(prop.name, "ABC") == 0, "prop.name (%s) == ABC", prop.name); - OSAPI_TEST_FUNCTION_RC(OS_BinSemGetInfo(UT_OBJID_1, NULL), OS_INVALID_POINTER); + OSAPI_TEST_FUNCTION_RC(OS_BinSemGetName(UT_OBJID_1, NULL), OS_INVALID_POINTER); + + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetById), OS_ERR_INVALID_ID); + OSAPI_TEST_FUNCTION_RC(OS_BinSemGetName(UT_OBJID_1, &prop), OS_ERR_INVALID_ID); +} + +void Test_OS_BinSemGetCreator(void) +{ + /* + * Test Case For: + * int32 OS_BinSemGetCreator (osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) + */ + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + OS_bin_sem_prop_t prop; + + memset(&prop, 0, sizeof(prop)); + + OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_BINSEM, UT_INDEX_1, "ABC", UT_OBJID_OTHER); + + actual = OS_BinSemGetCreator(UT_OBJID_1, &prop); + + UtAssert_True(actual == expected, "OS_BinSemGetCreator() (%ld) == OS_SUCCESS", (long)actual); + OSAPI_TEST_OBJID(prop.creator, ==, UT_OBJID_OTHER); + + OSAPI_TEST_FUNCTION_RC(OS_BinSemGetCreator(UT_OBJID_1, NULL), OS_INVALID_POINTER); + + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetById), OS_ERR_INVALID_ID); + OSAPI_TEST_FUNCTION_RC(OS_BinSemGetCreator(UT_OBJID_1, &prop), OS_ERR_INVALID_ID); +} + +void Test_OS_BinSemGetValue(void) +{ + /* + * Test Case For: + * int32 OS_BinSemGetValue (osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) + */ + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + OS_bin_sem_prop_t prop; + + memset(&prop, 0, sizeof(prop)); + + OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_BINSEM, UT_INDEX_1, "ABC", UT_OBJID_OTHER); + + actual = OS_BinSemGetValue(UT_OBJID_1, &prop); + + UtAssert_True(actual == expected, "OS_BinSemGetValue() (%ld) == OS_SUCCESS", (long)actual); + + OSAPI_TEST_FUNCTION_RC(OS_BinSemGetValue(UT_OBJID_1, NULL), OS_INVALID_POINTER); UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetById), OS_ERR_INVALID_ID); - OSAPI_TEST_FUNCTION_RC(OS_BinSemGetInfo(UT_OBJID_1, &prop), OS_ERR_INVALID_ID); + OSAPI_TEST_FUNCTION_RC(OS_BinSemGetValue(UT_OBJID_1, &prop), OS_ERR_INVALID_ID); } /* Osapi_Test_Setup @@ -204,5 +252,7 @@ void UtTest_Setup(void) ADD_TEST(OS_BinSemFlush); ADD_TEST(OS_BinSemTimedWait); ADD_TEST(OS_BinSemGetIdByName); - ADD_TEST(OS_BinSemGetInfo); + ADD_TEST(OS_BinSemGetName); + ADD_TEST(OS_BinSemGetCreator); + ADD_TEST(OS_BinSemGetValue); } diff --git a/src/unit-test-coverage/ut-stubs/src/os-shared-binsem-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/os-shared-binsem-impl-stubs.c index 38098fd25..bf91d12ea 100644 --- a/src/unit-test-coverage/ut-stubs/src/os-shared-binsem-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/os-shared-binsem-impl-stubs.c @@ -77,19 +77,19 @@ int32 OS_BinSemFlush_Impl(const OS_object_token_t *token) /* * ---------------------------------------------------- - * Generated stub function for OS_BinSemGetInfo_Impl() + * Generated stub function for OS_BinSemGetValue_Impl() * ---------------------------------------------------- */ -int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop) +int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop) { - UT_GenStub_SetupReturnBuffer(OS_BinSemGetInfo_Impl, int32); + UT_GenStub_SetupReturnBuffer(OS_BinSemGetValue_Impl, int32); - UT_GenStub_AddParam(OS_BinSemGetInfo_Impl, const OS_object_token_t *, token); - UT_GenStub_AddParam(OS_BinSemGetInfo_Impl, OS_bin_sem_prop_t *, bin_prop); + UT_GenStub_AddParam(OS_BinSemGetValue_Impl, const OS_object_token_t *, token); + UT_GenStub_AddParam(OS_BinSemGetValue_Impl, OS_bin_sem_prop_t *, bin_prop); - UT_GenStub_Execute(OS_BinSemGetInfo_Impl, Basic, NULL); + UT_GenStub_Execute(OS_BinSemGetValue_Impl, Basic, NULL); - return UT_GenStub_GetReturnValue(OS_BinSemGetInfo_Impl, int32); + return UT_GenStub_GetReturnValue(OS_BinSemGetValue_Impl, int32); } /* diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c b/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c index 11fd2842a..45ab36ced 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c @@ -123,17 +123,17 @@ void Test_OS_BinSemTimedWait_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(&token, 100), OS_ERROR); } -void Test_OS_BinSemGetInfo_Impl(void) +void Test_OS_BinSemGetValue_Impl(void) { /* * Test Case For: - * int32 OS_BinSemGetInfo_Impl (uint32 sem_id, OS_bin_sem_prop_t *sem_prop) + * int32 OS_BinSemGetValue_Impl (uint32 sem_id, OS_bin_sem_prop_t *sem_prop) */ OS_bin_sem_prop_t sem_prop; OS_object_token_t token = UT_TOKEN_0; memset(&sem_prop, 0xEE, sizeof(sem_prop)); - OSAPI_TEST_FUNCTION_RC(OS_BinSemGetInfo_Impl(&token, &sem_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_BinSemGetValue_Impl(&token, &sem_prop), OS_ERR_NOT_IMPLEMENTED); } /* ------------------- End of test cases --------------------------------------*/ @@ -175,5 +175,5 @@ void UtTest_Setup(void) ADD_TEST(OS_BinSemFlush_Impl); ADD_TEST(OS_BinSemTake_Impl); ADD_TEST(OS_BinSemTimedWait_Impl); - ADD_TEST(OS_BinSemGetInfo_Impl); + ADD_TEST(OS_BinSemGetValue_Impl); } diff --git a/src/ut-stubs/osapi-binsem-handlers.c b/src/ut-stubs/osapi-binsem-handlers.c index 96f551011..eb3d478c9 100644 --- a/src/ut-stubs/osapi-binsem-handlers.c +++ b/src/ut-stubs/osapi-binsem-handlers.c @@ -55,10 +55,10 @@ void UT_DefaultHandler_OS_BinSemCreate(void *UserObj, UT_EntryKey_t FuncKey, con /* * ----------------------------------------------------------------- - * Default handler implementation for 'OS_BinSemGetInfo' stub + * Default handler implementation for 'OS_BinSemGetName' stub * ----------------------------------------------------------------- */ -void UT_DefaultHandler_OS_BinSemGetInfo(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +void UT_DefaultHandler_OS_BinSemGetName(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { OS_bin_sem_prop_t *bin_prop = UT_Hook_GetArgValueByName(Context, "bin_prop", OS_bin_sem_prop_t *); int32 status; @@ -66,14 +66,32 @@ void UT_DefaultHandler_OS_BinSemGetInfo(void *UserObj, UT_EntryKey_t FuncKey, co UT_Stub_GetInt32StatusCode(Context, &status); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_BinSemGetInfo), bin_prop, sizeof(*bin_prop)) < sizeof(*bin_prop)) + UT_Stub_CopyToLocal(UT_KEY(OS_BinSemGetName), bin_prop, sizeof(*bin_prop)) < sizeof(*bin_prop)) { - UT_ObjIdCompose(1, OS_OBJECT_TYPE_OS_TASK, &bin_prop->creator); strncpy(bin_prop->name, "Name", sizeof(bin_prop->name) - 1); bin_prop->name[sizeof(bin_prop->name) - 1] = '\0'; } } +/* + * ----------------------------------------------------------------- + * Default handler implementation for 'OS_BinSemGetCreator' stub + * ----------------------------------------------------------------- + */ +void UT_DefaultHandler_OS_BinSemGetCreator(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + OS_bin_sem_prop_t *bin_prop = UT_Hook_GetArgValueByName(Context, "bin_prop", OS_bin_sem_prop_t *); + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status == OS_SUCCESS && + UT_Stub_CopyToLocal(UT_KEY(OS_BinSemGetCreator), bin_prop, sizeof(*bin_prop)) < sizeof(*bin_prop)) + { + UT_ObjIdCompose(1, OS_OBJECT_TYPE_OS_TASK, &bin_prop->creator); + } +} + /* * ----------------------------------------------------------------- * Default handler implementation for 'OS_BinSemDelete' stub diff --git a/src/ut-stubs/osapi-binsem-stubs.c b/src/ut-stubs/osapi-binsem-stubs.c index 2839b66e6..02e428b88 100644 --- a/src/ut-stubs/osapi-binsem-stubs.c +++ b/src/ut-stubs/osapi-binsem-stubs.c @@ -28,7 +28,8 @@ void UT_DefaultHandler_OS_BinSemCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_OS_BinSemDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_OS_BinSemGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); -void UT_DefaultHandler_OS_BinSemGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_BinSemGetName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_BinSemGetCreator(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- @@ -100,19 +101,36 @@ int32 OS_BinSemGetIdByName(osal_id_t *sem_id, const char *sem_name) /* * ---------------------------------------------------- - * Generated stub function for OS_BinSemGetInfo() + * Generated stub function for OS_BinSemGetName() * ---------------------------------------------------- */ -int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) +int32 OS_BinSemGetName(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) { - UT_GenStub_SetupReturnBuffer(OS_BinSemGetInfo, int32); + UT_GenStub_SetupReturnBuffer(OS_BinSemGetName, int32); - UT_GenStub_AddParam(OS_BinSemGetInfo, osal_id_t, sem_id); - UT_GenStub_AddParam(OS_BinSemGetInfo, OS_bin_sem_prop_t *, bin_prop); + UT_GenStub_AddParam(OS_BinSemGetName, osal_id_t, sem_id); + UT_GenStub_AddParam(OS_BinSemGetName, OS_bin_sem_prop_t *, bin_prop); - UT_GenStub_Execute(OS_BinSemGetInfo, Basic, UT_DefaultHandler_OS_BinSemGetInfo); + UT_GenStub_Execute(OS_BinSemGetName, Basic, UT_DefaultHandler_OS_BinSemGetName); - return UT_GenStub_GetReturnValue(OS_BinSemGetInfo, int32); + return UT_GenStub_GetReturnValue(OS_BinSemGetName, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for OS_BinSemGetCreator() + * ---------------------------------------------------- + */ +int32 OS_BinSemGetCreator(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) +{ + UT_GenStub_SetupReturnBuffer(OS_BinSemGetCreator, int32); + + UT_GenStub_AddParam(OS_BinSemGetCreator, osal_id_t, sem_id); + UT_GenStub_AddParam(OS_BinSemGetCreator, OS_bin_sem_prop_t *, bin_prop); + + UT_GenStub_Execute(OS_BinSemGetCreator, Basic, UT_DefaultHandler_OS_BinSemGetCreator); + + return UT_GenStub_GetReturnValue(OS_BinSemGetCreator, int32); } /*