summaryrefslogtreecommitdiff
path: root/libcxx/test
diff options
context:
space:
mode:
authorMichal Gorny <mgorny@gentoo.org>2018-12-16 15:12:06 +0000
committerMichal Gorny <mgorny@gentoo.org>2018-12-16 15:12:06 +0000
commitae0f1fca64d5d578726e053d0943faf61f866fe8 (patch)
treea870eb996cf124392e26e2e5be7bb0af50460275 /libcxx/test
parent7eb68c699a8cdefb60d93a856a6d40bbda0e33dc (diff)
[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
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/support/filesystem_dynamic_test_helper.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/libcxx/test/support/filesystem_dynamic_test_helper.py b/libcxx/test/support/filesystem_dynamic_test_helper.py
index 5bb5b258c85..07895827497 100644
--- a/libcxx/test/support/filesystem_dynamic_test_helper.py
+++ b/libcxx/test/support/filesystem_dynamic_test_helper.py
@@ -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__':