[libcxx] r349305 - [test] [support] Use socket()+bind() to create unix sockets portably
Michal Gorny
mgorny at gentoo.org
Sun Dec 16 07:12:06 PST 2018
Author: mgorny
Date: Sun Dec 16 07:12:06 2018
New Revision: 349305
URL: http://llvm.org/viewvc/llvm-project?rev=349305&view=rev
Log:
[test] [support] Use socket()+bind() to create unix sockets portably
Replace the mknod() call with socket() + bind() for creating unix
sockets. The mknod() method is not portable and does not work
on NetBSD while binding the socket should work on all systems supporting
unix sockets.
Differential Revision: https://reviews.llvm.org/D55576
Modified:
libcxx/trunk/test/support/filesystem_dynamic_test_helper.py
Modified: libcxx/trunk/test/support/filesystem_dynamic_test_helper.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/filesystem_dynamic_test_helper.py?rev=349305&r1=349304&r2=349305&view=diff
==============================================================================
--- libcxx/trunk/test/support/filesystem_dynamic_test_helper.py (original)
+++ libcxx/trunk/test/support/filesystem_dynamic_test_helper.py Sun Dec 16 07:12:06 2018
@@ -1,5 +1,6 @@
import sys
import os
+import socket
import stat
# Ensure that this is being run on a specific platform
@@ -76,8 +77,13 @@ def create_fifo(source):
def create_socket(source):
- mode = 0o600 | stat.S_IFSOCK
- os.mknod(sanitize(source), mode)
+ sock = socket.socket(socket.AF_UNIX)
+ sanitized_source = sanitize(source)
+ # AF_UNIX sockets may have very limited path length, so split it
+ # into chdir call (with technically unlimited length) followed
+ # by bind() relative to the directory
+ os.chdir(os.path.dirname(sanitized_source))
+ sock.bind(os.path.basename(sanitized_source))
if __name__ == '__main__':
More information about the libcxx-commits
mailing list