Completing model-check automation script with result extraction.
[smartthings-infrastructure.git] / ModelCheck.py
index c192cfa48ecafe72be736fc997adcd6bb9a33ef1..661018e1749353637721c704a8f2fdaea189c586 100644 (file)
@@ -4,6 +4,23 @@ import itertools
 import sys
 import os
 
+# Helper methods
+# Check the result in the log and print a summary
+def checkResult(logDirName):
+       extractResult = open(logDirName, "r")
+       result = "other errors--PLEASE CHECK!"
+       
+       for line in extractResult:
+               if "no errors detected" in line:
+                       result = "no conflict"
+                       break
+               elif "java.lang.RuntimeException: Conflict between apps App1 and App2:" in line:
+                       result = "conflict"
+                       break
+       
+       return result
+
+
 # Input parameters:
 # - JPF directory
 # - JPF logs directory
@@ -17,6 +34,7 @@ jpfLogDir = sys.argv[2]
 appDir = sys.argv[3]
 firstList = sys.argv[4]
 
+
 # PART 1: Generate the permutations of app pairs
 print "PHASE 1: Extracting the app pairs from the app lists ...\n"
 appList1 = []
@@ -57,7 +75,8 @@ else:
                        if appList1[i] == appList2[j]:
                                continue
                        appPairs.append((appList1[i], appList2[j]))
-                       
+
+               
 # PART 2: 
 print "PHASE 2: Running JPF ...\n"
 # List down all the log file names
@@ -78,7 +97,28 @@ for item in appPairs:
        # Call JPF
        print "==> Calling JPF and generate logs ...\n"
        logName = item[0] + "--" + item[1] + ".log"
-       writeLogList.write(logName + "\n")
        os.system("cd " + jpfDir + ";./run.sh " + jpfLogDir + logName + " main.jpf")
-       
+       result = checkResult(jpfLogDir + logName)
+       writeLogList.write(logName + "\t\t" + result + "\n")
+
 writeLogList.close()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+