From c2736b3168840111cc969b8585c2e4aa501677c4 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Fri, 9 Apr 2021 19:06:09 +0000 Subject: [PATCH] Fix #954, Additional coverage for OS_SocketAccept_Impl --- .../portable/src/coveragetest-bsd-sockets.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 95f570dd8..be2912a34 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-bsd-sockets.c +++ b/src/unit-test-coverage/portable/src/coveragetest-bsd-sockets.c @@ -242,6 +242,24 @@ 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); + UtAssert_True(!UT_PortablePosixIOTest_Get_Selectable(conn_token.obj_idx), + "Socket not selectable without O_NONBLOCK flag"); + + /* 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); + UtAssert_True(!UT_PortablePosixIOTest_Get_Selectable(conn_token.obj_idx), + "Socket not selectable without O_NONBLOCK flag"); } void Test_OS_SocketRecvFrom_Impl(void)