10 # find the buildtools directory
12 while not os
.path
.exists(srcdir
+'/buildtools') and len(srcdir
.split('/')) < 5:
13 srcdir
= '../' + srcdir
14 sys
.path
.insert(0, srcdir
+ '/buildtools/wafsamba')
16 import wafsamba
, samba_dist
, Options
, Logs
18 samba_dist
.DIST_DIRS('lib/tdb:. lib/replace:lib/replace buildtools:buildtools')
21 opt
.BUILTIN_DEFAULT('replace')
22 opt
.PRIVATE_EXTENSION_DEFAULT('tdb', noextension
='tdb')
23 opt
.RECURSE('lib/replace')
24 if opt
.IN_LAUNCH_DIR():
25 opt
.add_option('--disable-python',
26 help=("disable the pytdb module"),
27 action
="store_true", dest
='disable_python', default
=False)
31 conf
.RECURSE('lib/replace')
33 conf
.env
.standalone_tdb
= conf
.IN_LAUNCH_DIR()
34 conf
.env
.building_tdb
= True
36 if not conf
.env
.standalone_tdb
:
37 if conf
.CHECK_BUNDLED_SYSTEM_PKG('tdb', minversion
=VERSION
,
38 implied_deps
='replace'):
39 conf
.define('USING_SYSTEM_TDB', 1)
40 conf
.env
.building_tdb
= False
41 if conf
.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion
=VERSION
):
42 conf
.define('USING_SYSTEM_PYTDB', 1)
44 conf
.env
.disable_python
= getattr(Options
.options
, 'disable_python', False)
46 conf
.CHECK_XSLTPROC_MANPAGES()
48 if not conf
.env
.disable_python
:
49 # also disable if we don't have the python libs installed
50 conf
.find_program('python', var
='PYTHON')
51 conf
.check_tool('python')
52 conf
.check_python_version((2,4,2))
53 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=False)
54 if not conf
.env
.HAVE_PYTHON_H
:
55 Logs
.warn('Disabling pytdb as python devel libs not found')
56 conf
.env
.disable_python
= True
60 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
63 bld
.RECURSE('lib/replace')
65 COMMON_SRC
= bld
.SUBDIR('common',
66 '''check.c error.c tdb.c traverse.c
67 freelistcheck.c lock.c dump.c freelist.c
68 io.c open.c transaction.c hash.c summary.c''')
70 if bld
.env
.standalone_tdb
:
71 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
72 private_library
= False
74 private_library
= True
76 if not bld
.CONFIG_SET('USING_SYSTEM_TDB'):
77 bld
.SAMBA_LIBRARY('tdb',
85 public_headers
='include/tdb.h',
86 public_headers_install
=not private_library
,
88 private_library
=private_library
)
90 bld
.SAMBA_BINARY('tdbtorture',
95 bld
.SAMBA_BINARY('tdbrestore',
97 'tdb', manpages
='manpages/tdbrestore.8')
99 bld
.SAMBA_BINARY('tdbdump',
101 'tdb', manpages
='manpages/tdbdump.8')
103 bld
.SAMBA_BINARY('tdbbackup',
106 manpages
='manpages/tdbbackup.8')
108 bld
.SAMBA_BINARY('tdbtool',
110 'tdb', manpages
='manpages/tdbtool.8')
112 # FIXME: This hardcoded list is stupid, stupid, stupid.
113 bld
.SAMBA_SUBSYSTEM('tdb-test-helpers',
114 'test/external-agent.c test/lock-tracking.c test/logging.c',
118 bld
.SAMBA_BINARY('tdb1-run-3G-file', 'test/run-3G-file.c',
119 'replace tdb-test-helpers', includes
='include', install
=False)
120 bld
.SAMBA_BINARY('tdb1-run-bad-tdb-header', 'test/run-bad-tdb-header.c',
121 'replace tdb-test-helpers', includes
='include', install
=False)
122 bld
.SAMBA_BINARY('tdb1-run', 'test/run.c',
123 'replace tdb-test-helpers', includes
='include', install
=False)
124 bld
.SAMBA_BINARY('tdb1-run-check', 'test/run-check.c',
125 'replace tdb-test-helpers', includes
='include', install
=False)
126 bld
.SAMBA_BINARY('tdb1-run-corrupt', 'test/run-corrupt.c',
127 'replace tdb-test-helpers', includes
='include', install
=False)
128 bld
.SAMBA_BINARY('tdb1-run-die-during-transaction', 'test/run-die-during-transaction.c',
129 'replace tdb-test-helpers', includes
='include', install
=False)
130 bld
.SAMBA_BINARY('tdb1-run-endian', 'test/run-endian.c',
131 'replace tdb-test-helpers', includes
='include', install
=False)
132 bld
.SAMBA_BINARY('tdb1-run-incompatible', 'test/run-incompatible.c',
133 'replace tdb-test-helpers', includes
='include', install
=False)
134 bld
.SAMBA_BINARY('tdb1-run-nested-transactions', 'test/run-nested-transactions.c',
135 'replace tdb-test-helpers', includes
='include', install
=False)
136 bld
.SAMBA_BINARY('tdb1-run-nested-traverse', 'test/run-nested-traverse.c',
137 'replace tdb-test-helpers', includes
='include', install
=False)
138 bld
.SAMBA_BINARY('tdb1-run-no-lock-during-traverse', 'test/run-no-lock-during-traverse.c',
139 'replace tdb-test-helpers', includes
='include', install
=False)
140 bld
.SAMBA_BINARY('tdb1-run-oldhash', 'test/run-oldhash.c',
141 'replace tdb-test-helpers', includes
='include', install
=False)
142 bld
.SAMBA_BINARY('tdb1-run-open-during-transaction', 'test/run-open-during-transaction.c',
143 'replace tdb-test-helpers', includes
='include', install
=False)
144 bld
.SAMBA_BINARY('tdb1-run-readonly-check', 'test/run-readonly-check.c',
145 'replace tdb-test-helpers', includes
='include', install
=False)
146 bld
.SAMBA_BINARY('tdb1-run-rwlock-check', 'test/run-rwlock-check.c',
147 'replace tdb-test-helpers', includes
='include', install
=False)
148 bld
.SAMBA_BINARY('tdb1-run-summary', 'test/run-summary.c',
149 'replace tdb-test-helpers', includes
='include', install
=False)
150 bld
.SAMBA_BINARY('tdb1-run-transaction-expand', 'test/run-transaction-expand.c',
151 'replace tdb-test-helpers', includes
='include', install
=False)
152 bld
.SAMBA_BINARY('tdb1-run-traverse-in-transaction', 'test/run-traverse-in-transaction.c',
153 'replace tdb-test-helpers', includes
='include', install
=False)
154 bld
.SAMBA_BINARY('tdb1-run-wronghash-fail', 'test/run-wronghash-fail.c',
155 'replace tdb-test-helpers', includes
='include', install
=False)
156 bld
.SAMBA_BINARY('tdb1-run-zero-append', 'test/run-zero-append.c',
157 'replace tdb-test-helpers', includes
='include', install
=False)
159 if not bld
.CONFIG_SET('USING_SYSTEM_PYTDB'):
160 bld
.SAMBA_PYTHON('pytdb',
163 enabled
=not bld
.env
.disable_python
,
165 cflags
='-DPACKAGE_VERSION=\"%s\"' % VERSION
)
168 '''run tdb testsuite'''
169 import Utils
, samba_utils
, shutil
172 test_prefix
= "%s/st" % (Utils
.g_module
.blddir
)
173 shutil
.rmtree(test_prefix
, ignore_errors
=True)
174 os
.makedirs(test_prefix
)
175 os
.environ
['TEST_DATA_PREFIX'] = test_prefix
177 env
= samba_utils
.LOAD_ENVIRONMENT()
178 # FIXME: This is horrible :(
180 # Create scratch directory for tests.
181 testdir
= os
.path
.join(test_prefix
, 'tdb-tests')
182 samba_utils
.mkdir_p(testdir
)
183 # Symlink back to source dir so it can find tests in test/
184 link
= os
.path
.join(testdir
, 'test')
185 if not os
.path
.exists(link
):
186 os
.symlink(os
.path
.abspath(os
.path
.join(env
.cwd
, 'test')), link
)
188 for f
in 'tdb1-run-3G-file', 'tdb1-run-bad-tdb-header', 'tdb1-run', 'tdb1-run-check', 'tdb1-run-corrupt', 'tdb1-run-die-during-transaction', 'tdb1-run-endian', 'tdb1-run-incompatible', 'tdb1-run-nested-transactions', 'tdb1-run-nested-traverse', 'tdb1-run-no-lock-during-traverse', 'tdb1-run-oldhash', 'tdb1-run-open-during-transaction', 'tdb1-run-readonly-check', 'tdb1-run-rwlock-check', 'tdb1-run-summary', 'tdb1-run-transaction-expand', 'tdb1-run-traverse-in-transaction', 'tdb1-run-wronghash-fail', 'tdb1-run-zero-append':
189 cmd
= "cd " + testdir
+ " && " + os
.path
.abspath(os
.path
.join(Utils
.g_module
.blddir
, f
)) + " > test-output 2>&1"
191 ret
= samba_utils
.RUN_COMMAND(cmd
)
193 print("%s failed:" % f
)
194 samba_utils
.RUN_COMMAND("cat " + os
.path
.join(testdir
, 'test-output'))
199 cmd
= os
.path
.join(Utils
.g_module
.blddir
, 'tdbtorture')
200 ret
= samba_utils
.RUN_COMMAND(cmd
)
201 print("testsuite returned %d" % ret
)
206 # WAF doesn't build the unit tests for this, maybe because they don't link with tdb?
210 Scripting
.commands
.append('build')
211 Scripting
.commands
.append('testonly')
214 '''makes a tarball for distribution'''
217 def reconfigure(ctx
):
218 '''reconfigure if config scripts have changed'''
220 samba_utils
.reconfigure(ctx
)