forked from Errare-humanum-est/ProtoGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProtoGen.py
81 lines (70 loc) · 2.63 KB
/
ProtoGen.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
72
73
74
75
76
77
78
79
80
81
import time
import sys
from Parser.ClassProtoParser import ProtoParser
from Algorithm.ProtoAlgorithm import ProtoAlgorithm
from Algorithm.ProtoConfig import ProtoConfig
from Murphi.Murphi import Murphi
from Monitor.Debug import *
spacer = "\n\n\n"
if len(sys.argv[1:]) == 0:
file = "MSI_Proto.pcc"
else:
assert len(sys.argv[1:]) == 1, "Too many arguments"
file = sys.argv[1]
Config = ProtoConfig()
# Frontend
pheader("PROTOGEN PARSER")
Parser = ProtoParser(file)
if not Parser.checkAccessBehaviourDefined():
print("Exiting.")
sys.exit(1)
if not Parser.checkAllStatesReachable():
print("Exiting.")
sys.exit(1)
talgo = time.time()
pheader(spacer+"PROTOGEN ALGORITHM")
Algorithm = ProtoAlgorithm(Parser, Config)
pheader(spacer+"PROTOGEN BACKEND")
SSP_MurphiDesc = Murphi(Parser, Algorithm, True)
MurphiDesc = Murphi(Parser, Algorithm, False)
pdebug("ProtoGen runtime: " + str(time.time()-talgo) + '\n')
pheader(spacer+"Murphi make and run")
talgo = time.time()
pheader(spacer+"Starting SSP verification" + '\n')
SSP_MurphiDesc.runMurphi(True)
ssp_success = False
try:
resultsfile = open("SSP_" + file.split(".")[0] + "_results.txt")
except FileNotFoundError:
pwarning("SSP results file does not exist - did it compile correctly?"
"\nPlease check SSP_" + file.split(".")[0] + "_compile.txt"
" for details, and make sure your input is correctly specified.")
else:
if "No error found" in resultsfile.read():
psuccess("SSP verified without error")
ssp_success = True
else:
pwarning("SSP did not verify correctly; please see SSP_"
+ file.split(".")[0] + "_results.txt for the Murphi output.")
resultsfile.close()
if ssp_success:
pheader(spacer+"Starting full protocol verification" + '\n')
MurphiDesc.runMurphi(False)
try:
resultsfile = open(file.split(".")[0] + "_results.txt")
except FileNotFoundError:
pwarning("Results file does not exist - did it compile correctly?"
"\nPlease check " + file.split(".")[0] + "_compile.txt "
"for details, and make sure your input is correctly specified"
".")
else:
if "No error found" in resultsfile.read():
psuccess("Full protocol verified without error")
else:
pwarning("Full protocol did not verify correctly; please see "
+ file.split(".")[0] + "_results.txt for the Murphi "
" output.")
resultsfile.close()
else:
pwarning("Aborting full protocol verification as SSP deemed incorrect.")
pdebug(spacer + "Murphi runtime: " + str(time.time()-talgo) + '\n')