From da76459dc21b5af2449af2d36eb95226cb186ce2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:35:11 +0200 Subject: Adding upstream version 2.6.12. Signed-off-by: Daniel Baumann --- tests/unit/test-sockpair.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/unit/test-sockpair.py (limited to 'tests/unit/test-sockpair.py') 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) -- cgit v1.2.3