tsocket: Fix the build on FreeBSD
authorVolker Lendecke <vl@samba.org>
Fri, 9 Dec 2022 13:48:06 +0000 (14:48 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 12 Dec 2022 21:16:33 +0000 (21:16 +0000)
FreeBSD does not have TCP_USER_TIMEOUT

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/tsocket/wscript [new file with mode: 0644]
lib/tsocket/wscript_build [deleted file]
selftest/tests.py
wscript

diff --git a/lib/tsocket/wscript b/lib/tsocket/wscript
new file mode 100644 (file)
index 0000000..fa284a7
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+
+def configure(conf):
+    conf.CHECK_CODE('''
+                    #include <netinet/tcp.h>
+                    int main(void) { return TCP_USER_TIMEOUT; }
+                    ''',
+                    'HAVE_TCP_USER_TIMEOUT',
+                    addmain=False,
+                    msg='Checking for TCP_USER_TIMEOUT')
+
+def build(bld):
+    bld.SAMBA_SUBSYSTEM(
+        'LIBTSOCKET',
+       source='tsocket.c tsocket_helpers.c tsocket_bsd.c',
+       public_deps='talloc tevent iov_buf socket-blocking',
+       public_headers='tsocket.h tsocket_internal.h'
+    )
+
+    bld.SAMBA_BINARY(
+        'test_tsocket_bsd_addr',
+        source='tests/test_bsd_addr.c',
+        deps='cmocka replace LIBTSOCKET',
+        local_include=False,
+        for_selftest=True
+    )
+
+    bld.SAMBA_BINARY(
+        'test_tstream',
+        source='tests/test_tstream.c tests/socketpair_tcp.c',
+        deps='cmocka replace LIBTSOCKET',
+        local_include=False,
+        enabled=bld.CONFIG_SET('HAVE_TCP_USER_TIMEOUT'),
+        for_selftest=True
+    )
+
diff --git a/lib/tsocket/wscript_build b/lib/tsocket/wscript_build
deleted file mode 100644 (file)
index 73adcb9..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env python
-
-
-bld.SAMBA_SUBSYSTEM('LIBTSOCKET',
-       source='tsocket.c tsocket_helpers.c tsocket_bsd.c',
-       public_deps='talloc tevent iov_buf socket-blocking',
-       public_headers='tsocket.h tsocket_internal.h',
-       )
-
-bld.SAMBA_BINARY('test_tsocket_bsd_addr',
-                 source='tests/test_bsd_addr.c',
-                 deps='cmocka replace LIBTSOCKET',
-                 local_include=False,
-                 for_selftest=True)
-
-bld.SAMBA_BINARY('test_tstream',
-                 source='tests/test_tstream.c tests/socketpair_tcp.c',
-                 deps='cmocka replace LIBTSOCKET',
-                 local_include=False,
-                 for_selftest=True)
-
index 60efa5679f878b0469965af3a84d10671633aa1a..2cafe2faa4e90fbb429c586662c2b4daaf941e5f 100644 (file)
@@ -469,9 +469,10 @@ plantestsuite("samba.unittests.credentials", "none",
               [os.path.join(bindir(), "default/auth/credentials/test_creds")])
 plantestsuite("samba.unittests.tsocket_bsd_addr", "none",
               [os.path.join(bindir(), "default/lib/tsocket/test_tsocket_bsd_addr")])
-plantestsuite("samba.unittests.tsocket_tstream", "none",
-              [os.path.join(bindir(), "default/lib/tsocket/test_tstream")],
-              environ={'SOCKET_WRAPPER_DIR': ''})
+if ("HAVE_TCP_USER_TIMEOUT" in config_hash):
+    plantestsuite("samba.unittests.tsocket_tstream", "none",
+                  [os.path.join(bindir(), "default/lib/tsocket/test_tstream")],
+                  environ={'SOCKET_WRAPPER_DIR': ''})
 plantestsuite("samba.unittests.adouble", "none",
               [os.path.join(bindir(), "test_adouble")])
 plantestsuite("samba.unittests.gnutls_aead_aes_256_cbc_hmac_sha512", "none",
diff --git a/wscript b/wscript
index b556aa0cbe2c0fc6a821ae59def346c94cf48944..08995fbe4ec190f9b3f986f066d003c2e1f98477 100644 (file)
--- a/wscript
+++ b/wscript
@@ -348,6 +348,7 @@ def configure(conf):
 
     conf.RECURSE('source3')
     conf.RECURSE('lib/texpect')
+    conf.RECURSE('lib/tsocket')
     conf.RECURSE('python')
     if conf.env.with_ctdb:
         conf.RECURSE('ctdb')