| 1 |
#!/usr/bin/env python |
| 2 |
# vim: expandtab ft=python |
| 3 |
|
| 4 |
# selftest main code. |
| 5 |
|
| 6 |
import sys |
| 7 |
import os |
| 8 |
from waflib import Options, Utils |
| 9 |
|
| 10 |
from samba_utils import ( |
| 11 |
ADD_LD_LIBRARY_PATH, |
| 12 |
CHECK_MAKEFLAGS, |
| 13 |
EXPAND_VARIABLES, |
| 14 |
LOAD_ENVIRONMENT, |
| 15 |
RUN_COMMAND, |
| 16 |
) |
| 17 |
from samba_autoconf import CONFIG_GET, CONFIG_SET |
| 18 |
import types |
| 19 |
|
| 20 |
DEFAULT_SELFTEST_PREFIX="./st" |
| 21 |
|
| 22 |
def options(opt): |
| 23 |
|
| 24 |
opt.add_option('--enable-selftest', |
| 25 |
help=("enable options necessary for selftest (default=no)"), |
| 26 |
action="store_true", dest='enable_selftest', default=False) |
| 27 |
opt.add_option('--with-selftest-prefix', |
| 28 |
help=("specify location of selftest directory " |
| 29 |
"(default=%s)" % DEFAULT_SELFTEST_PREFIX), |
| 30 |
action="store", dest='SELFTEST_PREFIX', default=DEFAULT_SELFTEST_PREFIX) |
| 31 |
|
| 32 |
opt.ADD_COMMAND('test', cmd_test) |
| 33 |
opt.ADD_COMMAND('testonly', cmd_testonly) |
| 34 |
|
| 35 |
gr = opt.add_option_group('test options') |
| 36 |
|
| 37 |
gr.add_option('--load-list', |
| 38 |
help=("Load a test id list from a text file"), |
| 39 |
action="store", dest='LOAD_LIST', default=None) |
| 40 |
gr.add_option('--list', |
| 41 |
help=("List available tests"), |
| 42 |
action="store_true", dest='LIST', default=False) |
| 43 |
gr.add_option('--tests', |
| 44 |
help=("wildcard pattern of tests to run"), |
| 45 |
action="store", dest='TESTS', default='') |
| 46 |
gr.add_option('--filtered-subunit', |
| 47 |
help=("output (xfail) filtered subunit"), |
| 48 |
action="store_true", dest='FILTERED_SUBUNIT', default=False) |
| 49 |
gr.add_option('--quick', |
| 50 |
help=("enable only quick tests"), |
| 51 |
action="store_true", dest='QUICKTEST', default=False) |
| 52 |
gr.add_option('--slow', |
| 53 |
help=("enable the really slow tests"), |
| 54 |
action="store_true", dest='SLOWTEST', default=False) |
| 55 |
gr.add_option('--nb-slowest', |
| 56 |
help=("Show the n slowest tests (default=10)"), |
| 57 |
type=int, default=10, dest='NB_SLOWEST') |
| 58 |
gr.add_option('--testenv', |
| 59 |
help=("start a terminal with the test environment setup"), |
| 60 |
action="store_true", dest='TESTENV', default=False) |
| 61 |
gr.add_option('--valgrind', |
| 62 |
help=("use valgrind on client programs in the tests"), |
| 63 |
action="store_true", dest='VALGRIND', default=False) |
| 64 |
gr.add_option('--valgrind-log', |
| 65 |
help=("where to put the valgrind log"), |
| 66 |
action="store", dest='VALGRINDLOG', default=None) |
| 67 |
gr.add_option('--valgrind-server', |
| 68 |
help=("use valgrind on the server in the tests (opens an xterm)"), |
| 69 |
action="store_true", dest='VALGRIND_SERVER', default=False) |
| 70 |
gr.add_option('--screen', |
| 71 |
help=("run the samba servers in screen sessions"), |
| 72 |
action="store_true", dest='SCREEN', default=False) |
| 73 |
gr.add_option('--gdbtest', |
| 74 |
help=("run the servers within a gdb window"), |
| 75 |
action="store_true", dest='GDBTEST', default=False) |
| 76 |
gr.add_option('--fail-immediately', |
| 77 |
help=("stop tests on first failure"), |
| 78 |
action="store_true", dest='FAIL_IMMEDIATELY', default=False) |
| 79 |
gr.add_option('--socket-wrapper-pcap', |
| 80 |
help=("create a pcap file for each failing test"), |
| 81 |
action="store_true", dest='SOCKET_WRAPPER_PCAP', default=False) |
| 82 |
gr.add_option('--socket-wrapper-keep-pcap', |
| 83 |
help=("create a pcap file for all individual test"), |
| 84 |
action="store_true", dest='SOCKET_WRAPPER_KEEP_PCAP', default=False) |
| 85 |
gr.add_option('--random-order', dest='RANDOM_ORDER', default=False, |
| 86 |
action="store_true", help="Run testsuites in random order") |
| 87 |
gr.add_option('--perf-test', dest='PERF_TEST', default=False, |
| 88 |
action="store_true", help="run performance tests only") |
| 89 |
gr.add_option('--test-list', dest='TEST_LIST', default='', |
| 90 |
help=("use tests listed here, not defaults " |
| 91 |
"(--test-list='FOO|' will execute FOO; " |
| 92 |
"--test-list='FOO' will read it)")) |
| 93 |
gr.add_option('--no-subunit-filter', |
| 94 |
help=("no (xfail) subunit filtering"), |
| 95 |
action="store_true", dest='NO_SUBUNIT_FILTER', default=False) |
| 96 |
|
| 97 |
|
| 98 |
def configure(conf): |
| 99 |
conf.env.SELFTEST_PREFIX = Options.options.SELFTEST_PREFIX |
| 100 |
if Options.options.enable_selftest or Options.options.developer: |
| 101 |
conf.DEFINE('ENABLE_SELFTEST', 1) |
| 102 |
|
| 103 |
|
| 104 |
def cmd_testonly(opt): |
| 105 |
'''run tests without doing a build first''' |
| 106 |
env = LOAD_ENVIRONMENT() |
| 107 |
opt.env = env |
| 108 |
|
| 109 |
if Options.options.SELFTEST_PREFIX != DEFAULT_SELFTEST_PREFIX: |
| 110 |
env.SELFTEST_PREFIX = Options.options.SELFTEST_PREFIX |
| 111 |
|
| 112 |
if (not CONFIG_SET(opt, 'NSS_WRAPPER') or |
| 113 |
not CONFIG_SET(opt, 'UID_WRAPPER') or |
| 114 |
not CONFIG_SET(opt, 'SOCKET_WRAPPER')): |
| 115 |
print("ERROR: You must use --enable-selftest to enable selftest") |
| 116 |
sys.exit(1) |
| 117 |
|
| 118 |
os.environ['SAMBA_SELFTEST'] = '1' |
| 119 |
|
| 120 |
env.TESTS = Options.options.TESTS |
| 121 |
|
| 122 |
env.SUBUNIT_FORMATTER = os.getenv('SUBUNIT_FORMATTER') |
| 123 |
|
| 124 |
# Lots of test scripts need to run with the correct version |
| 125 |
# of python. With the correct shebang the script should run with the |
| 126 |
# correct version, the problem is that not all scripts are part |
| 127 |
# of the installation, some scripts are part of the source code, |
| 128 |
# and the shebang is not dynamically generated as yet. |
| 129 |
# It is safer if we are somewhat version neutral at the moment and |
| 130 |
# ignore the shebang and always run scripts from the test environment |
| 131 |
# with the python version (determined by PYTHON env variable) If this |
| 132 |
# env variable isn't set then set it according to the python version |
| 133 |
# that is running the tests |
| 134 |
if not os.getenv('PYTHON', None): |
| 135 |
from sys import executable as exe |
| 136 |
os.environ['PYTHON'] = os.path.basename(exe) |
| 137 |
|
| 138 |
if not env.SUBUNIT_FORMATTER: |
| 139 |
if Options.options.PERF_TEST: |
| 140 |
env.SUBUNIT_FORMATTER = '${PYTHON} -u ${srcdir}/selftest/format-subunit-json --prefix=${SELFTEST_PREFIX}' |
| 141 |
else: |
| 142 |
env.SUBUNIT_FORMATTER = '${PYTHON} -u ${srcdir}/selftest/format-subunit --prefix=${SELFTEST_PREFIX} --immediate' |
| 143 |
env.FILTER_XFAIL = ('${PYTHON} -u ${srcdir}/selftest/filter-subunit ' |
| 144 |
'--expected-failures=${srcdir}/selftest/knownfail ' |
| 145 |
'--expected-failures=${srcdir}/selftest/knownfail.d ' |
| 146 |
'--expected-failures=${srcdir}/selftest/expectedfail.d ' |
| 147 |
'--flapping=${srcdir}/selftest/flapping ' |
| 148 |
'--flapping=${srcdir}/selftest/flapping.d') |
| 149 |
|
| 150 |
if Options.options.FAIL_IMMEDIATELY: |
| 151 |
env.FILTER_XFAIL += ' --fail-immediately' |
| 152 |
|
| 153 |
env.FORMAT_TEST_OUTPUT = '${SUBUNIT_FORMATTER}' |
| 154 |
|
| 155 |
# clean any previous temporary files |
| 156 |
os.system("rm -rf %s/tmp" % env.SELFTEST_PREFIX); |
| 157 |
|
| 158 |
# put all command line options in the environment as TESTENV_*=* |
| 159 |
for o in dir(Options.options): |
| 160 |
if o[0:1] != '_': |
| 161 |
val = getattr(Options.options, o, '') |
| 162 |
if not issubclass(type(val), types.FunctionType) \ |
| 163 |
and not issubclass(type(val), types.MethodType): |
| 164 |
os.environ['TESTENV_%s' % o.upper()] = str(getattr(Options.options, o, '')) |
| 165 |
|
| 166 |
env.OPTIONS = '' |
| 167 |
if not Options.options.SLOWTEST: |
| 168 |
env.OPTIONS += ' --exclude=${srcdir}/selftest/slow' |
| 169 |
if Options.options.QUICKTEST: |
| 170 |
env.OPTIONS += ' --quick --include=${srcdir}/selftest/quick' |
| 171 |
if Options.options.LOAD_LIST: |
| 172 |
env.OPTIONS += ' --load-list=%s' % Options.options.LOAD_LIST |
| 173 |
if Options.options.TESTENV: |
| 174 |
env.OPTIONS += ' --testenv' |
| 175 |
if Options.options.SOCKET_WRAPPER_PCAP: |
| 176 |
env.OPTIONS += ' --socket-wrapper-pcap' |
| 177 |
if Options.options.SOCKET_WRAPPER_KEEP_PCAP: |
| 178 |
env.OPTIONS += ' --socket-wrapper-keep-pcap' |
| 179 |
if Options.options.RANDOM_ORDER: |
| 180 |
env.OPTIONS += ' --random-order' |
| 181 |
if Options.options.PERF_TEST: |
| 182 |
env.FILTER_OPTIONS = ('${PYTHON} -u ${srcdir}/selftest/filter-subunit ' |
| 183 |
'--perf-test-output') |
| 184 |
else: |
| 185 |
env.FILTER_OPTIONS = '${FILTER_XFAIL}' |
| 186 |
|
| 187 |
if Options.options.VALGRIND: |
| 188 |
os.environ['VALGRIND'] = 'valgrind -q --num-callers=30' |
| 189 |
if Options.options.VALGRINDLOG is not None: |
| 190 |
os.environ['VALGRIND'] += ' --log-file=%s' % Options.options.VALGRINDLOG |
| 191 |
|
| 192 |
server_wrapper='' |
| 193 |
|
| 194 |
if Options.options.VALGRIND_SERVER: |
| 195 |
server_wrapper = '${srcdir}/selftest/valgrind_run _DUMMY=X' |
| 196 |
elif Options.options.GDBTEST: |
| 197 |
server_wrapper = '${srcdir}/selftest/gdb_run _DUMMY=X' |
| 198 |
|
| 199 |
if Options.options.SCREEN: |
| 200 |
server_wrapper = '${srcdir}/selftest/in_screen %s' % server_wrapper |
| 201 |
os.environ['TERMINAL'] = EXPAND_VARIABLES(opt, '${srcdir}/selftest/in_screen') |
| 202 |
elif server_wrapper != '': |
| 203 |
server_wrapper = 'xterm -n server -l -e %s' % server_wrapper |
| 204 |
|
| 205 |
if server_wrapper != '': |
| 206 |
os.environ['SAMBA_VALGRIND'] = EXPAND_VARIABLES(opt, server_wrapper) |
| 207 |
os.environ['NMBD_VALGRIND'] = EXPAND_VARIABLES(opt, server_wrapper) |
| 208 |
os.environ['WINBINDD_VALGRIND'] = EXPAND_VARIABLES(opt, server_wrapper) |
| 209 |
os.environ['SMBD_VALGRIND'] = EXPAND_VARIABLES(opt, server_wrapper) |
| 210 |
os.environ['SAMBA_DCERPCD_VALGRIND'] = EXPAND_VARIABLES(opt, server_wrapper) |
| 211 |
|
| 212 |
# this is needed for systems without rpath, or with rpath disabled |
| 213 |
ADD_LD_LIBRARY_PATH('bin/shared') |
| 214 |
ADD_LD_LIBRARY_PATH('bin/shared/private') |
| 215 |
|
| 216 |
# if we are using a system version of ldb then we need to tell it to |
| 217 |
# load modules from our modules path |
| 218 |
if env.USING_SYSTEM_LDB: |
| 219 |
os.environ['LDB_MODULES_PATH'] = os.path.abspath( |
| 220 |
os.path.join(*(env.cwd + ['bin/modules/ldb']))) |
| 221 |
|
| 222 |
# tell build system where to find config.h |
| 223 |
os.environ['CONFIG_H'] = 'bin/default/include/config.h' |
| 224 |
|
| 225 |
# tell the test system where perl is |
| 226 |
if isinstance(env.PERL, list): |
| 227 |
perl = ' '.join(env.PERL) |
| 228 |
else: |
| 229 |
perl = env.PERL |
| 230 |
os.environ['PERL'] = perl |
| 231 |
|
| 232 |
st_done = os.path.join(env.SELFTEST_PREFIX, 'st_done') |
| 233 |
if os.path.exists(st_done): |
| 234 |
os.unlink(st_done) |
| 235 |
|
| 236 |
if not os.path.isdir(env.SELFTEST_PREFIX): |
| 237 |
os.makedirs(env.SELFTEST_PREFIX, int('755', 8)) |
| 238 |
|
| 239 |
if Options.options.TEST_LIST: |
| 240 |
env.TESTLISTS = '--testlist=%r' % Options.options.TEST_LIST |
| 241 |
elif Options.options.PERF_TEST: |
| 242 |
env.TESTLISTS = '--testlist="${PYTHON} ${srcdir}/selftest/perf_tests.py|" ' |
| 243 |
else: |
| 244 |
env.TESTLISTS = ('--testlist="${PYTHON} ${srcdir}/selftest/tests.py|" ' + |
| 245 |
'--testlist="${PYTHON} ${srcdir}/source3/selftest/tests.py|" ' + |
| 246 |
'--testlist="${PYTHON} ${srcdir}/source4/selftest/tests.py|"') |
| 247 |
|
| 248 |
if CONFIG_SET(opt, 'AD_DC_BUILD_IS_ENABLED'): |
| 249 |
env.SELFTEST_TARGET = "samba" |
| 250 |
else: |
| 251 |
env.SELFTEST_TARGET = "samba3" |
| 252 |
|
| 253 |
env.OPTIONS += " --nss_wrapper_so_path=" + CONFIG_GET(opt, 'LIBNSS_WRAPPER_SO_PATH') |
| 254 |
env.OPTIONS += " --resolv_wrapper_so_path=" + CONFIG_GET(opt, 'LIBRESOLV_WRAPPER_SO_PATH') |
| 255 |
env.OPTIONS += " --uid_wrapper_so_path=" + CONFIG_GET(opt, 'LIBUID_WRAPPER_SO_PATH') |
| 256 |
env.OPTIONS += " --pam_wrapper_so_path=" + CONFIG_GET(opt, 'LIBPAM_WRAPPER_SO_PATH') |
| 257 |
env.OPTIONS += " --pam_matrix_so_path=" + CONFIG_GET(opt, 'PAM_MATRIX_SO_PATH') |
| 258 |
|
| 259 |
# selftest can optionally use kernel namespaces instead of socket-wrapper |
| 260 |
if os.environ.get('USE_NAMESPACES') is None: |
| 261 |
env.OPTIONS += " --socket_wrapper_so_path=" + CONFIG_GET(opt, 'LIBSOCKET_WRAPPER_SO_PATH') |
| 262 |
if CONFIG_SET(opt, 'QUIC_KO_WRAPPER'): |
| 263 |
env.OPTIONS += " --quic_ko_wrapper_so_path=" + CONFIG_GET(opt, 'LIBQUIC_KO_WRAPPER_SO_PATH') |
| 264 |
|
| 265 |
if not CONFIG_SET(opt, 'HAVE_RESOLV_CONF_SUPPORT'): |
| 266 |
env.OPTIONS += " --use-dns-faking" |
| 267 |
|
| 268 |
if CONFIG_GET(opt, 'USING_SYSTEM_KRB5'): |
| 269 |
env.OPTIONS += " --mitkrb5" |
| 270 |
|
| 271 |
if CONFIG_GET(opt, 'USING_SYSTEM_KRB5') and CONFIG_GET(opt, 'MIT_KDC_PATH'): |
| 272 |
env.OPTIONS += " --exclude=${srcdir}/selftest/skip_mit_kdc" |
| 273 |
env.FILTER_XFAIL += ( |
| 274 |
" --expected-failures=${srcdir}/selftest/knownfail_mit_kdc" |
| 275 |
" --expected-failures=${srcdir}/selftest/knownfail_mit_kdc.d" |
| 276 |
) |
| 277 |
else: |
| 278 |
env.FILTER_XFAIL += ( |
| 279 |
" --expected-failures=${srcdir}/selftest/knownfail_heimdal_kdc" |
| 280 |
" --expected-failures=${srcdir}/selftest/knownfail_heimdal_kdc.d" |
| 281 |
) |
| 282 |
|
| 283 |
if CONFIG_SET(opt, 'USING_EMBEDDED_HEIMDAL'): |
| 284 |
env.FILTER_XFAIL += " --expected-failures=${srcdir}/selftest/"\ |
| 285 |
"expectedfail_heimdal" |
| 286 |
|
| 287 |
if CONFIG_GET(opt, 'SIZEOF_VOID_P') == 4: |
| 288 |
env.FILTER_XFAIL += " --expected-failures=${srcdir}/selftest/knownfail-32bit" |
| 289 |
env.OPTIONS += " --default-ldb-backend=tdb --exclude=${srcdir}/selftest/skip-32bit" |
| 290 |
|
| 291 |
if not CONFIG_GET(opt, 'HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X'): |
| 292 |
# older MIT krb5 libraries (< 1.14) don't have |
| 293 |
# GSS_KRB5_CRED_NO_CI_FLAGS_X |
| 294 |
env.OPTIONS += " --exclude=${srcdir}/selftest/skip.no-GSS_KRB5_CRED_NO_CI_FLAGS_X" |
| 295 |
|
| 296 |
if os.environ.get('DISABLE_OPATH'): |
| 297 |
env.OPTIONS += " --exclude=${srcdir}/selftest/skip.opath-required" |
| 298 |
|
| 299 |
libasan = None |
| 300 |
if env.ADDRESS_SANITIZER: |
| 301 |
# We try to find the correct libasan automatically |
| 302 |
libasan = Utils.cmd_output( |
| 303 |
r'ldd bin/texpect | grep libasan| cut -f 3 -d \ ', |
| 304 |
silent=True).strip() |
| 305 |
libasan = libasan.decode('utf8') |
| 306 |
|
| 307 |
# Have the selftest.pl LD_PRELOAD libasan in the right spot |
| 308 |
env.OPTIONS += " --asan_so_path=" + libasan |
| 309 |
|
| 310 |
if CONFIG_SET(opt, 'HAVE_CRYPT_R'): |
| 311 |
# We try to find the correct libcrypt automatically |
| 312 |
libcrypt = Utils.cmd_output( |
| 313 |
'ldd bin/modules/ldb/password_hash.so | awk \'/libcrypt.so/ { print $3 }\'', |
| 314 |
silent=True).strip() |
| 315 |
libcrypt = libcrypt.decode('utf8') |
| 316 |
env.OPTIONS += " --crypt_so_path=" + libcrypt |
| 317 |
|
| 318 |
subunit_cache = None |
| 319 |
# We use the full path rather than relative path to avoid problems on some platforms (ie. solaris 8). |
| 320 |
env.CORE_COMMAND = '${PERL} ${srcdir}/selftest/selftest.pl --target=${SELFTEST_TARGET} --prefix=${SELFTEST_PREFIX} --srcdir=${srcdir} --exclude=${srcdir}/selftest/skip ${TESTLISTS} ${OPTIONS} ${TESTS}' |
| 321 |
|
| 322 |
# If using namespaces (rather than socket-wrapper), run the selftest script |
| 323 |
# in its own network namespace (by doing an 'unshare'). (To create a new |
| 324 |
# namespace as a non-root user, we have to also unshare the current user |
| 325 |
# namespace, and remap ourself as root in the namespace created) |
| 326 |
if os.environ.get('USE_NAMESPACES') is not None: |
| 327 |
env.CORE_COMMAND = 'unshare --net --user --map-root-user ' + env.CORE_COMMAND |
| 328 |
|
| 329 |
if env.ADDRESS_SANITIZER and libasan: |
| 330 |
# For now we cannot run with leak and odr detection |
| 331 |
asan_options = "ASAN_OPTIONS=detect_leaks=0" |
| 332 |
asan_options += ":detect_odr_violation=0" |
| 333 |
# uncomment if you need asan logs |
| 334 |
# asan_options += ":verbosity=111" |
| 335 |
asan_options += ":suppressions=${srcdir}/selftest/sanitizer/asan.supp" |
| 336 |
asan_options += " " |
| 337 |
|
| 338 |
# We need to disable RTLD_DEEPBIND in socket wrapper |
| 339 |
no_leak_check = "SOCKET_WRAPPER_DISABLE_DEEP_BIND=1" |
| 340 |
no_leak_check += " " |
| 341 |
env.CORE_COMMAND = asan_options + no_leak_check + env.CORE_COMMAND |
| 342 |
|
| 343 |
# We need to have the subunit filter and formatter preload |
| 344 |
# libasan otherwise the tests fail at startup. |
| 345 |
# |
| 346 |
# Also, we do not care about leaks in python |
| 347 |
|
| 348 |
asan_envs = (asan_options + no_leak_check + "LD_PRELOAD=" + libasan |
| 349 |
+ ' ') |
| 350 |
env.FILTER_OPTIONS = asan_envs + env.FILTER_OPTIONS |
| 351 |
env.SUBUNIT_FORMATTER = asan_envs + env.SUBUNIT_FORMATTER |
| 352 |
|
| 353 |
if env.UNDEFINED_SANITIZER: |
| 354 |
# print a stack trace with the error. |
| 355 |
print_stack_trace = "UBSAN_OPTIONS=print_stacktrace=1" |
| 356 |
print_stack_trace += ",suppressions=${srcdir}/selftest/ubsan.supp" |
| 357 |
env.CORE_COMMAND = print_stack_trace + " " + env.CORE_COMMAND |
| 358 |
|
| 359 |
if Options.options.LIST: |
| 360 |
cmd = '${CORE_COMMAND} --list' |
| 361 |
else: |
| 362 |
if CONFIG_SET(opt, 'QUIC_KO_WRAPPER'): |
| 363 |
env.OPTIONS += ' --quic-ko-wrapper' |
| 364 |
env.OPTIONS += ' --socket-wrapper' |
| 365 |
cmd = '(${CORE_COMMAND} && touch ${SELFTEST_PREFIX}/st_done) | ${FILTER_OPTIONS}' |
| 366 |
|
| 367 |
if Options.options.NO_SUBUNIT_FILTER: |
| 368 |
# Skip subunit filtering (i.e. because python is disabled). |
| 369 |
# Use --one to bail out upon any failure |
| 370 |
cmd = '(${CORE_COMMAND} --one && touch ${SELFTEST_PREFIX}/st_done)' |
| 371 |
elif not Options.options.FILTERED_SUBUNIT: |
| 372 |
subunit_cache = os.path.join(env.SELFTEST_PREFIX, "subunit") |
| 373 |
cmd += ' | tee %s | ${FORMAT_TEST_OUTPUT}' % subunit_cache |
| 374 |
else: |
| 375 |
cmd += ' | ${FILTER_OPTIONS}' |
| 376 |
|
| 377 |
runcmd = EXPAND_VARIABLES(opt, cmd) |
| 378 |
|
| 379 |
print("test: running %s" % runcmd) |
| 380 |
ret = RUN_COMMAND(cmd, env=env) |
| 381 |
|
| 382 |
if (os.path.exists(".testrepository") and |
| 383 |
not Options.options.LIST and |
| 384 |
not Options.options.LOAD_LIST and |
| 385 |
subunit_cache is not None): |
| 386 |
testrcmd = 'testr load -q < %s > /dev/null' % subunit_cache |
| 387 |
runcmd = EXPAND_VARIABLES(opt, testrcmd) |
| 388 |
RUN_COMMAND(runcmd, env=env) |
| 389 |
|
| 390 |
if subunit_cache is not None: |
| 391 |
nb = Options.options.NB_SLOWEST |
| 392 |
cmd = "./script/show_testsuite_time %s %d" % (subunit_cache, nb) |
| 393 |
runcmd = EXPAND_VARIABLES(opt, cmd) |
| 394 |
RUN_COMMAND(runcmd, env=env) |
| 395 |
|
| 396 |
if ret != 0: |
| 397 |
print("ERROR: test failed with exit code %d" % ret) |
| 398 |
sys.exit(ret) |
| 399 |
|
| 400 |
if not Options.options.LIST and not os.path.exists(st_done): |
| 401 |
print("ERROR: test command failed to complete") |
| 402 |
sys.exit(1) |
| 403 |
|
| 404 |
|
| 405 |
######################################################################## |
| 406 |
# main test entry point |
| 407 |
def cmd_test(opt): |
| 408 |
'''Run the test suite (see test options below)''' |
| 409 |
|
| 410 |
# if running all tests, then force a symbol check |
| 411 |
env = LOAD_ENVIRONMENT() |
| 412 |
CHECK_MAKEFLAGS(env) |
| 413 |
Options.commands.append('build') |
| 414 |
Options.commands.append('testonly') |