8 # Check the result in the log and print a summary
9 def checkResult(logDirName):
10 extractResult = open(logDirName, "r")
11 result = "other errors--PLEASE CHECK!"
13 for line in extractResult:
14 if "no errors detected" in line:
15 result = "no conflict"
17 elif "java.lang.RuntimeException: Conflict between apps App1 and App2:" in line:
20 elif "Direct-Direct Interaction detected:" in line:
21 result = "direct-direct"
26 # Extract the error from specific error logs
29 if os.path.exists("appCreationError.log"):
30 extractError = open("appCreationError.log", "r")
31 for line in extractError:
34 os.system("rm appCreationError.log")
37 # Write error log to the log directory
38 # In this case we skip running JPF
39 # e.g., in the case of having a direct-direct interaction pair
40 def writeErrorLog(jpfLogDir, logName, error):
41 writeError = open(jpfLogDir + logName, "w+")
42 writeError.write(error)
47 # - JPF logs directory
50 # - list #2 (if needed)
52 # Index 0 is always for the Python script itself
54 jpfLogDir = sys.argv[2]
56 firstList = sys.argv[4]
59 # PART 1: Generate the permutations of app pairs
60 print "PHASE 1: Extracting the app pairs from the app lists ...\n"
64 # Extract the first list
65 extractAppList = open(firstList, "r")
66 for app in extractAppList:
68 appList1.append(app.strip())
69 extractAppList.close()
74 # Extract the second list if provided (this is for combinations between two lists)
75 if (len(sys.argv) == 6):
76 secondList = sys.argv[5]
77 extractAppList = open(secondList, "r")
78 for app in extractAppList:
80 appList2.append(app.strip())
81 extractAppList.close()
83 # Just copy the first list to the second list
87 if useSecondList is False:
88 # Generate the permutations of pairs
89 for i in range(len(appList1)):
90 for j in range(i + 1, len(appList2)):
91 appPairs.append((appList1[i], appList2[j]))
93 # Generate pairs from 2 lists
94 for i in range(len(appList1)):
95 for j in range(len(appList2)):
96 # Skip if both are the same
97 if appList1[i] == appList2[j]:
99 appPairs.append((appList1[i], appList2[j]))
103 print "PHASE 2: Running JPF ...\n"
104 # List down all the log file names
105 writeLogList = open(jpfLogDir + "logList", "w+")
106 for item in appPairs:
108 # Copy apps into Extractor/App1 and Extractor/App2
109 print "==> First app: %s" % item[0]
110 print "==> Second app: %s" % item[1]
111 os.system("cp " + appDir + item[0] + " Extractor/App1/App1.groovy")
112 os.system("cp " + appDir + item[1] + " Extractor/App2/App2.groovy")
114 # Run Runner.py to extract things and create main.groovy, then compile it
115 print "==> Compiling the apps ...\n"
116 os.system("make Runner")
117 error = extractError()
118 logName = item[0] + "--" + item[1] + ".log"
121 os.system("make main")
123 print "==> Calling JPF and generate logs ...\n"
124 os.system("cd " + jpfDir + ";./run.sh " + jpfLogDir + logName + " main.jpf")
126 # This is for specific error, e.g., direct-direct interaction that we need to skip
127 writeErrorLog(jpfLogDir, logName, error)
129 result = checkResult(jpfLogDir + logName)
130 writeLogList.write(logName + "\t\t" + result + "\n")