diff --git a/libraries/abstractions/secure_sockets/test/iot_test_tcp.c b/libraries/abstractions/secure_sockets/test/iot_test_tcp.c index 3dfa54b80cc..c267eef1718 100644 --- a/libraries/abstractions/secure_sockets/test/iot_test_tcp.c +++ b/libraries/abstractions/secure_sockets/test/iot_test_tcp.c @@ -782,7 +782,7 @@ TEST_GROUP_RUNNER( Full_TCP ) RUN_TEST_CASE( Full_TCP, AFQP_SOCKETS_Close ); RUN_TEST_CASE( Full_TCP, AFQP_SOCKETS_Recv_ByteByByte ); RUN_TEST_CASE( Full_TCP, AFQP_SOCKETS_SendRecv_VaryLength ); - RUN_TEST_CASE( Full_TCP, AFQP_SOCKETS_Socket_InvalidTooManySockets ); + RUN_TEST_CASE( Full_TCP, AFQP_SOCKETS_Socket_ConcurrentCount ); RUN_TEST_CASE( Full_TCP, AFQP_SOCKETS_Socket_InvalidInputParams ); RUN_TEST_CASE( Full_TCP, AFQP_SOCKETS_Send_Invalid ); RUN_TEST_CASE( Full_TCP, AFQP_SOCKETS_Recv_Invalid ); @@ -1744,64 +1744,80 @@ TEST( Full_TCP, AFQP_SOCKETS_Socket_InvalidInputParams ) /*-----------------------------------------------------------*/ -static void prvSOCKETS_Socket_InvalidTooManySockets( Server_t xConn ) +/* + * Verify the number of sockets that can be concurrently + * created up to a configured maximum. Return pdFAIL if + * fewer than that number are created. If more than the + * maximum can be created, a warning is printed, but this + * is not a failure condition. Some ports are limited only + * by free memory. For these ports, check that a reasonable + * number of sockets can be created concurrently. + */ +#ifdef integrationtestportableMAX_NUM_UNSECURE_SOCKETS + #define MAX_NUM_SOCKETS integrationtestportableMAX_NUM_UNSECURE_SOCKETS +#else + #define MAX_NUM_SOCKETS 5u +#endif +static void prvSOCKETS_Socket_ConcurrentCount( Server_t xConn ) { - #if !defined( WIN32 ) && !defined( PIC32MZ ) && !defined( ESP32 ) && !defined( ZYNQ7000 ) && !defined( __RX ) && !defined( MW320 ) /* Socket can be created as much as there is memory */ - BaseType_t xResult; - Socket_t xCreatedSockets[ integrationtestportableMAX_NUM_UNSECURE_SOCKETS ]; - BaseType_t xSocketsCreated; - Socket_t xSocket; + BaseType_t xResult = pdFAIL; + Socket_t xCreatedSockets[ MAX_NUM_SOCKETS ]; + BaseType_t xSocketsCreated; + Socket_t xSocket; - tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) ); + tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) ); - xResult = pdPASS; + xResult = pdPASS; - for( xSocketsCreated = 0; xSocketsCreated < integrationtestportableMAX_NUM_UNSECURE_SOCKETS; xSocketsCreated++ ) - { - xSocket = SOCKETS_Socket( SOCKETS_AF_INET, SOCKETS_SOCK_STREAM, SOCKETS_IPPROTO_TCP ); + for( xSocketsCreated = 0; xSocketsCreated < MAX_NUM_SOCKETS; xSocketsCreated++ ) + { + xSocket = SOCKETS_Socket( SOCKETS_AF_INET, SOCKETS_SOCK_STREAM, SOCKETS_IPPROTO_TCP ); - if( xSocket == SOCKETS_INVALID_SOCKET ) - { - xResult = pdFAIL; - tcptestPRINTF( ( "%s failed creating a socket number %d \r\n", __FUNCTION__, xSocketsCreated ) ); - break; - } - else - { - xCreatedSockets[ xSocketsCreated ] = xSocket; - } + if( xSocket == SOCKETS_INVALID_SOCKET ) + { + xResult = pdFAIL; + tcptestPRINTF( ( "%s failed creating a socket number %d \r\n", __FUNCTION__, xSocketsCreated ) ); + break; } + else + { + xCreatedSockets[ xSocketsCreated ] = xSocket; + } + } + #ifdef integrationtestportableMAX_NUM_UNSECURE_SOCKETS if( xResult == pdPASS ) { xSocket = SOCKETS_Socket( SOCKETS_AF_INET, SOCKETS_SOCK_STREAM, SOCKETS_IPPROTO_TCP ); if( xSocket != SOCKETS_INVALID_SOCKET ) { - xResult = pdFAIL; SOCKETS_Close( xSocket ); + tcptestPRINTF( ( "%s exceeded maximum number of sockets (%d > %d); is the value of " \ + "integrationtestportableMAX_NUM_UNSECURE_SOCKETS correct?\r\n", __FUNCTION__, + ( MAX_NUM_SOCKETS + 1 ), MAX_NUM_SOCKETS ) ); } } + #endif /* ifdef integrationtestportableMAX_NUM_UNSECURE_SOCKETS */ - /* Cleanup. */ - while( xSocketsCreated > 0 ) - { - --xSocketsCreated; - SOCKETS_Close( xCreatedSockets[ xSocketsCreated ] ); - } + /* Cleanup. */ + while( xSocketsCreated > 0 ) + { + --xSocketsCreated; + SOCKETS_Close( xCreatedSockets[ xSocketsCreated ] ); + } - TEST_ASSERT_EQUAL_UINT32_MESSAGE( pdPASS, xResult, "Max num sockets test failed" ); + TEST_ASSERT_EQUAL_UINT32_MESSAGE( pdPASS, xResult, "Concurrent num sockets test failed" ); - /* Report Test Results. */ - tcptestPRINTF( ( "%s passed\r\n", __FUNCTION__ ) ); - #endif /*ifndef WIN32 */ + /* Report Test Results. */ + tcptestPRINTF( ( "%s passed\r\n", __FUNCTION__ ) ); } -TEST( Full_TCP, AFQP_SOCKETS_Socket_InvalidTooManySockets ) +TEST( Full_TCP, AFQP_SOCKETS_Socket_ConcurrentCount ) { tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) ); - prvSOCKETS_Socket_InvalidTooManySockets( eNonsecure ); + prvSOCKETS_Socket_ConcurrentCount( eNonsecure ); } TEST( Full_TCP, AFQP_SECURE_SOCKETS_Socket_InvalidTooManySockets ) diff --git a/vendors/espressif/boards/esp32/aws_tests/config_files/aws_test_tcp_config.h b/vendors/espressif/boards/esp32/aws_tests/config_files/aws_test_tcp_config.h index 41acb521e4e..30fec0439c1 100644 --- a/vendors/espressif/boards/esp32/aws_tests/config_files/aws_test_tcp_config.h +++ b/vendors/espressif/boards/esp32/aws_tests/config_files/aws_test_tcp_config.h @@ -30,12 +30,6 @@ * @file aws_integration_test_tcp_portable.h * @brief Port-specific variables for TCP tests. */ -/** - * @brief The number of sockets that can be open at one time on a port. - * - */ -#define integrationtestportableMAX_NUM_UNSECURE_SOCKETS 1 - /** * @brief Indicates how much longer than the specified timeout is acceptable for * RCVTIMEO tests. diff --git a/vendors/marvell/boards/mw300_rd/aws_tests/config_files/aws_test_tcp_config.h b/vendors/marvell/boards/mw300_rd/aws_tests/config_files/aws_test_tcp_config.h index 07b445ffc79..7bbd21623be 100644 --- a/vendors/marvell/boards/mw300_rd/aws_tests/config_files/aws_test_tcp_config.h +++ b/vendors/marvell/boards/mw300_rd/aws_tests/config_files/aws_test_tcp_config.h @@ -29,12 +29,6 @@ /** * @file aws_integration_test_tcp_portable.h * @brief Port-specific variables for TCP tests. */ -#define MW320 -/** - * @brief The number of sockets that can be open at one time on a port. - * - */ -#define integrationtestportableMAX_NUM_UNSECURE_SOCKETS 20 /** * @brief Indicates how much longer than the specified timeout is acceptable for diff --git a/vendors/microchip/boards/curiosity_pic32mzef/aws_tests/config_files/aws_test_tcp_config.h b/vendors/microchip/boards/curiosity_pic32mzef/aws_tests/config_files/aws_test_tcp_config.h index 2fa1d3cf901..19705e0f556 100644 --- a/vendors/microchip/boards/curiosity_pic32mzef/aws_tests/config_files/aws_test_tcp_config.h +++ b/vendors/microchip/boards/curiosity_pic32mzef/aws_tests/config_files/aws_test_tcp_config.h @@ -31,13 +31,6 @@ * @brief Port-specific variables for TCP tests. */ -/** - * @brief The number of sockets that can be open at one time on a port. - * - * This test is not run in WinSim as there are too many sockets that can be opened at one time. - */ -#define integrationtestportableMAX_NUM_UNSECURE_SOCKETS 0 - /** * @brief Indicates how much longer than the specified timeout is acceptable for * RCVTIMEO tests. diff --git a/vendors/microchip/boards/ecc608a_plus_winsim/aws_tests/config_files/aws_test_tcp_config.h b/vendors/microchip/boards/ecc608a_plus_winsim/aws_tests/config_files/aws_test_tcp_config.h index b8f2de9b935..23e64060914 100644 --- a/vendors/microchip/boards/ecc608a_plus_winsim/aws_tests/config_files/aws_test_tcp_config.h +++ b/vendors/microchip/boards/ecc608a_plus_winsim/aws_tests/config_files/aws_test_tcp_config.h @@ -30,13 +30,6 @@ * @brief Port-specific variables for TCP tests. */ -/** - * @brief The number of sockets that can be open at one time on a port. - * - * This test is not run in WinSim as there are too many sockets that can be opened at one time. - */ -#define integrationtestportableMAX_NUM_UNSECURE_SOCKETS 0 - /** * @brief Indicates how much longer than the specified timeout is acceptable for * RCVTIMEO tests. diff --git a/vendors/pc/boards/windows/aws_tests/config_files/aws_test_tcp_config.h b/vendors/pc/boards/windows/aws_tests/config_files/aws_test_tcp_config.h index b8f2de9b935..23e64060914 100644 --- a/vendors/pc/boards/windows/aws_tests/config_files/aws_test_tcp_config.h +++ b/vendors/pc/boards/windows/aws_tests/config_files/aws_test_tcp_config.h @@ -30,13 +30,6 @@ * @brief Port-specific variables for TCP tests. */ -/** - * @brief The number of sockets that can be open at one time on a port. - * - * This test is not run in WinSim as there are too many sockets that can be opened at one time. - */ -#define integrationtestportableMAX_NUM_UNSECURE_SOCKETS 0 - /** * @brief Indicates how much longer than the specified timeout is acceptable for * RCVTIMEO tests. diff --git a/vendors/renesas/boards/rx65n-rsk/aws_tests/config_files/aws_test_tcp_config.h b/vendors/renesas/boards/rx65n-rsk/aws_tests/config_files/aws_test_tcp_config.h index 024d3134311..de1807bb981 100644 --- a/vendors/renesas/boards/rx65n-rsk/aws_tests/config_files/aws_test_tcp_config.h +++ b/vendors/renesas/boards/rx65n-rsk/aws_tests/config_files/aws_test_tcp_config.h @@ -30,12 +30,6 @@ * @file aws_integration_test_tcp_portable.h * @brief Port-specific variables for TCP tests. */ -/** - * @brief The number of sockets that can be open at one time on a port. - * - */ -#define integrationtestportableMAX_NUM_UNSECURE_SOCKETS 1 - /** * @brief Indicates how much longer than the specified timeout is acceptable for * RCVTIMEO tests. diff --git a/vendors/vendor/boards/board/aws_tests/config_files/aws_test_tcp_config.h b/vendors/vendor/boards/board/aws_tests/config_files/aws_test_tcp_config.h index 8c414c5967b..0d9c84993e5 100644 --- a/vendors/vendor/boards/board/aws_tests/config_files/aws_test_tcp_config.h +++ b/vendors/vendor/boards/board/aws_tests/config_files/aws_test_tcp_config.h @@ -31,10 +31,12 @@ * @brief Port-specific variables for TCP tests. */ /** - * @brief The number of sockets that can be open at one time on a port. - * + * @brief Port-specific maximum number of concurrent sockets + * Do not define this if the number is limited only by free memory. */ +#if 0 #define integrationtestportableMAX_NUM_UNSECURE_SOCKETS 1 /* FIX ME. */ +#endif /** * @brief Indicates how much longer than the specified timeout is acceptable for @@ -69,4 +71,4 @@ -#endif /*AWS_INTEGRATION_TEST_TCP_CONFIG_H */ \ No newline at end of file +#endif /*AWS_INTEGRATION_TEST_TCP_CONFIG_H */ diff --git a/vendors/xilinx/boards/microzed/aws_tests/config_files/aws_test_tcp_config.h b/vendors/xilinx/boards/microzed/aws_tests/config_files/aws_test_tcp_config.h index aee8823afb6..de1807bb981 100644 --- a/vendors/xilinx/boards/microzed/aws_tests/config_files/aws_test_tcp_config.h +++ b/vendors/xilinx/boards/microzed/aws_tests/config_files/aws_test_tcp_config.h @@ -30,12 +30,6 @@ * @file aws_integration_test_tcp_portable.h * @brief Port-specific variables for TCP tests. */ -/** - * @brief The number of sockets that can be open at one time on a port. - * - */ -#define integrationtestportableMAX_NUM_UNSECURE_SOCKETS 0 - /** * @brief Indicates how much longer than the specified timeout is acceptable for * RCVTIMEO tests.