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