MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / TC_sal_socket_connect

Function TC_sal_socket_connect

components/net/utest/tc_sal_socket.c:569–607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567}
568
569static void TC_sal_socket_connect(void)
570{
571 int ret;
572 int test_port = get_available_port(TEST_SERVER_BASE_PORT);
573
574 LOG_I("Starting TC_sal_socket_connect tests...");
575
576 /* Setup test server using threaded approach */
577 LOG_I("Setting up test server on port %d...", test_port);
578 ret = setup_test_server_threaded(RT_NULL, RT_NULL, test_port);
579
580 if (ret != 0)
581 {
582 LOG_W("Test server setup failed, may be expected in some environments");
583 }
584 else
585 {
586 LOG_I("Test server setup completed successfully");
587 }
588
589 /* Test connect to invalid address */
590 LOG_I("Testing connect to invalid address %s...", TEST_INVALID_IP);
591 int client_sock = create_test_socket(AF_INET, SOCK_STREAM, 0);
592 if (client_sock >= 0)
593 {
594 struct sockaddr_in connect_addr;
595 memset(&connect_addr, 0, sizeof(connect_addr));
596 connect_addr.sin_family = AF_INET;
597 connect_addr.sin_addr.s_addr = inet_addr(TEST_INVALID_IP);
598 connect_addr.sin_port = htons(test_port);
599
600 ret = sal_connect(client_sock, (struct sockaddr *)&connect_addr, sizeof(connect_addr));
601 LOG_I("Invalid address connect result: %d (expected -1)", ret);
602 uassert_int_equal(ret, -1);
603 close_test_socket(client_sock);
604 }
605
606 LOG_I("TC_sal_socket_connect tests completed");
607}
608
609static void TC_sal_socket_accept(void)
610{

Callers

nothing calls this directly

Calls 5

get_available_portFunction · 0.85
create_test_socketFunction · 0.85
sal_connectFunction · 0.85
close_test_socketFunction · 0.85

Tested by

no test coverage detected