-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_module_tests.py
71 lines (59 loc) · 1.76 KB
/
run_module_tests.py
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
#!/usr/bin/env python
import os
import subprocess
import shutil
def run_command(executable, *arguments):
try:
subprocess.run([executable, *arguments], check=True, capture_output=True)
except subprocess.CalledProcessError as err:
print(err.stdout.decode('utf-8'))
print(err.stderr.decode('utf-8'))
raise
parent_directory = os.path.dirname(os.path.realpath(__file__))
source_directory = os.path.join(parent_directory, 'src')
build_directory = os.path.join(parent_directory, 'build', 'module_tests')
if not os.path.exists(build_directory):
os.makedirs(build_directory)
run_command(
shutil.which('cmake'),
'-GNinja',
'-S', os.path.join(source_directory, 'module_tests'),
'-B', build_directory
)
run_command(
shutil.which('cmake'),
'--build',
build_directory
)
modules = [
'BusArbiter',
'StationParameter',
'IntegerUnit',
'RegisterFile',
'MemoryArbiter'
]
for name in modules:
print('Running module test {}... '.format(name), end='', flush=True)
executable_name = '{}-test.exe'.format(name) if os.name == 'nt' else '{}-test'.format(name)
try:
subprocess.run(
[os.path.join(build_directory, executable_name)],
capture_output=True,
timeout=5,
check=True
)
print('Passed')
except subprocess.CalledProcessError as err:
print('Failed')
print('stdout:')
print(err.stdout.decode('utf-8'))
print('stderr:')
print(err.stderr.decode('utf-8'))
exit(1)
except subprocess.TimeoutExpired as err:
print('Failed (timeout)')
print('stdout:')
print(err.stdout.decode('utf-8'))
print('stderr:')
print(err.stderr.decode('utf-8'))
exit(1)