summaryrefslogtreecommitdiff
path: root/source4/selftest/wscript
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-03-17 15:22:36 +1100
committerAndrew Tridgell <tridge@samba.org>2010-04-06 20:26:50 +1000
commit495c5e2c834536ee933c9991648fcea9f1cad142 (patch)
treeeb9932375ca5026b7bb6dc589dcf37b94517520a /source4/selftest/wscript
parenta559edf9067a1ecc0972c88961ed697ec5836490 (diff)
downloadsamba-495c5e2c834536ee933c9991648fcea9f1cad142.tar.gz
samba-495c5e2c834536ee933c9991648fcea9f1cad142.tar.bz2
samba-495c5e2c834536ee933c9991648fcea9f1cad142.zip
build: added a lot more options to waf test
Diffstat (limited to 'source4/selftest/wscript')
-rw-r--r--source4/selftest/wscript94
1 files changed, 74 insertions, 20 deletions
diff --git a/source4/selftest/wscript b/source4/selftest/wscript
index e6628fd0a4..98b9a3924d 100644
--- a/source4/selftest/wscript
+++ b/source4/selftest/wscript
@@ -1,40 +1,94 @@
# selftest main code.
-import Scripting, os, Options, Utils, Environment, optparse
+import Scripting, os, Options, Utils, Environment, optparse, sys
+
+def set_options(opt):
+ opt.ADD_COMMAND('test', cmd_test)
+ opt.ADD_COMMAND('testonly', cmd_testonly)
+
+ gr = opt.add_option_group('test options')
+
+ gr.add_option('--tests',
+ help=("wildcard pattern of tests to run"),
+ action="store", dest='TESTS', default='')
+ 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)
def cmd_testonly(opt):
+ '''run tests without doing a build first'''
env = Environment.Environment()
- env.TESTS = Options.options.TESTS
+ env.TESTS = Options.options.TESTS
+ env.PERL = 'perl -W'
+ env.PYTHON = 'python'
+
+ env.TEST_FORMAT = 'plain'
+ env.SUBUNIT_FORMATTER = '${PERL} ../selftest/format-subunit.pl --prefix=./st --format=${TEST_FORMAT} --immediate'
+ env.FILTER_XFAIL = '${PERL} ../selftest/filter-subunit.pl --expected-failures=./selftest/knownfail'
+ env.FORMAT_TEST_OUTPUT = '${SUBUNIT_FORMATTER}'
env.OPTIONS = ''
+ if not Options.options.SLOWTEST:
+ env.OPTIONS += ' --exclude=./selftest/slow'
if Options.options.QUICKTEST:
- env.OPTIONS += '--exclude=./selftest/slow --quick --include=./selftest/quick'
+ env.OPTIONS += ' --quick --include=./selftest/quick'
+
+ if Options.options.TESTENV:
+ env.OPTIONS += ' --testenv'
+
+ 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} | ${FORMAT_TEST_OUTPUT}'
+
+ 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
+
+ if Options.options.VALGRIND_SERVER:
+ os.environ['SAMBA_VALGRIND'] = 'xterm -n server -e ../selftest/valgrind_run A=B '
- SELFTEST = 'PYTHON=/usr/bin/python perl -W ../selftest/selftest.pl --prefix=./st --builddir=. --srcdir=. --exclude=./selftest/skip --testlist="./selftest/tests.sh|" ${OPTIONS} --socket-wrapper ${TESTS} | perl -W ../selftest/filter-subunit.pl --expected-failures=./selftest/knownfail | /usr/bin/perl -W ../selftest/format-subunit.pl --prefix=./st --format=plain --immediate'
+ st_done = 'st/st_done'
+ if os.path.exists(st_done):
+ os.unlink(st_done)
+
+ cmd = '(PYTHON=/usr/bin/python perl -W ../selftest/selftest.pl --prefix=./st --builddir=. --srcdir=. --exclude=./selftest/skip --testlist="./selftest/tests.sh|" ${OPTIONS} --socket-wrapper ${TESTS} | ${FILTER_OPTIONS}) && touch st/st_done'
+
+ while cmd.find('${') != -1:
+ cmd = Utils.subst_vars(cmd, env)
- cmd = Utils.subst_vars(SELFTEST, env)
print "test: running %s" % cmd
ret = os.system(cmd)
+ if ret != 0:
+ print("test failed with exit code %d" % ret)
+ sys.exit(ret)
+
+ if not os.path.exists(st_done):
+ print("test command failed to complete")
+ sys.exit(1)
+
########################################################################
# main test entry point
def cmd_test(opt):
- '''Run the quick test suite'''
- print "Starting quick test"
+ '''Run the test suite (see test options below)'''
Scripting.commands.append('build')
Scripting.commands.append('testonly')
-
-def set_options(opt):
- opt.ADD_COMMAND('test', cmd_test)
- opt.ADD_COMMAND('testonly', cmd_testonly)
-
- gr = opt.add_option_group('test options')
-
- gr.add_option('--tests',
- help=("wildcard pattern of tests to run"),
- action="store", dest='TESTS', default='')
- gr.add_option('--quick',
- help=("enable only quick tests"),
- action="store_true", dest='QUICKTEST', default=False)