File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -359,6 +359,35 @@ def test_socket_af_vsock(self):
359359 def test_os_pidfd_open (self ):
360360 self .assertTrue (hasattr (os , "pidfd_open" ))
361361
362+ @unittest .skipUnless (
363+ "-linux-gnu" in os .environ ["TARGET_TRIPLE" ],
364+ "memfd_create weak linking is enabled for Linux GNU targets" ,
365+ )
366+ def test_os_memfd_create (self ):
367+ import ctypes
368+ import errno
369+
370+ libc = ctypes .CDLL (None )
371+ libc_has_memfd_create = hasattr (libc , "memfd_create" )
372+ self .assertEqual (hasattr (os , "memfd_create" ), libc_has_memfd_create )
373+
374+ if not libc_has_memfd_create :
375+ return
376+
377+ try :
378+ fd = os .memfd_create ("python-build-standalone-test" )
379+ except OSError as exc :
380+ if exc .errno == errno .ENOSYS :
381+ self .skipTest ("the runtime kernel does not support memfd_create" )
382+ raise
383+
384+ try :
385+ os .write (fd , b"memfd_create" )
386+ os .lseek (fd , 0 , os .SEEK_SET )
387+ self .assertEqual (os .read (fd , 12 ), b"memfd_create" )
388+ finally :
389+ os .close (fd )
390+
362391 def test_linux_uapi_not_in_sysconfig (self ):
363392 import sysconfig
364393
You can’t perform that action at this time.
0 commit comments