selftest: Add a variable to indicate that selftest is running
[ambi/samba-autobuild/.git] / ctdb / wscript
index 59bd8e2e7d5f90e608520536947626f83e6a7bf5..fe0a8a23dbada92fd48b86377dae580608a25b2a 100644 (file)
@@ -58,6 +58,10 @@ manpages_etcd = [
     'ctdb-etcd.7',
 ]
 
+manpages_ceph = [
+    'ctdb_mutex_ceph_rados_helper.7',
+]
+
 
 def set_options(opt):
     opt.PRIVATE_EXTENSION_DEFAULT('ctdb')
@@ -103,8 +107,8 @@ def configure(conf):
     if conf.env.standalone_ctdb:
         conf.SAMBA_CHECK_PERL(mandatory=True)
 
-        conf.SAMBA_CHECK_PYTHON(mandatory=True, version=(2,5,0))
-        conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
+        conf.SAMBA_CHECK_PYTHON(mandatory=False, version=(2,5,0))
+        conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
 
     if conf.CHECK_FOR_THIRD_PARTY():
         conf.RECURSE('third_party/popt')
@@ -273,7 +277,9 @@ def configure(conf):
         conf.env.ctdb_prebuilt_manpages = []
         manpages = manpages_binary + manpages_misc
         if conf.env.etcd_reclock:
-            manpages = manpages + manpages_etcd
+            manpages += manpages_etcd
+        if conf.env.HAVE_LIBRADOS:
+            manpages += manpages_ceph
         for m in manpages:
             if os.path.exists(os.path.join("doc", m)):
                 Logs.info("  %s: yes" % (m))
@@ -375,7 +381,7 @@ def build(bld):
     bld.SAMBA_SUBSYSTEM('ctdb-common',
                         source=bld.SUBDIR('common',
                                           '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
-                                          '''),
+                                             sock_io.c'''),
                         includes='include',
                         deps='replace popt talloc tevent tdb popt ctdb-system')
 
@@ -384,7 +390,8 @@ def build(bld):
                                           '''db_hash.c srvid.c reqid.c
                                              pkt_read.c pkt_write.c comm.c
                                              logging.c rb_tree.c tunable.c
-                                             pidfile.c'''),
+                                             pidfile.c run_proc.c
+                                             hash_count.c'''),
                         deps='''samba-util sys_rw tevent-util
                                 replace talloc tevent tdb''')
 
@@ -396,7 +403,8 @@ def build(bld):
                                              protocol_control.c
                                              protocol_client.c
                                              protocol_debug.c
-                                             protocol_util.c'''),
+                                             protocol_util.c
+                                             protocol_event.c'''),
                         includes='include',
                         deps='replace talloc tdb')
 
@@ -413,10 +421,17 @@ def build(bld):
                                              client_message_sync.c
                                              client_control_sync.c
                                              client_db.c client_util.c
+                                             client_event.c
                                           '''),
                         includes='include',
                         deps='replace talloc tevent tdb tdb-wrap')
 
+    bld.SAMBA_SUBSYSTEM('ctdb-server-util',
+                        source=bld.SUBDIR('common',
+                                          '''sock_daemon.c'''),
+                        deps='''samba-util ctdb-util tevent-util
+                                replace talloc tevent''')
+
     bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
                         source=bld.SUBDIR('server',
                                           '''ipalloc_deterministic.c
@@ -428,8 +443,8 @@ def build(bld):
                         includes='include',
                         deps='ctdb-protocol replace talloc tevent')
 
-    bld.SAMBA_SUBSYSTEM('ctdb-server',
-                        source='server/ctdbd.c ' +
+    bld.SAMBA_BINARY('ctdbd',
+                     source='server/ctdbd.c ' +
                                bld.SUBDIR('server',
                                           '''ctdb_daemon.c ctdb_recoverd.c
                                              ctdb_recover.c ctdb_freeze.c
@@ -446,14 +461,10 @@ def build(bld):
                                              ctdb_statistics.c
                                              ctdb_update_record.c
                                              ctdb_lock.c ctdb_fork.c'''),
-                        includes='include',
-                        deps='''ctdb-ipalloc replace sys_rw
-                                popt talloc tevent tdb talloc_report''')
-
-    bld.SAMBA_BINARY('ctdbd',
-                     source='',
-                     deps='''ctdb-server ctdb-client ctdb-common
-                             ctdb-system ctdb-tcp ctdb-util''' +
+                     includes='include',
+                     deps='''ctdb-ipalloc ctdb-client ctdb-common ctdb-system
+                             ctdb-tcp ctdb-util replace sys_rw popt
+                             talloc tevent tdb talloc_report''' +
                           ib_deps,
                      install_path='${SBINDIR}',
                      manpages='ctdbd.1')
@@ -471,6 +482,12 @@ def build(bld):
                              samba-util replace''',
                      install_path='${CTDB_HELPER_BINDIR}')
 
