import Scripting, os, Options, Utils, Environment, optparse, sys
from samba_utils import *
from samba_autoconf import *
+import types
def set_options(opt):
opt.add_option('--enable-selftest',
help=("enable options necessary for selftest (default=no)"),
action="store_true", dest='enable_selftest', default=False)
+ opt.add_option('--enable-coverage',
+ help=("enable options necessary for code coverage reporting on selftest (default=no)"),
+ action="store_true", dest='enable_coverage', default=False)
opt.add_option('--with-selftest-prefix',
help=("specify location of selftest directory (default=./st)"),
action="store", dest='SELFTEST_PREFIX', default='./st')
gr.add_option('--socket-wrapper-keep-pcap',
help=("create a pcap file for all individual test"),
action="store_true", dest='SOCKET_WRAPPER_KEEP_PCAP', default=False)
+ gr.add_option('--random-order', dest='RANDOM_ORDER', default=False,
+ action="store_true", help="Run testsuites in random order")
def configure(conf):
conf.env.SELFTEST_PREFIX = Options.options.SELFTEST_PREFIX
+ conf.env.enable_coverage = Options.options.enable_coverage
+ if conf.env.enable_coverage:
+ conf.ADD_LDFLAGS('-lgcov', testflags=True)
+ conf.ADD_CFLAGS('--coverage')
+
+ if Options.options.enable_selftest or Options.options.developer:
+ conf.DEFINE('ENABLE_SELFTEST', 1)
+
def cmd_testonly(opt):
'''run tests without doing a build first'''
# put all command line options in the environment as TESTENV_*=*
for o in dir(Options.options):
if o[0:1] != '_':
- os.environ['TESTENV_%s' % o.upper()] = str(getattr(Options.options, o, ''))
+ val = getattr(Options.options, o, '')
+ if not issubclass(type(val), types.FunctionType) \
+ and not issubclass(type(val), types.MethodType):
+ os.environ['TESTENV_%s' % o.upper()] = str(getattr(Options.options, o, ''))
+
- binary_mapping = ('nmblookup3:nmblookup3,' +
- 'smbclient3:smbclient3,' +
+ binary_mapping = ('nmblookup3:nmblookup,' +
+ 'nmblookup4:nmblookup4,' +
+ 'smbclient3:smbclient,' +
+ 'smbclient4:smbclient4,' +
'smbtorture4:smbtorture,' +
- 'ntlm_auth3:ntlm_auth3')
+ 'ntlm_auth3:ntlm_auth')
env.OPTIONS = '--binary-mapping=%s' % binary_mapping
if not Options.options.SLOWTEST:
env.OPTIONS += ' --socket-wrapper-pcap'
if Options.options.SOCKET_WRAPPER_KEEP_PCAP:
env.OPTIONS += ' --socket-wrapper-keep-pcap'
+ if Options.options.RANDOM_ORDER:
+ env.OPTIONS += ' --random-order'
if os.environ.get('RUN_FROM_BUILD_FARM') is not None:
env.FILTER_OPTIONS = '${FILTER_XFAIL} --strip-passed-output'
else:
if env.USING_SYSTEM_LDB:
os.environ['LDB_MODULES_PATH'] = 'bin/modules/ldb'
- if env.BUILD_TDB2:
- os.environ['BUILD_TDB2'] = '1'
-
# tell build system where to find config.h
- os.environ['VFSLIBDIR'] = os.path.abspath('bin/modules/vfs')
os.environ['CONFIG_H'] = 'bin/default/include/config.h'
st_done = os.path.join(env.SELFTEST_PREFIX, 'st_done')
if not os.path.isdir(env.SELFTEST_PREFIX):
os.makedirs(env.SELFTEST_PREFIX, int('755', 8))
- env.TESTLISTS = ('--testlist="${PYTHON} ${srcdir}/source3/selftest/tests.py|" ' +
+ env.TESTLISTS = ('--testlist="${PYTHON} ${srcdir}/selftest/tests.py|" ' +
+ '--testlist="${PYTHON} ${srcdir}/source3/selftest/tests.py|" ' +
'--testlist="${PYTHON} ${srcdir}/source4/selftest/tests.py|"')
+ if CONFIG_SET(opt, 'AD_DC_BUILD_IS_ENABLED'):
+ env.SELFTEST_TARGET="samba"
+ else:
+ env.SELFTEST_TARGET="samba3"
+
# We use the full path rather than relative path because it cause problems on some plateforms (ie. solaris 8).
- env.CORE_COMMAND = '${PERL} ${srcdir}/selftest/selftest.pl --target=samba --prefix=${SELFTEST_PREFIX} --srcdir=${srcdir} --exclude=${srcdir}/selftest/skip ${TESTLISTS} ${OPTIONS} ${TESTS}'
+ env.CORE_COMMAND = '${PERL} ${srcdir}/selftest/selftest.pl --target=${SELFTEST_TARGET} --prefix=${SELFTEST_PREFIX} --srcdir=${srcdir} --exclude=${srcdir}/selftest/skip ${TESTLISTS} ${OPTIONS} ${TESTS}'
if Options.options.LIST:
cmd = '${CORE_COMMAND} --list'
else:
if (os.environ.get('RUN_FROM_BUILD_FARM') is None and
not Options.options.FILTERED_SUBUNIT):
cmd += ' | tee ${SELFTEST_PREFIX}/subunit | ${FORMAT_TEST_OUTPUT}'
+ else:
+ cmd += ' | ${FILTER_OPTIONS}'
runcmd = EXPAND_VARIABLES(opt, cmd)
print("test: running %s" % runcmd)