diff options
author | Jack Lloyd <[email protected]> | 2018-03-04 06:37:13 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-03-04 06:37:13 -0500 |
commit | c563f15c6fe7327c27a8f988e66dcf20ff23a523 (patch) | |
tree | 5e0f37e7caf70b9366aee9f91d18f44b3b9a43b1 /src/scripts/test_all_configs.py | |
parent | 9b2f336feba2aa0462a16625ab3cae34ce395f4a (diff) |
Rename build_tests.py to make it more obvious this is not for end users
GH #1456
Diffstat (limited to 'src/scripts/test_all_configs.py')
-rwxr-xr-x | src/scripts/test_all_configs.py | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/src/scripts/test_all_configs.py b/src/scripts/test_all_configs.py new file mode 100755 index 000000000..f90d7722e --- /dev/null +++ b/src/scripts/test_all_configs.py @@ -0,0 +1,119 @@ +#!/usr/bin/python + +""" +This configures and builds with many different sub-configurations +in an attempt to flush out missing feature macro checks, etc. + +There is probably no reason for you to run this. Unless you want to. + +(C) 2017 Jack Lloyd + +Botan is released under the Simplified BSD License (see license.txt) +""" + +import optparse # pylint: disable=deprecated-module +import sys +import subprocess + +def get_module_list(configure_py): + configure = subprocess.Popen([configure_py, '--list-modules'], stdout=subprocess.PIPE) + + (stdout, _) = configure.communicate() + + if configure.returncode != 0: + raise Exception("Running configure.py --list-modules failed") + + modules = [s.decode('ascii') for s in stdout.split()] + modules.remove('bearssl') # can't test + modules.remove('tpm') # can't test + modules.remove('base') # can't remove + return modules + +def get_concurrency(): + def_concurrency = 2 + + try: + import multiprocessing + return max(def_concurrency, multiprocessing.cpu_count()) + except ImportError: + return def_concurrency + +def try_to_run(cmdline): + print("Running %s ... " % (' '.join(cmdline))) + sys.stdout.flush() + + cmd = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (stdout, stderr) = cmd.communicate() + + failed = (cmd.returncode != 0) + + if failed: + print("FAILURE") + print(stdout.decode('ascii')) + print(stderr.decode('ascii')) + sys.stdout.flush() + + return not failed + +def run_test_build(configure_py, modules, include, run_tests=False): + config = [configure_py] + + if include: + config.append('--minimized') + if modules: + config.append('--enable-modules=' + ','.join(modules)) + else: + config.append('--disable-modules=' + ','.join(modules)) + + if try_to_run(config) is False: + return False + + if try_to_run(['make', '-j', str(get_concurrency())]) is False: + return False + + if run_tests is False: + return True + + return try_to_run(['./botan-test']) + +def main(args): + + # TODO take configure.py and botan-test paths via options + + parser = optparse.OptionParser() + + parser.add_option('--run-tests', default=False, action='store_true') + + (options, args) = parser.parse_args(args) + + run_tests = options.run_tests + + configure_py = './configure.py' + modules = get_module_list(configure_py) + + cant_disable = ['block', 'hash', 'hex', 'mac', 'modes', 'rng', 'stream', 'utils', 'cpuid', 'entropy'] + always_include = ['sha2_32', 'sha2_64', 'aes'] + + failed = [] + + for module in sorted(modules): + if (module in always_include) or (module in cant_disable): + continue # already testing it + + extra = [] + if module == 'auto_rng': + extra.append('dev_random') + if run_test_build(configure_py, [module] + always_include + extra, True, run_tests) is False: + failed.append(module) + + for module in sorted(modules): + if module in cant_disable or module in always_include: + continue + if run_test_build(configure_py, [module], False, run_tests) is False: + failed.append(module) + + print("Failed building with %s", ' '.join(failed)) + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) |