+    bld.SAMBA_BINARY('ctdb_event',
+                     source='tools/ctdb_event.c',
+                     deps='''ctdb-client2 ctdb-protocol ctdb-util ctdb-system
+                             samba-util replace''',
+                     install_path='${CTDB_HELPER_BINDIR}')
+
     bld.SAMBA_BINARY('ltdbtool',
                      source='tools/ltdbtool.c',
                      includes='include',
@@ -478,16 +495,17 @@ def build(bld):
                      install_path='${BINDIR}',
                      manpages='ltdbtool.1')
 
-    bld.SAMBA_BINARY('ctdb_lock_helper',
-                     source='server/ctdb_lock_helper.c',
-                     deps='samba-util sys_rw ctdb-system talloc tdb',
-                     includes='include',
+    bld.SAMBA_BINARY('ctdb_eventd',
+                     source='server/ctdb_eventd.c',
+                     deps='''ctdb-server-util ctdb-protocol ctdb-util
+                             samba-util LIBASYNC_REQ replace popt''',
                      install_path='${CTDB_HELPER_BINDIR}')
 
-    bld.SAMBA_BINARY('ctdb_event_helper',
-                     source='server/ctdb_event_helper.c',
+    bld.SAMBA_BINARY('ctdb_lock_helper',
+                     source='server/ctdb_lock_helper.c',
+                     deps='''samba-util sys_rw ctdb-system tevent-util
+                             talloc tevent tdb''',
                      includes='include',
-                     deps='samba-util sys_rw ctdb-system replace tdb',
                      install_path='${CTDB_HELPER_BINDIR}')
 
     bld.SAMBA_BINARY('ctdb_recovery_helper',
@@ -496,6 +514,12 @@ def build(bld):
                              samba-util sys_rw replace tdb''',
                      install_path='${CTDB_HELPER_BINDIR}')
 
+    bld.SAMBA_BINARY('ctdb_takeover_helper',
+                     source='server/ctdb_takeover_helper.c',
+                     deps='''ctdb-client2 ctdb-protocol ctdb-util
+                             samba-util sys_rw replace ctdb-ipalloc popt''',
+                     install_path='${CTDB_HELPER_BINDIR}')
+
     bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
                      source='server/ctdb_mutex_fcntl_helper.c',
                      deps='sys_rw ctdb-system',
@@ -572,7 +596,9 @@ def build(bld):
 
     manpages_extra = manpages_misc
     if bld.env.etcd_reclock:
-        manpages_extra = manpages_extra + manpages_etcd
+        manpages_extra += manpages_etcd
+    if bld.env.HAVE_LIBRADOS:
+        manpages_extra += manpages_ceph
     for f in manpages_binary + manpages_extra:
         x = '%s.xml' % (f)
         bld.SAMBA_GENERATOR(x,
@@ -710,6 +736,10 @@ def build(bld):
         'protocol_types_test',
         'protocol_client_test',
         'pidfile_test',
+        'run_proc_test',
+        'sock_daemon_test',
+        'sock_io_test',
+        'hash_count_test'
     ]
 
     for target in ctdb_unit_tests:
@@ -718,7 +748,7 @@ def build(bld):
         bld.SAMBA_BINARY(target,
                          source=src,
                          deps='''talloc tevent tdb tevent-util
-                                 LIBASYNC_REQ samba-util''',
+                                 LIBASYNC_REQ samba-util sys_rw''',
                          install_path='${CTDB_TEST_LIBEXECDIR}')
 
     bld.SAMBA_BINARY('reqid_test',
@@ -748,6 +778,12 @@ def build(bld):
                         includes='include',
                         deps='replace popt talloc tevent tdb')
 
+    bld.SAMBA_BINARY('protocol_util_test',
+                     source='tests/src/protocol_util_test.c',
+                     deps='talloc ctdb-protocol samba-util',
+                     install_path='${CTDB_TEST_LIBEXECDIR}')
+
+    # Test binaries
     ctdb_tests = [
         'g_lock_loop',
         'message_ring',
@@ -773,7 +809,8 @@ def build(bld):
                          install_path='${CTDB_TEST_LIBEXECDIR}')
 
     bld.SAMBA_BINARY('ctdb_takeover_tests',
-                     source='tests/src/ctdb_takeover_tests.c',
+                     source='''tests/src/ctdb_takeover_tests.c
+                               tests/src/ipalloc_read_known_ips.c''',
                      deps='''replace popt tdb tevent talloc ctdb-system
                              samba-util tdb-wrap talloc_report
                              ctdb-ipalloc ctdb-protocol ctdb-util''',
@@ -781,7 +818,8 @@ def build(bld):
                      install_path='${CTDB_TEST_LIBEXECDIR}')
 
     bld.SAMBA_BINARY('fake_ctdbd',
-                     source='tests/src/fake_ctdbd.c',
+                     source='''tests/src/fake_ctdbd.c
+                               tests/src/ipalloc_read_known_ips.c''',
                      deps='''ctdb-util ctdb-protocol ctdb-system
                              samba-util tevent-util LIBASYNC_REQ popt''',
                      install_path='${CTDB_TEST_LIBEXECDIR}')
@@ -794,20 +832,33 @@ def build(bld):
                               ib_deps,
                          install_path='${CTDB_TEST_LIBEXECDIR}')
 
+    if bld.env.HAVE_ROBUST_MUTEXES and sys.platform.startswith('linux'):
+        bld.SAMBA_BINARY('test_mutex_raw',
+                         source='tests/src/test_mutex_raw.c',
+                         deps='pthread',
+                         install_path='${CTDB_TEST_LIBEXECDIR}')
+
     test_subdirs = [
         'complex',
         'cunit',
+        'eventd',
         'events.d',
         'eventscripts',
         'onnode',
         'shellcheck',
         'simple',
         'takeover',
+        'takeover_helper',
         'tool'
     ]
 
+    if bld.env.standalone_ctdb:
+        testdir = 'tests'
+    else:
+        testdir = 'ctdb/tests'
+
     for t in test_subdirs:
-        files = SUBDIR_MODE('tests/%s' % t, trim_path='tests')
+        files = SUBDIR_MODE('%s/%s' % (testdir, t), trim_path=testdir)
         for fmode in files:
             bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
                               destname=fmode[0], chmod=fmode[1])
