From 009abc1303cd5350aa3c99ad233185de84a71d74 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 20 Sep 2021 20:40:12 -0400 Subject: [PATCH] Fix #1153, add os-specifc socket flag function Adds the capability for the bsd sockets implementation to use a function provided by the OS layer to set the socket flags. This allows VxWorks to have an alternative implementation that uses ioctl rather than fcntl to set the flags. --- src/os/portable/os-impl-bsd-sockets.c | 93 ++++++++++--------- src/os/shared/inc/os-shared-sockets.h | 1 + src/os/vxworks/CMakeLists.txt | 1 + src/os/vxworks/inc/os-impl-sockets.h | 23 ++--- src/os/vxworks/src/os-impl-sockets.c | 64 +++++++++++++ .../portable/src/coveragetest-bsd-sockets.c | 34 +++---- .../ut-stubs/inc/OCS_ioLib.h | 1 + .../ut-stubs/override_inc/ioLib.h | 1 + .../src/os-shared-sockets-impl-stubs.c | 12 +++ src/unit-test-coverage/vxworks/CMakeLists.txt | 1 + .../vxworks/adaptors/CMakeLists.txt | 1 + .../vxworks/adaptors/inc/ut-adaptor-sockets.h | 35 +++++++ .../vxworks/adaptors/src/ut-adaptor-sockets.c | 44 +++++++++ .../vxworks/src/coveragetest-sockets.c | 68 ++++++++++++++ .../vxworks/ut-stubs/CMakeLists.txt | 1 + .../src/vxworks-os-impl-sockets-stubs.c | 33 +++++++ 16 files changed, 338 insertions(+), 75 deletions(-) create mode 100644 src/os/vxworks/src/os-impl-sockets.c create mode 100644 src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-sockets.h create mode 100644 src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-sockets.c create mode 100644 src/unit-test-coverage/vxworks/src/coveragetest-sockets.c create mode 100644 src/unit-test-coverage/vxworks/ut-stubs/src/vxworks-os-impl-sockets-stubs.c diff --git a/src/os/portable/os-impl-bsd-sockets.c b/src/os/portable/os-impl-bsd-sockets.c index cb31211a6..1d8d8f4f5 100644 --- a/src/os/portable/os-impl-bsd-sockets.c +++ b/src/os/portable/os-impl-bsd-sockets.c @@ -63,6 +63,22 @@ DEFINES ****************************************************************************************/ +/* + * The OS layer may define a macro to set the proper flags on newly-opened sockets. + * If not set, then a default implementation is used, which uses fcntl() to set O_NONBLOCK + */ +#ifndef OS_IMPL_SOCKET_FLAGS +#ifdef O_NONBLOCK +#define OS_IMPL_SOCKET_FLAGS O_NONBLOCK +#else +#define OS_IMPL_SOCKET_FLAGS 0 /* do not set any flags */ +#endif +#endif + +#ifndef OS_IMPL_SET_SOCKET_FLAGS +#define OS_IMPL_SET_SOCKET_FLAGS(tok) OS_SetSocketDefaultFlags_Impl(tok) +#endif + typedef union { char data[OS_SOCKADDR_MAX_LEN]; @@ -82,6 +98,37 @@ typedef union */ CompileTimeAssert(sizeof(OS_SockAddr_Accessor_t) == OS_SOCKADDR_MAX_LEN, SockAddrSize); +/* + * Default flags implementation: Set the O_NONBLOCK flag via fcntl(). + * An implementation can also elect custom configuration by setting + * the OS_IMPL_SET_SOCKET_FLAGS macro to point to an alternate function. + */ +void OS_SetSocketDefaultFlags_Impl(const OS_object_token_t *token) +{ + OS_impl_file_internal_record_t *impl; + int os_flags; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); + + os_flags = fcntl(impl->fd, F_GETFL); + if (os_flags == -1) + { + /* No recourse if F_GETFL fails - just report the error and move on. */ + OS_DEBUG("fcntl(F_GETFL): %s\n", strerror(errno)); + } + else + { + os_flags |= OS_IMPL_SOCKET_FLAGS; + if (fcntl(impl->fd, F_SETFL, os_flags) == -1) + { + /* No recourse if F_SETFL fails - just report the error and move on. */ + OS_DEBUG("fcntl(F_SETFL): %s\n", strerror(errno)); + } + } + + impl->selectable = true; +} + /**************************************************************************************** Sockets API ***************************************************************************************/ @@ -160,23 +207,7 @@ int32 OS_SocketOpen_Impl(const OS_object_token_t *token) * nonblock mode does improve robustness in the event that multiple tasks * attempt to accept new connections from the same server socket at the same time. */ - os_flags = fcntl(impl->fd, F_GETFL); - if (os_flags == -1) - { - /* No recourse if F_GETFL fails - just report the error and move on. */ - OS_DEBUG("fcntl(F_GETFL): %s\n", strerror(errno)); - } - else - { - os_flags |= OS_IMPL_SOCKET_FLAGS; - if (fcntl(impl->fd, F_SETFL, os_flags) == -1) - { - /* No recourse if F_SETFL fails - just report the error and move on. */ - OS_DEBUG("fcntl(F_SETFL): %s\n", strerror(errno)); - } - } - - impl->selectable = OS_IMPL_SOCKET_SELECTABLE; + OS_IMPL_SET_SOCKET_FLAGS(token); return OS_SUCCESS; } /* end OS_SocketOpen_Impl */ @@ -397,7 +428,6 @@ int32 OS_SocketAccept_Impl(const OS_object_token_t *sock_token, const OS_object_ int32 return_code; uint32 operation; socklen_t addrlen; - int os_flags; OS_impl_file_internal_record_t *sock_impl; OS_impl_file_internal_record_t *conn_impl; @@ -432,32 +462,7 @@ int32 OS_SocketAccept_Impl(const OS_object_token_t *sock_token, const OS_object_ { Addr->ActualLength = addrlen; - /* - * Set the standard options on the filehandle by default -- - * this may set it to non-blocking mode if the implementation supports it. - * any blocking would be done explicitly via the select() wrappers - * - * NOTE: The implementation still generally works without this flag set, but - * nonblock mode does improve robustness in the event that multiple tasks - * attempt to read from the same socket at the same time. - */ - os_flags = fcntl(conn_impl->fd, F_GETFL); - if (os_flags == -1) - { - /* No recourse if F_GETFL fails - just report the error and move on. */ - OS_DEBUG("fcntl(F_GETFL): %s\n", strerror(errno)); - } - else - { - os_flags |= OS_IMPL_SOCKET_FLAGS; - if (fcntl(conn_impl->fd, F_SETFL, os_flags) == -1) - { - /* No recourse if F_SETFL fails - just report the error and move on. */ - OS_DEBUG("fcntl(F_SETFL): %s\n", strerror(errno)); - } - } - - conn_impl->selectable = OS_IMPL_SOCKET_SELECTABLE; + OS_IMPL_SET_SOCKET_FLAGS(conn_token); } } } diff --git a/src/os/shared/inc/os-shared-sockets.h b/src/os/shared/inc/os-shared-sockets.h index 032339fa5..3d9933eab 100644 --- a/src/os/shared/inc/os-shared-sockets.h +++ b/src/os/shared/inc/os-shared-sockets.h @@ -188,5 +188,6 @@ int32 OS_SocketAddrSetPort_Impl(OS_SockAddr_t *Addr, uint16 PortNum); * Not normally called outside the local unit, except during unit test */ void OS_CreateSocketName(const OS_object_token_t *token, const OS_SockAddr_t *Addr, const char *parent_name); +void OS_SetSocketDefaultFlags_Impl(const OS_object_token_t *token); #endif /* OS_SHARED_SOCKETS_H */ diff --git a/src/os/vxworks/CMakeLists.txt b/src/os/vxworks/CMakeLists.txt index 912f3e74c..fb4f56c36 100644 --- a/src/os/vxworks/CMakeLists.txt +++ b/src/os/vxworks/CMakeLists.txt @@ -65,6 +65,7 @@ if (OSAL_CONFIG_INCLUDE_NETWORK) list(APPEND VXWORKS_IMPL_SRCLIST src/os-impl-network.c ../portable/os-impl-bsd-sockets.c # Use BSD socket layer implementation + src/os-impl-sockets.c # Additional vxworks-specific code to handle socket flags ) else() list(APPEND VXWORKS_IMPL_SRCLIST diff --git a/src/os/vxworks/inc/os-impl-sockets.h b/src/os/vxworks/inc/os-impl-sockets.h index bf7c716f6..6b1a05d5a 100644 --- a/src/os/vxworks/inc/os-impl-sockets.h +++ b/src/os/vxworks/inc/os-impl-sockets.h @@ -29,6 +29,7 @@ #define OS_IMPL_SOCKETS_H #include "os-impl-io.h" +#include "os-shared-globaldefs.h" #include #include @@ -37,25 +38,19 @@ #include #include #include +#include /* - * Socket descriptors should be usable with the select() API + * Override the socket flag set routine on this platform. + * This is required because some versions of VxWorks do not support + * the standard POSIX fcntl() opcodes, and must use ioctl() instead. */ -#define OS_IMPL_SOCKET_SELECTABLE true - -/* - * Use the O_NONBLOCK flag on sockets - * - * NOTE: the fcntl() F_GETFL/F_SETFL opcodes that set descriptor flags may not - * work correctly on some version of VxWorks. - * - * This flag is not strictly required, things still mostly work without it, - * but lack of this mode does introduce some potential race conditions if more - * than one task attempts to use the same descriptor handle at the same time. - */ -#define OS_IMPL_SOCKET_FLAGS O_NONBLOCK +#define OS_IMPL_SET_SOCKET_FLAGS(impl) OS_VxWorks_SetSocketFlags_Impl(impl) /* The "in.h" header file supplied in VxWorks 6.9 is missing the "in_port_t" typedef */ typedef u_short in_port_t; +/* VxWorks-specific helper function to configure the socket flags on a connection */ +void OS_VxWorks_SetSocketFlags_Impl(const OS_object_token_t *token); + #endif /* OS_IMPL_SOCKETS_H */ diff --git a/src/os/vxworks/src/os-impl-sockets.c b/src/os/vxworks/src/os-impl-sockets.c new file mode 100644 index 000000000..5b51ecd02 --- /dev/null +++ b/src/os/vxworks/src/os-impl-sockets.c @@ -0,0 +1,64 @@ +/* + * NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer" + * + * Copyright (c) 2019 United States Government as represented by + * the Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * \file os-impl-sockets.c + * \ingroup vxworks + * \author joseph.p.hickey@nasa.gov + * + */ + +/**************************************************************************************** + INCLUDE FILES + ***************************************************************************************/ + +#include "os-vxworks.h" +#include "os-shared-idmap.h" +#include "os-impl-io.h" +#include "os-impl-sockets.h" + +/**************************************************************************************** + INITIALIZATION FUNCTION + ***************************************************************************************/ + +/*---------------------------------------------------------------- + * + * Function: OS_VxWorks_ModuleAPI_Impl_Init + * + * Purpose: Local helper routine, not part of OSAL API. + * + *-----------------------------------------------------------------*/ +void OS_VxWorks_SetSocketFlags_Impl(const OS_object_token_t *token) +{ + OS_impl_file_internal_record_t *impl; + int os_flags; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); + + /* Use ioctl/FIONBIO on this platform, rather than standard fcntl() */ + os_flags = 1; + if (ioctl(impl->fd, FIONBIO, &os_flags) == -1) + { + /* No recourse if ioctl fails - just report the error and move on. */ + OS_DEBUG("ioctl(FIONBIO): %s\n", strerror(errno)); + } + + impl->selectable = true; +} 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 7abcd2bbe..9322fa2bc 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-bsd-sockets.c +++ b/src/unit-test-coverage/portable/src/coveragetest-bsd-sockets.c @@ -100,21 +100,34 @@ void Test_OS_SocketOpen_Impl(void) OS_stream_table[0].socket_type = OS_SocketType_STREAM; OS_stream_table[0].socket_domain = OS_SocketDomain_INET6; OSAPI_TEST_FUNCTION_RC(OS_SocketOpen_Impl, (&token), OS_SUCCESS); - UtAssert_True(UT_PortablePosixIOTest_Get_Selectable(token.obj_idx), "Socket is selectable"); +} + +void Test_OS_SetSocketDefaultFlags_Impl(void) +{ + OS_object_token_t token = {0}; /* Failure in fcntl() GETFL */ UT_PortablePosixIOTest_ResetImpl(token.obj_idx); UT_ResetState(UT_KEY(OCS_fcntl)); UT_SetDeferredRetcode(UT_KEY(OCS_fcntl), 1, -1); - OSAPI_TEST_FUNCTION_RC(OS_SocketOpen_Impl, (&token), OS_SUCCESS); + UtAssert_VOIDCALL(OS_SetSocketDefaultFlags_Impl(&token)); UtAssert_STUB_COUNT(OCS_fcntl, 1); + UtAssert_True(UT_PortablePosixIOTest_Get_Selectable(token.obj_idx), "Socket is selectable"); /* Failure in fcntl() SETFL */ UT_PortablePosixIOTest_ResetImpl(token.obj_idx); UT_ResetState(UT_KEY(OCS_fcntl)); UT_SetDeferredRetcode(UT_KEY(OCS_fcntl), 2, -1); - OSAPI_TEST_FUNCTION_RC(OS_SocketOpen_Impl, (&token), OS_SUCCESS); + UtAssert_VOIDCALL(OS_SetSocketDefaultFlags_Impl(&token)); + UtAssert_STUB_COUNT(OCS_fcntl, 2); + UtAssert_True(UT_PortablePosixIOTest_Get_Selectable(token.obj_idx), "Socket is selectable"); + + /* Nominal path */ + UT_PortablePosixIOTest_ResetImpl(token.obj_idx); + UT_ResetState(UT_KEY(OCS_fcntl)); + UtAssert_VOIDCALL(OS_SetSocketDefaultFlags_Impl(&token)); UtAssert_STUB_COUNT(OCS_fcntl, 2); + UtAssert_True(UT_PortablePosixIOTest_Get_Selectable(token.obj_idx), "Socket is selectable"); } void Test_OS_SocketBind_Impl(void) @@ -255,20 +268,6 @@ void Test_OS_SocketAccept_Impl(void) /* Success case */ OSAPI_TEST_FUNCTION_RC(OS_SocketAccept_Impl, (&sock_token, &conn_token, &addr, 0), OS_SUCCESS); - - /* Failure in fcntl() GETFL */ - UT_PortablePosixIOTest_ResetImpl(conn_token.obj_idx); - UT_ResetState(UT_KEY(OCS_fcntl)); - UT_SetDeferredRetcode(UT_KEY(OCS_fcntl), 1, -1); - OSAPI_TEST_FUNCTION_RC(OS_SocketAccept_Impl, (&sock_token, &conn_token, &addr, 0), OS_SUCCESS); - UtAssert_STUB_COUNT(OCS_fcntl, 1); - - /* Failure in fcntl() SETFL */ - UT_PortablePosixIOTest_ResetImpl(conn_token.obj_idx); - UT_ResetState(UT_KEY(OCS_fcntl)); - UT_SetDeferredRetcode(UT_KEY(OCS_fcntl), 2, -1); - OSAPI_TEST_FUNCTION_RC(OS_SocketAccept_Impl, (&sock_token, &conn_token, &addr, 0), OS_SUCCESS); - UtAssert_STUB_COUNT(OCS_fcntl, 2); } void Test_OS_SocketRecvFrom_Impl(void) @@ -484,6 +483,7 @@ void Osapi_Test_Teardown(void) {} void UtTest_Setup(void) { ADD_TEST(OS_SocketOpen_Impl); + ADD_TEST(OS_SetSocketDefaultFlags_Impl); ADD_TEST(OS_SocketBind_Impl); ADD_TEST(OS_SocketConnect_Impl); ADD_TEST(OS_SocketShutdown_Impl); diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_ioLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_ioLib.h index f864eb8a4..43cced0db 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_ioLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_ioLib.h @@ -37,6 +37,7 @@ #define OCS_FIOCHKDSK 0x1E01 #define OCS_FIOUNMOUNT 0x1E02 +#define OCS_FIONBIO 0x1E03 /* ----------------------------------------- */ /* types normally defined in ioLib.h */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/ioLib.h b/src/unit-test-coverage/ut-stubs/override_inc/ioLib.h index a9ba0f0cc..2fdfe6419 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/ioLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/ioLib.h @@ -37,6 +37,7 @@ #define FIOCHKDSK OCS_FIOCHKDSK #define FIOUNMOUNT OCS_FIOUNMOUNT +#define FIONBIO OCS_FIONBIO #define ioctl OCS_ioctl #endif /* OVERRIDE_IOLIB_H */ 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 227fcde60..6ffd258f0 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 @@ -27,6 +27,18 @@ #include "os-shared-sockets.h" #include "utgenstub.h" +/* + * ---------------------------------------------------- + * Generated stub function for OS_SetSocketDefaultFlags_Impl() + * ---------------------------------------------------- + */ +void OS_SetSocketDefaultFlags_Impl(const OS_object_token_t *token) +{ + UT_GenStub_AddParam(OS_SetSocketDefaultFlags_Impl, const OS_object_token_t *, token); + + UT_GenStub_Execute(OS_SetSocketDefaultFlags_Impl, Basic, NULL); +} + /* * ---------------------------------------------------- * Generated stub function for OS_SocketAccept_Impl() diff --git a/src/unit-test-coverage/vxworks/CMakeLists.txt b/src/unit-test-coverage/vxworks/CMakeLists.txt index b97b2edd1..0124d3e23 100644 --- a/src/unit-test-coverage/vxworks/CMakeLists.txt +++ b/src/unit-test-coverage/vxworks/CMakeLists.txt @@ -15,6 +15,7 @@ set(VXWORKS_MODULE_LIST network queues shell + sockets symtab tasks timebase diff --git a/src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt b/src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt index eb22c05de..b0789bdb6 100644 --- a/src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt +++ b/src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt @@ -21,6 +21,7 @@ add_library(ut-adaptor-${SETNAME} STATIC src/ut-adaptor-mutex.c src/ut-adaptor-queues.c src/ut-adaptor-filetable-stub.c + src/ut-adaptor-sockets.c src/ut-adaptor-symtab.c src/ut-adaptor-tasks.c src/ut-adaptor-timebase.c diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-sockets.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-sockets.h new file mode 100644 index 000000000..755fe063e --- /dev/null +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-sockets.h @@ -0,0 +1,35 @@ +/* + * NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer" + * + * Copyright (c) 2019 United States Government as represented by + * the Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * \file + * \ingroup adaptors + * + * Declarations and prototypes for ut-adaptor-symtab + */ + +#ifndef UT_ADAPTOR_SOCKETS_H +#define UT_ADAPTOR_SOCKETS_H + +#include "common_types.h" + +void UT_SocketTest_CallVxWorksSetFlags_Impl(uint32 index); + +#endif /* UT_ADAPTOR_SOCKETS_H */ diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-sockets.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-sockets.c new file mode 100644 index 000000000..d13d0f39e --- /dev/null +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-sockets.c @@ -0,0 +1,44 @@ +/* + * NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer" + * + * Copyright (c) 2019 United States Government as represented by + * the Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * \file ut-adaptor-sockets.c + * \ingroup adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +/* pull in the OSAL configuration */ +#include "osconfig.h" +#include "ut-adaptor-sockets.h" + +#include "os-vxworks.h" +#include "os-shared-idmap.h" +#include "os-impl-sockets.h" + +/* + * A UT-specific wrapper function to invoke the VxWorks "SetFlag" helper + */ +void UT_SocketTest_CallVxWorksSetFlags_Impl(uint32 index) +{ + OS_object_token_t token = {.obj_idx = index}; + + OS_VxWorks_SetSocketFlags_Impl(&token); +} diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-sockets.c b/src/unit-test-coverage/vxworks/src/coveragetest-sockets.c new file mode 100644 index 000000000..f83b11db3 --- /dev/null +++ b/src/unit-test-coverage/vxworks/src/coveragetest-sockets.c @@ -0,0 +1,68 @@ +/* + * NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer" + * + * Copyright (c) 2019 United States Government as represented by + * the Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * \file coveragetest-no-module.c + * \ingroup vxworks + * \author joseph.p.hickey@nasa.gov + * + */ +#include "os-vxworks-coveragetest.h" +#include "ut-adaptor-sockets.h" + +#include "OCS_ioLib.h" + +void Test_OS_VxWorks_SetSocketFlags_Impl(void) +{ + UtAssert_VOIDCALL(UT_SocketTest_CallVxWorksSetFlags_Impl(0)); + + UT_SetDefaultReturnValue(UT_KEY(OCS_ioctl), OCS_ERROR); + UtAssert_VOIDCALL(UT_SocketTest_CallVxWorksSetFlags_Impl(0)); +} + +/* ------------------- End of test cases --------------------------------------*/ + +/* Osapi_Test_Setup + * + * Purpose: + * Called by the unit test tool to set up the app prior to each test + */ +void Osapi_Test_Setup(void) +{ + UT_ResetState(0); +} + +/* + * Osapi_Test_Teardown + * + * Purpose: + * Called by the unit test tool to tear down the app after each test + */ +void Osapi_Test_Teardown(void) {} + +/* UtTest_Setup + * + * Purpose: + * Registers the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(OS_VxWorks_SetSocketFlags_Impl); +} diff --git a/src/unit-test-coverage/vxworks/ut-stubs/CMakeLists.txt b/src/unit-test-coverage/vxworks/ut-stubs/CMakeLists.txt index f19cd1b93..c24c1d8e5 100644 --- a/src/unit-test-coverage/vxworks/ut-stubs/CMakeLists.txt +++ b/src/unit-test-coverage/vxworks/ut-stubs/CMakeLists.txt @@ -8,6 +8,7 @@ add_library(ut_vxworks_impl_stubs src/vxworks-os-impl-module-stubs.c src/vxworks-os-impl-mutex-stubs.c src/vxworks-os-impl-queue-stubs.c + src/vxworks-os-impl-sockets-stubs.c src/vxworks-os-impl-task-stubs.c src/vxworks-os-impl-timer-stubs.c ) diff --git a/src/unit-test-coverage/vxworks/ut-stubs/src/vxworks-os-impl-sockets-stubs.c b/src/unit-test-coverage/vxworks/ut-stubs/src/vxworks-os-impl-sockets-stubs.c new file mode 100644 index 000000000..0c68f6524 --- /dev/null +++ b/src/unit-test-coverage/vxworks/ut-stubs/src/vxworks-os-impl-sockets-stubs.c @@ -0,0 +1,33 @@ +/* + * NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer" + * + * Copyright (c) 2019 United States Government as represented by + * the Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * \file vxworks-os-impl-socket-stubs.c + * \ingroup ut-stubs + * \author joseph.p.hickey@nasa.gov + * + */ +#include +#include +#include "utstubs.h" + +#include "os-shared-idmap.h" + +void OS_VxWorks_SetSocketFlags_Impl(const OS_object_token_t *token) {}