summaryrefslogtreecommitdiff
path: root/source4/selftest
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-04-15 16:42:35 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-04-16 11:43:04 +0200
commit47b7c6fccf944ae2ae4bdbfa983adfa1d12204df (patch)
tree4a2dee31824e8b55925098b45ea0e0966a53084b /source4/selftest
parent1870d254956ec56b8116a923adc38f8aae675963 (diff)
downloadsamba-47b7c6fccf944ae2ae4bdbfa983adfa1d12204df.tar.gz
samba-47b7c6fccf944ae2ae4bdbfa983adfa1d12204df.tar.bz2
samba-47b7c6fccf944ae2ae4bdbfa983adfa1d12204df.zip
selftest: Move Samba4 selftest wscript to the top level
Diffstat (limited to 'source4/selftest')
-rw-r--r--source4/selftest/wscript201
1 files changed, 0 insertions, 201 deletions
diff --git a/source4/selftest/wscript b/source4/selftest/wscript
deleted file mode 100644
index 2bc2d4005b..0000000000
--- a/source4/selftest/wscript
+++ /dev/null
@@ -1,201 +0,0 @@
-#!/usr/bin/env python
-# vim: expandtab ft=python
-
-# selftest main code.
-
-import Scripting, os, Options, Utils, Environment, optparse, sys
-from samba_utils import *
-from samba_autoconf import *
-
-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('--with-selftest-prefix',
- help=("specify location of selftest directory (default=./st)"),
- action="store", dest='SELFTEST_PREFIX', default='./st')
-
- opt.ADD_COMMAND('test', cmd_test)
- opt.ADD_COMMAND('testonly', cmd_testonly)
-
- gr = opt.add_option_group('test options')
-
- gr.add_option('--load-list',
- help=("Load a test id list from a text file"),
- action="store", dest='LOAD_LIST', default=None)
- gr.add_option('--list',
- help=("List available tests"),
- action="store_true", dest='LIST', default=False)
- gr.add_option('--tests',
- help=("wildcard pattern of tests to run"),
- action="store", dest='TESTS', default='')
- gr.add_option('--filtered-subunit',
- help=("output (xfail) filtered subunit"),
- action="store_true", dest='FILTERED_SUBUNIT', default=False)
- gr.add_option('--quick',
- help=("enable only quick tests"),
- action="store_true", dest='QUICKTEST', default=False)
- gr.add_option('--slow',
- help=("enable the really slow tests"),
- action="store_true", dest='SLOWTEST', default=False)
- gr.add_option('--testenv',
- help=("start a terminal with the test environment setup"),
- action="store_true", dest='TESTENV', default=False)
- gr.add_option('--valgrind',
- help=("use valgrind on client programs in the tests"),
- action="store_true", dest='VALGRIND', default=False)
- gr.add_option('--valgrind-log',
- help=("where to put the valgrind log"),
- action="store", dest='VALGRINDLOG', default=None)
- gr.add_option('--valgrind-server',
- help=("use valgrind on the server in the tests (opens an xterm)"),
- action="store_true", dest='VALGRIND_SERVER', default=False)
- gr.add_option('--screen',
- help=("run the samba servers in screen sessions"),
- action="store_true", dest='SCREEN', default=False)
- gr.add_option('--gdbtest',
- help=("run the servers within a gdb window"),
- action="store_true", dest='GDBTEST', default=False)
- gr.add_option('--fail-immediately',
- help=("stop tests on first failure"),
- action="store_true", dest='FAIL_IMMEDIATELY', default=False)
- gr.add_option('--socket-wrapper-pcap',
- help=("create a pcap file for each failing test"),
- action="store_true", dest='SOCKET_WRAPPER_PCAP', default=False)
- 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)
-
-def configure(conf):
- conf.env.SELFTEST_PREFIX = Options.options.SELFTEST_PREFIX
-
-def cmd_testonly(opt):
- '''run tests without doing a build first'''
- env = LOAD_ENVIRONMENT()
- opt.env = env
-
- if (not CONFIG_SET(opt, 'NSS_WRAPPER') or
- not CONFIG_SET(opt, 'UID_WRAPPER') or
- not CONFIG_SET(opt, 'SOCKET_WRAPPER')):
- print("ERROR: You must use --enable-selftest to enable selftest")
- sys.exit(1)
-
- os.environ['SAMBA_SELFTEST'] = '1'
-
- env.TESTS = Options.options.TESTS
-
- env.SUBUNIT_FORMATTER = os.getenv('SUBUNIT_FORMATTER')
- if not env.SUBUNIT_FORMATTER:
- env.SUBUNIT_FORMATTER = '${PYTHON} -u ${srcdir}/selftest/format-subunit --prefix=${SELFTEST_PREFIX} --immediate'
- env.FILTER_XFAIL = '${PYTHON} -u ${srcdir}/selftest/filter-subunit --expected-failures=${srcdir}/source4/selftest/knownfail'
-
- if Options.options.FAIL_IMMEDIATELY:
- env.FILTER_XFAIL += ' --fail-immediately'
-
- env.FORMAT_TEST_OUTPUT = '${SUBUNIT_FORMATTER}'
-
- # clean any previous temporary files
- os.system("rm -rf %s/tmp" % env.SELFTEST_PREFIX);
-
- # 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, ''))
-
- env.OPTIONS = '--binary-mapping=smbtorture4:smbtorture'
- if not Options.options.SLOWTEST:
- env.OPTIONS += ' --exclude=${srcdir}/source4/selftest/slow'
- if Options.options.QUICKTEST:
- env.OPTIONS += ' --quick --include=${srcdir}/source4/selftest/quick'
- if Options.options.LOAD_LIST:
- env.OPTIONS += ' --load-list=%s' % Options.options.LOAD_LIST
- if Options.options.TESTENV:
- env.OPTIONS += ' --testenv'
- if Options.options.SOCKET_WRAPPER_PCAP:
- env.OPTIONS += ' --socket-wrapper-pcap'
- if Options.options.SOCKET_WRAPPER_KEEP_PCAP:
- env.OPTIONS += ' --socket-wrapper-keep-pcap'
- if Options.options.LIST:
- env.OPTIONS += ' --list'
- if os.environ.get('RUN_FROM_BUILD_FARM') is not None:
- env.FILTER_OPTIONS = '${FILTER_XFAIL} --strip-passed-output'
- else:
- env.FILTER_OPTIONS = '${FILTER_XFAIL}'
-
- if Options.options.VALGRIND:
- os.environ['VALGRIND'] = 'valgrind -q --num-callers=30'
- if Options.options.VALGRINDLOG is not None:
- os.environ['VALGRIND'] += ' --log-file=%s' % Options.options.VALGRINDLOG
-
- server_wrapper=''
-
- if Options.options.VALGRIND_SERVER:
- server_wrapper = '${srcdir}/selftest/valgrind_run _DUMMY=X'
- elif Options.options.GDBTEST:
- server_wrapper = '${srcdir}/selftest/gdb_run _DUMMY=X'
-
- if Options.options.SCREEN:
- server_wrapper = '${srcdir}/selftest/in_screen %s' % server_wrapper
- os.environ['TERMINAL'] = EXPAND_VARIABLES(opt, '${srcdir}/selftest/in_screen')
- elif server_wrapper != '':
- server_wrapper = 'xterm -n server -l -e %s' % server_wrapper
-
- if server_wrapper != '':
- os.environ['SAMBA_VALGRIND'] = EXPAND_VARIABLES(opt, server_wrapper)
-
- # this is needed for systems without rpath, or with rpath disabled
- ADD_LD_LIBRARY_PATH('bin/shared')
- ADD_LD_LIBRARY_PATH('bin/shared/private')
-
- # if we are using a system version of ldb then we need to tell it to
- # load modules from our modules path
- if env.USING_SYSTEM_LDB:
- os.environ['LDB_MODULES_PATH'] = 'bin/modules/ldb'
-
- # tell build system where to find config.h
- config_paths = [ 'bin/default/source4/include/config.h',
- 'bin/default/include/config.h' ]
- for p in config_paths:
- if os.path.exists(p):
- os.environ['CONFIG_H'] = p
- break
-
- st_done = os.path.join(env.SELFTEST_PREFIX, 'st_done')
- if os.path.exists(st_done):
- os.unlink(st_done)
-
- if not os.path.isdir(env.SELFTEST_PREFIX):
- os.makedirs(env.SELFTEST_PREFIX, int('755', 8))
-
- # We use the full path rather than relative path because it cause problems on some plateforms (ie. solaris 8).
- cmd = '(${PERL} ${srcdir}/selftest/selftest.pl --prefix=${SELFTEST_PREFIX} --srcdir=${srcdir} --exclude=${srcdir}/source4/selftest/skip --testlist="${PYTHON} ${srcdir}/source4/selftest/tests.py|" ${OPTIONS} --socket-wrapper ${TESTS} && touch ${SELFTEST_PREFIX}/st_done) | ${FILTER_OPTIONS} | tee ${SELFTEST_PREFIX}/subunit'
- if os.environ.get('RUN_FROM_BUILD_FARM') is None and not Options.options.FILTERED_SUBUNIT:
- cmd += ' | ${FORMAT_TEST_OUTPUT}'
- else:
- cmd += ' | ${PYTHON} -u ${srcdir}/selftest/filter-subunit'
- cmd = EXPAND_VARIABLES(opt, cmd)
-
- print("test: running %s" % cmd)
- ret = RUN_COMMAND(cmd, env=env)
- if os.path.exists(".testrepository"):
- # "testr load -q" isn't
- cmd = 'testr load -q < ${SELFTEST_PREFIX}/subunit > /dev/null'
- cmd = EXPAND_VARIABLES(opt, cmd)
- RUN_COMMAND(cmd, env=env)
-
- if ret != 0:
- print("ERROR: test failed with exit code %d" % ret)
- sys.exit(ret)
-
- if not os.path.exists(st_done):
- print("ERROR: test command failed to complete")
- sys.exit(1)
-
-
-########################################################################
-# main test entry point
-def cmd_test(opt):
- '''Run the test suite (see test options below)'''
- Scripting.commands.append('build')
- Scripting.commands.append('testonly')