-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.py
More file actions
executable file
·57 lines (45 loc) · 1.54 KB
/
Copy pathtesting.py
File metadata and controls
executable file
·57 lines (45 loc) · 1.54 KB
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
#!/usr/bin/env python3
from os import listdir
from os.path import join as pjoin, isdir, isfile
import subprocess
from termcolor import colored
import sys
tests_path = 'tests'
def run_test(tc, verbose=False):
path = pjoin(tests_path, tc)
def file_ends_with(f, s):
return f.endswith(s) and isfile(f)
vers = [v for v in listdir(path)
if file_ends_with(pjoin(path, v), '.ver')]
for v in vers:
with open(pjoin(path, v[:-2]), 'w') as fw:
subprocess.run(['./veriexp.py', pjoin(path, v)],
stdout=fw, check=True)
verilogs = [pjoin(path, v) for v in listdir(path)
if v[-2:] == '.v' and isfile(pjoin(path, v))]
subprocess.run(['iverilog', '-o', pjoin(path, 'tb'), *verilogs], check=True)
res = subprocess.run(['vvp', pjoin(path, 'tb')],
stdout=subprocess.PIPE, check=True)
if verbose:
print(res.stdout)
return 'err' not in res.stdout.decode().lower()
def run_all_test():
all_tests = [t for t in listdir(tests_path)
if isdir(pjoin(tests_path, t))]
T = 0
P = 0
for tc in all_tests:
res = run_test(tc)
T += 1
print('Test #%d, %s:' % (T, tc), end=' ')
if res:
print(colored('[PASSED]', 'green'))
P += 1
else:
print(colored('[FAILED]', 'red'))
print('Total = %d, Passed = %d' % (T, P))
if __name__ == '__main__':
if len(sys.argv) > 1:
run_test(sys.argv[1], verbose=True)
else:
run_all_test()