-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_statements
73 lines (61 loc) · 2.49 KB
/
generate_statements
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
#!/usr/bin/env python3
# Run a set of tests, based on the config.json file
import sys
from pathlib import Path
import json
import subprocess
# Map primes here for testing
prime_names = {}
prime_names['p1'] = 2305843009213693951
directory='examples/substring_search/IR0/' #Reative to where you run the generate_statements
# Map descriptors to files
desc_to_script = {}
desc_to_script["after_all_multi"] = "after_all_multi.py"
desc_to_script["after_multi"] = "after_multi.py"
desc_to_script["begins_multi"] = "begins_multi.py"
desc_to_script["between_multi"] = "between_multi.py"
desc_to_script["point_to_multi"] = "point_to_multi.py"
desc_to_script["string_search"] = "string_search.py"
desc_to_script["after_all"] = "after_all.py"
desc_to_script["after"] = "after.py"
desc_to_script["begins"] = "begins.py"
desc_to_script["between"] = "between.py"
desc_to_script["point_to"] = "point_to.py"
desc_to_script["stringlist_search"] = "stringlist_search.py"
if __name__ == "__main__":
if len(sys.argv) > 2:
print("Expecting generate_statements <config file>")
print(" <config file> default is config.json")
exit(1)
if len(sys.argv) > 1:
config_file = sys.argv[1]
else:
config_file = "./config.json"
with open(config_file, 'r') as f:
cf = json.load(f)
# Extract metadata
target = cf['target']
Path(target).mkdir(parents=True, exist_ok=True)
for name, family in cf['test-families'].items():
script = directory+desc_to_script[name]
# sizes = " ".join((str(x) for x in family['sizes']))
for prime in family['primes']:
for size in family['sizes']:
size = str(size)
operation="test"
this_ex = f'python3 {script} {target} {prime_names[prime]} {prime} {size} {operation}'
print('* Generating:', this_ex)
try:
retcode = subprocess.call(this_ex, shell=True)
if retcode != 0:
print(script + " returned nonzero:", retcode, file=sys.stderr)
sys.exit(retcode)
fname = f'{target}/{name}_{prime}_{size}'
test_ex = f'wtk-firealarm {fname}.rel {fname}.type0.ins {fname}.type0.wit'
print('* Testing:', test_ex)
retcode = subprocess.call(test_ex, shell=True)
if retcode != 0:
print(script + " returned nonzero:", retcode, file=sys.stderr)
sys.exit(retcode)
except OSError as e:
print("Error:", e, file=sys.stderr)