lib/ldb/wscript: update to handle waf 2.0.4
[samba.git] / lib / ldb / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'ldb'
4 VERSION = '1.5.1'
5
6 import sys, os
7
8 # find the buildtools directory
9 top = '.'
10 while not os.path.exists(top+'/buildtools') and len(top.split('/')) < 5:
11     top = top + '/..'
12 sys.path.insert(0, top + '/buildtools/wafsamba')
13
14 out = 'bin'
15
16 import wafsamba
17 from wafsamba import samba_dist, samba_utils
18 from waflib import Errors, Options, Logs, Context
19 import shutil
20
21 samba_dist.DIST_DIRS('''lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
22                         lib/tdb:lib/tdb lib/tdb:lib/tdb lib/tevent:lib/tevent
23                         third_party/popt:third_party/popt
24                         third_party/cmocka:third_party/cmocka
25                         buildtools:buildtools third_party/waf:third_party/waf''')
26
27 samba_dist.DIST_FILES('''lib/util/binsearch.h:lib/util/binsearch.h''')
28
29 def options(opt):
30     opt.BUILTIN_DEFAULT('replace')
31     opt.PRIVATE_EXTENSION_DEFAULT('ldb', noextension='ldb')
32     opt.RECURSE('lib/tdb')
33     opt.RECURSE('lib/tevent')
34     opt.RECURSE('lib/replace')
35     opt.load('python') # options for disabling pyc or pyo compilation
36
37     opt.add_option('--without-ldb-lmdb',
38                    help='disable new LMDB backend for LDB',
39                    action='store_true', dest='without_ldb_lmdb', default=False)
40
41
42 def configure(conf):
43     conf.RECURSE('lib/tdb')
44     conf.RECURSE('lib/tevent')
45
46     if conf.CHECK_FOR_THIRD_PARTY():
47         conf.RECURSE('third_party/popt')
48         conf.RECURSE('third_party/cmocka')
49     else:
50         if not conf.CHECK_POPT():
51             raise Errors.WafError('popt development packages have not been found.\nIf third_party is installed, check that it is in the proper place.')
52         else:
53             conf.define('USING_SYSTEM_POPT', 1)
54
55         if not conf.CHECK_CMOCKA():
56             raise Errors.WafError('cmocka development package have not been found.\nIf third_party is installed, check that it is in the proper place.')
57         else:
58             conf.define('USING_SYSTEM_CMOCKA', 1)
59
60     conf.RECURSE('lib/replace')
61     conf.find_program('python', var='PYTHON')
62     conf.find_program('xsltproc', var='XSLTPROC')
63     conf.load('python')
64     conf.check_python_version((2,4,2))
65     conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=not conf.env.disable_python)
66
67     # where does the default LIBDIR end up? in conf.env somewhere?
68     #
69     conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
70
71     conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
72
73     if not conf.env.standalone_ldb:
74         max_ldb_version = [int(x) for x in VERSION.split(".")]
75         max_ldb_version[2] = 999
76         max_ldb_version_dots = "%d.%d.%d" % tuple(max_ldb_version)
77
78         if conf.env.disable_python:
79             if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb',
80                                              minversion=VERSION,
81                                              maxversion=max_ldb_version_dots,
82                                              onlyif='talloc tdb tevent',
83                                              implied_deps='replace talloc tdb tevent'):
84                 conf.define('USING_SYSTEM_LDB', 1)
85         else:
86             using_system_pyldb_util = True
87             if not conf.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util',
88                                                  minversion=VERSION,
89                                                  maxversion=max_ldb_version_dots,
90                                                  onlyif='talloc tdb tevent',
91                                                  implied_deps='replace talloc tdb tevent ldb'):
92                 using_system_pyldb_util = False
93
94             # We need to get a pyldb-util for all the python versions
95             # we are building for
96             if conf.env['EXTRA_PYTHON']:
97                 name = 'pyldb-util' + conf.all_envs['extrapython']['PYTHON_SO_ABI_FLAG']
98                 if not conf.CHECK_BUNDLED_SYSTEM_PKG(name,
99                                                      minversion=VERSION,
100                                                      maxversion=max_ldb_version_dots,
101                                                      onlyif='talloc tdb tevent',
102                                                      implied_deps='replace talloc tdb tevent ldb'):
103                     using_system_pyldb_util = False
104
105             if using_system_pyldb_util:
106                 conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
107
108             if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb',
109                                              minversion=VERSION,
110                                              maxversion=max_ldb_version_dots,
111                                              onlyif='talloc tdb tevent pyldb-util',
112                                              implied_deps='replace talloc tdb tevent'):
113                 conf.define('USING_SYSTEM_LDB', 1)
114
115     if not conf.CHECK_CODE('return !(sizeof(size_t) >= 8)',
116                            "HAVE_64_BIT_SIZE_T_FOR_LMDB",
117                            execute=True,
118                            msg='Checking for a 64-bit host to '
119                            'support lmdb'):
120         Logs.warn("--without-ldb-lmdb implied as this "
121                   "host is not 64-bit")
122
123         if not conf.env.standalone_ldb and \
124            not Options.options.without_ad_dc and \
125            conf.CONFIG_GET('ENABLE_SELFTEST'):
126             Logs.warn("NOTE: Some AD DC parts of selftest will fail")
127
128         conf.env.REQUIRE_LMDB = False
129     else:
130         if conf.env.standalone_ldb:
131             if Options.options.without_ldb_lmdb:
132                 conf.env.REQUIRE_LMDB = False
133             else:
134                 conf.env.REQUIRE_LMDB = True
135         elif Options.options.without_ad_dc:
136             conf.env.REQUIRE_LMDB = False
137         else:
138             if Options.options.without_ldb_lmdb:
139                 if not Options.options.without_ad_dc and \
140                    conf.CONFIG_GET('ENABLE_SELFTEST'):
141                     raise Errors.WafError('--without-ldb-lmdb conflicts '
142                                          'with --enable-selftest while '
143                                          'building the AD DC')
144
145                 conf.env.REQUIRE_LMDB = False
146             else:
147                 conf.env.REQUIRE_LMDB = True
148
149
150     if conf.CONFIG_SET('USING_SYSTEM_LDB'):
151         v = VERSION.split('.')
152         conf.DEFINE('EXPECTED_SYSTEM_LDB_VERSION_MAJOR', int(v[0]))
153         conf.DEFINE('EXPECTED_SYSTEM_LDB_VERSION_MINOR', int(v[1]))
154         conf.DEFINE('EXPECTED_SYSTEM_LDB_VERSION_RELEASE', int(v[2]))
155
156     if conf.env.standalone_ldb:
157         conf.CHECK_XSLTPROC_MANPAGES()
158
159         # we need this for the ldap backend
160         if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
161             conf.env.ENABLE_LDAP_BACKEND = True
162
163         # we don't want any libraries or modules to rely on runtime
164         # resolution of symbols
165         if not sys.platform.startswith("openbsd"):
166             conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
167
168     # if lmdb support is enabled then we require lmdb
169     # is present, build the mdb back end and enable lmdb support in
170     # the tools.
171     if conf.env.REQUIRE_LMDB and \
172        not conf.CONFIG_SET('USING_SYSTEM_LDB'):
173         if not conf.CHECK_CFG(package='lmdb',
174                               args='"lmdb >= 0.9.16" --cflags --libs',
175                               msg='Checking for lmdb >= 0.9.16',
176                               mandatory=False):
177             if not conf.CHECK_CODE('''
178                     #if MDB_VERSION_MAJOR == 0 \
179                       && MDB_VERSION_MINOR <= 9 \
180                       && MDB_VERSION_PATCH < 16
181                     #error LMDB too old
182                     #endif
183                     ''',
184                     'HAVE_GOOD_LMDB_VERSION',
185                     headers='lmdb.h',
186                     msg='Checking for lmdb >= 0.9.16 via header check'):
187
188                 if conf.env.standalone_ldb:
189                     raise Errors.WafError('ldb build (unless --without-ldb-lmdb) '
190                                          'requires '
191                                          'lmdb 0.9.16 or later')
192                 elif not Options.options.without_ad_dc:
193                     raise Errors.WafError('Samba AD DC and --enable-selftest '
194                                          'requires '
195                                          'lmdb 0.9.16 or later')
196
197         if conf.CHECK_FUNCS_IN('mdb_env_create', 'lmdb', headers='lmdb.h'):
198             conf.DEFINE('HAVE_LMDB', '1')
199
200
201     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
202
203     conf.SAMBA_CONFIG_H()
204
205     conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
206
207 def build(bld):
208     bld.RECURSE('lib/tevent')
209
210     if bld.CHECK_FOR_THIRD_PARTY():
211         bld.RECURSE('third_party/popt')
212         bld.RECURSE('third_party/cmocka')
213
214     bld.RECURSE('lib/replace')
215     bld.RECURSE('lib/tdb')
216
217     if bld.env.standalone_ldb:
218         if not 'PACKAGE_VERSION' in bld.env:
219             bld.env.PACKAGE_VERSION = VERSION
220         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
221         private_library = False
222     else:
223         private_library = True
224     # we're not currently linking against the ldap libs, but ldb.pc.in
225     # has @LDAP_LIBS@
226     bld.env.LDAP_LIBS = ''
227
228     LDB_MAP_SRC = bld.SUBDIR('ldb_map',
229                              'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
230
231     COMMON_SRC = bld.SUBDIR('common',
232                             '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
233                             ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
234                             ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
235
236     bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
237                      init_function='ldb_ldap_init',
238                      module_init_name='ldb_init_module',
239                      deps='talloc lber ldap ldb',
240                      enabled=bld.env.ENABLE_LDAP_BACKEND,
241                      internal_module=False,
242                      subsystem='ldb')
243
244     if bld.PYTHON_BUILD_IS_ENABLED():
245         if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
246             for env in bld.gen_python_environments(['PKGCONFIGDIR']):
247
248                 name = bld.pyembed_libname('pyldb-util')
249                 bld.SAMBA_LIBRARY(name,
250                                   deps='ldb',
251                                   source='pyldb_util.c',
252                                   public_headers=('' if private_library else 'pyldb.h'),
253                                   public_headers_install=not private_library,
254                                   vnum=VERSION,
255                                   private_library=private_library,
256                                   pc_files='pyldb-util.pc',
257                                   pyembed=True,
258                                   enabled=bld.PYTHON_BUILD_IS_ENABLED(),
259                                   abi_directory='ABI',
260                                   abi_match='pyldb_*')
261
262                 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
263                     bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
264                                      deps='ldb ' + name,
265                                      realname='ldb.so',
266                                      cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
267
268         # Do only install this file as part of the Samba build if we do not
269         # use the system libldb!
270         if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
271             for env in bld.gen_python_environments(['PKGCONFIGDIR']):
272                     bld.SAMBA_SCRIPT('_ldb_text.py',
273                                      pattern='_ldb_text.py',
274                                      installdir='python')
275
276                     bld.INSTALL_FILES('${PYTHONARCHDIR}', '_ldb_text.py')
277
278     if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
279         if bld.is_install:
280             modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
281         else:
282             # when we run from the source directory, we want to use
283             # the current modules, not the installed ones
284             modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
285
286         abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
287
288         ldb_headers = ('include/ldb.h include/ldb_errors.h '
289                        'include/ldb_module.h include/ldb_handlers.h')
290
291         bld.SAMBA_LIBRARY('ldb',
292                           COMMON_SRC + ' ' + LDB_MAP_SRC,
293                           deps='tevent LIBLDB_MAIN replace',
294                           includes='include',
295                           public_headers=('' if private_library else ldb_headers),
296                           public_headers_install=not private_library,
297                           pc_files='ldb.pc',
298                           vnum=VERSION,
299                           private_library=private_library,
300                           manpages='man/ldb.3',
301                           abi_directory='ABI',
302                           abi_match = abi_match)
303
304         # generate a include/ldb_version.h
305         def generate_ldb_version_h(t):
306             '''generate a vscript file for our public libraries'''
307
308             tgt = t.outputs[0].bldpath(t.env)
309
310             v = t.env.LDB_VERSION.split('.')
311
312             f = open(tgt, mode='w')
313             try:
314                 f.write('#define LDB_VERSION "%s"\n' % t.env.LDB_VERSION)
315                 f.write('#define LDB_VERSION_MAJOR %d\n' % int(v[0]))
316                 f.write('#define LDB_VERSION_MINOR %d\n' % int(v[1]))
317                 f.write('#define LDB_VERSION_RELEASE %d\n' % int(v[2]))
318             finally:
319                 f.close()
320             return
321         t = bld.SAMBA_GENERATOR('ldb_version.h',
322                                 rule=generate_ldb_version_h,
323                                 dep_vars=['LDB_VERSION'],
324                                 target='include/ldb_version.h',
325                                 public_headers='include/ldb_version.h',
326                                 public_headers_install=not private_library)
327         t.env.LDB_VERSION = VERSION
328
329
330         bld.SAMBA_MODULE('ldb_paged_results',
331                          'modules/paged_results.c',
332                          init_function='ldb_paged_results_init',
333                          module_init_name='ldb_init_module',
334                          internal_module=False,
335                          deps='ldb',
336                          subsystem='ldb')
337
338         bld.SAMBA_MODULE('ldb_asq',
339                          'modules/asq.c',
340                          init_function='ldb_asq_init',
341                          module_init_name='ldb_init_module',
342                          internal_module=False,
343                          deps='ldb',
344                          subsystem='ldb')
345
346         bld.SAMBA_MODULE('ldb_server_sort',
347                          'modules/sort.c',
348                          init_function='ldb_server_sort_init',
349                          internal_module=False,
350                          module_init_name='ldb_init_module',
351                          deps='ldb',
352                          subsystem='ldb')
353
354         bld.SAMBA_MODULE('ldb_paged_searches',
355                          'modules/paged_searches.c',
356                          init_function='ldb_paged_searches_init',
357                          internal_module=False,
358                          module_init_name='ldb_init_module',
359                          deps='ldb',
360                          subsystem='ldb')
361
362         bld.SAMBA_MODULE('ldb_rdn_name',
363                          'modules/rdn_name.c',
364                          init_function='ldb_rdn_name_init',
365                          internal_module=False,
366                          module_init_name='ldb_init_module',
367                          deps='ldb',
368                          subsystem='ldb')
369
370         bld.SAMBA_MODULE('ldb_sample',
371                          'tests/sample_module.c',
372                          init_function='ldb_sample_init',
373                          internal_module=False,
374                          module_init_name='ldb_init_module',
375                          deps='ldb',
376                          subsystem='ldb')
377
378         bld.SAMBA_MODULE('ldb_skel',
379                          'modules/skel.c',
380                          init_function='ldb_skel_init',
381                          internal_module=False,
382                          module_init_name='ldb_init_module',
383                          deps='ldb',
384                          subsystem='ldb')
385
386         bld.SAMBA_MODULE('ldb_sqlite3',
387                          'sqlite3/ldb_sqlite3.c',
388                          init_function='ldb_sqlite3_init',
389                          internal_module=False,
390                          module_init_name='ldb_init_module',
391                          enabled=False,
392                          deps='ldb',
393                          subsystem='ldb')
394
395         bld.SAMBA_MODULE('ldb_tdb',
396                          bld.SUBDIR('ldb_tdb',
397                                     '''ldb_tdb_init.c'''),
398                          init_function='ldb_tdb_init',
399                          module_init_name='ldb_init_module',
400                          internal_module=False,
401                          deps='ldb ldb_tdb_int ldb_key_value',
402                          subsystem='ldb')
403
404         bld.SAMBA_LIBRARY('ldb_tdb_int',
405                           bld.SUBDIR('ldb_tdb',
406                                      '''ldb_tdb_wrap.c ldb_tdb.c'''),
407                           private_library=True,
408                           deps='ldb tdb ldb_key_value ldb_tdb_err_map')
409
410         bld.SAMBA_LIBRARY('ldb_tdb_err_map',
411                           bld.SUBDIR('ldb_tdb',
412                                      '''ldb_tdb_err_map.c '''),
413                           private_library=True,
414                           deps='ldb tdb')
415
416         bld.SAMBA_LIBRARY('ldb_key_value',
417                           bld.SUBDIR('ldb_key_value',
418                                     '''ldb_kv.c ldb_kv_search.c ldb_kv_index.c
419                                     ldb_kv_cache.c'''),
420                           private_library=True,
421                           deps='tdb ldb ldb_tdb_err_map')
422
423         if bld.CONFIG_SET('HAVE_LMDB'):
424             bld.SAMBA_MODULE('ldb_mdb',
425                              bld.SUBDIR('ldb_mdb',
426                                         '''ldb_mdb_init.c'''),
427                              init_function='ldb_mdb_init',
428                              module_init_name='ldb_init_module',
429                              internal_module=False,
430                              deps='ldb ldb_key_value ldb_mdb_int',
431                              subsystem='ldb')
432
433             bld.SAMBA_LIBRARY('ldb_mdb_int',
434                               bld.SUBDIR('ldb_mdb',
435                                          '''ldb_mdb.c '''),
436                               private_library=True,
437                               deps='ldb lmdb ldb_key_value')
438             lmdb_deps = ' ldb_mdb_int'
439         else:
440             lmdb_deps = ''
441
442
443         bld.SAMBA_MODULE('ldb_ldb',
444                          bld.SUBDIR('ldb_ldb',
445                                     '''ldb_ldb.c'''),
446                          init_function='ldb_ldb_init',
447                          module_init_name='ldb_init_module',
448                          internal_module=False,
449                          deps='ldb ldb_tdb ldb_key_value' + lmdb_deps,
450                          subsystem='ldb')
451
452         # have a separate subsystem for common/ldb.c, so it can rebuild
453         # for install with a different -DLDB_MODULESDIR=
454         bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
455                             'common/ldb.c',
456                             deps='tevent tdb',
457                             includes='include',
458                             cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
459
460         LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
461         for t in LDB_TOOLS.split():
462             bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
463                              manpages='man/%s.1' % t)
464
465         # ldbtest doesn't get installed
466         bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
467                          install=False)
468
469         if bld.CONFIG_SET('HAVE_LMDB'):
470             lmdb_deps = ' lmdb'
471         else:
472             lmdb_deps = ''
473         # ldbdump doesn't get installed
474         bld.SAMBA_BINARY('ldbdump',
475                          'tools/ldbdump.c',
476                          deps='ldb-cmdline ldb' + lmdb_deps,
477                          install=False)
478
479         bld.SAMBA_LIBRARY('ldb-cmdline',
480                           source='tools/ldbutil.c tools/cmdline.c',
481                           deps='ldb dl popt',
482                           private_library=True)
483
484         bld.SAMBA_BINARY('ldb_tdb_mod_op_test',
485                          source='tests/ldb_mod_op_test.c',
486                          cflags='-DTEST_BE=\"tdb\"',
487                          deps='cmocka ldb',
488                          install=False)
489
490         bld.SAMBA_BINARY('ldb_tdb_guid_mod_op_test',
491                          source='tests/ldb_mod_op_test.c',
492                          cflags='-DTEST_BE=\"tdb\" -DGUID_IDX=1',
493                          deps='cmocka ldb',
494                          install=False)
495
496         bld.SAMBA_BINARY('ldb_tdb_kv_ops_test',
497                          source='tests/ldb_kv_ops_test.c',
498                          cflags='-DTEST_BE=\"tdb\"',
499                          deps='cmocka ldb',
500                          install=False)
501
502         bld.SAMBA_BINARY('ldb_tdb_test',
503                          source='tests/ldb_tdb_test.c',
504                          deps='cmocka ldb',
505                          install=False)
506
507         bld.SAMBA_BINARY('ldb_msg_test',
508                          source='tests/ldb_msg.c',
509                          deps='cmocka ldb',
510                          install=False)
511
512         bld.SAMBA_BINARY('test_ldb_qsort',
513                          source='tests/test_ldb_qsort.c',
514                          deps='cmocka ldb',
515                          install=False)
516
517         bld.SAMBA_BINARY('test_ldb_dn',
518                          source='tests/test_ldb_dn.c',
519                          deps='cmocka ldb',
520                          install=False)
521
522         if bld.CONFIG_SET('HAVE_LMDB'):
523             bld.SAMBA_BINARY('ldb_mdb_mod_op_test',
524                              source='tests/ldb_mod_op_test.c',
525                              cflags='-DTEST_BE=\"mdb\" -DGUID_IDX=1 '
526                                   + '-DTEST_LMDB=1',
527                              deps='cmocka ldb lmdb',
528                              install=False)
529
530             bld.SAMBA_BINARY('ldb_lmdb_test',
531                              source='tests/ldb_lmdb_test.c',
532                              deps='cmocka ldb',
533                              install=False)
534
535             bld.SAMBA_BINARY('ldb_lmdb_size_test',
536                              source='tests/ldb_lmdb_size_test.c',
537                              deps='cmocka ldb',
538                              install=False)
539
540             bld.SAMBA_BINARY('ldb_mdb_kv_ops_test',
541                              source='tests/ldb_kv_ops_test.c',
542                              cflags='-DTEST_BE=\"mdb\"',
543                              deps='cmocka ldb',
544                              install=False)
545
546 def test(ctx):
547     '''run ldb testsuite'''
548     env = samba_utils.LOAD_ENVIRONMENT()
549     ctx.env = env
550
551     if not env.HAVE_LMDB:
552         raise Errors.WafError('make test called, but ldb was built '
553                              '--without-ldb-lmdb')
554
555     test_prefix = "%s/st" % (Context.g_module.out)
556     shutil.rmtree(test_prefix, ignore_errors=True)
557     os.makedirs(test_prefix)
558     os.environ['TEST_DATA_PREFIX'] = test_prefix
559     os.environ['LDB_MODULES_PATH'] = Context.g_module.out + "/modules/ldb"
560     samba_utils.ADD_LD_LIBRARY_PATH('bin/shared')
561     samba_utils.ADD_LD_LIBRARY_PATH('bin/shared/private')
562
563     cmd = 'tests/test-tdb.sh %s' % Context.g_module.out
564     ret = samba_utils.RUN_COMMAND(cmd)
565     print("testsuite returned %d" % ret)
566
567     tmp_dir = os.path.join(test_prefix, 'tmp')
568     if not os.path.exists(tmp_dir):
569         os.mkdir(tmp_dir)
570     pyret = samba_utils.RUN_PYTHON_TESTS(
571         ['tests/python/api.py', 'tests/python/index.py'],
572         extra_env={'SELFTEST_PREFIX': test_prefix})
573     print("Python testsuite returned %d" % pyret)
574
575     cmocka_ret = 0
576     test_exes = ['test_ldb_qsort',
577                  'test_ldb_dn',
578                  'ldb_msg_test',
579                  'ldb_tdb_mod_op_test',
580                  'ldb_tdb_guid_mod_op_test',
581                  'ldb_msg_test',
582                  'ldb_tdb_kv_ops_test',
583                  'ldb_tdb_test',
584                  'ldb_mdb_mod_op_test',
585                  'ldb_lmdb_test',
586                  # we don't want to run ldb_lmdb_size_test (which proves we can
587                  # fit > 4G of data into the DB), it would fill up the disk on
588                  # many of our test instances
589                  'ldb_mdb_kv_ops_test']
590
591     for test_exe in test_exes:
592             cmd = os.path.join(Context.g_module.out, test_exe)
593             cmocka_ret = cmocka_ret or samba_utils.RUN_COMMAND(cmd)
594
595     sys.exit(ret or pyret or cmocka_ret)
596
597 def dist():
598     '''makes a tarball for distribution'''
599     samba_dist.dist()
600
601 def reconfigure(ctx):
602     '''reconfigure if config scripts have changed'''
603     import samba_utils
604     samba_utils.reconfigure(ctx)