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