1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#!/usr/bin/python3
"""
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 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()]
return modules
def get_concurrency():
def_concurrency = 2
try:
import multiprocessing
return max(def_concurrency, multiprocessing.cpu_count())
except ImportError:
return def_concurrency
def run_test_build(configure_py, modules):
cmdline = [configure_py, '--minimized']
if modules:
cmdline.append('--enable-modules=' + ','.join(modules))
print("Testing", cmdline)
configure = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
configure.communicate()
if configure.returncode != 0:
raise Exception("Running %s failed" % (' '.join(cmdline)))
make = subprocess.Popen(['make', '-j', str(get_concurrency())],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = make.communicate()
if make.returncode != 0:
print("Build failed:")
print(stdout.decode('ascii'))
print(stderr.decode('ascii'))
tests = subprocess.Popen(['./botan-test'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(stdout, stderr) = tests.communicate()
if tests.returncode != 0:
print("Tests failed:")
print(stdout.decode('ascii'))
print(stderr.decode('ascii'))
sys.stdout.flush()
def main(args):
# TODO take configure.py and botan-test paths via options
configure_py = './configure.py'
modules = get_module_list(configure_py)
for module in sorted(modules):
if module in ['bearssl']:
continue
extra = ['sha2_32', 'sha2_64', 'aes']
if module == 'auto_rng':
extra.append('dev_random')
run_test_build(configure_py, [module] + extra)
if __name__ == '__main__':
sys.exit(main(sys.argv))
|