@@ -908,7 +959,27 @@ def show_version(ctx):
     print VERSION
 
 
-def dist():
+def manpages(ctx):
+    BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current'
+    MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL
+    HTML_XSL = '%s/html/docbook.xsl' % BASE_URL
+    CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s'
+    manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
+    for t in manpages:
+        cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t)
+        ret = samba_utils.RUN_COMMAND(cmd)
+        if ret != 0:
+            print('Command %s failed with exit status %d' % (cmd, ret))
+            sys.exit(ret)
+
+        cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t)
+        ret = samba_utils.RUN_COMMAND(cmd)
+        if ret != 0:
+            print('Command %s failed with exit status %d' % (cmd, ret))
+            sys.exit(ret)
+
+
+def distonly(ctx):
     samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
 
     t = 'include/ctdb_version.h'
@@ -930,24 +1001,8 @@ def dist():
         sys.exit(ret)
     samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
 
-    BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current'
-    MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL
-    HTML_XSL = '%s/html/docbook.xsl' % BASE_URL
-    CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s'
-    manpages = manpages_binary + manpages_misc + manpages_etcd
+    manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
     for t in manpages:
-        cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t)
-        ret = samba_utils.RUN_COMMAND(cmd)
-        if ret != 0:
-            print('Command %s failed with exit status %d' % (cmd, ret))
-            sys.exit(ret)
-
-        cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t)
-        ret = samba_utils.RUN_COMMAND(cmd)
-        if ret != 0:
-            print('Command %s failed with exit status %d' % (cmd, ret))
-            sys.exit(ret)
-
         samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
         samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
                               extend=True)
@@ -955,6 +1010,12 @@ def dist():
     samba_dist.dist()
 
 
+def dist():
+    import Scripting
+    Scripting.commands.append('manpages')
+    Scripting.commands.append('distonly')
+
+
 def rpmonly(ctx):
     opts = os.getenv('RPM_OPTIONS') or ''
     cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % (opts, VERSION)
@@ -966,7 +1027,8 @@ def rpmonly(ctx):
 
 def rpm(ctx):
     import Scripting
-    Scripting.commands.append('dist')
+    Scripting.commands.append('manpages')
+    Scripting.commands.append('distonly')
     Scripting.commands.append('rpmonly')