ldb: version 2.4 will be used for Samba 4.15
[Samba.git] / lib / ldb / wscript
blob863dfde93399de61f7d66313d7e5241254b77495
1 #!/usr/bin/env python
3 APPNAME = 'ldb'
4 # For Samba 4.15.x
5 VERSION = '2.4.0'
7 import sys, os
9 # find the buildtools directory
10 top = '.'
11 while not os.path.exists(top+'/buildtools') and len(top.split('/')) < 5:
12 top = top + '/..'
13 sys.path.insert(0, top + '/buildtools/wafsamba')
15 out = 'bin'
17 import wafsamba
18 from wafsamba import samba_dist, samba_utils
19 from waflib import Errors, Options, Logs, Context
20 import shutil
22 samba_dist.DIST_DIRS('''lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
23 lib/tdb:lib/tdb lib/tdb:lib/tdb lib/tevent:lib/tevent
24 third_party/popt:third_party/popt
25 third_party/cmocka:third_party/cmocka
26 buildtools:buildtools third_party/waf:third_party/waf''')
28 samba_dist.DIST_FILES('''lib/util/binsearch.h:lib/util/binsearch.h
29 lib/util/attr.h:lib/util/attr.h''')
31 def options(opt):
32 opt.BUILTIN_DEFAULT('replace')
33 opt.PRIVATE_EXTENSION_DEFAULT('ldb', noextension='ldb')
34 opt.RECURSE('lib/tdb')
35 opt.RECURSE('lib/tevent')
36 opt.RECURSE('lib/replace')
37 opt.load('python') # options for disabling pyc or pyo compilation
39 opt.add_option('--without-ldb-lmdb',
40 help='disable new LMDB backend for LDB',
41 action='store_true', dest='without_ldb_lmdb', default=False)
44 def configure(conf):
45 conf.RECURSE('lib/tdb')
46 conf.RECURSE('lib/tevent')
48 if conf.CHECK_FOR_THIRD_PARTY():
49 conf.RECURSE('third_party/popt')
50 conf.RECURSE('third_party/cmocka')
51 else:
52 if not conf.CHECK_POPT():
53 raise Errors.WafError('popt development packages have not been found.\nIf third_party is installed, check that it is in the proper place.')
54 else:
55 conf.define('USING_SYSTEM_POPT', 1)
57 if not conf.CHECK_CMOCKA():
58 raise Errors.WafError('cmocka development package have not been found.\nIf third_party is installed, check that it is in the proper place.')
59 else:
60 conf.define('USING_SYSTEM_CMOCKA', 1)
62 conf.RECURSE('lib/replace')
63 conf.find_program('xsltproc', var='XSLTPROC')
64 conf.SAMBA_CHECK_PYTHON()
65 conf.SAMBA_CHECK_PYTHON_HEADERS()
67 # where does the default LIBDIR end up? in conf.env somewhere?
69 conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
71 conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
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)
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
95 if using_system_pyldb_util:
96 conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
98 if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb',
99 minversion=VERSION,
100 maxversion=max_ldb_version_dots,
101 onlyif='talloc tdb tevent %s' % dflt_name,
102 implied_deps='replace talloc tdb tevent'):
103 conf.define('USING_SYSTEM_LDB', 1)
105 if not conf.CHECK_CODE('return !(sizeof(size_t) >= 8)',
106 "HAVE_64_BIT_SIZE_T_FOR_LMDB",
107 execute=True,
108 msg='Checking for a 64-bit host to '
109 'support lmdb'):
110 Logs.warn("--without-ldb-lmdb implied as this "
111 "host is not 64-bit")
113 if not conf.env.standalone_ldb and \
114 not Options.options.without_ad_dc and \
115 conf.CONFIG_GET('ENABLE_SELFTEST'):
116 Logs.warn("NOTE: Some AD DC parts of selftest will fail")
118 conf.env.REQUIRE_LMDB = False
119 else:
120 if conf.env.standalone_ldb:
121 if Options.options.without_ldb_lmdb:
122 conf.env.REQUIRE_LMDB = False
123 else:
124 conf.env.REQUIRE_LMDB = True
125 elif Options.options.without_ad_dc:
126 conf.env.REQUIRE_LMDB = False
127 else:
128 if Options.options.without_ldb_lmdb:
129 if not Options.options.without_ad_dc and \
130 conf.CONFIG_GET('ENABLE_SELFTEST'):
131 raise Errors.WafError('--without-ldb-lmdb conflicts '
132 'with --enable-selftest while '
133 'building the AD DC')
135 conf.env.REQUIRE_LMDB = False
136 else:
137 conf.env.REQUIRE_LMDB = True
140 if conf.CONFIG_SET('USING_SYSTEM_LDB'):
141 v = VERSION.split('.')
142 conf.DEFINE('EXPECTED_SYSTEM_LDB_VERSION_MAJOR', int(v[0]))
143 conf.DEFINE('EXPECTED_SYSTEM_LDB_VERSION_MINOR', int(v[1]))
144 conf.DEFINE('EXPECTED_SYSTEM_LDB_VERSION_RELEASE', int(v[2]))
146 if conf.env.standalone_ldb:
147 conf.CHECK_XSLTPROC_MANPAGES()
149 # we need this for the ldap backend
150 if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
151 conf.env.ENABLE_LDAP_BACKEND = True
153 # we don't want any libraries or modules to rely on runtime
154 # resolution of symbols
155 if not sys.platform.startswith("openbsd"):
156 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
158 # if lmdb support is enabled then we require lmdb
159 # is present, build the mdb back end and enable lmdb support in
160 # the tools.
161 if conf.env.REQUIRE_LMDB and \
162 not conf.CONFIG_SET('USING_SYSTEM_LDB'):
163 if not conf.CHECK_CFG(package='lmdb',
164 args='"lmdb >= 0.9.16" --cflags --libs',
165 msg='Checking for lmdb >= 0.9.16',
166 mandatory=False):
167 if not conf.CHECK_CODE('''
168 #if MDB_VERSION_MAJOR == 0 \
169 && MDB_VERSION_MINOR <= 9 \
170 && MDB_VERSION_PATCH < 16
171 #error LMDB too old
172 #endif
173 ''',
174 'HAVE_GOOD_LMDB_VERSION',
175 headers='lmdb.h',
176 msg='Checking for lmdb >= 0.9.16 via header check'):
178 if conf.env.standalone_ldb:
179 raise Errors.WafError('ldb build (unless --without-ldb-lmdb) '
180 'requires '
181 'lmdb 0.9.16 or later')
182 elif not Options.options.without_ad_dc:
183 raise Errors.WafError('Samba AD DC and --enable-selftest '
184 'requires '
185 'lmdb 0.9.16 or later')
187 if conf.CHECK_FUNCS_IN('mdb_env_create', 'lmdb', headers='lmdb.h'):
188 conf.DEFINE('HAVE_LMDB', '1')
189 conf.env.HAVE_LMDB = True
192 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
194 conf.SAMBA_CONFIG_H()
196 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
198 def build(bld):
199 bld.RECURSE('lib/tevent')
201 if bld.CHECK_FOR_THIRD_PARTY():
202 bld.RECURSE('third_party/popt')
203 bld.RECURSE('third_party/cmocka')
205 bld.RECURSE('lib/replace')
206 bld.RECURSE('lib/tdb')
208 if bld.env.standalone_ldb:
209 if not 'PACKAGE_VERSION' in bld.env:
210 bld.env.PACKAGE_VERSION = VERSION
211 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
212 private_library = False
213 else:
214 private_library = True
215 # we're not currently linking against the ldap libs, but ldb.pc.in
216 # has @LDAP_LIBS@
217 bld.env.LDAP_LIBS = ''
219 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
220 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
222 COMMON_SRC = bld.SUBDIR('common',
223 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
224 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
225 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
227 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
228 init_function='ldb_ldap_init',
229 module_init_name='ldb_init_module',
230 deps='talloc lber ldap ldb',
231 enabled=bld.env.ENABLE_LDAP_BACKEND,
232 internal_module=False,
233 subsystem='ldb')
235 if bld.PYTHON_BUILD_IS_ENABLED():
236 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
237 name = bld.pyembed_libname('pyldb-util')
238 bld.SAMBA_LIBRARY(name,
239 deps='replace ldb',
240 source='pyldb_util.c',
241 public_headers=('' if private_library else 'pyldb.h'),
242 public_headers_install=not private_library,
243 vnum=VERSION,
244 private_library=private_library,
245 pc_files='pyldb-util.pc',
246 pyembed=True,
247 enabled=bld.PYTHON_BUILD_IS_ENABLED(),
248 abi_directory='ABI',
249 abi_match='pyldb_*')
251 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
252 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
253 deps='replace ldb ' + name,
254 realname='ldb.so',
255 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
257 # Do only install this file as part of the Samba build if we do not
258 # use the system libldb!
259 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
260 bld.SAMBA_SCRIPT('_ldb_text.py',
261 pattern='_ldb_text.py',
262 installdir='python')
264 bld.INSTALL_FILES('${PYTHONARCHDIR}', '_ldb_text.py')
266 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
267 if bld.is_install:
268 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
269 else:
270 # when we run from the source directory, we want to use
271 # the current modules, not the installed ones
272 modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
274 abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
276 ldb_headers = ('include/ldb.h include/ldb_errors.h '
277 'include/ldb_module.h include/ldb_handlers.h')
279 bld.SAMBA_LIBRARY('ldb',
280 COMMON_SRC + ' ' + LDB_MAP_SRC,
281 deps='tevent LIBLDB_MAIN replace',
282 includes='include',
283 public_headers=('' if private_library else ldb_headers),
284 public_headers_install=not private_library,
285 pc_files='ldb.pc',
286 vnum=VERSION,
287 private_library=private_library,
288 manpages='man/ldb.3',
289 abi_directory='ABI',
290 abi_match = abi_match)
292 # generate a include/ldb_version.h
293 def generate_ldb_version_h(t):
294 '''generate a vscript file for our public libraries'''
296 tgt = t.outputs[0].bldpath(t.env)
298 v = t.env.LDB_VERSION.split('.')
300 f = open(tgt, mode='w')
301 try:
302 f.write('#define LDB_VERSION "%s"\n' % t.env.LDB_VERSION)
303 f.write('#define LDB_VERSION_MAJOR %d\n' % int(v[0]))
304 f.write('#define LDB_VERSION_MINOR %d\n' % int(v[1]))
305 f.write('#define LDB_VERSION_RELEASE %d\n' % int(v[2]))
306 finally:
307 f.close()
308 return
309 t = bld.SAMBA_GENERATOR('ldb_version.h',
310 rule=generate_ldb_version_h,
311 dep_vars=['LDB_VERSION'],
312 target='include/ldb_version.h',
313 public_headers='include/ldb_version.h',
314 public_headers_install=not private_library)
315 t.env.LDB_VERSION = VERSION
317 bld.SAMBA_MODULE('ldb_asq',
318 'modules/asq.c',
319 init_function='ldb_asq_init',
320 module_init_name='ldb_init_module',
321 internal_module=False,
322 deps='ldb',
323 subsystem='ldb')
325 bld.SAMBA_MODULE('ldb_server_sort',
326 'modules/sort.c',
327 init_function='ldb_server_sort_init',
328 internal_module=False,
329 module_init_name='ldb_init_module',
330 deps='ldb',
331 subsystem='ldb')
333 bld.SAMBA_MODULE('ldb_paged_searches',
334 'modules/paged_searches.c',
335 init_function='ldb_paged_searches_init',
336 internal_module=False,
337 module_init_name='ldb_init_module',
338 deps='ldb',
339 subsystem='ldb')
341 bld.SAMBA_MODULE('ldb_rdn_name',
342 'modules/rdn_name.c',
343 init_function='ldb_rdn_name_init',
344 internal_module=False,
345 module_init_name='ldb_init_module',
346 deps='ldb',
347 subsystem='ldb')
349 bld.SAMBA_MODULE('ldb_sample',
350 'tests/sample_module.c',
351 init_function='ldb_sample_init',
352 internal_module=False,
353 module_init_name='ldb_init_module',
354 deps='ldb',
355 subsystem='ldb')
357 bld.SAMBA_MODULE('ldb_skel',
358 'modules/skel.c',
359 init_function='ldb_skel_init',
360 internal_module=False,
361 module_init_name='ldb_init_module',
362 deps='ldb',
363 subsystem='ldb')
365 bld.SAMBA_MODULE('ldb_sqlite3',
366 'sqlite3/ldb_sqlite3.c',
367 init_function='ldb_sqlite3_init',
368 internal_module=False,
369 module_init_name='ldb_init_module',
370 enabled=False,
371 deps='ldb',
372 subsystem='ldb')
374 bld.SAMBA_MODULE('ldb_tdb',
375 bld.SUBDIR('ldb_tdb',
376 '''ldb_tdb_init.c'''),
377 init_function='ldb_tdb_init',
378 module_init_name='ldb_init_module',
379 internal_module=False,
380 deps='ldb ldb_tdb_int ldb_key_value',
381 subsystem='ldb')
383 bld.SAMBA_LIBRARY('ldb_tdb_int',
384 bld.SUBDIR('ldb_tdb',
385 '''ldb_tdb_wrap.c ldb_tdb.c'''),
386 private_library=True,
387 deps='ldb tdb ldb_key_value ldb_tdb_err_map')
389 bld.SAMBA_LIBRARY('ldb_tdb_err_map',
390 bld.SUBDIR('ldb_tdb',
391 '''ldb_tdb_err_map.c '''),
392 private_library=True,
393 deps='ldb tdb')
395 bld.SAMBA_LIBRARY('ldb_key_value',
396 bld.SUBDIR('ldb_key_value',
397 '''ldb_kv.c ldb_kv_search.c ldb_kv_index.c
398 ldb_kv_cache.c'''),
399 private_library=True,
400 deps='tdb ldb ldb_tdb_err_map')
402 if bld.CONFIG_SET('HAVE_LMDB'):
403 bld.SAMBA_MODULE('ldb_mdb',
404 bld.SUBDIR('ldb_mdb',
405 '''ldb_mdb_init.c'''),
406 init_function='ldb_mdb_init',
407 module_init_name='ldb_init_module',
408 internal_module=False,
409 deps='ldb ldb_key_value ldb_mdb_int',
410 subsystem='ldb')
412 bld.SAMBA_LIBRARY('ldb_mdb_int',
413 bld.SUBDIR('ldb_mdb',
414 '''ldb_mdb.c '''),
415 private_library=True,
416 deps='ldb lmdb ldb_key_value')
417 lmdb_deps = ' ldb_mdb_int'
418 else:
419 lmdb_deps = ''
422 bld.SAMBA_MODULE('ldb_ldb',
423 bld.SUBDIR('ldb_ldb',
424 '''ldb_ldb.c'''),
425 init_function='ldb_ldb_init',
426 module_init_name='ldb_init_module',
427 internal_module=False,
428 deps='ldb ldb_tdb_int ldb_key_value' + lmdb_deps,
429 subsystem='ldb')
431 # have a separate subsystem for common/ldb.c, so it can rebuild
432 # for install with a different -DLDB_MODULESDIR=
433 bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
434 'common/ldb.c',
435 deps='tevent tdb',
436 includes='include',
437 cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
439 LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
440 for t in LDB_TOOLS.split():
441 bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
442 manpages='man/%s.1' % t)
444 # ldbtest doesn't get installed
445 bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
446 install=False)
448 if bld.CONFIG_SET('HAVE_LMDB'):
449 lmdb_deps = ' lmdb'
450 else:
451 lmdb_deps = ''
452 # ldbdump doesn't get installed
453 bld.SAMBA_BINARY('ldbdump',
454 'tools/ldbdump.c',
455 deps='ldb-cmdline ldb' + lmdb_deps,
456 install=False)
458 bld.SAMBA_LIBRARY('ldb-cmdline',
459 source='tools/ldbutil.c tools/cmdline.c',
460 deps='ldb dl popt',
461 private_library=True)
463 bld.SAMBA_BINARY('ldb_tdb_mod_op_test',
464 source='tests/ldb_mod_op_test.c',
465 cflags='-DTEST_BE=\"tdb\"',
466 deps='cmocka ldb',
467 install=False)
469 bld.SAMBA_BINARY('ldb_tdb_guid_mod_op_test',
470 source='tests/ldb_mod_op_test.c',
471 cflags='-DTEST_BE=\"tdb\" -DGUID_IDX=1',
472 deps='cmocka ldb',
473 install=False)
475 bld.SAMBA_BINARY('ldb_tdb_kv_ops_test',
476 source='tests/ldb_kv_ops_test.c',
477 cflags='-DTEST_BE=\"tdb\"',
478 deps='cmocka ldb',
479 install=False)
481 bld.SAMBA_BINARY('ldb_tdb_test',
482 source='tests/ldb_tdb_test.c',
483 deps='cmocka ldb',
484 install=False)
486 bld.SAMBA_BINARY('ldb_msg_test',
487 source='tests/ldb_msg.c',
488 deps='cmocka ldb',
489 install=False)
491 bld.SAMBA_BINARY('test_ldb_qsort',
492 source='tests/test_ldb_qsort.c',
493 deps='cmocka ldb',
494 install=False)
496 bld.SAMBA_BINARY('test_ldb_dn',
497 source='tests/test_ldb_dn.c',
498 deps='cmocka ldb',
499 install=False)
501 bld.SAMBA_BINARY('ldb_match_test',
502 source='tests/ldb_match_test.c',
503 deps='cmocka ldb',
504 install=False)
506 bld.SAMBA_BINARY('ldb_key_value_test',
507 source='tests/ldb_key_value_test.c',
508 deps='cmocka ldb ldb_tdb_err_map',
509 install=False)
511 bld.SAMBA_BINARY('ldb_parse_test',
512 source='tests/ldb_parse_test.c',
513 deps='cmocka ldb ldb_tdb_err_map',
514 install=False)
516 bld.SAMBA_BINARY('ldb_filter_attrs_test',
517 source='tests/ldb_filter_attrs_test.c',
518 deps='cmocka ldb ldb_tdb_err_map',
519 install=False)
521 bld.SAMBA_BINARY('ldb_key_value_sub_txn_tdb_test',
522 bld.SUBDIR('ldb_key_value',
523 '''ldb_kv_search.c
524 ldb_kv_index.c
525 ldb_kv_cache.c''') +
526 'tests/ldb_key_value_sub_txn_test.c',
527 cflags='-DTEST_BE=\"tdb\"',
528 deps='cmocka ldb ldb_tdb_err_map',
529 install=False)
531 # If both libldap and liblber are available, test ldb_ldap
532 # code for a regression of bz#14413 -- even if we don't build
533 # it ourselves and simply using the system version
534 if bld.env.LIB_LDAP and bld.env.LIB_LBER:
535 bld.SAMBA_BINARY('lldb_ldap_test',
536 source='tests/lldb_ldap.c',
537 deps='cmocka talloc lber ldap ldb',
538 install=False)
540 if bld.CONFIG_SET('HAVE_LMDB'):
541 bld.SAMBA_BINARY('ldb_mdb_mod_op_test',
542 source='tests/ldb_mod_op_test.c',
543 cflags='-DTEST_BE=\"mdb\" -DGUID_IDX=1 '
544 + '-DTEST_LMDB=1',
545 deps='cmocka ldb lmdb',
546 install=False)
548 bld.SAMBA_BINARY('ldb_lmdb_test',
549 source='tests/ldb_lmdb_test.c',
550 deps='cmocka ldb',
551 install=False)
553 bld.SAMBA_BINARY('ldb_lmdb_size_test',
554 source='tests/ldb_lmdb_size_test.c',
555 deps='cmocka ldb',
556 install=False)
558 bld.SAMBA_BINARY('ldb_mdb_kv_ops_test',
559 source='tests/ldb_kv_ops_test.c',
560 cflags='-DTEST_BE=\"mdb\" -DTEST_LMDB=1',
561 deps='cmocka ldb',
562 install=False)
564 bld.SAMBA_BINARY('ldb_lmdb_free_list_test',
565 source='tests/ldb_lmdb_free_list_test.c',
566 cflags='-DTEST_BE=\"mdb\" -DTEST_LMDB=1',
567 deps='cmocka ldb',
568 install=False)
570 # We rely on the versions of the ldb_key_value functions included
571 # in ldb_key_value_sub_txn_test.c taking priority over the versions
572 # in the ldb_key_value shared library.
573 # If this turns out to not be the case, the dependencies will
574 # need to be unrolled, and all the source files included and the
575 # ldb_tdb module initialization code will need to be called
576 # manually.
577 bld.SAMBA_BINARY('ldb_key_value_sub_txn_mdb_test',
578 bld.SUBDIR('ldb_key_value',
579 '''ldb_kv_search.c
580 ldb_kv_index.c
581 ldb_kv_cache.c''') +
582 'tests/ldb_key_value_sub_txn_test.c',
583 cflags='-DTEST_BE=\"mdb\"',
584 deps='cmocka ldb ldb_tdb_err_map',
585 install=False)
586 else:
587 bld.SAMBA_BINARY('ldb_no_lmdb_test',
588 source='tests/ldb_no_lmdb_test.c',
589 deps='cmocka ldb',
590 install=False)
592 def test(ctx):
593 '''run ldb testsuite'''
594 env = samba_utils.LOAD_ENVIRONMENT()
595 ctx.env = env
597 test_prefix = "%s/st" % (Context.g_module.out)
598 shutil.rmtree(test_prefix, ignore_errors=True)
599 os.makedirs(test_prefix)
600 os.environ['TEST_DATA_PREFIX'] = test_prefix
601 os.environ['LDB_MODULES_PATH'] = Context.g_module.out + "/modules/ldb"
602 if env.HAVE_LMDB:
603 os.environ['HAVE_LMDB'] = '1'
604 else:
605 os.environ['HAVE_LMDB'] = '0'
606 samba_utils.ADD_LD_LIBRARY_PATH('bin/shared')
607 samba_utils.ADD_LD_LIBRARY_PATH('bin/shared/private')
609 cmd = 'tests/test-tdb.sh %s' % Context.g_module.out
610 ret = samba_utils.RUN_COMMAND(cmd)
611 print("testsuite returned %d" % ret)
613 tmp_dir = os.path.join(test_prefix, 'tmp')
614 if not os.path.exists(tmp_dir):
615 os.mkdir(tmp_dir)
616 pyret = samba_utils.RUN_PYTHON_TESTS(
617 ['tests/python/api.py',
618 'tests/python/crash.py',
619 'tests/python/index.py',
620 'tests/python/repack.py'],
621 extra_env={'SELFTEST_PREFIX': test_prefix})
622 print("Python testsuite returned %d" % pyret)
624 cmocka_ret = 0
625 test_exes = ['test_ldb_qsort',
626 'test_ldb_dn',
627 'ldb_msg_test',
628 'ldb_tdb_mod_op_test',
629 'ldb_tdb_guid_mod_op_test',
630 'ldb_msg_test',
631 'ldb_tdb_kv_ops_test',
632 'ldb_tdb_test',
633 'ldb_match_test',
634 'ldb_key_value_test',
635 # we currently don't run ldb_key_value_sub_txn_tdb_test as it
636 # tests the nested/sub transaction handling
637 # on operations which the TDB backend does not currently
638 # support
639 # 'ldb_key_value_sub_txn_tdb_test'
640 'ldb_parse_test']
642 # if LIB_LDAP and LIB_LBER defined, then we can test ldb_ldap backend
643 # behavior regression for bz#14413
644 if env.LIB_LDAP and env.LIB_LBER:
645 test_exes += ["lldb_ldap_test"]
647 if env.HAVE_LMDB:
648 test_exes += ['ldb_mdb_mod_op_test',
649 'ldb_lmdb_test',
650 # we don't want to run ldb_lmdb_size_test (which proves
651 # we can fit > 4G of data into the DB), it would fill up
652 # the disk on many of our test instances
653 'ldb_mdb_kv_ops_test',
654 'ldb_key_value_sub_txn_mdb_test',
655 'ldb_lmdb_free_list_test']
656 else:
657 test_exes += ['ldb_no_lmdb_test']
659 for test_exe in test_exes:
660 cmd = os.path.join(Context.g_module.out, test_exe)
661 cmocka_ret = cmocka_ret or samba_utils.RUN_COMMAND(cmd)
663 sys.exit(ret or pyret or cmocka_ret)
665 def dist():
666 '''makes a tarball for distribution'''
667 samba_dist.dist()
669 def reconfigure(ctx):
670 '''reconfigure if config scripts have changed'''
671 import samba_utils
672 samba_utils.reconfigure(ctx)