@@ -7362,8 +7362,6 @@ def testSendAndRecvFds(self):
73627362        for  index , ((_ , wfd ), rfd ) in  enumerate (zip (pipes , fds2 )):
73637363            self ._test_pipe (rfd , wfd , str (index ).encode ())
73647364
7365-     @unittest .skipUnless (sys .platform  in  ("linux" , "android" , "darwin" ), 
7366-                          "works on Linux and macOS" ) 
73677365    def  test_send_recv_fds_with_addrs (self ):
73687366        sock1  =  socket .socket (socket .AF_UNIX , socket .SOCK_DGRAM )
73697367        sock2  =  socket .socket (socket .AF_UNIX , socket .SOCK_DGRAM )
@@ -7379,10 +7377,18 @@ def test_send_recv_fds_with_addrs(self):
73797377            sock2 .setblocking (False )
73807378
73817379            socket .send_fds (sock1 , [MSG ], [rfd ], address = sock2_addr )
7382-             msg , fds , flags , addr  =  socket .recv_fds (sock2 , len (MSG ), 1 )
7380+             if  sys .platform .startswith ("freebsd" ):
7381+                 # FreeBSD requires at least CMSG_LEN(2 * sizeof(int)), otherwise 
7382+                 # the cmsg will be truncated 
7383+                 recv_fds_len  =  2 
7384+             else :
7385+                 recv_fds_len  =  1 
7386+             msg , fds , flags , addr  =  socket .recv_fds (sock2 , len (MSG ), recv_fds_len )
73837387            self ._cleanup_fds (fds )
73847388
73857389        self .assertEqual (msg , MSG )
7390+         if  hasattr (socket , "MSG_CTRUNC" ):
7391+             self .assertEqual (flags  &  socket .MSG_CTRUNC , 0 )
73867392        self .assertEqual (len (fds ), 1 )
73877393        self .assertEqual (addr , sock1_addr )
73887394
@@ -7409,6 +7415,8 @@ def test_recv_fds_peek(self):
74097415            self .assertEqual (len (msg ), peek_len )
74107416            self .assertEqual (msg , MSG [:peek_len ])
74117417            self .assertEqual (flags  &  socket .MSG_TRUNC , socket .MSG_TRUNC )
7418+             if  hasattr (socket , "MSG_CTRUNC" ):
7419+                 self .assertEqual (flags  &  socket .MSG_CTRUNC , 0 )
74127420            self .assertEqual (len (fds ), 1 )
74137421            self ._test_pipe (fds [0 ], wfd , MSG )
74147422
@@ -7417,6 +7425,8 @@ def test_recv_fds_peek(self):
74177425            self ._cleanup_fds (fds )
74187426
74197427            self .assertEqual (msg , MSG )
7428+             if  hasattr (socket , "MSG_CTRUNC" ):
7429+                 self .assertEqual (flags  &  socket .MSG_CTRUNC , 0 )
74207430            self .assertEqual (len (fds ), 1 )
74217431            self ._test_pipe (fds [0 ], wfd , MSG )
74227432
0 commit comments