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

Function test_socket_options

components/net/utest/tc_lwip.c:858–893  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

856}
857
858static void test_socket_options(void)
859{
860 int sock = -1;
861 int opt_val;
862 socklen_t opt_len = sizeof(int);
863
864 sock = lwip_socket(AF_INET, SOCK_STREAM, 0);
865 if (sock < 0)
866 {
867 uassert_true(RT_FALSE);
868 return;
869 }
870
871 /* Test setsockopt */
872 opt_val = 1;
873 if (lwip_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &opt_val, sizeof(int)) != 0)
874 {
875 rt_kprintf("setsockopt SO_REUSEADDR failed\n");
876 uassert_true(RT_FALSE);
877 goto __exit;
878 }
879
880 /* Test getsockopt */
881 if (lwip_getsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &opt_val, &opt_len) != 0)
882 {
883 rt_kprintf("getsockopt SO_REUSEADDR failed\n");
884 uassert_true(RT_FALSE);
885 goto __exit;
886 }
887 /* Note: lwIP may return a different value due to internal implementation, skip exact value check */
888 rt_kprintf("Socket options test passed\n");
889
890__exit:
891 if (sock >= 0)
892 lwip_close(sock);
893}
894
895static void test_address_conversion(void)
896{

Callers

nothing calls this directly

Calls 5

rt_kprintfFunction · 0.85
lwip_socketFunction · 0.50
lwip_setsockoptFunction · 0.50
lwip_getsockoptFunction · 0.50
lwip_closeFunction · 0.50

Tested by

no test coverage detected