From 2e22d6d78d636d0f5a1d2602d4906a3192ab3da6 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 26 Jul 2023 16:49:16 -0400 Subject: [PATCH 1/3] Fix #1396, do not use intmax_t/uintmax_t types Replace these with long and unsigned long, respectively, as some old systems might not have these types even if it does provide stdint.h --- ut_assert/src/utassert.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ut_assert/src/utassert.c b/ut_assert/src/utassert.c index ae298ff4c..aaec81cf3 100644 --- a/ut_assert/src/utassert.c +++ b/ut_assert/src/utassert.c @@ -45,8 +45,8 @@ static char CurrentSegment[64]; typedef union { - intmax_t s; /**< If value is signed */ - uintmax_t u; /**< If value is unsigned */ + long s; /**< If value is signed */ + unsigned long u; /**< If value is unsigned */ } UtAssert_IntBuf_t; #define UT_COMPARE_TYPE(t, s) (((t) << 1) | (s)) @@ -417,7 +417,7 @@ static const char *UtAssert_GetValueText(char *TempBuf, size_t TempSz, UT_IntChe return TempBuf; } -static bool UtAssert_DoCompare(intmax_t ActualValueIn, UtAssert_Compare_t CompareType, UT_IntCheck_t ReferenceValueIn, +static bool UtAssert_DoCompare(long ActualValueIn, UtAssert_Compare_t CompareType, UT_IntCheck_t ReferenceValueIn, bool IsUnsigned) { bool Result; From 1747e64e7dde2f5ae3a59fad3a8139a76ecbc1c3 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 27 Jul 2023 11:51:01 -0400 Subject: [PATCH 2/3] Fix #1398, separate bind and listen calls for streams Add OS_SocketBindAddress() and OS_SocketListen() to allow users to bind an address without also calling listen(). The use case is for client side connections where the source port needs to be controlled. --- src/os/inc/osapi-select.h | 3 +- src/os/inc/osapi-sockets.h | 50 +++++++- src/os/portable/os-impl-bsd-sockets.c | 35 ++++-- src/os/portable/os-impl-no-sockets.c | 12 +- src/os/shared/inc/os-shared-sockets.h | 10 +- src/os/shared/src/osapi-sockets.c | 81 +++++++++++- .../portable/src/coveragetest-bsd-sockets.c | 40 +++--- .../portable/src/coveragetest-no-sockets.c | 3 +- .../shared/src/coveragetest-sockets.c | 117 ++++++++++++++++-- .../src/os-shared-common-impl-stubs.c | 2 + .../src/os-shared-sockets-impl-stubs.c | 30 +++-- .../ut-stubs/src/os-shared-task-impl-stubs.c | 1 + src/ut-stubs/osapi-binsem-stubs.c | 8 +- src/ut-stubs/osapi-clock-stubs.c | 4 +- src/ut-stubs/osapi-common-stubs.c | 3 + src/ut-stubs/osapi-countsem-stubs.c | 8 +- src/ut-stubs/osapi-dir-stubs.c | 6 +- src/ut-stubs/osapi-error-stubs.c | 2 +- src/ut-stubs/osapi-file-stubs.c | 18 +-- src/ut-stubs/osapi-filesys-stubs.c | 10 +- src/ut-stubs/osapi-heap-stubs.c | 2 +- src/ut-stubs/osapi-idmap-stubs.c | 12 +- src/ut-stubs/osapi-module-stubs.c | 10 +- src/ut-stubs/osapi-mutex-stubs.c | 8 +- src/ut-stubs/osapi-network-stubs.c | 2 +- src/ut-stubs/osapi-printf-stubs.c | 4 +- src/ut-stubs/osapi-queue-stubs.c | 12 +- src/ut-stubs/osapi-sockets-stubs.c | 51 ++++++-- src/ut-stubs/osapi-task-stubs.c | 13 +- src/ut-stubs/osapi-timebase-stubs.c | 10 +- src/ut-stubs/osapi-timer-stubs.c | 10 +- src/ut-stubs/osapi-version-stubs.c | 5 +- 32 files changed, 448 insertions(+), 134 deletions(-) diff --git a/src/os/inc/osapi-select.h b/src/os/inc/osapi-select.h index 70dff8282..20214c9f7 100644 --- a/src/os/inc/osapi-select.h +++ b/src/os/inc/osapi-select.h @@ -57,7 +57,8 @@ typedef enum OS_STREAM_STATE_BOUND = 0x01, /**< @brief whether the stream is bound */ OS_STREAM_STATE_CONNECTED = 0x02, /**< @brief whether the stream is connected */ OS_STREAM_STATE_READABLE = 0x04, /**< @brief whether the stream is readable */ - OS_STREAM_STATE_WRITABLE = 0x08 /**< @brief whether the stream is writable */ + OS_STREAM_STATE_WRITABLE = 0x08, /**< @brief whether the stream is writable */ + OS_STREAM_STATE_LISTENING = 0x10 /**< @brief whether the stream is listening */ } OS_StreamState_t; /** @defgroup OSAPISelect OSAL Select APIs diff --git a/src/os/inc/osapi-sockets.h b/src/os/inc/osapi-sockets.h index 5dba7df60..93d046527 100644 --- a/src/os/inc/osapi-sockets.h +++ b/src/os/inc/osapi-sockets.h @@ -274,15 +274,14 @@ int32 OS_SocketOpen(osal_id_t *sock_id, OS_SocketDomain_t Domain, OS_SocketType_ /*-------------------------------------------------------------------------------------*/ /** - * @brief Binds a socket to a given local address. + * @brief Binds a socket to a given local address and enter listening (server) mode. * - * The specified socket will be bound to the local address and port, if available. + * This is a convenience/compatibility routine to perform both OS_SocketBindAddress() and + * OS_SocketListen() operations in a single call, intended to simplify the setup for a server + * role. * * If the socket is connectionless, then it only binds to the local address. * - * If the socket is connection-oriented (stream), then this will also put the - * socket into a listening state for incoming connections at the local address. - * * @param[in] sock_id The socket ID * @param[in] Addr The local address to bind to @nonnull * @@ -295,6 +294,47 @@ int32 OS_SocketOpen(osal_id_t *sock_id, OS_SocketDomain_t Domain, OS_SocketType_ */ int32 OS_SocketBind(osal_id_t sock_id, const OS_SockAddr_t *Addr); +/*-------------------------------------------------------------------------------------*/ +/** + * @brief Places the specified socket into a listening state. + * + * This function only applies to connection-oriented (stream) sockets that are intended + * to be used in a server-side role. This places the socket into a state where it can + * accept incoming connections from clients. + * + * @param[in] sock_id The socket ID + * + * @return Execution status, see @ref OSReturnCodes + * @retval #OS_SUCCESS @copybrief OS_SUCCESS + * @retval #OS_ERR_INVALID_ID if the sock_id parameter is not valid + * @retval #OS_ERR_INCORRECT_OBJ_STATE if the socket is already listening + * @retval #OS_ERR_INCORRECT_OBJ_TYPE if the handle is not a stream socket + */ +int32 OS_SocketListen(osal_id_t sock_id); + +/*-------------------------------------------------------------------------------------*/ +/** + * @brief Binds a socket to a given local address. + * + * The specified socket will be bound to the local address and port, if available. + * This controls the source address reflected in network traffic transmitted via this + * socket. + * + * After binding to the address, a stream socket may be followed by a call to either + * OS_SocketListen() for a server role or to OS_SocketConnect() for a client role. + * + * @param[in] sock_id The socket ID + * @param[in] Addr The local address to bind to @nonnull + * + * @return Execution status, see @ref OSReturnCodes + * @retval #OS_SUCCESS @copybrief OS_SUCCESS + * @retval #OS_ERR_INVALID_ID if the sock_id parameter is not valid + * @retval #OS_INVALID_POINTER if argument is NULL + * @retval #OS_ERR_INCORRECT_OBJ_STATE if the socket is already bound + * @retval #OS_ERR_INCORRECT_OBJ_TYPE if the handle is not a socket + */ +int32 OS_SocketBindAddress(osal_id_t sock_id, const OS_SockAddr_t *Addr); + /*-------------------------------------------------------------------------------------*/ /** * @brief Connects a socket to a given remote address. diff --git a/src/os/portable/os-impl-bsd-sockets.c b/src/os/portable/os-impl-bsd-sockets.c index f02be9ed1..de03b270a 100644 --- a/src/os/portable/os-impl-bsd-sockets.c +++ b/src/os/portable/os-impl-bsd-sockets.c @@ -214,16 +214,14 @@ int32 OS_SocketOpen_Impl(const OS_object_token_t *token) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SocketBind_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Addr) +int32 OS_SocketBindAddress_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Addr) { int os_result; socklen_t addrlen; const struct sockaddr * sa; OS_impl_file_internal_record_t *impl; - OS_stream_internal_record_t * stream; - impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); - stream = OS_OBJECT_TABLE_GET(OS_stream_table, *token); + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); sa = (const struct sockaddr *)&Addr->AddrData; @@ -254,16 +252,29 @@ int32 OS_SocketBind_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Ad return OS_ERROR; } - /* Start listening on the socket (implied for stream sockets) */ - if (stream->socket_type == OS_SocketType_STREAM) + return OS_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Purpose: Implemented per internal OSAL API + * See prototype for argument/return detail + * + *-----------------------------------------------------------------*/ +int32 OS_SocketListen_Impl(const OS_object_token_t *token) +{ + int os_result; + OS_impl_file_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); + + os_result = listen(impl->fd, 10); + if (os_result < 0) { - os_result = listen(impl->fd, 10); - if (os_result < 0) - { - OS_DEBUG("listen: %s\n", strerror(errno)); - return OS_ERROR; - } + OS_DEBUG("listen: %s\n", strerror(errno)); + return OS_ERROR; } + return OS_SUCCESS; } diff --git a/src/os/portable/os-impl-no-sockets.c b/src/os/portable/os-impl-no-sockets.c index f72cc88b7..0d14700d2 100644 --- a/src/os/portable/os-impl-no-sockets.c +++ b/src/os/portable/os-impl-no-sockets.c @@ -54,7 +54,17 @@ int32 OS_SocketOpen_Impl(const OS_object_token_t *token) * * See prototype for argument/return detail *-----------------------------------------------------------------*/ -int32 OS_SocketBind_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Addr) +int32 OS_SocketBindAddress_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Addr) +{ + return OS_ERR_NOT_IMPLEMENTED; +} + +/*---------------------------------------------------------------- + * Implementation for no network configuration + * + * See prototype for argument/return detail + *-----------------------------------------------------------------*/ +int32 OS_SocketListen_Impl(const OS_object_token_t *token) { return OS_ERR_NOT_IMPLEMENTED; } diff --git a/src/os/shared/inc/os-shared-sockets.h b/src/os/shared/inc/os-shared-sockets.h index 4d5f2b950..547d011f6 100644 --- a/src/os/shared/inc/os-shared-sockets.h +++ b/src/os/shared/inc/os-shared-sockets.h @@ -56,7 +56,15 @@ int32 OS_SocketOpen_Impl(const OS_object_token_t *token); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_SocketBind_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Addr); +int32 OS_SocketBindAddress_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Addr); + +/*---------------------------------------------------------------- + + Purpose: Binds the indicated socket table entry to the passed-in address + + Returns: OS_SUCCESS on success, or relevant error code + ------------------------------------------------------------------*/ +int32 OS_SocketListen_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- diff --git a/src/os/shared/src/osapi-sockets.c b/src/os/shared/src/osapi-sockets.c index d15703820..6e47ffe1d 100644 --- a/src/os/shared/src/osapi-sockets.c +++ b/src/os/shared/src/osapi-sockets.c @@ -151,8 +151,87 @@ int32 OS_SocketOpen(osal_id_t *sock_id, OS_SocketDomain_t Domain, OS_SocketType_ * Purpose: Implemented per public OSAL API * See description in API and header file for detail * + * This is now just a convenience/shorthand routine handling both bind + * and listen, preserved for backward compatibility. + * *-----------------------------------------------------------------*/ int32 OS_SocketBind(osal_id_t sock_id, const OS_SockAddr_t *Addr) +{ + int32 return_code; + + return_code = OS_SocketBindAddress(sock_id, Addr); + if (return_code == OS_SUCCESS) + { + return_code = OS_SocketListen(sock_id); + if (return_code == OS_ERR_INCORRECT_OBJ_TYPE) + { + /* This one is OK, it happens if the socket is a datagram/connectionless + * type that does not need to listen(). For backward compatibility, report + * success to the caller. + */ + return_code = OS_SUCCESS; + } + } + + return return_code; +} + +/*---------------------------------------------------------------- + * + * Purpose: Implemented per public OSAL API + * See description in API and header file for detail + * + *-----------------------------------------------------------------*/ +int32 OS_SocketListen(osal_id_t sock_id) +{ + OS_stream_internal_record_t *stream; + OS_object_token_t token; + int32 return_code; + + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, sock_id, &token); + if (return_code == OS_SUCCESS) + { + stream = OS_OBJECT_TABLE_GET(OS_stream_table, token); + + /* This call is only applicable to stream sockets */ + if (stream->socket_domain == OS_SocketDomain_INVALID || stream->socket_type != OS_SocketType_STREAM) + { + /* Not a stream socket */ + return_code = OS_ERR_INCORRECT_OBJ_TYPE; + } + else if ((stream->stream_state & OS_STREAM_STATE_BOUND) == 0) + { + /* Socket must be bound to an address already */ + return_code = OS_ERR_INCORRECT_OBJ_STATE; + } + else if ((stream->stream_state & (OS_STREAM_STATE_LISTENING | OS_STREAM_STATE_CONNECTED)) != 0) + { + /* Socket must be neither listening nor connected */ + return_code = OS_ERR_INCORRECT_OBJ_STATE; + } + else + { + return_code = OS_SocketListen_Impl(&token); + + if (return_code == OS_SUCCESS) + { + stream->stream_state |= OS_STREAM_STATE_LISTENING; + } + } + + OS_ObjectIdRelease(&token); + } + + return return_code; +} + +/*---------------------------------------------------------------- + * + * Purpose: Implemented per public OSAL API + * See description in API and header file for detail + * + *-----------------------------------------------------------------*/ +int32 OS_SocketBindAddress(osal_id_t sock_id, const OS_SockAddr_t *Addr) { OS_common_record_t * record; OS_stream_internal_record_t *stream; @@ -180,7 +259,7 @@ int32 OS_SocketBind(osal_id_t sock_id, const OS_SockAddr_t *Addr) } else { - return_code = OS_SocketBind_Impl(&token, Addr); + return_code = OS_SocketBindAddress_Impl(&token, Addr); if (return_code == OS_SUCCESS) { diff --git a/src/unit-test-coverage/portable/src/coveragetest-bsd-sockets.c b/src/unit-test-coverage/portable/src/coveragetest-bsd-sockets.c index d04c0b0b5..90c8459bd 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-bsd-sockets.c +++ b/src/unit-test-coverage/portable/src/coveragetest-bsd-sockets.c @@ -128,7 +128,7 @@ void Test_OS_SetSocketDefaultFlags_Impl(void) UtAssert_True(UT_PortablePosixIOTest_Get_Selectable(token.obj_idx), "Socket is selectable"); } -void Test_OS_SocketBind_Impl(void) +void Test_OS_SocketBindAddress_Impl(void) { OS_object_token_t token = {0}; OS_SockAddr_t addr = {0}; @@ -139,7 +139,7 @@ void Test_OS_SocketBind_Impl(void) /* Default family case */ sa->sa_family = -1; - OSAPI_TEST_FUNCTION_RC(OS_SocketBind_Impl, (&token, &addr), OS_ERR_BAD_ADDRESS); + OSAPI_TEST_FUNCTION_RC(OS_SocketBindAddress_Impl, (&token, &addr), OS_ERR_BAD_ADDRESS); /* Note - not attempting to hit addrlen > OS_SOCKADDR_MAX_LEN at this point (NOT MC/DC) * would require compiling with a small OS_SOCKADDR_MAX_LEN or bigger structure */ @@ -147,20 +147,31 @@ void Test_OS_SocketBind_Impl(void) /* Fail bind */ sa->sa_family = OCS_AF_INET; UT_SetDeferredRetcode(UT_KEY(OCS_bind), 1, -1); - OSAPI_TEST_FUNCTION_RC(OS_SocketBind_Impl, (&token, &addr), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_SocketBindAddress_Impl, (&token, &addr), OS_ERROR); - /* Fail listen */ - sa->sa_family = OCS_AF_INET6; - OS_stream_table[0].socket_type = OS_SocketType_STREAM; - UT_SetDeferredRetcode(UT_KEY(OCS_listen), 1, -1); - OSAPI_TEST_FUNCTION_RC(OS_SocketBind_Impl, (&token, &addr), OS_ERROR); + /* Success with INET address */ + sa->sa_family = OCS_AF_INET; + OSAPI_TEST_FUNCTION_RC(OS_SocketBindAddress_Impl, (&token, &addr), OS_SUCCESS); + + /* Success with INET6 address */ + sa->sa_family = OCS_AF_INET6; + OSAPI_TEST_FUNCTION_RC(OS_SocketBindAddress_Impl, (&token, &addr), OS_SUCCESS); +} + +void Test_OS_SocketListen_Impl(void) +{ + OS_object_token_t token = {0}; + + /* Set up token for index 0 */ + token.obj_idx = UT_INDEX_0; - /* Success with OS_SocketType_STREAM */ - OSAPI_TEST_FUNCTION_RC(OS_SocketBind_Impl, (&token, &addr), OS_SUCCESS); + /* Nominal Success */ + OS_stream_table[0].socket_type = OS_SocketType_STREAM; + OSAPI_TEST_FUNCTION_RC(OS_SocketListen_Impl, (&token), OS_SUCCESS); - /* Success with ~OS_SocketType_STREAM */ - OS_stream_table[0].socket_type = ~OS_SocketType_STREAM; - OSAPI_TEST_FUNCTION_RC(OS_SocketBind_Impl, (&token, &addr), OS_SUCCESS); + /* Fail listen */ + UT_SetDeferredRetcode(UT_KEY(OCS_listen), 1, -1); + OSAPI_TEST_FUNCTION_RC(OS_SocketListen_Impl, (&token), OS_ERROR); } void Test_OS_SocketConnect_Impl(void) @@ -482,7 +493,8 @@ void UtTest_Setup(void) { ADD_TEST(OS_SocketOpen_Impl); ADD_TEST(OS_SetSocketDefaultFlags_Impl); - ADD_TEST(OS_SocketBind_Impl); + ADD_TEST(OS_SocketBindAddress_Impl); + ADD_TEST(OS_SocketListen_Impl); ADD_TEST(OS_SocketConnect_Impl); ADD_TEST(OS_SocketShutdown_Impl); ADD_TEST(OS_SocketAccept_Impl); diff --git a/src/unit-test-coverage/portable/src/coveragetest-no-sockets.c b/src/unit-test-coverage/portable/src/coveragetest-no-sockets.c index 7e416b658..71a274180 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-no-sockets.c +++ b/src/unit-test-coverage/portable/src/coveragetest-no-sockets.c @@ -27,7 +27,8 @@ void Test_No_Sockets(void) { OSAPI_TEST_FUNCTION_RC(OS_SocketOpen_Impl, (NULL), OS_ERR_NOT_IMPLEMENTED); - OSAPI_TEST_FUNCTION_RC(OS_SocketBind_Impl, (NULL, NULL), OS_ERR_NOT_IMPLEMENTED); + OSAPI_TEST_FUNCTION_RC(OS_SocketBindAddress_Impl, (NULL, NULL), OS_ERR_NOT_IMPLEMENTED); + OSAPI_TEST_FUNCTION_RC(OS_SocketListen_Impl, (NULL), OS_ERR_NOT_IMPLEMENTED); OSAPI_TEST_FUNCTION_RC(OS_SocketConnect_Impl, (NULL, NULL, 0), OS_ERR_NOT_IMPLEMENTED); OSAPI_TEST_FUNCTION_RC(OS_SocketAccept_Impl, (NULL, NULL, NULL, 0), OS_ERR_NOT_IMPLEMENTED); OSAPI_TEST_FUNCTION_RC(OS_SocketShutdown_Impl, (NULL, 0), OS_ERR_NOT_IMPLEMENTED); diff --git a/src/unit-test-coverage/shared/src/coveragetest-sockets.c b/src/unit-test-coverage/shared/src/coveragetest-sockets.c index ceeebf08c..b2becc22a 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-sockets.c +++ b/src/unit-test-coverage/shared/src/coveragetest-sockets.c @@ -117,29 +117,120 @@ void Test_OS_SocketBind(void) OS_stream_table[1].socket_domain = OS_SocketDomain_INET; memset(&Addr, 0, sizeof(Addr)); - /* Fail implementation */ - UT_SetDeferredRetcode(UT_KEY(OS_SocketBind_Impl), 1, OS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_SocketBind(UT_OBJID_1, &Addr), OS_ERROR); + /* Non-stream socket (not an error) */ + OS_stream_table[1].stream_state = 0; + OS_stream_table[1].socket_type = OS_SocketType_DATAGRAM; + OSAPI_TEST_FUNCTION_RC(OS_SocketBind(UT_OBJID_1, &Addr), OS_SUCCESS); + /* Normal success */ + OS_stream_table[1].stream_state = 0; + OS_stream_table[1].socket_type = OS_SocketType_STREAM; OSAPI_TEST_FUNCTION_RC(OS_SocketBind(UT_OBJID_1, &Addr), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(OS_SocketBind(UT_OBJID_1, NULL), OS_INVALID_POINTER); + /* Failure of OS_SocketBind() - RC passed thru */ + OS_stream_table[1].stream_state = 0; + UT_SetDeferredRetcode(UT_KEY(OS_ObjectIdGetById), 1, -111); + OSAPI_TEST_FUNCTION_RC(OS_SocketBind(UT_OBJID_1, &Addr), -111); + + /* Failure of OS_SocketListen() - RC passed thru */ + OS_stream_table[1].stream_state = 0; + UT_SetDeferredRetcode(UT_KEY(OS_ObjectIdGetById), 2, -112); + OSAPI_TEST_FUNCTION_RC(OS_SocketBind(UT_OBJID_1, &Addr), -112); +} +/***************************************************************************** + * + * Test case for OS_SocketBindAddress() + * + *****************************************************************************/ +void Test_OS_SocketBindAddress(void) +{ /* - * Should fail if not a socket domain + * Test Case For: + * int32 OS_SocketBindAddress(uint32 sock_id, const OS_SockAddr_t *Addr) */ - OS_stream_table[1].socket_domain = OS_SocketDomain_INVALID; + OS_SockAddr_t Addr; + OS_stream_internal_record_t *stream; + + stream = &OS_stream_table[1]; + + stream->socket_type = OS_SocketType_STREAM; + stream->socket_domain = OS_SocketDomain_INET; + stream->stream_state = 0; + + memset(&Addr, 0, sizeof(Addr)); + + /* Bad pointer */ + OSAPI_TEST_FUNCTION_RC(OS_SocketBindAddress(UT_OBJID_1, NULL), OS_INVALID_POINTER); + + /* Invalid object ID */ + UT_SetDeferredRetcode(UT_KEY(OS_ObjectIdGetById), 1, OS_ERR_INVALID_ID); + OSAPI_TEST_FUNCTION_RC(OS_SocketBindAddress(UT_OBJID_1, &Addr), OS_ERR_INVALID_ID); + + /* Fail implementation */ + UT_SetDeferredRetcode(UT_KEY(OS_SocketBindAddress_Impl), 1, OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_SocketBindAddress(UT_OBJID_1, &Addr), OS_ERROR); + UtAssert_BITMASK_UNSET(stream->stream_state, OS_STREAM_STATE_BOUND); + + /* Nominal success */ + OSAPI_TEST_FUNCTION_RC(OS_SocketBindAddress(UT_OBJID_1, &Addr), OS_SUCCESS); + UtAssert_BITMASK_SET(stream->stream_state, OS_STREAM_STATE_BOUND); + + /* Should fail if already bound */ + OSAPI_TEST_FUNCTION_RC(OS_SocketBind(UT_OBJID_1, &Addr), OS_ERR_INCORRECT_OBJ_STATE); + + /* Should fail if not a socket domain */ + stream->socket_domain = OS_SocketDomain_INVALID; OSAPI_TEST_FUNCTION_RC(OS_SocketBind(UT_OBJID_1, &Addr), OS_ERR_INCORRECT_OBJ_TYPE); +} +/***************************************************************************** + * + * Test case for OS_SocketListen() + * + *****************************************************************************/ +void Test_OS_SocketListen(void) +{ /* - * Should fail if already bound + * Test Case For: + * int32 OS_SocketListen(uint32 sock_id) */ - OS_stream_table[1].socket_domain = OS_SocketDomain_INET; - OS_stream_table[1].stream_state = OS_STREAM_STATE_BOUND; - OSAPI_TEST_FUNCTION_RC(OS_SocketBind(UT_OBJID_1, &Addr), OS_ERR_INCORRECT_OBJ_STATE); + OS_stream_internal_record_t *stream; + + stream = &OS_stream_table[1]; + + stream->socket_type = OS_SocketType_INVALID; + stream->socket_domain = OS_SocketDomain_INVALID; + stream->stream_state = 0; + + /* Invalid object ID */ + UT_SetDeferredRetcode(UT_KEY(OS_ObjectIdGetById), 1, OS_ERR_INVALID_ID); + OSAPI_TEST_FUNCTION_RC(OS_SocketListen(UT_OBJID_1), OS_ERR_INVALID_ID); + + /* Should fail if not a stream */ + OSAPI_TEST_FUNCTION_RC(OS_SocketListen(UT_OBJID_1), OS_ERR_INCORRECT_OBJ_TYPE); + + /* Should fail if not a socket domain */ + stream->socket_type = OS_SocketType_STREAM; + OSAPI_TEST_FUNCTION_RC(OS_SocketListen(UT_OBJID_1), OS_ERR_INCORRECT_OBJ_TYPE); + + /* Should fail if not bound */ + stream->socket_domain = OS_SocketDomain_INET; + OSAPI_TEST_FUNCTION_RC(OS_SocketListen(UT_OBJID_1), OS_ERR_INCORRECT_OBJ_STATE); + + /* Fail implementation (does not set listenting state) */ + stream->stream_state = OS_STREAM_STATE_BOUND; + UT_SetDeferredRetcode(UT_KEY(OS_SocketListen_Impl), 1, OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_SocketListen(UT_OBJID_1), OS_ERROR); + UtAssert_BITMASK_SET(stream->stream_state, OS_STREAM_STATE_BOUND); + UtAssert_BITMASK_UNSET(stream->stream_state, OS_STREAM_STATE_LISTENING); + + /* Nominal success */ + OSAPI_TEST_FUNCTION_RC(OS_SocketListen(UT_OBJID_1), OS_SUCCESS); + UtAssert_BITMASK_SET(stream->stream_state, OS_STREAM_STATE_LISTENING); - UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetById), OS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_SocketBind(UT_OBJID_1, &Addr), OS_ERROR); + /* Should fail if already listening */ + OSAPI_TEST_FUNCTION_RC(OS_SocketListen(UT_OBJID_1), OS_ERR_INCORRECT_OBJ_STATE); } /***************************************************************************** @@ -521,6 +612,8 @@ void UtTest_Setup(void) ADD_TEST(OS_SocketAddr); ADD_TEST(OS_SocketOpen); ADD_TEST(OS_SocketBind); + ADD_TEST(OS_SocketBindAddress); + ADD_TEST(OS_SocketListen); ADD_TEST(OS_SocketAccept); ADD_TEST(OS_SocketConnect); ADD_TEST(OS_SocketRecvFrom); diff --git a/src/unit-test-coverage/ut-stubs/src/os-shared-common-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/os-shared-common-impl-stubs.c index 9e0ed2e80..25198883a 100644 --- a/src/unit-test-coverage/ut-stubs/src/os-shared-common-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/os-shared-common-impl-stubs.c @@ -32,6 +32,7 @@ */ void OS_ApplicationShutdown_Impl(void) { + UT_GenStub_Execute(OS_ApplicationShutdown_Impl, Basic, NULL); } @@ -42,5 +43,6 @@ void OS_ApplicationShutdown_Impl(void) */ void OS_IdleLoop_Impl(void) { + UT_GenStub_Execute(OS_IdleLoop_Impl, Basic, NULL); } diff --git a/src/unit-test-coverage/ut-stubs/src/os-shared-sockets-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/os-shared-sockets-impl-stubs.c index 501245390..5ec3ea0f9 100644 --- a/src/unit-test-coverage/ut-stubs/src/os-shared-sockets-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/os-shared-sockets-impl-stubs.c @@ -147,19 +147,19 @@ int32 OS_SocketAddrToString_Impl(char *buffer, size_t buflen, const OS_SockAddr_ /* * ---------------------------------------------------- - * Generated stub function for OS_SocketBind_Impl() + * Generated stub function for OS_SocketBindAddress_Impl() * ---------------------------------------------------- */ -int32 OS_SocketBind_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Addr) +int32 OS_SocketBindAddress_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Addr) { - UT_GenStub_SetupReturnBuffer(OS_SocketBind_Impl, int32); + UT_GenStub_SetupReturnBuffer(OS_SocketBindAddress_Impl, int32); - UT_GenStub_AddParam(OS_SocketBind_Impl, const OS_object_token_t *, token); - UT_GenStub_AddParam(OS_SocketBind_Impl, const OS_SockAddr_t *, Addr); + UT_GenStub_AddParam(OS_SocketBindAddress_Impl, const OS_object_token_t *, token); + UT_GenStub_AddParam(OS_SocketBindAddress_Impl, const OS_SockAddr_t *, Addr); - UT_GenStub_Execute(OS_SocketBind_Impl, Basic, NULL); + UT_GenStub_Execute(OS_SocketBindAddress_Impl, Basic, NULL); - return UT_GenStub_GetReturnValue(OS_SocketBind_Impl, int32); + return UT_GenStub_GetReturnValue(OS_SocketBindAddress_Impl, int32); } /* @@ -197,6 +197,22 @@ int32 OS_SocketGetInfo_Impl(const OS_object_token_t *token, OS_socket_prop_t *so return UT_GenStub_GetReturnValue(OS_SocketGetInfo_Impl, int32); } +/* + * ---------------------------------------------------- + * Generated stub function for OS_SocketListen_Impl() + * ---------------------------------------------------- + */ +int32 OS_SocketListen_Impl(const OS_object_token_t *token) +{ + UT_GenStub_SetupReturnBuffer(OS_SocketListen_Impl, int32); + + UT_GenStub_AddParam(OS_SocketListen_Impl, const OS_object_token_t *, token); + + UT_GenStub_Execute(OS_SocketListen_Impl, Basic, NULL); + + return UT_GenStub_GetReturnValue(OS_SocketListen_Impl, int32); +} + /* * ---------------------------------------------------- * Generated stub function for OS_SocketOpen_Impl() diff --git a/src/unit-test-coverage/ut-stubs/src/os-shared-task-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/os-shared-task-impl-stubs.c index c5b9bc600..cf5317e09 100644 --- a/src/unit-test-coverage/ut-stubs/src/os-shared-task-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/os-shared-task-impl-stubs.c @@ -97,6 +97,7 @@ int32 OS_TaskDetach_Impl(const OS_object_token_t *token) */ void OS_TaskExit_Impl(void) { + UT_GenStub_Execute(OS_TaskExit_Impl, Basic, NULL); } diff --git a/src/ut-stubs/osapi-binsem-stubs.c b/src/ut-stubs/osapi-binsem-stubs.c index 6a93126a9..2839b66e6 100644 --- a/src/ut-stubs/osapi-binsem-stubs.c +++ b/src/ut-stubs/osapi-binsem-stubs.c @@ -25,10 +25,10 @@ #include "osapi-binsem.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_BinSemCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_BinSemDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_BinSemGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_BinSemGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +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 *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-clock-stubs.c b/src/ut-stubs/osapi-clock-stubs.c index 23b68e64d..4d3b11bc8 100644 --- a/src/ut-stubs/osapi-clock-stubs.c +++ b/src/ut-stubs/osapi-clock-stubs.c @@ -25,8 +25,8 @@ #include "osapi-clock.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_GetLocalTime(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_SetLocalTime(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_GetLocalTime(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_SetLocalTime(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-common-stubs.c b/src/ut-stubs/osapi-common-stubs.c index 68149e22f..d3e85afb6 100644 --- a/src/ut-stubs/osapi-common-stubs.c +++ b/src/ut-stubs/osapi-common-stubs.c @@ -46,6 +46,7 @@ int32 OS_API_Init(void) */ void OS_API_Teardown(void) { + UT_GenStub_Execute(OS_API_Teardown, Basic, NULL); } @@ -80,6 +81,7 @@ void OS_ApplicationShutdown(uint8 flag) */ void OS_DeleteAllObjects(void) { + UT_GenStub_Execute(OS_DeleteAllObjects, Basic, NULL); } @@ -90,6 +92,7 @@ void OS_DeleteAllObjects(void) */ void OS_IdleLoop(void) { + UT_GenStub_Execute(OS_IdleLoop, Basic, NULL); } diff --git a/src/ut-stubs/osapi-countsem-stubs.c b/src/ut-stubs/osapi-countsem-stubs.c index 813234fe9..86718dc9e 100644 --- a/src/ut-stubs/osapi-countsem-stubs.c +++ b/src/ut-stubs/osapi-countsem-stubs.c @@ -25,10 +25,10 @@ #include "osapi-countsem.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_CountSemCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_CountSemDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_CountSemGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_CountSemGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_CountSemCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_CountSemDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_CountSemGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_CountSemGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-dir-stubs.c b/src/ut-stubs/osapi-dir-stubs.c index c0e85a6c3..f16d6aafb 100644 --- a/src/ut-stubs/osapi-dir-stubs.c +++ b/src/ut-stubs/osapi-dir-stubs.c @@ -25,9 +25,9 @@ #include "osapi-dir.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_DirectoryClose(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_DirectoryOpen(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_DirectoryRead(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_DirectoryClose(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_DirectoryOpen(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_DirectoryRead(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-error-stubs.c b/src/ut-stubs/osapi-error-stubs.c index 62eee38a0..eca60fa03 100644 --- a/src/ut-stubs/osapi-error-stubs.c +++ b/src/ut-stubs/osapi-error-stubs.c @@ -25,7 +25,7 @@ #include "osapi-error.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_GetErrorName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_GetErrorName(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-file-stubs.c b/src/ut-stubs/osapi-file-stubs.c index 1df42a726..de52a1570 100644 --- a/src/ut-stubs/osapi-file-stubs.c +++ b/src/ut-stubs/osapi-file-stubs.c @@ -25,15 +25,15 @@ #include "osapi-file.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_FDGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_OpenCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TimedRead(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TimedWrite(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_close(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_lseek(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_read(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_stat(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_write(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_FDGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_OpenCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TimedRead(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TimedWrite(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_close(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_lseek(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_read(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_stat(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_write(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-filesys-stubs.c b/src/ut-stubs/osapi-filesys-stubs.c index cc16ae63f..da647cc69 100644 --- a/src/ut-stubs/osapi-filesys-stubs.c +++ b/src/ut-stubs/osapi-filesys-stubs.c @@ -25,11 +25,11 @@ #include "osapi-filesys.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_FS_GetPhysDriveName(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_FileSysAddFixedMap(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_FileSysStatVolume(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_GetFsInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TranslatePath(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_FS_GetPhysDriveName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_FileSysAddFixedMap(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_FileSysStatVolume(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_GetFsInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TranslatePath(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-heap-stubs.c b/src/ut-stubs/osapi-heap-stubs.c index ac39aa023..c42d92601 100644 --- a/src/ut-stubs/osapi-heap-stubs.c +++ b/src/ut-stubs/osapi-heap-stubs.c @@ -25,7 +25,7 @@ #include "osapi-heap.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_HeapGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_HeapGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-idmap-stubs.c b/src/ut-stubs/osapi-idmap-stubs.c index 6db397765..da6793d2d 100644 --- a/src/ut-stubs/osapi-idmap-stubs.c +++ b/src/ut-stubs/osapi-idmap-stubs.c @@ -25,12 +25,12 @@ #include "osapi-idmap.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_ConvertToArrayIndex(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_ForEachObject(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_ForEachObjectOfType(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_GetResourceName(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_IdentifyObject(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_ObjectIdToArrayIndex(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_ConvertToArrayIndex(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_ForEachObject(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_ForEachObjectOfType(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_GetResourceName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_IdentifyObject(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_ObjectIdToArrayIndex(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-module-stubs.c b/src/ut-stubs/osapi-module-stubs.c index 9d97045ad..8e922b6ce 100644 --- a/src/ut-stubs/osapi-module-stubs.c +++ b/src/ut-stubs/osapi-module-stubs.c @@ -25,11 +25,11 @@ #include "osapi-module.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_ModuleInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_ModuleLoad(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_ModuleSymbolLookup(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_ModuleUnload(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_SymbolLookup(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_ModuleInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_ModuleLoad(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_ModuleSymbolLookup(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_ModuleUnload(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_SymbolLookup(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-mutex-stubs.c b/src/ut-stubs/osapi-mutex-stubs.c index 0980ae3c3..f4cd96df8 100644 --- a/src/ut-stubs/osapi-mutex-stubs.c +++ b/src/ut-stubs/osapi-mutex-stubs.c @@ -25,10 +25,10 @@ #include "osapi-mutex.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_MutSemCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_MutSemDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_MutSemGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_MutSemGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_MutSemCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_MutSemDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_MutSemGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_MutSemGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-network-stubs.c b/src/ut-stubs/osapi-network-stubs.c index b235e7e8e..2dc877ba7 100644 --- a/src/ut-stubs/osapi-network-stubs.c +++ b/src/ut-stubs/osapi-network-stubs.c @@ -25,7 +25,7 @@ #include "osapi-network.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_NetworkGetHostName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_NetworkGetHostName(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-printf-stubs.c b/src/ut-stubs/osapi-printf-stubs.c index 368dd4c84..38ffb22fa 100644 --- a/src/ut-stubs/osapi-printf-stubs.c +++ b/src/ut-stubs/osapi-printf-stubs.c @@ -27,7 +27,7 @@ #include "osapi-printf.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_printf(void *, UT_EntryKey_t, const UT_StubContext_t *, va_list); +void UT_DefaultHandler_OS_printf(void *, UT_EntryKey_t, const UT_StubContext_t *, va_list); /* * ---------------------------------------------------- @@ -52,6 +52,7 @@ void OS_printf(const char *string, ...) */ void OS_printf_disable(void) { + UT_GenStub_Execute(OS_printf_disable, Basic, NULL); } @@ -62,5 +63,6 @@ void OS_printf_disable(void) */ void OS_printf_enable(void) { + UT_GenStub_Execute(OS_printf_enable, Basic, NULL); } diff --git a/src/ut-stubs/osapi-queue-stubs.c b/src/ut-stubs/osapi-queue-stubs.c index e1f973288..a5ccd3ba5 100644 --- a/src/ut-stubs/osapi-queue-stubs.c +++ b/src/ut-stubs/osapi-queue-stubs.c @@ -25,12 +25,12 @@ #include "osapi-queue.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_QueueCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_QueueDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_QueueGet(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_QueueGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_QueueGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_QueuePut(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_QueueCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_QueueDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_QueueGet(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_QueueGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_QueueGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_QueuePut(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-sockets-stubs.c b/src/ut-stubs/osapi-sockets-stubs.c index 63fa5be6f..d8676076a 100644 --- a/src/ut-stubs/osapi-sockets-stubs.c +++ b/src/ut-stubs/osapi-sockets-stubs.c @@ -25,15 +25,15 @@ #include "osapi-sockets.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_SocketAddrFromString(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_SocketAddrGetPort(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_SocketAddrInit(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_SocketAddrToString(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_SocketGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_SocketGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_SocketOpen(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_SocketRecvFrom(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_SocketSendTo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_SocketAddrFromString(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_SocketAddrGetPort(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_SocketAddrInit(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_SocketAddrToString(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_SocketGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_SocketGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_SocketOpen(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_SocketRecvFrom(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_SocketSendTo(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- @@ -157,6 +157,23 @@ int32 OS_SocketBind(osal_id_t sock_id, const OS_SockAddr_t *Addr) return UT_GenStub_GetReturnValue(OS_SocketBind, int32); } +/* + * ---------------------------------------------------- + * Generated stub function for OS_SocketBindAddress() + * ---------------------------------------------------- + */ +int32 OS_SocketBindAddress(osal_id_t sock_id, const OS_SockAddr_t *Addr) +{ + UT_GenStub_SetupReturnBuffer(OS_SocketBindAddress, int32); + + UT_GenStub_AddParam(OS_SocketBindAddress, osal_id_t, sock_id); + UT_GenStub_AddParam(OS_SocketBindAddress, const OS_SockAddr_t *, Addr); + + UT_GenStub_Execute(OS_SocketBindAddress, Basic, NULL); + + return UT_GenStub_GetReturnValue(OS_SocketBindAddress, int32); +} + /* * ---------------------------------------------------- * Generated stub function for OS_SocketConnect() @@ -209,6 +226,22 @@ int32 OS_SocketGetInfo(osal_id_t sock_id, OS_socket_prop_t *sock_prop) return UT_GenStub_GetReturnValue(OS_SocketGetInfo, int32); } +/* + * ---------------------------------------------------- + * Generated stub function for OS_SocketListen() + * ---------------------------------------------------- + */ +int32 OS_SocketListen(osal_id_t sock_id) +{ + UT_GenStub_SetupReturnBuffer(OS_SocketListen, int32); + + UT_GenStub_AddParam(OS_SocketListen, osal_id_t, sock_id); + + UT_GenStub_Execute(OS_SocketListen, Basic, NULL); + + return UT_GenStub_GetReturnValue(OS_SocketListen, int32); +} + /* * ---------------------------------------------------- * Generated stub function for OS_SocketOpen() diff --git a/src/ut-stubs/osapi-task-stubs.c b/src/ut-stubs/osapi-task-stubs.c index a59580c09..b5bfe607f 100644 --- a/src/ut-stubs/osapi-task-stubs.c +++ b/src/ut-stubs/osapi-task-stubs.c @@ -25,12 +25,12 @@ #include "osapi-task.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_TaskCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TaskDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TaskFindIdBySystemData(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TaskGetId(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TaskGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TaskGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TaskCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TaskDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TaskFindIdBySystemData(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TaskGetId(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TaskGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TaskGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- @@ -94,6 +94,7 @@ int32 OS_TaskDelete(osal_id_t task_id) */ void OS_TaskExit(void) { + UT_GenStub_Execute(OS_TaskExit, Basic, NULL); } diff --git a/src/ut-stubs/osapi-timebase-stubs.c b/src/ut-stubs/osapi-timebase-stubs.c index b082bfdb0..080110300 100644 --- a/src/ut-stubs/osapi-timebase-stubs.c +++ b/src/ut-stubs/osapi-timebase-stubs.c @@ -25,11 +25,11 @@ #include "osapi-timebase.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_TimeBaseCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TimeBaseDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TimeBaseGetFreeRun(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TimeBaseGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TimeBaseGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TimeBaseCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TimeBaseDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TimeBaseGetFreeRun(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TimeBaseGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TimeBaseGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-timer-stubs.c b/src/ut-stubs/osapi-timer-stubs.c index 2ea44903e..ec87cf3bb 100644 --- a/src/ut-stubs/osapi-timer-stubs.c +++ b/src/ut-stubs/osapi-timer-stubs.c @@ -25,11 +25,11 @@ #include "osapi-timer.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_TimerAdd(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TimerCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TimerDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TimerGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_TimerGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TimerAdd(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TimerCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TimerDelete(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TimerGetIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_TimerGetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- diff --git a/src/ut-stubs/osapi-version-stubs.c b/src/ut-stubs/osapi-version-stubs.c index 24272912c..2e438b396 100644 --- a/src/ut-stubs/osapi-version-stubs.c +++ b/src/ut-stubs/osapi-version-stubs.c @@ -25,8 +25,8 @@ #include "osapi-version.h" #include "utgenstub.h" -extern void UT_DefaultHandler_OS_GetVersionCodeName(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_OS_GetVersionString(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_GetVersionCodeName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_OS_GetVersionString(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- @@ -63,6 +63,7 @@ const char *OS_GetVersionCodeName(void) */ void OS_GetVersionNumber(uint8 VersionNumbers[4]) { + UT_GenStub_Execute(OS_GetVersionNumber, Basic, NULL); } From 7a9c7e6e84931ceb75750e09e0f1114e3c5e79af Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 27 Jul 2023 18:39:01 +0000 Subject: [PATCH 3/3] Updating documentation and version numbers for v6.0.0-rc4+dev223 --- CHANGELOG.md | 6 ++++++ src/os/inc/osapi-version.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 424381c54..a83310066 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Development Build: v6.0.0-rc4+dev223 +- 'Fix #1396, do not use intmax_t/uintmax_t types' +- 'Fix #1398, separate bind and listen calls for streams' +- See: + + ## Development Build: v6.0.0-rc4+dev217 - Add additional counters to test summary - See diff --git a/src/os/inc/osapi-version.h b/src/os/inc/osapi-version.h index 674c65871..e94571378 100644 --- a/src/os/inc/osapi-version.h +++ b/src/os/inc/osapi-version.h @@ -34,7 +34,7 @@ /* * Development Build Macro Definitions */ -#define OS_BUILD_NUMBER 217 +#define OS_BUILD_NUMBER 223 #define OS_BUILD_BASELINE "v6.0.0-rc4" /*