|
|
@ -20,6 +20,7 @@ class SimpleConfig(object): |
|
|
|
def __init__(self, config): |
|
|
|
def __init__(self, config): |
|
|
|
self.build_config = config |
|
|
|
self.build_config = config |
|
|
|
self.maxjobs = 32 * multiprocessing.cpu_count() |
|
|
|
self.maxjobs = 32 * multiprocessing.cpu_count() |
|
|
|
|
|
|
|
self.allow_hashing = (config != 'gcov') |
|
|
|
|
|
|
|
|
|
|
|
def run_command(self, binary): |
|
|
|
def run_command(self, binary): |
|
|
|
return [binary] |
|
|
|
return [binary] |
|
|
@ -32,11 +33,43 @@ class ValgrindConfig(object): |
|
|
|
self.build_config = config |
|
|
|
self.build_config = config |
|
|
|
self.tool = tool |
|
|
|
self.tool = tool |
|
|
|
self.maxjobs = 4 * multiprocessing.cpu_count() |
|
|
|
self.maxjobs = 4 * multiprocessing.cpu_count() |
|
|
|
|
|
|
|
self.allow_hashing = False |
|
|
|
|
|
|
|
|
|
|
|
def run_command(self, binary): |
|
|
|
def run_command(self, binary): |
|
|
|
return ['valgrind', binary, '--tool=%s' % self.tool] |
|
|
|
return ['valgrind', binary, '--tool=%s' % self.tool] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CLanguage(object): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, make_target): |
|
|
|
|
|
|
|
self.allow_hashing = True |
|
|
|
|
|
|
|
self.make_target = make_target |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_binaries(self, config): |
|
|
|
|
|
|
|
return glob.glob('bins/%s/*_test' % config) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_targets(self): |
|
|
|
|
|
|
|
return ['buildtests_%s' % self.make_target] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_steps(self): |
|
|
|
|
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PhpLanguage(object): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self): |
|
|
|
|
|
|
|
self.allow_hashing = False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_binaries(self, config): |
|
|
|
|
|
|
|
return ['src/php/bin/run_tests.sh'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_targets(self): |
|
|
|
|
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_steps(self): |
|
|
|
|
|
|
|
return [['tools/run_tests/build_php.sh']] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# different configurations we can run under |
|
|
|
# different configurations we can run under |
|
|
|
_CONFIGS = { |
|
|
|
_CONFIGS = { |
|
|
|
'dbg': SimpleConfig('dbg'), |
|
|
|
'dbg': SimpleConfig('dbg'), |
|
|
@ -51,9 +84,10 @@ _CONFIGS = { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_DEFAULT = ['dbg', 'opt'] |
|
|
|
_DEFAULT = ['dbg', 'opt'] |
|
|
|
_LANGUAGE_TEST_TARGETS = { |
|
|
|
_LANGUAGES = { |
|
|
|
'c++': 'buildtests_cxx', |
|
|
|
'c++': CLanguage('cxx'), |
|
|
|
'c': 'buildtests_c', |
|
|
|
'c': CLanguage('c'), |
|
|
|
|
|
|
|
'php': PhpLanguage() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# parse command line |
|
|
|
# parse command line |
|
|
@ -62,7 +96,6 @@ argp.add_argument('-c', '--config', |
|
|
|
choices=['all'] + sorted(_CONFIGS.keys()), |
|
|
|
choices=['all'] + sorted(_CONFIGS.keys()), |
|
|
|
nargs='+', |
|
|
|
nargs='+', |
|
|
|
default=_DEFAULT) |
|
|
|
default=_DEFAULT) |
|
|
|
argp.add_argument('-t', '--test-filter', nargs='*', default=['*']) |
|
|
|
|
|
|
|
argp.add_argument('-n', '--runs_per_test', default=1, type=int) |
|
|
|
argp.add_argument('-n', '--runs_per_test', default=1, type=int) |
|
|
|
argp.add_argument('-f', '--forever', |
|
|
|
argp.add_argument('-f', '--forever', |
|
|
|
default=False, |
|
|
|
default=False, |
|
|
@ -73,9 +106,9 @@ argp.add_argument('--newline_on_success', |
|
|
|
action='store_const', |
|
|
|
action='store_const', |
|
|
|
const=True) |
|
|
|
const=True) |
|
|
|
argp.add_argument('-l', '--language', |
|
|
|
argp.add_argument('-l', '--language', |
|
|
|
choices=sorted(_LANGUAGE_TEST_TARGETS.keys()), |
|
|
|
choices=sorted(_LANGUAGES.keys()), |
|
|
|
nargs='+', |
|
|
|
nargs='+', |
|
|
|
default=sorted(_LANGUAGE_TEST_TARGETS.keys())) |
|
|
|
default=sorted(_LANGUAGES.keys())) |
|
|
|
args = argp.parse_args() |
|
|
|
args = argp.parse_args() |
|
|
|
|
|
|
|
|
|
|
|
# grab config |
|
|
|
# grab config |
|
|
@ -84,8 +117,18 @@ run_configs = set(_CONFIGS[cfg] |
|
|
|
_CONFIGS.iterkeys() if x == 'all' else [x] |
|
|
|
_CONFIGS.iterkeys() if x == 'all' else [x] |
|
|
|
for x in args.config)) |
|
|
|
for x in args.config)) |
|
|
|
build_configs = set(cfg.build_config for cfg in run_configs) |
|
|
|
build_configs = set(cfg.build_config for cfg in run_configs) |
|
|
|
make_targets = set(_LANGUAGE_TEST_TARGETS[x] for x in args.language) |
|
|
|
|
|
|
|
filters = args.test_filter |
|
|
|
make_targets = [] |
|
|
|
|
|
|
|
languages = set(_LANGUAGES[l] for l in args.language) |
|
|
|
|
|
|
|
build_steps = [['make', |
|
|
|
|
|
|
|
'-j', '%d' % (multiprocessing.cpu_count() + 1), |
|
|
|
|
|
|
|
'CONFIG=%s' % cfg] + list(set( |
|
|
|
|
|
|
|
itertools.chain.from_iterable(l.make_targets() |
|
|
|
|
|
|
|
for l in languages))) |
|
|
|
|
|
|
|
for cfg in build_configs] + list( |
|
|
|
|
|
|
|
itertools.chain.from_iterable(l.build_steps() |
|
|
|
|
|
|
|
for l in languages)) |
|
|
|
|
|
|
|
|
|
|
|
runs_per_test = args.runs_per_test |
|
|
|
runs_per_test = args.runs_per_test |
|
|
|
forever = args.forever |
|
|
|
forever = args.forever |
|
|
|
|
|
|
|
|
|
|
@ -127,26 +170,19 @@ class TestCache(object): |
|
|
|
def _build_and_run(check_cancelled, newline_on_success, cache): |
|
|
|
def _build_and_run(check_cancelled, newline_on_success, cache): |
|
|
|
"""Do one pass of building & running tests.""" |
|
|
|
"""Do one pass of building & running tests.""" |
|
|
|
# build latest, sharing cpu between the various makes |
|
|
|
# build latest, sharing cpu between the various makes |
|
|
|
if not jobset.run( |
|
|
|
if not jobset.run(build_steps): |
|
|
|
(['make', |
|
|
|
|
|
|
|
'-j', '%d' % (multiprocessing.cpu_count() + 1), |
|
|
|
|
|
|
|
'CONFIG=%s' % cfg] + list(make_targets) |
|
|
|
|
|
|
|
for cfg in build_configs), |
|
|
|
|
|
|
|
check_cancelled, maxjobs=1): |
|
|
|
|
|
|
|
return 1 |
|
|
|
return 1 |
|
|
|
|
|
|
|
|
|
|
|
# run all the tests |
|
|
|
# run all the tests |
|
|
|
if not jobset.run( |
|
|
|
one_run = dict( |
|
|
|
itertools.ifilter( |
|
|
|
(' '.join(config.run_command(x)), config.run_command(x)) |
|
|
|
lambda x: x is not None, ( |
|
|
|
|
|
|
|
config.run_command(x) |
|
|
|
|
|
|
|
for config in run_configs |
|
|
|
for config in run_configs |
|
|
|
for filt in filters |
|
|
|
for language in args.language |
|
|
|
for x in itertools.chain.from_iterable(itertools.repeat( |
|
|
|
for x in _LANGUAGES[language].test_binaries(config.build_config) |
|
|
|
glob.glob('bins/%s/%s_test' % ( |
|
|
|
).values() |
|
|
|
config.build_config, filt)), |
|
|
|
all_runs = itertools.chain.from_iterable( |
|
|
|
runs_per_test)))), |
|
|
|
itertools.repeat(one_run, runs_per_test)) |
|
|
|
check_cancelled, |
|
|
|
if not jobset.run(all_runs, check_cancelled, |
|
|
|
newline_on_success=newline_on_success, |
|
|
|
newline_on_success=newline_on_success, |
|
|
|
maxjobs=min(c.maxjobs for c in run_configs), |
|
|
|
maxjobs=min(c.maxjobs for c in run_configs), |
|
|
|
cache=cache): |
|
|
|
cache=cache): |
|
|
@ -155,9 +191,9 @@ def _build_and_run(check_cancelled, newline_on_success, cache): |
|
|
|
return 0 |
|
|
|
return 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_cache = (None if runs_per_test != 1 |
|
|
|
test_cache = (None |
|
|
|
or 'gcov' in build_configs |
|
|
|
if not all(x.allow_hashing |
|
|
|
or 'valgrind' in build_configs |
|
|
|
for x in itertools.chain(languages, run_configs)) |
|
|
|
else TestCache()) |
|
|
|
else TestCache()) |
|
|
|
if test_cache: |
|
|
|
if test_cache: |
|
|
|
test_cache.maybe_load() |
|
|
|
test_cache.maybe_load() |
|
|
@ -177,6 +213,7 @@ if forever: |
|
|
|
'All tests are now passing properly', |
|
|
|
'All tests are now passing properly', |
|
|
|
do_newline=True) |
|
|
|
do_newline=True) |
|
|
|
jobset.message('IDLE', 'No change detected') |
|
|
|
jobset.message('IDLE', 'No change detected') |
|
|
|
|
|
|
|
if test_cache: test_cache.save() |
|
|
|
while not have_files_changed(): |
|
|
|
while not have_files_changed(): |
|
|
|
time.sleep(1) |
|
|
|
time.sleep(1) |
|
|
|
else: |
|
|
|
else: |
|
|
@ -187,5 +224,5 @@ else: |
|
|
|
jobset.message('SUCCESS', 'All tests passed', do_newline=True) |
|
|
|
jobset.message('SUCCESS', 'All tests passed', do_newline=True) |
|
|
|
else: |
|
|
|
else: |
|
|
|
jobset.message('FAILED', 'Some tests failed', do_newline=True) |
|
|
|
jobset.message('FAILED', 'Some tests failed', do_newline=True) |
|
|
|
test_cache.save() |
|
|
|
if test_cache: test_cache.save() |
|
|
|
sys.exit(result) |
|
|
|
sys.exit(result) |
|
|
|