2010-03-28 01:48:49 +03:00
#!/usr/bin/env python
2010-04-04 04:06:34 +04:00
APPNAME = 'tdb'
2024-01-29 17:08:08 +03:00
VERSION = '1.4.10'
2010-03-17 12:31:46 +03:00
2010-04-04 04:18:39 +04:00
import sys, os
# find the buildtools directory
2018-02-02 17:34:31 +03:00
top = '.'
while not os.path.exists(top+'/buildtools') and len(top.split('/')) < 5:
top = top + '/..'
sys.path.insert(0, top + '/buildtools/wafsamba')
out = 'bin'
2010-04-04 04:18:39 +04:00
2018-02-02 17:34:31 +03:00
import wafsamba
from wafsamba import samba_dist, samba_utils
from waflib import Options, Logs, Context
import shutil
2010-04-04 05:00:42 +04:00
2015-03-25 14:13:40 +03:00
samba_dist.DIST_DIRS('lib/tdb:. lib/replace:lib/replace buildtools:buildtools third_party/waf:third_party/waf')
2010-02-26 14:21:50 +03:00
2014-02-03 13:40:45 +04:00
tdb1_unit_tests = [
'run-3G-file',
'run-bad-tdb-header',
'run',
'run-check',
'run-corrupt',
'run-die-during-transaction',
'run-endian',
'run-incompatible',
'run-nested-transactions',
'run-nested-traverse',
'run-no-lock-during-traverse',
'run-oldhash',
'run-open-during-transaction',
'run-readonly-check',
'run-rescue',
'run-rescue-find_entry',
2016-11-08 19:01:56 +03:00
'run-rdlock-upgrade',
2014-02-03 13:40:45 +04:00
'run-rwlock-check',
'run-summary',
'run-transaction-expand',
'run-traverse-in-transaction',
'run-wronghash-fail',
2013-02-21 19:34:32 +04:00
'run-zero-append',
2017-04-11 18:21:20 +03:00
'run-fcntl-deadlock',
2014-01-22 14:15:55 +04:00
'run-marklock-deadlock',
2015-07-06 11:49:47 +03:00
'run-allrecord-traverse-deadlock',
2013-02-21 19:34:32 +04:00
'run-mutex-openflags2',
'run-mutex-trylock',
'run-mutex-allrecord-bench',
'run-mutex-allrecord-trylock',
'run-mutex-allrecord-block',
2014-12-12 14:24:50 +03:00
'run-mutex-transaction1',
2013-02-21 19:34:32 +04:00
'run-mutex-die',
'run-mutex1',
2018-10-04 22:41:27 +03:00
'run-circular-chain',
2018-10-04 18:42:09 +03:00
'run-circular-freelist',
2018-10-07 23:03:09 +03:00
'run-traverse-chain',
2014-02-03 13:40:45 +04:00
]
2018-02-02 17:34:31 +03:00
def options(opt):
2010-03-28 08:42:28 +04:00
opt.BUILTIN_DEFAULT('replace')
2010-10-24 01:26:43 +04:00
opt.PRIVATE_EXTENSION_DEFAULT('tdb', noextension='tdb')
2010-04-04 07:16:49 +04:00
opt.RECURSE('lib/replace')
2013-02-21 19:34:32 +04:00
opt.add_option('--disable-tdb-mutex-locking',
help=("Disable the use of pthread robust mutexes"),
action="store_true", dest='disable_tdb_mutex_locking',
default=False)
2010-04-13 14:13:00 +04:00
2010-02-20 16:24:40 +03:00
def configure(conf):
2013-02-21 19:34:32 +04:00
conf.env.disable_tdb_mutex_locking = getattr(Options.options,
'disable_tdb_mutex_locking',
False)
if not conf.env.disable_tdb_mutex_locking:
conf.env.replace_add_global_pthread = True
2010-04-04 07:16:49 +04:00
conf.RECURSE('lib/replace')
2010-03-28 09:38:27 +04:00
2010-04-13 14:13:00 +04:00
conf.env.standalone_tdb = conf.IN_LAUNCH_DIR()
tdb: build and run unit tests in tdb/test/
Now we can build the test binaries: the CCAN style is to compile
everything called "compile_ok*.c", compile and run everything called
"run*.c", compile, link with the module, and run everything called
"api*.c", and link any other C files (presumably test helpers) into
all the tests.
Unfortunately, actually passing that between the various parts of
wscript is painful, so I open-coded the names.
Also, the tests expect to be run in a (temporary) directory they can
pollute, with the test directory found in test/ (to find the canned
TDB files, for example).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Feb 14 06:53:46 CET 2012 on sn-devel-104
2012-02-14 08:15:29 +04:00
conf.env.building_tdb = True
2010-04-13 15:33:04 +04:00
if not conf.env.standalone_tdb:
2011-11-12 19:36:18 +04:00
if conf.CHECK_BUNDLED_SYSTEM_PKG('tdb', minversion=VERSION,
2010-04-13 15:33:04 +04:00
implied_deps='replace'):
conf.define('USING_SYSTEM_TDB', 1)
tdb: build and run unit tests in tdb/test/
Now we can build the test binaries: the CCAN style is to compile
everything called "compile_ok*.c", compile and run everything called
"run*.c", compile, link with the module, and run everything called
"api*.c", and link any other C files (presumably test helpers) into
all the tests.
Unfortunately, actually passing that between the various parts of
wscript is painful, so I open-coded the names.
Also, the tests expect to be run in a (temporary) directory they can
pollute, with the test directory found in test/ (to find the canned
TDB files, for example).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Feb 14 06:53:46 CET 2012 on sn-devel-104
2012-02-14 08:15:29 +04:00
conf.env.building_tdb = False
2017-01-27 22:42:05 +03:00
if not conf.env.disable_python and \
conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion=VERSION):
2010-10-04 15:39:32 +04:00
conf.define('USING_SYSTEM_PYTDB', 1)
2010-04-13 15:33:04 +04:00
2013-02-21 19:34:32 +04:00
if (conf.CONFIG_SET('HAVE_ROBUST_MUTEXES') and
conf.env.building_tdb and
not conf.env.disable_tdb_mutex_locking):
conf.define('USE_TDB_MUTEX_LOCKING', 1)
2010-06-24 10:03:02 +04:00
conf.CHECK_XSLTPROC_MANPAGES()
2010-04-13 14:13:00 +04:00
2019-02-15 06:13:48 +03:00
conf.SAMBA_CHECK_PYTHON()
conf.SAMBA_CHECK_PYTHON_HEADERS()
2010-04-13 14:13:00 +04:00
2010-03-17 12:31:46 +03:00
conf.SAMBA_CONFIG_H()
2010-02-20 16:24:40 +03:00
2011-11-13 21:01:09 +04:00
conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
2010-02-20 16:24:40 +03:00
def build(bld):
2010-04-04 07:16:49 +04:00
bld.RECURSE('lib/replace')
2010-02-20 16:24:40 +03:00
2013-02-21 19:34:32 +04:00
COMMON_FILES='''check.c error.c tdb.c traverse.c
freelistcheck.c lock.c dump.c freelist.c
io.c open.c transaction.c hash.c summary.c rescue.c
mutex.c'''
COMMON_SRC = bld.SUBDIR('common', COMMON_FILES)
2010-02-20 16:24:40 +03:00
2010-10-24 22:50:47 +04:00
if bld.env.standalone_tdb:
bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
private_library = False
else:
private_library = True
2010-03-28 09:38:27 +04:00
if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
2013-02-21 19:34:32 +04:00
tdb_deps = 'replace'
if bld.CONFIG_SET('USE_TDB_MUTEX_LOCKING'):
tdb_deps += ' pthread'
2010-03-28 09:38:27 +04:00
bld.SAMBA_LIBRARY('tdb',
COMMON_SRC,
2013-02-21 19:34:32 +04:00
deps=tdb_deps,
2010-03-28 09:38:27 +04:00
includes='include',
2010-12-09 03:10:45 +03:00
abi_directory='ABI',
2010-04-18 06:46:33 +04:00
abi_match='tdb_*',
2010-04-20 07:53:35 +04:00
hide_symbols=True,
2010-12-09 13:58:20 +03:00
vnum=VERSION,
2016-01-04 18:21:02 +03:00
public_headers=('' if private_library else 'include/tdb.h'),
2011-03-03 09:19:33 +03:00
public_headers_install=not private_library,
2011-08-21 05:02:58 +04:00
pc_files='tdb.pc',
2010-10-24 22:50:47 +04:00
private_library=private_library)
2010-02-20 16:24:40 +03:00
2010-05-31 06:20:44 +04:00
bld.SAMBA_BINARY('tdbtorture',
'tools/tdbtorture.c',
'tdb',
install=False)
2021-12-13 19:49:51 +03:00
bld.SAMBA_BINARY('tdbtortseq',
'tools/tdbtortseq.c',
'tdb',
install=False)
2010-05-31 06:20:44 +04:00
2010-09-18 10:56:10 +04:00
bld.SAMBA_BINARY('tdbrestore',
'tools/tdbrestore.c',
2012-11-30 12:39:22 +04:00
'tdb', manpages='man/tdbrestore.8')
2010-09-18 10:56:10 +04:00
2010-05-31 06:20:44 +04:00
bld.SAMBA_BINARY('tdbdump',
'tools/tdbdump.c',
2012-11-30 12:39:22 +04:00
'tdb', manpages='man/tdbdump.8')
2010-05-31 06:20:44 +04:00
bld.SAMBA_BINARY('tdbbackup',
'tools/tdbbackup.c',
'tdb',
2012-11-30 12:39:22 +04:00
manpages='man/tdbbackup.8')
2010-05-31 06:20:44 +04:00
bld.SAMBA_BINARY('tdbtool',
'tools/tdbtool.c',
2012-11-30 12:39:22 +04:00
'tdb', manpages='man/tdbtool.8')
2010-03-17 09:20:02 +03:00
2014-08-15 05:36:40 +04:00
if bld.env.standalone_tdb:
# FIXME: This hardcoded list is stupid, stupid, stupid.
bld.SAMBA_SUBSYSTEM('tdb-test-helpers',
'test/external-agent.c test/lock-tracking.c test/logging.c',
tdb_deps,
includes='include')
for t in tdb1_unit_tests:
b = "tdb1-" + t
s = "test/" + t + ".c"
bld.SAMBA_BINARY(b, s, 'replace tdb-test-helpers',
includes='include', install=False)
tdb: build and run unit tests in tdb/test/
Now we can build the test binaries: the CCAN style is to compile
everything called "compile_ok*.c", compile and run everything called
"run*.c", compile, link with the module, and run everything called
"api*.c", and link any other C files (presumably test helpers) into
all the tests.
Unfortunately, actually passing that between the various parts of
wscript is painful, so I open-coded the names.
Also, the tests expect to be run in a (temporary) directory they can
pollute, with the test directory found in test/ (to find the canned
TDB files, for example).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Feb 14 06:53:46 CET 2012 on sn-devel-104
2012-02-14 08:15:29 +04:00
2010-10-04 15:38:39 +04:00
if not bld.CONFIG_SET('USING_SYSTEM_PYTDB'):
2019-02-15 06:37:48 +03:00
bld.SAMBA_PYTHON('pytdb',
'pytdb.c',
deps='tdb',
enabled=not bld.env.disable_python,
realname='tdb.so',
cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
2010-03-17 09:20:02 +03:00
2015-07-23 02:47:24 +03:00
if not bld.env.disable_python:
2019-02-15 06:37:48 +03:00
bld.SAMBA_SCRIPT('_tdb_text.py',
pattern='_tdb_text.py',
installdir='python')
bld.INSTALL_FILES('${PYTHONARCHDIR}', '_tdb_text.py')
2015-06-18 14:43:27 +03:00
tdb: build and run unit tests in tdb/test/
Now we can build the test binaries: the CCAN style is to compile
everything called "compile_ok*.c", compile and run everything called
"run*.c", compile, link with the module, and run everything called
"api*.c", and link any other C files (presumably test helpers) into
all the tests.
Unfortunately, actually passing that between the various parts of
wscript is painful, so I open-coded the names.
Also, the tests expect to be run in a (temporary) directory they can
pollute, with the test directory found in test/ (to find the canned
TDB files, for example).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Feb 14 06:53:46 CET 2012 on sn-devel-104
2012-02-14 08:15:29 +04:00
def testonly(ctx):
2010-04-04 16:11:30 +04:00
'''run tdb testsuite'''
2012-05-28 16:16:44 +04:00
ecode = 0
tdb: build and run unit tests in tdb/test/
Now we can build the test binaries: the CCAN style is to compile
everything called "compile_ok*.c", compile and run everything called
"run*.c", compile, link with the module, and run everything called
"api*.c", and link any other C files (presumably test helpers) into
all the tests.
Unfortunately, actually passing that between the various parts of
wscript is painful, so I open-coded the names.
Also, the tests expect to be run in a (temporary) directory they can
pollute, with the test directory found in test/ (to find the canned
TDB files, for example).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Feb 14 06:53:46 CET 2012 on sn-devel-104
2012-02-14 08:15:29 +04:00
2018-02-02 17:34:31 +03:00
blddir = Context.g_module.out
test_prefix = "%s/st" % (blddir)
2010-12-27 14:20:47 +03:00
shutil.rmtree(test_prefix, ignore_errors=True)
os.makedirs(test_prefix)
2011-02-21 08:46:58 +03:00
os.environ['TEST_DATA_PREFIX'] = test_prefix
tdb: build and run unit tests in tdb/test/
Now we can build the test binaries: the CCAN style is to compile
everything called "compile_ok*.c", compile and run everything called
"run*.c", compile, link with the module, and run everything called
"api*.c", and link any other C files (presumably test helpers) into
all the tests.
Unfortunately, actually passing that between the various parts of
wscript is painful, so I open-coded the names.
Also, the tests expect to be run in a (temporary) directory they can
pollute, with the test directory found in test/ (to find the canned
TDB files, for example).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Feb 14 06:53:46 CET 2012 on sn-devel-104
2012-02-14 08:15:29 +04:00
env = samba_utils.LOAD_ENVIRONMENT()
# FIXME: This is horrible :(
if env.building_tdb:
# Create scratch directory for tests.
testdir = os.path.join(test_prefix, 'tdb-tests')
samba_utils.mkdir_p(testdir)
# Symlink back to source dir so it can find tests in test/
link = os.path.join(testdir, 'test')
if not os.path.exists(link):
2016-03-26 15:18:07 +03:00
os.symlink(ctx.path.make_node('test').abspath(), link)
2012-03-10 07:38:48 +04:00
2018-07-31 01:07:53 +03:00
sh_tests = ["test/test_tdbbackup.sh test/jenkins-be-hash.tdb"]
for sh_test in sh_tests:
tdb: Fix compatibility of wscript with older python
Traceback (most recent call last):
File "tdb-1.3.17/third_party/waf/waflib/Scripting.py", line 158, in waf_entry_point
run_commands()
File "tdb-1.3.17/third_party/waf/waflib/Scripting.py", line 251, in run_commands
ctx = run_command(cmd_name)
File "tdb-1.3.17/third_party/waf/waflib/Scripting.py", line 235, in run_command
ctx.execute()
File "tdb-1.3.17/third_party/waf/waflib/Context.py", line 204, in execute
self.recurse([os.path.dirname(g_module.root_path)])
File "tdb-1.3.17/third_party/waf/waflib/Context.py", line 286, in recurse
user_function(self)
File "tdb-1.3.17/wscript", line 225, in testonly
cmd = "BINDIR={} {}".format(blddir, sh_test)
ValueError: zero length field name in format
Signed-off-by: Lukas Slebodnik <lslebodn@fedoraproject.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Sun Jan 20 03:49:59 CET 2019 on sn-devel-144
2019-01-18 18:38:03 +03:00
cmd = "BINDIR=%s %s" % (blddir, sh_test)
2018-07-31 01:07:53 +03:00
print("shell test: " + cmd)
ret = samba_utils.RUN_COMMAND(cmd)
if ret != 0:
print("%s sh test failed" % cmd)
ecode = ret
break
2014-02-03 13:40:45 +04:00
for t in tdb1_unit_tests:
f = "tdb1-" + t
2018-02-02 17:34:31 +03:00
cmd = "cd " + testdir + " && " + os.path.abspath(os.path.join(blddir, f)) + " > test-output 2>&1"
tdb: build and run unit tests in tdb/test/
Now we can build the test binaries: the CCAN style is to compile
everything called "compile_ok*.c", compile and run everything called
"run*.c", compile, link with the module, and run everything called
"api*.c", and link any other C files (presumably test helpers) into
all the tests.
Unfortunately, actually passing that between the various parts of
wscript is painful, so I open-coded the names.
Also, the tests expect to be run in a (temporary) directory they can
pollute, with the test directory found in test/ (to find the canned
TDB files, for example).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Feb 14 06:53:46 CET 2012 on sn-devel-104
2012-02-14 08:15:29 +04:00
print("..." + f)
ret = samba_utils.RUN_COMMAND(cmd)
if ret != 0:
print("%s failed:" % f)
samba_utils.RUN_COMMAND("cat " + os.path.join(testdir, 'test-output'))
2012-05-28 16:16:44 +04:00
ecode = ret
break
tdb: build and run unit tests in tdb/test/
Now we can build the test binaries: the CCAN style is to compile
everything called "compile_ok*.c", compile and run everything called
"run*.c", compile, link with the module, and run everything called
"api*.c", and link any other C files (presumably test helpers) into
all the tests.
Unfortunately, actually passing that between the various parts of
wscript is painful, so I open-coded the names.
Also, the tests expect to be run in a (temporary) directory they can
pollute, with the test directory found in test/ (to find the canned
TDB files, for example).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Feb 14 06:53:46 CET 2012 on sn-devel-104
2012-02-14 08:15:29 +04:00
if ecode == 0:
2018-02-02 17:34:31 +03:00
cmd = os.path.join(blddir, 'tdbtorture')
tdb: build and run unit tests in tdb/test/
Now we can build the test binaries: the CCAN style is to compile
everything called "compile_ok*.c", compile and run everything called
"run*.c", compile, link with the module, and run everything called
"api*.c", and link any other C files (presumably test helpers) into
all the tests.
Unfortunately, actually passing that between the various parts of
wscript is painful, so I open-coded the names.
Also, the tests expect to be run in a (temporary) directory they can
pollute, with the test directory found in test/ (to find the canned
TDB files, for example).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Feb 14 06:53:46 CET 2012 on sn-devel-104
2012-02-14 08:15:29 +04:00
ret = samba_utils.RUN_COMMAND(cmd)
print("testsuite returned %d" % ret)
if ret != 0:
2012-05-28 16:16:44 +04:00
ecode = ret
2015-05-22 18:10:34 +03:00
pyret = samba_utils.RUN_PYTHON_TESTS(['python/tests/simple.py'])
print("python testsuite returned %d" % pyret)
sys.exit(ecode or pyret)
tdb: build and run unit tests in tdb/test/
Now we can build the test binaries: the CCAN style is to compile
everything called "compile_ok*.c", compile and run everything called
"run*.c", compile, link with the module, and run everything called
"api*.c", and link any other C files (presumably test helpers) into
all the tests.
Unfortunately, actually passing that between the various parts of
wscript is painful, so I open-coded the names.
Also, the tests expect to be run in a (temporary) directory they can
pollute, with the test directory found in test/ (to find the canned
TDB files, for example).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Feb 14 06:53:46 CET 2012 on sn-devel-104
2012-02-14 08:15:29 +04:00
# WAF doesn't build the unit tests for this, maybe because they don't link with tdb?
# This forces it
def test(ctx):
2016-03-26 15:18:07 +03:00
Options.commands.append('build')
Options.commands.append('testonly')
2010-04-05 03:58:23 +04:00
def dist():
'''makes a tarball for distribution'''
samba_dist.dist()
2010-11-03 04:09:23 +03:00
def reconfigure(ctx):
'''reconfigure if config scripts have changed'''
samba_utils.reconfigure(ctx)