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"
63 # Extract the first list
64 extractAppList = open(firstList, "r")
65 for app in extractAppList:
67 appList1.append(app.strip())
68 extractAppList.close()
73 # Extract the second list if provided (this is for combinations between two lists)
74 if (len(sys.argv) == 6):
75 secondList = sys.argv[5]
76 extractAppList = open(secondList, "r")
77 for app in extractAppList:
79 appList2.append(app.strip())
80 extractAppList.close()
82 # Just copy the first list to the second list
86 if useSecondList is False:
87 # Generate the permutations of pairs
88 for i in range(len(appList1)):
89 for j in range(i + 1, len(appList2)):
90 appPairs.append((appList1[i], appList2[j]))
92 # Generate pairs from 2 lists
93 for i in range(len(appList1)):
94 for j in range(len(appList2)):
95 # Skip if both are the same
96 if appList1[i] == appList2[j]:
98 appPairs.append((appList1[i], appList2[j]))
102 print "PHASE 2: Running JPF ...\n"
103 # List down all the log file names
104 writeLogList = open(jpfLogDir + "logList", "w+")
105 for item in appPairs:
107 # Copy apps into Extractor/App1 and Extractor/App2
108 print "==> First app: %s" % item[0]
109 print "==> Second app: %s" % item[1]
110 os.system("cp " + appDir + item[0] + " Extractor/App1/App1.groovy")
111 os.system("cp " + appDir + item[1] + " Extractor/App2/App2.groovy")
113 # Run Runner.py to extract things and create main.groovy, then compile it
114 print "==> Compiling the apps ...\n"
115 os.system("make Runner")
116 error = extractError()
117 logName = item[0] + "--" + item[1] + ".log"
120 os.system("make main")
122 print "==> Calling JPF and generate logs ...\n"
123 os.system("cd " + jpfDir + ";./run.sh " + jpfLogDir + logName + " main.jpf")
125 # This is for specific error, e.g., direct-direct interaction that we need to skip
126 writeErrorLog(jpfLogDir, logName, error)
128 result = checkResult(jpfLogDir + logName)
129 writeLogList.write(logName + "\t\t" + result + "\n")