summaryrefslogtreecommitdiffstats
path: root/tests/unit/test-sockpair.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:18:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:18:05 +0000
commitb46aad6df449445a9fc4aa7b32bd40005438e3f7 (patch)
tree751aa858ca01f35de800164516b298887382919d /tests/unit/test-sockpair.py
parentInitial commit. (diff)
downloadhaproxy-4ab0e6324476345d1b93a1acd3eb15c0b8cfaf40.tar.xz
haproxy-4ab0e6324476345d1b93a1acd3eb15c0b8cfaf40.zip
Adding upstream version 2.9.5.upstream/2.9.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/unit/test-sockpair.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/unit/test-sockpair.py b/tests/unit/test-sockpair.py
new file mode 100644
index 0000000..922c6d0
--- /dev/null
+++ b/tests/unit/test-sockpair.py
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+"""
+Python wrapper example to test socketpair protocol
+./test-socketpair.py test.cfg
+
+use sockpair@${FD1} and sockpair@${FD2} in your configuration file
+
+"""
+
+import socket, os, sys
+
+s = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM)
+os.set_inheritable(s[0].fileno(), 1)
+os.set_inheritable(s[1].fileno(), 1)
+
+FD1 = s[0].fileno()
+FD2 = s[1].fileno()
+
+print("FD1={} FD2={}".format(FD1, FD2))
+
+os.environ["FD1"] = str(FD1)
+os.environ["FD2"] = str(FD2)
+
+cmd = ["./haproxy",
+ "-f",
+ "{}".format(sys.argv[1])
+]
+os.execve(cmd[0], cmd, os.environ)